aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.classpath1
-rw-r--r--build.xml35
-rwxr-xr-xjitsi.eml3
-rw-r--r--lib/accounts.properties.template43
-rw-r--r--lib/installer-exclude/jml-1.0b5.jarbin334030 -> 0 bytes
-rw-r--r--lib/jitsi-defaults.properties2
-rw-r--r--lib/logging.properties3
-rw-r--r--nbproject/project.xml2
-rw-r--r--resources/images/images.properties6
-rw-r--r--resources/images/protocol/msn/msn16x16-away.pngbin1061 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-brb.pngbin1041 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-busy.pngbin1046 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-connecting.gifbin3234 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-connecting.pngbin990 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-invisible.pngbin1083 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-lunch.pngbin1030 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-meeting.pngbin2089 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-na.pngbin1040 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-offline.pngbin888 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-online.pngbin1018 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16-phone.pngbin1107 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn16x16.pngbin1018 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn32x32.pngbin2504 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn48x48.pngbin3994 -> 0 bytes
-rw-r--r--resources/images/protocol/msn/msn64x64.pngbin6965 -> 0 bytes
-rw-r--r--resources/install/debian/jitsi.1.tmpl2
-rw-r--r--resources/languages/resources.properties6
-rw-r--r--src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java6
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/AbstractContactGroupMsnImpl.java29
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomInvitationMsnImpl.java71
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomMsnImpl.java595
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ContactGroupMsnImpl.java437
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java283
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/EventAdapter.java41
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/EventManager.java256
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java106
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java195
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/MessageMsnImpl.java36
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/MsnAccountID.java24
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java168
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/MsnContactListEventListener.java43
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java687
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetAvatarMsnImpl.java26
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetBasicInstantMessagingMsnImpl.java506
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java434
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java913
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java608
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetTypingNotificationsMsnImpl.java173
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ProtocolIconMsnImpl.java145
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java160
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java612
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ReferenceURLStreamHandlerService.java114
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/RootContactGroupMsnImpl.java285
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java1484
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/VolatileContact.java75
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/VolatileGroup.java46
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/mail/utils/Base64InputStream.java187
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/mail/utils/MimeUtility.java199
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QInputStream.java105
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QPInputStream.java171
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf40
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java6
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java288
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java150
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistration.java83
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java348
-rw-r--r--src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java70
-rwxr-xr-xsrc/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf33
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java11
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolNames.java5
-rw-r--r--src/net/java/sip/communicator/service/protocol/msnconstants/MsnStatusEnum.java165
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java120
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/MsnSlickFixture.java134
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestAccountInstallation.java222
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallation.java275
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java102
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetAdHocMultiUserChatMsnImpl.java158
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetBasicInstantMessaging.java502
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java252
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetInstantMessageTransformMsnImpl.java275
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPersistentPresence.java707
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPresence.java971
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetTypingNotifications.java304
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/TestProtocolProviderServiceMsnImpl.java267
-rw-r--r--test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf17
85 files changed, 3 insertions, 14825 deletions
diff --git a/.classpath b/.classpath
index 4eb796b..f7255dd 100755
--- a/.classpath
+++ b/.classpath
@@ -42,7 +42,6 @@
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jfontchooser-1.0.5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmdns.jar"/>
- <classpathentry kind="lib" path="lib/installer-exclude/jml-1.0b5.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jmyspell-core.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jna.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/jnsapi.jar"/>
diff --git a/build.xml b/build.xml
index b7e117e..0e47b78 100644
--- a/build.xml
+++ b/build.xml
@@ -1531,7 +1531,6 @@ javax.swing.event, javax.swing.border"/>
<include name="protocol/googletalk/**/*"/>
<include name="protocol/facebook/**/*"/>
<include name="protocol/jabber/**/*"/>
- <include name="protocol/msn/**/*"/>
<include name="protocol/yahoo/**/*"/>
<!-- the media package lives in the protocol-media bundle -->
<exclude name="protocol/media/**/*"/>
@@ -1654,30 +1653,6 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
- <!-- BUNDLE-MSN -->
- <target name="bundle-msn">
- <!-- Creates a bundle containing the msn impl of the protocol provider.-->
- <jar compress="false" destfile="${bundles.dest}/protocol-msn.jar"
- manifest="${src}/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf">
- <zipfileset dir="${dest}/net/java/sip/communicator/impl/protocol/msn"
- prefix="net/java/sip/communicator/impl/protocol/msn"/>
- <zipfileset src="${lib.noinst}/jml-1.0b5.jar" prefix=""/>
- </jar>
- </target>
-
- <!-- BUNDLE-MSN-SLICK -->
- <!-- Creates a bundle containing the slick for the Msn protocol provider.-->
- <target name="bundle-msn-slick">
- <jar compress="false" destfile="${bundles.dest}/protocol-msn-slick.jar"
- manifest="${testsrc}/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf">
- <zipfileset dir="${dest}/net/java/sip/communicator/slick/protocol/msn"
- prefix="net/java/sip/communicator/slick/protocol/msn"/>
- <zipfileset src="${lib.noinst}/jml-1.0b5.jar" prefix=""/>
- <zipfileset dir="${dest}/net/java/sip/communicator/slick/protocol/generic"
- prefix="net/java/sip/communicator/slick/protocol/generic"/>
- </jar>
- </target>
-
<!-- BUNDLE-SSH -->
<target name="bundle-ssh">
<!-- Creates a bundle containing the SSH impl of the protocol provider.-->
@@ -1840,16 +1815,6 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
- <!-- BUNDLE-PLUGIN-MSNACCREGWIZZ -->
- <target name="bundle-plugin-msnaccregwizz">
- <!-- Creates a bundle for the plugin Msn Account Registration Wizard.-->
- <jar compress="false" destfile="${bundles.dest}/msnaccregwizz.jar"
- manifest="${src}/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf">
- <zipfileset dir="${dest}/net/java/sip/communicator/plugin/msnaccregwizz"
- prefix="net/java/sip/communicator/plugin/msnaccregwizz"/>
- </jar>
- </target>
-
<!-- BUNDLE-PLUGIN-YAHOOACCREGWIZZ -->
<target name="bundle-plugin-yahooaccregwizz">
<!-- Creates a bundle for the plugin Yahoo Account Registration Wizard.-->
diff --git a/jitsi.eml b/jitsi.eml
index 5ffe2d8..7a448a0 100755
--- a/jitsi.eml
+++ b/jitsi.eml
@@ -86,9 +86,6 @@
<lib name="jmdns.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/lib/installer-exclude/jmdns.jar!/"/>
</lib>
- <lib name="jml-1.0b5.jar" scope="COMPILE">
- <relative-module-cls project-related="jar://$PROJECT_DIR$/lib/installer-exclude/jml-1.0b5.jar!/"/>
- </lib>
<lib name="jmyspell-core.jar" scope="COMPILE">
<relative-module-cls project-related="jar://$PROJECT_DIR$/lib/installer-exclude/jmyspell-core.jar!/"/>
</lib>
diff --git a/lib/accounts.properties.template b/lib/accounts.properties.template
index 4e3b537..3845c47 100644
--- a/lib/accounts.properties.template
+++ b/lib/accounts.properties.template
@@ -189,47 +189,6 @@ accounts.jabber.CONTACT_LIST=
# list of icq accounts to notify during testing (optional)
accounts.reporting.JABBER_REPORT_LIST=
-# MSN PROPERTIES
-
-# MSN ACCOUNT 1
-# The user email needed to log onto the server
-accounts.msn.account1.USER_ID=
-
-# The password (in plain text) needed to log the user specified in USER_ID
-# on the server
-accounts.msn.account1.PASSWORD=
-
-# MSN ACCOUNT 2
-
-# The user email needed to log onto the server
-accounts.msn.account2.USER_ID=
-
-# The password (in plain text) needed to log the user specified in USER_ID
-# on the server
-accounts.msn.account2.PASSWORD=
-
-# MSN ACCOUNT 3
-
-# The user email needed to log onto the server
-accounts.msn.account3.USER_ID=
-
-# The password (in plain text) needed to log the user specified in USER_ID
-# on the server
-accounts.msn.account3.PASSWORD=
-
-# The following describes the contact list that we will store on the Msn
-# server for the tested account implementation. The value of the CONTACT_LIST
-# property must be a space separated string containing elements each of which
-# is in the format: GroupName.UIN
-#
-#
-# VERY IMPORTANT!!! All other users in this contact list will be removed and
-# the contacts and contact groups enumerated beneath will be added instead
-accounts.msn.CONTACT_LIST=
-
-# list of msn accounts to notify during testing (optional)
-accounts.reporting.MSN_REPORT_LIST=
-
# YAHOO PROPERTIES
# YAHOO ACCOUNT 1
@@ -258,7 +217,7 @@ accounts.yahoo.account3.USER_ID=
# on the server
accounts.yahoo.account3.PASSWORD=
-# The following describes the contact list that we will store on the Msn
+# The following describes the contact list that we will store on the yahoo
# server for the tested account implementation. The value of the CONTACT_LIST
# property must be a space separated string containing elements each of which
# is in the format: GroupName.UIN
diff --git a/lib/installer-exclude/jml-1.0b5.jar b/lib/installer-exclude/jml-1.0b5.jar
deleted file mode 100644
index 71d761f..0000000
--- a/lib/installer-exclude/jml-1.0b5.jar
+++ /dev/null
Binary files differ
diff --git a/lib/jitsi-defaults.properties b/lib/jitsi-defaults.properties
index 539ae12..b5d6016 100644
--- a/lib/jitsi-defaults.properties
+++ b/lib/jitsi-defaults.properties
@@ -109,8 +109,6 @@ net.java.sip.communicator.plugin.pluginmanager.SYSTEM_BUNDLES=\
net.java.sip.communicator.contactlist,\
net.java.sip.communicator.replacement.metacafe,\
net.java.sip.communicator.plugin.msofficecomm,\
- net.java.sip.communicator.protocol.msn,\
- net.java.sip.communicator.plugin.msnaccregwizz,\
net.java.sip.communicator.neomedia,\
net.java.sip.communicator.netaddr,\
net.java.sip.communicator.plugin.nimbuzzavatars,\
diff --git a/lib/logging.properties b/lib/logging.properties
index 456ea93..1adcab2 100644
--- a/lib/logging.properties
+++ b/lib/logging.properties
@@ -55,9 +55,6 @@ java.util.logging.ConsoleHandler.formatter = net.java.sip.communicator.util.ScLo
# We don't want trace logs from joscar and joustsim
net.kano.level = INFO
-# We don't want trace logs from java-jml
-net.sf.cindy.impl.level = INFO
-
# But we want everything coming from the sip-comm
# For example, set the com.xyz.foo logger to only log SEVERE
diff --git a/nbproject/project.xml b/nbproject/project.xml
index 475883b..939c825 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -116,7 +116,7 @@
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>
<package-root>src</package-root>
- <classpath mode="compile">lib/felix.jar:lib/bundle/commons-logging.jar:lib/bundle/junit.jar:lib/bundle/log4j.jar:lib/installer-exclude/apache-ant-1.7.0.jar:lib/installer-exclude/dhcp4java-1.00.jar:lib/installer-exclude/dict4j.jar:lib/installer-exclude/dnsjava.jar:lib/installer-exclude/fmj.jar:lib/installer-exclude/forms-1.2.1.jar:lib/installer-exclude/gdata-client-1.0.jar:lib/installer-exclude/gdata-client-meta-1.0.jar:lib/installer-exclude/gdata-contacts-3.0.jar:lib/installer-exclude/gdata-contacts-meta-3.0.jar:lib/installer-exclude/gdata-core-1.0.jar:lib/installer-exclude/google-collect-1.0-rc1.jar:lib/installer-exclude/hexdump-0.2.jar:lib/installer-exclude/httpclient-osgi-4.2.3.jar:lib/installer-exclude/httpcore-osgi-4.2.3.jar:lib/installer-exclude/ice4j.jar:lib/installer-exclude/irc-api-1.0.jar:lib/installer-exclude/jain-sdp.jar:lib/installer-exclude/jain-sip-api.jar:lib/installer-exclude/jain-sip-ri.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/jfontchooser-1.0.5.jar:lib/installer-exclude/jmdns.jar:lib/installer-exclude/jml-1.0b5.jar:lib/installer-exclude/jmyspell-core.jar:lib/installer-exclude/jna.jar:lib/installer-exclude/jnsapi.jar:lib/installer-exclude/joscar-client.jar:lib/installer-exclude/joscar-common.jar:lib/installer-exclude/joscar-protocol.jar:lib/installer-exclude/jsch-0.1.36.jar:lib/installer-exclude/jsocks-klea.jar:lib/installer-exclude/json-simple-1.1.1.jar:lib/installer-exclude/jspeex.jar:lib/installer-exclude/junit.jar:lib/installer-exclude/laf-widget.jar:lib/installer-exclude/lcrypto-jdk16-143.jar:lib/installer-exclude/libdbus-java-2.7.jar:lib/installer-exclude/libjitsi.jar:lib/installer-exclude/log4j-1.2.8.jar:lib/installer-exclude/lti-civil-no_s_w_t.jar:lib/installer-exclude/mac_widgets-0.9.5.jar:lib/installer-exclude/nist-sdp-1.0.jar:lib/installer-exclude/otr4j.jar:lib/installer-exclude/pircbot.jar:lib/installer-exclude/profiler4j-1.0-beta3-SC.jar:lib/installer-exclude/sdes4j.jar:lib/installer-exclude/smack.jar:lib/installer-exclude/smackx.jar:lib/installer-exclude/swing-worker-1.2.jar:lib/installer-exclude/jna-platform.jar:lib/installer-exclude/unix-0.5.jar:lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar:lib/installer-exclude/ymsg_network_v0_67.jar:lib/installer-exclude/zrtp4j-light.jar:lib/installer-exclude/jcalendar-1.4.jar:lib/installer-exclude/bcpkix-jdk15on-151.jar:lib/installer-exclude/bcprov-jdk15on-151.jar:lib/installer-exclude/guava-15.0.jar:lib/installer-exclude/libphonenumber-5.9.jar:lib/installer-exclude/commons-lang3-3.1.jar:lib/installer-exclude/jmork-1.0.5-SNAPSHOT.jar:lib/os-specific/mac/growl4j.jar:lib/os-specific/mac/OrangeExtensions.jar:lib/os-specific/mac/installer-exclude/dock.jar</classpath>
+ <classpath mode="compile">lib/felix.jar:lib/bundle/commons-logging.jar:lib/bundle/junit.jar:lib/bundle/log4j.jar:lib/installer-exclude/apache-ant-1.7.0.jar:lib/installer-exclude/dhcp4java-1.00.jar:lib/installer-exclude/dict4j.jar:lib/installer-exclude/dnsjava.jar:lib/installer-exclude/fmj.jar:lib/installer-exclude/forms-1.2.1.jar:lib/installer-exclude/gdata-client-1.0.jar:lib/installer-exclude/gdata-client-meta-1.0.jar:lib/installer-exclude/gdata-contacts-3.0.jar:lib/installer-exclude/gdata-contacts-meta-3.0.jar:lib/installer-exclude/gdata-core-1.0.jar:lib/installer-exclude/google-collect-1.0-rc1.jar:lib/installer-exclude/hexdump-0.2.jar:lib/installer-exclude/httpclient-osgi-4.2.3.jar:lib/installer-exclude/httpcore-osgi-4.2.3.jar:lib/installer-exclude/ice4j.jar:lib/installer-exclude/irc-api-1.0.jar:lib/installer-exclude/jain-sdp.jar:lib/installer-exclude/jain-sip-api.jar:lib/installer-exclude/jain-sip-ri.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/jfontchooser-1.0.5.jar:lib/installer-exclude/jmdns.jar:lib/installer-exclude/jmyspell-core.jar:lib/installer-exclude/jna.jar:lib/installer-exclude/jnsapi.jar:lib/installer-exclude/joscar-client.jar:lib/installer-exclude/joscar-common.jar:lib/installer-exclude/joscar-protocol.jar:lib/installer-exclude/jsch-0.1.36.jar:lib/installer-exclude/jsocks-klea.jar:lib/installer-exclude/json-simple-1.1.1.jar:lib/installer-exclude/jspeex.jar:lib/installer-exclude/junit.jar:lib/installer-exclude/laf-widget.jar:lib/installer-exclude/lcrypto-jdk16-143.jar:lib/installer-exclude/libdbus-java-2.7.jar:lib/installer-exclude/libjitsi.jar:lib/installer-exclude/log4j-1.2.8.jar:lib/installer-exclude/lti-civil-no_s_w_t.jar:lib/installer-exclude/mac_widgets-0.9.5.jar:lib/installer-exclude/nist-sdp-1.0.jar:lib/installer-exclude/otr4j.jar:lib/installer-exclude/pircbot.jar:lib/installer-exclude/profiler4j-1.0-beta3-SC.jar:lib/installer-exclude/sdes4j.jar:lib/installer-exclude/smack.jar:lib/installer-exclude/smackx.jar:lib/installer-exclude/swing-worker-1.2.jar:lib/installer-exclude/jna-platform.jar:lib/installer-exclude/unix-0.5.jar:lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar:lib/installer-exclude/ymsg_network_v0_67.jar:lib/installer-exclude/zrtp4j-light.jar:lib/installer-exclude/jcalendar-1.4.jar:lib/installer-exclude/bcpkix-jdk15on-151.jar:lib/installer-exclude/bcprov-jdk15on-151.jar:lib/installer-exclude/guava-15.0.jar:lib/installer-exclude/libphonenumber-5.9.jar:lib/installer-exclude/commons-lang3-3.1.jar:lib/installer-exclude/jmork-1.0.5-SNAPSHOT.jar:lib/os-specific/mac/growl4j.jar:lib/os-specific/mac/OrangeExtensions.jar:lib/os-specific/mac/installer-exclude/dock.jar</classpath>
<built-to>classes</built-to>
<source-level>1.5</source-level>
</compilation-unit>
diff --git a/resources/images/images.properties b/resources/images/images.properties
index 5b8e050..d0ff14c 100644
--- a/resources/images/images.properties
+++ b/resources/images/images.properties
@@ -445,12 +445,6 @@ service.protocol.zeroconf.OFFLINE_STATUS_ICON=resources/images/protocol/zeroconf
service.protocol.zeroconf.DND_STATUS_ICON=resources/images/protocol/zeroconf/zeroconf-dnd.png
service.protocol.zeroconf.INVISIBLE_STATUS_ICON=resources/images/protocol/zeroconf/zeroconf-invisible.png
-#msn accregwizz
-service.protocol.msn.MSN_16x16=resources/images/protocol/msn/msn16x16.png
-service.protocol.msn.MSN_32x32=resources/images/protocol/msn/msn32x32.png
-service.protocol.msn.MSN_48x48=resources/images/protocol/msn/msn48x48.png
-service.protocol.msn.MSN_64x64=resources/images/protocol/msn/msn64x64.png
-
# ssh protocol icons
service.protocol.ssh.SSH_16x16=resources/images/protocol/ssh/ssh-online.png
service.protocol.ssh.SSH_32x32=resources/images/protocol/ssh/ssh32x32.png
diff --git a/resources/images/protocol/msn/msn16x16-away.png b/resources/images/protocol/msn/msn16x16-away.png
deleted file mode 100644
index 42539a3..0000000
--- a/resources/images/protocol/msn/msn16x16-away.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-brb.png b/resources/images/protocol/msn/msn16x16-brb.png
deleted file mode 100644
index d08e180..0000000
--- a/resources/images/protocol/msn/msn16x16-brb.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-busy.png b/resources/images/protocol/msn/msn16x16-busy.png
deleted file mode 100644
index 9abc68c..0000000
--- a/resources/images/protocol/msn/msn16x16-busy.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-connecting.gif b/resources/images/protocol/msn/msn16x16-connecting.gif
deleted file mode 100644
index 4b6e15b..0000000
--- a/resources/images/protocol/msn/msn16x16-connecting.gif
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-connecting.png b/resources/images/protocol/msn/msn16x16-connecting.png
deleted file mode 100644
index e8c4a41..0000000
--- a/resources/images/protocol/msn/msn16x16-connecting.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-invisible.png b/resources/images/protocol/msn/msn16x16-invisible.png
deleted file mode 100644
index 410a6b8..0000000
--- a/resources/images/protocol/msn/msn16x16-invisible.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-lunch.png b/resources/images/protocol/msn/msn16x16-lunch.png
deleted file mode 100644
index c796d07..0000000
--- a/resources/images/protocol/msn/msn16x16-lunch.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-meeting.png b/resources/images/protocol/msn/msn16x16-meeting.png
deleted file mode 100644
index 4cb974b..0000000
--- a/resources/images/protocol/msn/msn16x16-meeting.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-na.png b/resources/images/protocol/msn/msn16x16-na.png
deleted file mode 100644
index 1bd5d27..0000000
--- a/resources/images/protocol/msn/msn16x16-na.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-offline.png b/resources/images/protocol/msn/msn16x16-offline.png
deleted file mode 100644
index 6d7f5b3..0000000
--- a/resources/images/protocol/msn/msn16x16-offline.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-online.png b/resources/images/protocol/msn/msn16x16-online.png
deleted file mode 100644
index 82a4a1e..0000000
--- a/resources/images/protocol/msn/msn16x16-online.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16-phone.png b/resources/images/protocol/msn/msn16x16-phone.png
deleted file mode 100644
index 32e8368..0000000
--- a/resources/images/protocol/msn/msn16x16-phone.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn16x16.png b/resources/images/protocol/msn/msn16x16.png
deleted file mode 100644
index 82a4a1e..0000000
--- a/resources/images/protocol/msn/msn16x16.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn32x32.png b/resources/images/protocol/msn/msn32x32.png
deleted file mode 100644
index dc610c5..0000000
--- a/resources/images/protocol/msn/msn32x32.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn48x48.png b/resources/images/protocol/msn/msn48x48.png
deleted file mode 100644
index f2ffe27..0000000
--- a/resources/images/protocol/msn/msn48x48.png
+++ /dev/null
Binary files differ
diff --git a/resources/images/protocol/msn/msn64x64.png b/resources/images/protocol/msn/msn64x64.png
deleted file mode 100644
index 4e9cfa9..0000000
--- a/resources/images/protocol/msn/msn64x64.png
+++ /dev/null
Binary files differ
diff --git a/resources/install/debian/jitsi.1.tmpl b/resources/install/debian/jitsi.1.tmpl
index 84e3d98..5608d63 100644
--- a/resources/install/debian/jitsi.1.tmpl
+++ b/resources/install/debian/jitsi.1.tmpl
@@ -26,7 +26,7 @@ _PACKAGE_NAME_ \- the Java VoIP and Instant Messaging client
.\" respectively.
\fB_APP_NAME_\fP is an audio/video Internet phone and instant messenger
that supports some of the most popular instant messaging and telephony
-protocols such as SIP, Jabber, AIM/ICQ, MSN, Yahoo! Messenger, Bonjour, IRC
+protocols such as SIP, Jabber, AIM/ICQ, Yahoo! Messenger, Bonjour, IRC
and soon others like IAX.
.PP
.RI "An optional " uri-to-call " expression can be specified to start a call from the command-line. If _APP_NAME_ is already running then the call is handled by the running application, except when it is explicitly told to allow multiple instance launch."
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index cf8c91b..fb3a24c 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -1185,12 +1185,6 @@ plugin.mailbox.CONFIRM=Confirm
plugin.mailbox.DEFAULTS=Defaults
plugin.mailbox.MAILBOX=Mailbox
-# msn accregwizz
-plugin.msnaccregwizz.PROTOCOL_NAME=MSN
-plugin.msnaccregwizz.PROTOCOL_DESCRIPTION=A protocol to connect and chat on the MSN Service.
-plugin.msnaccregwizz.USERNAME=Email:
-plugin.msnaccregwizz.USERNAME_AND_PASSWORD=ID and Password
-
# plugin manager
plugin.pluginmanager.INSTALL=Install
plugin.pluginmanager.UNINSTALL=Uninstall
diff --git a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
index f37121e..8148777 100644
--- a/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
+++ b/src/net/java/sip/communicator/impl/googlecontacts/GoogleContactsQuery.java
@@ -346,12 +346,6 @@ public class GoogleContactsQuery
OperationSetBasicTelephony.class,
ProtocolNames.JABBER);
break;
- case MSN:
- supportedOpSets.add(OperationSetBasicInstantMessaging.class);
- preferredProtocols.put(
- OperationSetBasicInstantMessaging.class,
- ProtocolNames.MSN);
- break;
case YAHOO:
supportedOpSets.add(OperationSetBasicInstantMessaging.class);
preferredProtocols.put(
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/AbstractContactGroupMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/AbstractContactGroupMsnImpl.java
deleted file mode 100644
index 0a7b9cf..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/AbstractContactGroupMsnImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Msn implementation of the service.protocol.ContactGroup interface. There
- * are two types of groups possible here. <tt>RootContactGroupMsnImpl</tt>
- * which is the root node of the ContactList itself and
- * <tt>ContactGroupMsnImpl</tt> which represents standard groups. The
- * reason for having those 2 is that generally, Msn groups may not contain
- * subgroups. A contact list on the other hand may not directly contain buddies.
- *
- *
- * The reason for having an abstract class is only - being able to esily
- * recognize our own (Msn) contacts.
- * @author Damian Minkov
- */
-public abstract class AbstractContactGroupMsnImpl
- implements ContactGroup
-{
-
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomInvitationMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomInvitationMsnImpl.java
deleted file mode 100644
index aeef55e..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomInvitationMsnImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The MSN implementation of the <tt>AdHocChatRoomInvitation</tt> interface.
- *
- * @author Rupert Burchardi
- * @author Yana Stamcheva
- */
-public class AdHocChatRoomInvitationMsnImpl
- implements AdHocChatRoomInvitation
-{
- /**
- * Corresponding chat room instance.
- */
- private AdHocChatRoom chatRoom;
- /**
- * The name of the inviter.
- */
- private String inviter;
-
- /**
- * Creates an instance of the <tt>AdHocChatRoomInvitationMsnImpl</tt> by
- * specifying the targetChatRoom, the inviter, the reason and the password.
- *
- * @param targetChatRoom the <tt>AdHocChatRoom</tt> for which the invitation
- * is
- * @param inviter the contact, which sent the invitation
- */
- public AdHocChatRoomInvitationMsnImpl(AdHocChatRoom targetChatRoom,
- String inviter)
- {
- this.chatRoom = targetChatRoom;
- this.inviter = inviter;
- }
-
- /**
- * Returns the corresponding chat room.
- * @return The chat room
- */
- public AdHocChatRoom getTargetAdHocChatRoom()
- {
- return chatRoom;
- }
-
- /**
- * Returns the corresponding inviter.
- * @return The name of the inviter
- */
- public String getInviter()
- {
- return inviter;
- }
-
- /**
- * Returns the invitation reason.
- * @return the invitation reason
- */
- public String getReason()
- {
- //Not supported in the Msn protocol.
- return null;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomMsnImpl.java
deleted file mode 100644
index cadcfd8..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/AdHocChatRoomMsnImpl.java
+++ /dev/null
@@ -1,595 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license. See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-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 net.sf.jml.*;
-
-/**
- * Implements ad-hoc chat rooms for MSN.
- *
- * @author Rupert Burchardi
- * @author Valentin Martinet
- */
-public class AdHocChatRoomMsnImpl
- implements AdHocChatRoom
-{
- private static final Logger logger
- = Logger.getLogger(AdHocChatRoomMsnImpl.class);
-
- /**
- * The protocol provider that created us
- */
- private final ProtocolProviderServiceMsnImpl provider;
-
- /**
- * The OperationSet for MSN multi user chats.
- */
- private OperationSetAdHocMultiUserChatMsnImpl opSetAdHocMuc = null;
-
- /**
- * The corresponding switchboard for the chat room. Each chat room has its
- * own switchboard and if it is closed the user cannot reconnect to it, see
- * MSN documentation for further infos.
- */
- private MsnSwitchboard switchboard = null;
-
- /**
- * Listeners that will be notified of changes in participants status in the
- * ad-hoc room, such as participant joined, left, etc.
- */
- private Vector<AdHocChatRoomParticipantPresenceListener>
- participantsPresenceListeners =
- new Vector<AdHocChatRoomParticipantPresenceListener>();
-
- /**
- * Listeners that will be notified every time a new message is received on
- * this ad-hoc chat room.
- */
- private Vector<AdHocChatRoomMessageListener> messageListeners
- = new Vector<AdHocChatRoomMessageListener>();
-
- /**
- * A Message buffer, will keep all messages until the MSN ad-hoc chat room
- * is ready.
- */
- public Vector<EventObject> messageBuffer = new Vector<EventObject>();
-
- /**
- * The name of this ad-hoc chat room
- */
- private String name;
-
- /**
- * The list of participants of this ad-hoc chat room.
- */
- private final Hashtable<String, Contact> participants =
- new Hashtable<String, Contact>();
-
- /**
- * List of unresolved member names.
- */
- private ArrayList<String> pendingInvitations = new ArrayList<String>();
-
- /**
- * The presence operation set for the Msn protocol.
- */
- private final OperationSetPersistentPresenceMsnImpl presenceOpSet;
-
- /**
- * Creates a new ad-hoc chat room for MSN named <tt>name</tt>, using the
- * protocol provider <tt>provider</tt>.
- *
- * @param name
- * @param provider
- */
- public AdHocChatRoomMsnImpl(String name,
- ProtocolProviderServiceMsnImpl provider)
- {
- this.name = name;
- this.provider = provider;
- this.opSetAdHocMuc =
- (OperationSetAdHocMultiUserChatMsnImpl)
- this.provider.getOperationSet(OperationSetAdHocMultiUserChat.class);
-
- this.presenceOpSet
- = (OperationSetPersistentPresenceMsnImpl)
- this.provider.getOperationSet(
- OperationSetPersistentPresence.class);
- }
-
- /**
- * Creates a new ad-hoc chat room for MSN named <tt>name</tt>, using the
- * protocol provider <tt>provider</tt> and the msn switchboard
- * <tt>switchboard</tt>.
- *
- * @param name
- * @param provider
- * @param switchboard
- */
- public AdHocChatRoomMsnImpl(String name,
- ProtocolProviderServiceMsnImpl provider,
- MsnSwitchboard switchboard)
- {
- this.name = name;
- this.provider = provider;
- this.opSetAdHocMuc
- = (OperationSetAdHocMultiUserChatMsnImpl)
- this.provider.getOperationSet(OperationSetAdHocMultiUserChat.class);
-
- this.presenceOpSet
- = (OperationSetPersistentPresenceMsnImpl)
- this.provider.getOperationSet(
- OperationSetPersistentPresence.class);
-
- this.switchboard = switchboard;
-
- this.updateParticipantsList(switchboard);
- }
-
- /**
- * Adds a listener that will be notified of changes in our status in the
- * room.
- *
- * @param listener a participant status listener.
- */
- public void addParticipantPresenceListener(
- AdHocChatRoomParticipantPresenceListener listener)
- {
- synchronized(this.participantsPresenceListeners)
- {
- if (!this.participantsPresenceListeners.contains(listener))
- this.participantsPresenceListeners.add(listener);
- }
- }
-
- /**
- * Registers <tt>listener</tt> so that it would receive events every time a
- * new message is received on this chat room.
- *
- * @param listener a <tt>MessageListener</tt> that would be notified every
- * time a new message is received on this chat room.
- */
- public void addMessageListener(AdHocChatRoomMessageListener listener)
- {
- synchronized(this.messageListeners)
- {
- if (!this.messageListeners.contains(listener))
- this.messageListeners.add(listener);
- }
- }
-
- /**
- * Removes <tt>listener</tt> so that it won't receive any further message
- * events from this room.
- *
- * @param listener the <tt>MessageListener</tt> to remove from this room
- */
- public void removeMessageListener(ChatRoomMessageListener listener)
- {
- synchronized (messageListeners)
- {
- if (messageListeners.contains(listener))
- messageListeners.remove(messageListeners.indexOf(listener));
- }
- }
-
- /**
- * Finds the participant of this ad-hoc chat room corresponding to the
- * given address.
- *
- * @param address the address to search for.
- * @return the participant of this chat room corresponding to the given
- * nick name.
- */
- public Contact findParticipantForAddress(String address)
- {
- Iterator<Contact> participantsIter
- = this.participants.values().iterator();
-
- while (participantsIter.hasNext())
- {
- Contact contact = participantsIter.next();
-
- if (contact.getAddress().equals(address))
- {
- return contact;
- }
- }
-
- return null;
- }
-
- /**
- * Creates a <tt>Message</tt> for this ad-hoc chat room containing
- * <tt>text</tt>.
- *
- * @param text
- * @return Message the newly created <tt>Message</tt>
- */
- public Message createMessage(String text)
- {
- Message msg =
- new MessageMsnImpl(text,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING, null);
-
- return msg;
- }
-
- /**
- * Returns the name of this ad-hoc chatroom
- *
- * @return String
- */
- public String getName()
- {
- return this.name;
- }
-
- /**
- * Returns the parent provider
- *
- * @return ProtocolProviderService
- */
- public ProtocolProviderService getParentProvider()
- {
- return this.provider;
- }
-
- /**
- * Returns a list containing all the <tt>Contact</tt>s who participate in
- * this ad-hoc chat room.
- *
- * @return List<Contact>
- */
- public List<Contact> getParticipants()
- {
- return new LinkedList<Contact>(this.participants.values());
- }
-
- /**
- * Returns the participant of this ad-hoc chat room which corresponds to
- * the given id.
- *
- * @param id ID of the participant
- * @return Contact the corresponding Contact
- */
- public Contact getAdHocChatRoomParticipant(String id)
- {
- return this.participants.get(id);
- }
-
- /**
- * Adds a participant to the participants list.
- *
- * @param id the ID
- * @param participant The participant (<tt>Contact</tt>) to add.
- */
- public void addAdHocChatRoomParticipant(String id, Contact participant)
- {
- this.participants.put(id, participant);
-
- fireParticipantPresenceEvent(participant,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_JOINED, null);
- }
-
- /**
- * Removes the participant of this ad-hoc chat room which corresponds to
- * the given id.
- *
- * @param id ID of the participant
- */
- public void removeParticipant(String id)
- {
- Contact contact= this.participants.get(id);
- this.participants.remove(id);
-
- fireParticipantPresenceEvent(contact,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT, null);
- }
-
- /**
- * Returns the number of <tt>Contact</tt>s who participate in this ad-hoc
- * chat room.
- */
- public int getParticipantsCount()
- {
- return this.participants.size();
- }
-
- /**
- * Returns the subject.
- *
- * @return null
- */
- public String getSubject()
- {
- return null;
- }
-
- /**
- * Invites another user to this room. If we're not joined nothing will
- * happen.
- *
- * @param userAddress the address of the user (email address) to invite to
- * the room.(one may also invite users not on their contact
- * list).
- * @param reason You cannot specify a Reason inside the msn protocol
- */
- public void invite(String userAddress, String reason)
- {
- // msn requires lower case email addresses
- userAddress = userAddress.toLowerCase();
-
- if (switchboard == null)
- {
- pendingInvitations.add(userAddress);
- }
- else
- {
- switchboard.inviteContact(Email.parseStr(userAddress));
- }
- }
-
- public void join()
- {
- // We don't specify a reason.
- this.opSetAdHocMuc.fireLocalUserPresenceEvent(this,
- LocalUserAdHocChatRoomPresenceChangeEvent.LOCAL_USER_JOINED, null);
-
- // We buffered the messages before the user has joined the chat, now the
- // user has joined so we fire them again
- for (EventObject evt : this.messageBuffer)
- {
- this.fireMessageEvent(evt);
- }
- }
-
- /**
- * Leave this chat room. Once this method is called, the user won't be
- * listed as a member of the chat room any more and no further chat events
- * will be delivered. Depending on the underlying protocol and
- * implementation leave() might cause the room to be destroyed if it has
- * been created by the local user.
- */
- public void leave()
- {
- if (switchboard != null)
- {
- switchboard.close();
- switchboard = null;
- }
-
- Iterator<Contact> participantsIter
- = participants.values().iterator();
-
- while (participantsIter.hasNext())
- {
- Contact participant = participantsIter.next();
-
- fireParticipantPresenceEvent(participant,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_LEFT,
- "Local user has left the chat room.");
- }
-
- // Delete the list of members
- participants.clear();
- }
-
- /**
- * Returns if this chatroom is a system ones.
- *
- * @return false
- */
- public boolean isSystem()
- {
- return false;
- }
-
- /**
- * Sends the given message through the participants of this ad-hoc chat
- * room.
- *
- * @param message the message to delivered
- *
- * @throws OperationFailedException if send fails
- */
- public void sendMessage(Message message) throws OperationFailedException
- {
- if (logger.isInfoEnabled())
- logger.info("switchboard="+this.switchboard);
- this.switchboard.sendText(message.getContent());
-
- AdHocChatRoomMessageDeliveredEvent msgDeliveredEvt
- = new AdHocChatRoomMessageDeliveredEvent(
- this,
- new Date(),
- message,
- AdHocChatRoomMessageDeliveredEvent.CONVERSATION_MESSAGE_DELIVERED);
-
- this.fireMessageEvent(msgDeliveredEvt);
- }
-
- /**
- * Sets the corresponding switchboard.
- *
- * @param switchboard Corresponding switchboard.
- */
- public void setSwitchboard(MsnSwitchboard switchboard)
- {
- this.switchboard = switchboard;
- }
-
- /**
- * Creates the corresponding AdHocChatRoomParticipantPresenceChangeEvent and
- * notifies all <tt>AdHocChatRoomParticipantPresenceListener</tt>s that a
- * participant has joined or left this <tt>AdHocChatRoom</tt>.
- *
- * @param participant the <tt>Contact</tt>
- * @param eventID the identifier of the event
- * @param eventReason the reason of the event
- */
- private void fireParticipantPresenceEvent( Contact participant,
- String eventID,
- String eventReason)
- {
- AdHocChatRoomParticipantPresenceChangeEvent evt =
- new AdHocChatRoomParticipantPresenceChangeEvent(
- this, participant, eventID, eventReason);
-
- if (logger.isTraceEnabled())
- logger.trace("Will dispatch the following AdHocChatRoom event: " + evt);
-
- Iterator<AdHocChatRoomParticipantPresenceListener> listeners = null;
- synchronized (this.participantsPresenceListeners)
- {
- listeners = new ArrayList<AdHocChatRoomParticipantPresenceListener>(
- this.participantsPresenceListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- listeners.next().participantPresenceChanged(evt);
- }
- }
-
- /**
- * Notifies all interested listeners that a
- * <tt>AdHocChatRoomMessageDeliveredEvent</tt>,
- * <tt>AdHocChatRoomMessageReceivedEvent</tt> or a
- * <tt>AdHocChatRoomMessageDeliveryFailedEvent</tt> has been fired.
- *
- * @param evt The specific event
- */
- public void fireMessageEvent(EventObject evt)
- {
- Iterator<AdHocChatRoomMessageListener> listeners = null;
- synchronized (messageListeners)
- {
- listeners = new ArrayList<AdHocChatRoomMessageListener>(
- messageListeners).iterator();
- }
-
- if (!listeners.hasNext())
- {
- messageBuffer.add(evt);
- }
-
- while (listeners.hasNext())
- {
- AdHocChatRoomMessageListener listener = listeners.next();
-
- if (evt instanceof AdHocChatRoomMessageDeliveredEvent)
- {
- listener.messageDelivered(
- (AdHocChatRoomMessageDeliveredEvent) evt);
- }
- else if (evt instanceof AdHocChatRoomMessageReceivedEvent)
- {
- listener.messageReceived(
- (AdHocChatRoomMessageReceivedEvent) evt);
- }
- else if (evt instanceof AdHocChatRoomMessageDeliveryFailedEvent)
- {
- listener.messageDeliveryFailed(
- (AdHocChatRoomMessageDeliveryFailedEvent) evt);
- }
- }
- }
-
- /**
- * Fills the participants list with all participants inside the switchboard
- * (ad-hoc chat room).
- *
- * @param switchboard The corresponding switchboard
- */
- public void updateParticipantsList(MsnSwitchboard switchboard)
- {
- MsnContact[] contacts = switchboard.getAllContacts();
-
- for (MsnContact msnContact : contacts)
- {
- if (!this.participants.containsKey(msnContact.getId()))
- {
- // if the member is not inside the members list, create a
- // contact instance,
- // add it to the list and fire a member presence event
- ContactMsnImpl contact
- = presenceOpSet.getServerStoredContactList()
- .findContactById(
- msnContact.getEmail().getEmailAddress());
-
- if (contact == null)
- contact = new ContactMsnImpl(
- msnContact,
- presenceOpSet.getServerStoredContactList(),
- false,
- false);
-
- this.participants.put(msnContact.getId(), contact);
-
- fireParticipantPresenceEvent(
- contact,
- AdHocChatRoomParticipantPresenceChangeEvent.CONTACT_JOINED,
- null);
- }
- }
-
- for (String contactAddress: this.pendingInvitations)
- {
- this.invite(contactAddress, "");
- }
- // We have sent all invites and we can now clear the content of
- // pending invitations.
- pendingInvitations.clear();
- }
-
- /**
- * Returns the identifier of this ad-hoc chat room.
- *
- * @return a <tt>String</tt> containing the identifier of this ad-hoc room
- */
- public String getIdentifier()
- {
- return this.getName();
- }
-
- /**
- * Removes the given participant presence listener.
- *
- * @param listener the listener to remove
- */
- public void removeParticipantPresenceListener(
- AdHocChatRoomParticipantPresenceListener listener)
- {
- synchronized (this.participantsPresenceListeners)
- {
- if (this.participantsPresenceListeners.contains(listener))
- this.participantsPresenceListeners.remove(listener);
- }
- }
-
- /**
- * Removes the given message listener.
- *
- * @param listener the listener to remove
- */
- public void removeMessageListener(AdHocChatRoomMessageListener listener)
- {
- synchronized(this.messageListeners)
- {
- if(this.messageListeners.contains(listener))
- {
- this.messageListeners.remove(listener);
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ContactGroupMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ContactGroupMsnImpl.java
deleted file mode 100644
index 64085a6..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ContactGroupMsnImpl.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.sf.jml.*;
-
-/**
- * The Msn implementation of the ContactGroup interface. Instances of this class
- * (contrary to <tt>RootContactGroupMsnImpl</tt>) may only contain buddies
- * and cannot have sub groups. Note that instances of this class only use the
- * corresponding smack source group for reading their names and only
- * initially fill their <tt>buddies</tt> <tt>java.util.List</tt> with
- * the ContactMsnImpl objects corresponding to those contained in the source
- * group at the moment it is being created. They would, however, never try to
- * sync or update their contents ulteriorly. This would have to be done through
- * the addContact()/removeContact() methods.
- * The content of buddies is created on creating of the group and when the smack
- * source group is changed.
- *
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class ContactGroupMsnImpl
- extends AbstractContactGroupMsnImpl
-{
-
- /**
- * Maps all MSN IDs in our contact list to the actual contacts so that we
- * could easily search the set of existing contacts. Note that we only store
- * lower case strings in the left column because MSN IDs in XMPP are not
- * case sensitive.
- */
- private final Map<String, Contact> buddies
- = new Hashtable<String, Contact>();
-
- private boolean isResolved = false;
-
- /**
- * The Msn Group corresponding to this contact group.
- */
- private MsnGroup msnGroup = null;
-
- /**
- * a list that would always remain empty. We only use it so that we're able
- * to extract empty iterators
- */
- private final List<ContactGroup> dummyGroupsList
- = new LinkedList<ContactGroup>();
-
- private final ServerStoredContactListMsnImpl ssclCallback;
-
- /**
- * Whether this group is persistent.
- */
- private boolean isPersistent;
-
- /**
- * Creates an Msn group using the specified <tt>RosterGroup</tt> as
- * a source. The newly created group will always return the name of the
- * underlying RosterGroup and would thus automatically adapt to changes.
- * It would, however, not receive or try to poll for modifications of the
- * buddies it contains and would therefore have to be updated manually by
- * ServerStoredContactListImpl update will only be done if source group
- * is changed.
-
- * @param msnGroup the Msn Group corresponding to the group
- * @param groupMembers the group members that we should add to the group.
- * @param ssclCallback a callback to the server stored contact list
- * we're creating.
- * @param isResolved a boolean indicating whether or not the group has been
- * resolved against the server.
- */
- ContactGroupMsnImpl(MsnGroup msnGroup,
- MsnContact[] groupMembers,
- ServerStoredContactListMsnImpl ssclCallback,
- boolean isResolved,
- boolean isPersistent)
- {
- this.msnGroup = msnGroup;
- this.isResolved = isResolved;
- this.isPersistent = isPersistent;
- this.ssclCallback = ssclCallback;
-
- for (MsnContact groupMember : groupMembers)
- {
- /*
- * Only add the contact if it doesn't already exist in some other
- * group. This is necessary because MSN would allow having one and
- * the same contact in more than one group.
- */
- if(ssclCallback.findContactById(
- groupMember.getEmail().getEmailAddress())
- == null)
- addContact(
- new ContactMsnImpl(groupMember, ssclCallback, true, true));
- }
- }
-
- /**
- * Returns the number of <tt>Contact</tt> members of this
- * <tt>ContactGroup</tt>
- *
- * @return an int indicating the number of <tt>Contact</tt>s,
- * members of this <tt>ContactGroup</tt>.
- */
- public int countContacts()
- {
- return buddies.size();
- }
-
- /**
- * Returns a reference to the root group which in Msn is the parent of
- * any other group since the protocol does not support subgroups.
- * @return a reference to the root group.
- */
- public ContactGroup getParentContactGroup()
- {
- return ssclCallback.getRootGroup();
- }
-
- /**
- * Adds the specified contact to the end of this group.
- * @param contact the new contact to add to this group
- */
- void addContact(ContactMsnImpl contact)
- {
- buddies.put(contact.getAddress().toLowerCase(), contact);
- }
-
-
- /**
- * Removes the specified contact from this contact group
- * @param contact the contact to remove.
- *
- * @return <tt>true</tt> if the argument was a component of this vector;
- * false otherwise.
- */
- boolean removeContact(ContactMsnImpl contact)
- {
- return buddies.remove(contact.getAddress().toLowerCase()) != null;
- }
-
- /**
- * Returns an Iterator over all contacts, member of this
- * <tt>ContactGroup</tt>.
- *
- * @return a java.util.Iterator over all contacts inside this
- * <tt>ContactGroup</tt>. In case the group doesn't contain any members it
- * will return an empty iterator.
- */
- public Iterator<Contact> contacts()
- {
- return buddies.values().iterator();
- }
-
- /**
- * Returns the <tt>Contact</tt> with the specified address or
- * identifier.
- * @param id the address or identifier of the <tt>Contact</tt> we are
- * looking for.
- * @return the <tt>Contact</tt> with the specified id or address.
- */
- public Contact getContact(String id)
- {
- return this.findContact(id);
- }
-
- /**
- * Returns the name of this group.
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- return msnGroup.getGroupName();
- }
-
- /**
- * Determines whether the group may contain subgroups or not.
- *
- * @return always false since only the root group may contain subgroups.
- */
- public boolean canContainSubgroups()
- {
- return false;
- }
-
- /**
- * Returns the subgroup with the specified index (i.e. always null since
- * this group may not contain subgroups).
- *
- * @param index the index of the <tt>ContactGroup</tt> to retrieve.
- * @return always null
- */
- public ContactGroup getGroup(int index)
- {
- return null;
- }
-
- /**
- * Returns the subgroup with the specified name.
- * @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(String groupName)
- {
- return null;
- }
-
- /**
- * Returns an empty iterator. Subgroups may only be present in the root
- * group.
- *
- * @return an empty iterator
- */
- public Iterator<ContactGroup> subgroups()
- {
- return dummyGroupsList.iterator();
- }
-
- /**
- * Returns the number of subgroups contained by this group, which is
- * always 0 since sub groups in the protocol may only be contained
- * by the root group - <tt>RootContactGroupImpl</tt>.
- * @return a 0 int.
- */
- public int countSubgroups()
- {
- return 0;
- }
-
- /**
- * Returns a hash code value for the object, which is actually the hashcode
- * value of the groupname.
- *
- * @return a hash code value for this ContactGroup.
- */
- @Override
- public int hashCode()
- {
- return getGroupName().hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this group.
- *
- * @param obj the reference object with which to compare.
- * @return <tt>true</tt> if this object is the same as the obj
- * argument; <tt>false</tt> otherwise.
- */
- @Override
- public boolean equals(Object obj)
- {
- if( obj == this )
- return true;
-
- if (obj == null
- || !(obj instanceof ContactGroupMsnImpl) )
- return false;
-
- if(!((ContactGroup)obj).getGroupName().equals(getGroupName()))
- return false;
-
- if(getProtocolProvider() != ((ContactGroup)obj).getProtocolProvider())
- return false;
-
- //since Msn does not support having two groups with the same name
- // at this point we could bravely state that the groups are the same
- // and not bother to compare buddies. (gotta check that though)
- return true;
- }
-
- /**
- * Returns the protocol provider that this group belongs to.
- * @return a regerence to the ProtocolProviderService instance that this
- * ContactGroup belongs to.
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return this.ssclCallback.getParentProvider();
- }
-
- /**
- * Returns a string representation of this group, in the form
- * MsnGroup.GroupName[size]{ buddy1.toString(), buddy2.toString(), ...}.
- * @return a String representation of the object.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer("MSnGroup.");
- buff.append(getGroupName());
- buff.append(", childContacts="+countContacts()+":[");
-
- Iterator<Contact> contacts = contacts();
- while (contacts.hasNext())
- {
- Contact contact = contacts.next();
- buff.append(contact.toString());
- if(contacts.hasNext())
- buff.append(", ");
- }
- return buff.append("]").toString();
- }
-
- /**
- * Returns the contact encapsulating with the spcieified name or
- * null if no such contact was found.
- *
- * @param id the id for the contact we're looking for.
- * @return the <tt>ContactMsnImpl</tt> corresponding to the specified
- * screnname or null if no such contact existed.
- */
- ContactMsnImpl findContact(String id)
- {
- if (id == null)
- return null;
-
- return (ContactMsnImpl)buddies.get(id.toLowerCase());
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return 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 group has been resolved against
- * the server. Unresolved group are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts and groups to their corresponding on-line
- * buddies.
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Resolve this contact group against the specified group
- * @param msnGroup the server stored group
- */
- void setResolved(MsnGroup msnGroup)
- {
- if(isResolved)
- return;
-
- this.isResolved = true;
- this.isPersistent = true;
-
- this.msnGroup = msnGroup;
-
- MsnContact[] contacts = msnGroup.getContacts();
- for (int i = 0; i < contacts.length; i++)
- {
- MsnContact item = contacts[i];
-
- ContactMsnImpl contact =
- ssclCallback.findContactById(item.getEmail().getEmailAddress());
- if(contact != null)
- {
- contact.setResolved(item);
-
- ssclCallback.fireContactResolved(this, contact);
- }
- else
- {
- ContactMsnImpl newContact =
- new ContactMsnImpl(item, ssclCallback, true, true);
- addContact(newContact);
-
- ssclCallback.fireContactAdded(this, newContact);
- }
-
- }
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group. In this we
- * use the name of the group as an identifier. This may cause problems
- * though, in clase the name is changed by some other application between
- * consecutive runs of the sip-communicator.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return getGroupName();
- }
-
- /**
- * The source group we are encapsulating
- * @return MsnGroup
- */
- MsnGroup getSourceGroup()
- {
- return msnGroup;
- }
-
- /**
- * Change the source group
- * change the buddies
- *
- * @param newGroup MsnGroup
- */
- void setSourceGroup(MsnGroup newGroup)
- {
- this.msnGroup = newGroup;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java
deleted file mode 100644
index 9db02a3..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.msnconstants.*;
-import net.sf.jml.*;
-
-/**
- * The Msn implementation of the service.protocol.Contact interface.
- * @author Damian Minkov
- */
-public class ContactMsnImpl
- extends AbstractContact
-{
- private MsnContact contact = null;
- private byte[] image = null;
- private PresenceStatus status = MsnStatusEnum.OFFLINE;
- private ServerStoredContactListMsnImpl ssclCallback = null;
- private boolean isPersistent = false;
- private boolean isResolved = false;
-
- /**
- * The contact's status message.
- */
- private String statusMessage = null;
-
- /**
- * Creates an MsnContactImpl
- * @param contact the contact object that we will be encapsulating.
- * @param ssclCallback a reference to the ServerStoredContactListImpl
- * instance that created us.
- * @param isPersistent determines whether this contact is persistent or not.
- * @param isResolved specifies whether the contact has been resolved against
- * the server contact list
- */
- ContactMsnImpl(MsnContact contact,
- ServerStoredContactListMsnImpl ssclCallback,
- boolean isPersistent,
- boolean isResolved)
- {
- this.contact = contact;
- this.ssclCallback = ssclCallback;
- this.isPersistent = isPersistent;
- this.isResolved = isResolved;
- }
-
- /**
- * Returns the Msn Userid of this contact
- * @return the Msn Userid of this contact
- */
- public String getAddress()
- {
- if(isResolved)
- return contact.getEmail().getEmailAddress();
- else
- return contact.getId();
- }
-
- /**
- * Returns an avatar if one is already present or <tt>null</tt> in case it
- * is not in which case it the method also queues the contact for image
- * updates.
- *
- * @return the avatar of this contact or <tt>null</tt> if no avatar is
- * currently available.
- */
- public byte[] getImage()
- {
- return getImage(true);
- }
-
- /**
- * Returns a reference to the image assigned to this contact. If no image
- * is present and the retrieveIfNecessary flag is true, we schedule the
- * image for retrieval from the server.
- *
- * @param retrieveIfNecessary specifies whether the method should queue
- * this contact for avatar update from the server.
- *
- * @return a reference to the image currently stored by this contact.
- */
- byte[] getImage(boolean retrieveIfNecessary)
- {
- if((image == null) && retrieveIfNecessary)
- ssclCallback.addContactForImageUpdate(this);
- return image;
- }
-
- /**
- * Set the image of the contact
- *
- * @param imgBytes the new image we'd like to assign this contact.
- */
- void setImage(byte[] imgBytes)
- {
- this.image = imgBytes;
- }
-
- /**
- * 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("MsnContact[ id=");
- buff.append(getAddress()).append("]");
-
- return buff.toString();
- }
-
- /**
- * Sets the status that this contact is currently in. The method is to
- * only be called as a result of a status update received from the server.
- *
- * @param status the MsnStatusEnum that this contact is currently in.
- */
- void updatePresenceStatus(PresenceStatus status)
- {
- this.status = status;
- }
-
- /**
- * Returns the status of the contact as per the last status update we've
- * received for it. Note that this method is not to perform any network
- * operations and will simply return the status received in the last
- * status update message. If you want a reliable way of retrieving someone's
- * status, you should use the <tt>queryContactStatus()</tt> method in
- * <tt>OperationSetPresence</tt>.
- * @return the PresenceStatus that we've received in the last status update
- * pertaining to this contact.
- */
- public PresenceStatus getPresenceStatus()
- {
- return status;
- }
-
- /**
- * Returns a String that could be used by any user interacting modules for
- * referring to this contact. An alias is not necessarily unique but is
- * often more human readable than an address (or id).
- * @return a String that can be used for referring to this contact when
- * interacting with the user.
- */
- public String getDisplayName()
- {
- String name = contact.getFriendlyName();
-
- if (name == null)
- name = getAddress();
-
- return name;
- }
-
- /**
- * Returns a reference to the contact group that this contact is currently
- * a child of or null if the underlying protocol does not suppord persistent
- * presence.
- * @return a reference to the contact group that this contact is currently
- * a child of or null if the underlying protocol does not suppord persistent
- * presence.
- */
- public ContactGroup getParentContactGroup()
- {
- return ssclCallback.findContactGroup(this);
- }
-
-
- /**
- * Returns a reference to the protocol provider that created the contact.
- * @return a refererence to an instance of the ProtocolProviderService
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return ssclCallback.getParentProvider();
- }
-
- /**
- * Determines whether or not this contact is being stored by the server.
- * Non persistent contacts are common in the case of simple, non-persistent
- * presence operation sets. They could however also be seen in persistent
- * presence operation sets when for example we have received an event
- * from someone not on our contact list. Non persistent contacts are
- * volatile even when coming from a persistent presence op. set. They would
- * only exist until the application is closed and will not be there next
- * time it is loaded.
- * @return true if the contact is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return isPersistent;
- }
-
- /**
- * Specifies whether this contact is to be considered persistent or not. The
- * method is to be used _only_ when a non-persistent contact has been added
- * to the contact list and its encapsulated VolatileBuddy has been repalced
- * with a standard buddy.
- * @param persistent true if the buddy is to be considered persistent and
- * false for volatile.
- */
- void setPersistent(boolean persistent)
- {
- this.isPersistent = persistent;
- }
-
- /**
- * Resolve this contact against the given entry
- * @param entry the server stored entry
- */
- void setResolved(MsnContact entry)
- {
- if(isResolved)
- return;
-
- this.isResolved = true;
- this.isPersistent = true;
- contact = entry;
- }
-
- /**
- * Returns the persistent data
- * @return the persistent data
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this contact has been resolved against the
- * server. Unresolved contacts are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped contacts to their on-line buddies.
- * @return true if the contact has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- public void setPersistentData(String persistentData)
- {
- }
-
- /**
- * Get source contact
- * @return MsnContact
- */
- MsnContact getSourceContact()
- {
- return contact;
- }
-
- /**
- * Return the current status message of this contact.
- *
- * @return the current status messages
- */
- public String getStatusMessage()
- {
- return statusMessage;
- }
-
- /**
- * Changes the current status message of this contact.
- *
- * @param newStatusMessage the new message.
- */
- public void setStatusMessage(String newStatusMessage)
- {
- this.statusMessage = newStatusMessage;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/EventAdapter.java b/src/net/java/sip/communicator/impl/protocol/msn/EventAdapter.java
deleted file mode 100644
index 9562f32..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/EventAdapter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.sf.jml.*;
-
-/**
- * Contactlist modification listener receives events
- * for successful changing
- *
- * @author Damian Minkov
- */
-public class EventAdapter
- implements MsnContactListEventListener
-{
- /**
- * Message is successfully delivered
- * @param transactionID int the transaction that send the message
- */
- public void messageDelivered(int transactionID){}
- /**
- * Message is not delivered
- * @param transactionID int the transaction that send the message
- */
- public void messageDeliveredFailed(int transactionID){}
- /**
- * Indicates that a group is successfully renamed
- * @param group MsnGroup the renamed group with the new name
- */
- public void groupRenamed(MsnGroup group){}
-
- /**
- * Indicates that we are logged out
- * because account logged in from other location
- */
- public void loggingFromOtherLocation(){}
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/EventManager.java b/src/net/java/sip/communicator/impl/protocol/msn/EventManager.java
deleted file mode 100644
index 646be8a..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/EventManager.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-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 net.sf.jml.*;
-import net.sf.jml.impl.*;
-import net.sf.jml.net.*;
-import net.sf.jml.net.Message;
-import net.sf.jml.protocol.*;
-import net.sf.jml.protocol.incoming.*;
-
-/**
- * Manager which listens for changing of the contact list and fires some events.
- *
- * @author Damian Minkov
- */
-public class EventManager
- extends SessionAdapter
-{
- /**
- * The class logger.
- */
- private static final Logger logger = Logger.getLogger(EventManager.class);
-
- /**
- * Whether we are connected.
- */
- private boolean connected = false;
-
- /**
- * The timer for monitoring connection.
- */
- private Timer connectionTimer;
-
- /**
- * Event listeners.
- */
- private final List<MsnContactListEventListener> listeners
- = new Vector<MsnContactListEventListener>();
-
- /**
- * The messenger.
- */
- private final BasicMessenger msnMessenger;
-
- /**
- * The provider that is on top of us.
- */
- private final ProtocolProviderServiceMsnImpl msnProvider;
-
- /**
- * Initializes a new <tt>EventManager</tt> instance which is to manage the
- * events of a specific <tt>BasicMessenger</tt> as part of its operation for
- * the purposes of a specific <tt>ProtocolProviderServiceMsnImpl</tt>.
- *
- * @param msnProvider the <tt>ProtocolProviderServiceMsnImpl</tt> which is
- * the creator of the new instance
- * @param msnMessenger the <tt>BasicMessenger</tt> which is to have its
- * events managed by the new instance
- */
- public EventManager(ProtocolProviderServiceMsnImpl msnProvider,
- BasicMessenger msnMessenger)
- {
- this.msnProvider = msnProvider;
- this.msnMessenger = msnMessenger;
-
- msnMessenger.addSessionListener(this);
- }
-
- /**
- * Adds listener of the modification fired events
- * @param listener the modification listener we're adding
- */
- public void addModificationListener(MsnContactListEventListener listener)
- {
- synchronized(listeners)
- {
- if (!listeners.contains(listener))
- listeners.add(listener);
- }
- }
-
- /**
- * Removes listener of the modification fired events
- * @param listener EventListener
- */
- public void removeModificationListener(MsnContactListEventListener listener)
- {
- synchronized(listeners)
- {
- listeners.remove(listener);
- }
- }
-
- /**
- * Called from the underling lib when message is sent to the server
- * @param session Session
- * @param message Message
- * @throws Exception
- */
- @Override
- public void messageSent(Session session, Message message) throws Exception
- {
- if (logger.isTraceEnabled())
- logger.trace(msnMessenger.getOwner().getEmail().getEmailAddress() +
- " outgoing " + message);
- }
-
- /**
- * Called from the underling lib when message is received from the server
- * @param session Session
- * @param message Message
- * @throws Exception
- */
- @Override
- public void messageReceived(Session session, Message message)
- throws Exception
- {
- MsnIncomingMessage incoming = (MsnIncomingMessage)((WrapperMessage)message)
- .getMessage();
-
- if (logger.isTraceEnabled())
- logger.trace(msnMessenger.getOwner().getEmail().getEmailAddress() +
- " incoming : " + incoming);
-
- if(incoming instanceof IncomingACK)
- {
- //indicate the message has successed send to remote user.
- fireMessageDelivered(((IncomingACK)incoming).getTransactionId());
- }
- else if(incoming instanceof IncomingNAK)
- {
- //indicate the message has not successed send to remote user.
- fireMessageDeliveredFailed(((IncomingNAK)incoming).getTransactionId());
- }
- else if(incoming instanceof IncomingREG)
- {
- //indicate the group name has changed successfully.
- IncomingREG incomingREG = (IncomingREG)incoming;
-
- MsnGroupImpl group = (MsnGroupImpl)msnMessenger.getContactList().
- getGroup(incomingREG.getGroupId());
- fireGroupRenamed(group);
- }
- else if(incoming instanceof IncomingOUT)
- {
- IncomingOUT incomingOUT = (IncomingOUT)incoming;
- if(incomingOUT.isLoggingFromOtherLocation())
- fireLoggingFromOtherLocation();
- }
- else if(incoming instanceof IncomingQNG)
- {
- connected = true;
- }
- }
-
- /**
- * Called when there was timeout on the connection.
- * @param socketSession
- * @throws Exception
- */
- @Override
- public void sessionTimeout(Session socketSession) throws Exception
- {
- Timer connectionTimer;
-
- /*
- * Delays the creation of Timer because it immediately starts a new
- * Thread while it may not be necessary at all.
- */
- synchronized (this)
- {
- if (this.connectionTimer == null)
- this.connectionTimer = new Timer("Msn connection timer", true);
- connectionTimer = this.connectionTimer;
- }
-
- connectionTimer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- if(!connected && msnProvider.isRegistered())
- {
- msnProvider.unregisterInternal(false);
- msnProvider.fireRegistrationStateChanged(
- msnProvider.getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
- null);
- }
- }
- }, 20000);
- connected = false;
- }
-
- /**
- * Fired when a message is delivered successfully
- * @param transactionID int
- */
- private void fireMessageDelivered(int transactionID)
- {
- synchronized(listeners)
- {
- for (MsnContactListEventListener listener : listeners)
- listener.messageDelivered(transactionID);
- }
- }
-
- /**
- * Fired when a message is not delivered successfully
- * @param transactionID int
- */
- private void fireMessageDeliveredFailed(int transactionID)
- {
- synchronized(listeners)
- {
- for (MsnContactListEventListener listener : listeners)
- listener.messageDeliveredFailed(transactionID);
- }
- }
-
- /**
- * Fired when a group is renamed successfully
- * @param group MsnGroup
- */
- private void fireGroupRenamed(MsnGroup group)
- {
- synchronized(listeners)
- {
- for (MsnContactListEventListener listener : listeners)
- listener.groupRenamed(group);
- }
- }
-
- /**
- * Fired when we received event for logging in from other location
- */
- private void fireLoggingFromOtherLocation()
- {
- synchronized (listeners)
- {
- for (MsnContactListEventListener listener : listeners)
- listener.loggingFromOtherLocation();
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java
deleted file mode 100644
index 6774ef6..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/FileTransferImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.sf.jml.*;
-
-/**
- * The Filetransfer imeplementation for msn.
- * @author Damian Minkov
- */
-public class FileTransferImpl
- extends AbstractFileTransfer
-{
- private String id = null;
- private Contact contact = null;
- private File file = null;
- private int direction = -1;
- private long transferedBytes;
- private MsnFileTransfer fileTransfer;
-
- public FileTransferImpl(
- MsnFileTransfer fileTransfer,
- Contact contact, File file, int direction)
- {
- this.fileTransfer = fileTransfer;
- this.id = fileTransfer.getID();
- this.contact = contact;
- this.file = file;
- this.direction = direction;
- }
-
- /**
- * Cancels this file transfer. When this method is called transfer should
- * be interrupted.
- */
- @Override
- public void cancel()
- {
- fileTransfer.cancel();
- }
-
- /**
- * Returns the number of bytes already transfered through this file transfer.
- *
- * @return the number of bytes already transfered through this file transfer
- */
- @Override
- public long getTransferedBytes()
- {
- return transferedBytes;
- }
-
- /**
- * Uniquie ID that is identifying the FileTransfer
- * if the request has been accepted.
- *
- * @return the id.
- */
- public String getID()
- {
- return id;
- }
-
- /**
- * The file transfer direction.
- * @return returns the direction of the file transfer : IN or OUT.
- */
- public int getDirection()
- {
- return direction;
- }
-
- /**
- * Returns the file that is transfered.
- *
- * @return the file
- */
- public File getLocalFile()
- {
- return file;
- }
-
- /**
- * Returns the contact that we are transfering files with.
- * @return the contact.
- */
- public Contact getContact()
- {
- return contact;
- }
-
- /**
- * @param transferedBytes the transferedBytes to set
- */
- public void setTransferedBytes(long transferedBytes)
- {
- this.transferedBytes = transferedBytes;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java
deleted file mode 100644
index b6744f1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/IncomingFileTransferRequestMsnImpl.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-
-/**
- * Msn implementation of the incoming file transfer request
- *
- * @author Damian Minkov
- */
-public class IncomingFileTransferRequestMsnImpl
- implements IncomingFileTransferRequest
-{
- /**
- * Logger
- */
- private static final Logger logger =
- Logger.getLogger(IncomingFileTransferRequestMsnImpl.class);
-
- private OperationSetFileTransferMsnImpl fileTransferOpSet;
-
- /**
- * The msn file transfer received
- */
- private MsnFileTransfer incomingFileTransfer = null;
-
- private Contact sender = null;
-
- private Date date;
-
- private String id;
-
- private boolean rejected = false;
-
- /**
- * Constructor
- *
- * @param incomingFileTransfer MSN file transfer request that was received
- */
- public IncomingFileTransferRequestMsnImpl(
- OperationSetFileTransferMsnImpl fileTransferOpSet,
- MsnFileTransfer incomingFileTransfer,
- Contact sender,
- Date date)
- {
- this.fileTransferOpSet = fileTransferOpSet;
- this.incomingFileTransfer = incomingFileTransfer;
- this.sender = sender;
- this.date = date;
-
- id = incomingFileTransfer.getID();
- }
-
- /**
- * Uniquie ID that is identifying the request and then the FileTransfer
- * if the request has been accepted.
- *
- * @return the id.
- */
- public String getID()
- {
- return id;
- }
-
- /**
- * Returns a String that represents the name of the file that is being
- * received.
- * If there is no name, returns null.
- * @return a String that represents the name of the file
- */
- public String getFileName()
- {
- return incomingFileTransfer.getFile().getName();
- }
-
- /**
- * Returns a String that represents the description of the file that is
- * being received.
- * If there is no description available, returns null.
- *
- * @return a String that represents the description of the file
- */
- public String getFileDescription()
- {
- return "";
- }
-
- /**
- * Returns a long that represents the size of the file that is being
- * received.
- * If there is no file size available, returns null.
- *
- * @return a long that represents the size of the file
- */
- public long getFileSize()
- {
- return incomingFileTransfer.getFileTotalSize();
- }
-
- /**
- * Returns a String that represents the name of the sender of the file
- * being received.
- * If there is no sender name available, returns null.
- *
- * @return a String that represents the name of the sender
- */
- public Contact getSender()
- {
- return sender;
- }
-
- /**
- * Function called to accept and receive the file.
- *
- * @param file the file to accept
- * @return the <tt>FileTransfer</tt> object managing the transfer
- */
- public FileTransfer acceptFile(File file)
- {
- incomingFileTransfer.setFile(file);
-
- FileTransferImpl inFileTransfer =
- new FileTransferImpl(
- incomingFileTransfer,
- sender,
- file,
- FileTransfer.IN);
-
- FileTransferCreatedEvent event
- = new FileTransferCreatedEvent(inFileTransfer, date);
-
- fileTransferOpSet.fireFileTransferCreated(event);
-
- inFileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.PREPARING);
-
- incomingFileTransfer.start();
-
- return inFileTransfer;
- }
-
- /**
- * Function called to refuse the file.
- */
- public void rejectFile()
- {
- try
- {
- rejected = true;
-
- incomingFileTransfer.cancel();
-
- fileTransferOpSet.fireFileTransferRequestRejected(
- new FileTransferRequestEvent(fileTransferOpSet, this, date));
- }
- catch(IllegalStateException e)
- {
- if (logger.isDebugEnabled())
- logger.debug("Error rejecting file",e);
- return;
- }
- }
-
- public byte[] getThumbnail()
- {
- return null;
- }
-
- /**
- * @return the date
- */
- public Date getDate()
- {
- return date;
- }
-
- /**
- * @return the rejected
- */
- public boolean isRejected()
- {
- return rejected;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/MessageMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/MessageMsnImpl.java
deleted file mode 100644
index c1ffeb4..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/MessageMsnImpl.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license. See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A simple implementation of the <tt>Message</tt> interface. Right now the
- * message only supports test contents and no binary data.
- *
- * @author Damian Minkov
- * @author Lubomir Marinov
- */
-public class MessageMsnImpl
- extends AbstractMessage
-{
-
- /**
- * Creates an instance of this Message with the specified parameters.
- *
- * @param content the text content of the message.
- * @param contentType a MIME string indicating the content type of the
- * <tt>content</tt> String.
- * @param contentEncoding a MIME String indicating the content encoding of
- * the <tt>content</tt> String.
- * @param subject the subject of the message or null for empty.
- */
- public MessageMsnImpl(String content, String contentType,
- String contentEncoding, String subject)
- {
- super(content, contentType, contentEncoding, subject);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/MsnAccountID.java b/src/net/java/sip/communicator/impl/protocol/msn/MsnAccountID.java
deleted file mode 100644
index 5580928..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/MsnAccountID.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The Msn implementation of a sip-communicator AccountID
- *
- * @author Damian Minkov
- */
-public class MsnAccountID
- extends AccountID
-{
- /**
- * Creates an account id from the specified id and account properties.
- * @param id the id identifying this account
- * @param accountProperties any other properties necessary for the account.
- */
- MsnAccountID(String id, Map<String, String> accountProperties )
- {
- super(id, accountProperties, ProtocolNames.MSN, "msn.com");
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java b/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java
deleted file mode 100644
index 50b1fd2..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/MsnActivator.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.configuration.*;
-import org.jitsi.service.fileaccess.*;
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Loads the MSN provider factory and registers it with service in the OSGI
- * bundle context.
- *
- * @author Damian Minkov
- * @author Lubomir Marinov
- */
-public class MsnActivator
- implements BundleActivator
-{
- private ServiceRegistration msnPpFactoryServReg = null;
- private static BundleContext bundleContext = null;
- private static ConfigurationService configurationService = null;
- private static FileAccessService fileAccessService = null;
-
- private static ProtocolProviderFactoryMsnImpl msnProviderFactory = null;
-
- /**
- * The <tt>ResourceManagementService</tt> instance which provides common
- * resources such as internationalized and localized strings, images to the
- * MSN bundle.
- */
- private static ResourceManagementService resources;
-
- /**
- * Called when this bundle is started so the Framework can perform the
- * bundle-specific activities necessary to start this bundle.
- *
- * @param context The execution context of the bundle being started.
- * @throws Exception If this method throws an exception, this bundle is
- * marked as stopped and the Framework will remove this bundle's
- * listeners, unregister all services registered by this bundle, and
- * release all services used by this bundle.
- */
- public void start(BundleContext context) throws Exception
- {
- MsnActivator.bundleContext = context;
-
- Hashtable<String, String> hashtable = new Hashtable<String, String>();
- hashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.MSN);
-
- msnProviderFactory = new ProtocolProviderFactoryMsnImpl();
-
- /*
- * Fixes issue #647: MalformedURLException in java-jml. Has to execute
- * before a login in attempted so before the factory is registered seems
- * OK since the ProtocolProviderService instances are not created yet.
- */
- ReferenceURLStreamHandlerService.registerService(bundleContext);
-
- //reg the msn account man.
- msnPpFactoryServReg = context.registerService(
- ProtocolProviderFactory.class.getName(),
- msnProviderFactory,
- hashtable);
- }
-
- /**
- * Returns a reference to a ConfigurationService implementation currently
- * registered in the bundle context or null if no such implementation was
- * found.
- *
- * @return ConfigurationService a currently valid implementation of the
- * configuration service.
- */
- public static ConfigurationService getConfigurationService()
- {
- if(configurationService == null)
- {
- ServiceReference confReference
- = bundleContext.getServiceReference(
- ConfigurationService.class.getName());
- configurationService
- = (ConfigurationService) bundleContext.getService(confReference);
- }
- return configurationService;
- }
-
- /**
- * Returns a reference to the bundle context that we were started with.
- * @return a reference to the BundleContext instance that we were started
- * witn.
- */
- public static BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Retrurns a reference to the protocol provider factory that we have
- * registered.
- * @return a reference to the <tt>ProtocolProviderFactoryMsnImpl</tt>
- * instance that we have registered from this package.
- */
- static ProtocolProviderFactoryMsnImpl getProtocolProviderFactory()
- {
- return msnProviderFactory;
- }
-
- /**
- * 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
- {
- msnProviderFactory.stop();
- msnPpFactoryServReg.unregister();
- }
-
- /**
- * Gets the <tt>ResourceManagementService</tt> instance which provides
- * common resources such as internationalized and localized strings, images
- * to the MSN bundle.
- *
- * @return the <tt>ResourceManagementService</tt> instance which provides
- * common resources such as internationalized and localized strings, images
- * to the MSN bundle
- */
- public static ResourceManagementService getResources()
- {
- if (resources == null)
- resources
- = ResourceManagementServiceUtils.getService(bundleContext);
- return resources;
- }
-
- /**
- * Returns the <tt>FileAccessService</tt> obtained from the bundle context.
- *
- * @return the <tt>FileAccessService</tt> obtained from the bundle context
- */
- public static FileAccessService getFileAccessService()
- {
- if (fileAccessService == null)
- {
- fileAccessService
- = ServiceUtils.getService(
- bundleContext,
- FileAccessService.class);
- }
- return fileAccessService;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/MsnContactListEventListener.java b/src/net/java/sip/communicator/impl/protocol/msn/MsnContactListEventListener.java
deleted file mode 100644
index 38d1ddb..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/MsnContactListEventListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.sf.jml.*;
-
-/**
- * Contactlist modification listener receives events
- * for successful changing
- *
- * @author Damian Minkov
- */
-public interface MsnContactListEventListener
- extends java.util.EventListener
-{
- /**
- * Message is successfully delivered
- * @param transactionID int the transaction that send the message
- */
- public void messageDelivered(int transactionID);
-
- /**
- * Message is not delivered
- * @param transactionID int the transaction that send the message
- */
- public void messageDeliveredFailed(int transactionID);
-
- /**
- * Indicates that a group is successfully renamed
- * @param group MsnGroup the renamed group with the new name
- */
- public void groupRenamed(MsnGroup group);
-
- /**
- * Indicates that we are logged out
- * because account logged in from other location
- */
- public void loggingFromOtherLocation();
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java
deleted file mode 100644
index 46851a1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAdHocMultiUserChatMsnImpl.java
+++ /dev/null
@@ -1,687 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-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 net.sf.jml.*;
-import net.sf.jml.event.*;
-import net.sf.jml.message.*;
-
-/**
- * A MSN implementation of the ad-hoc multi user chat operation set.
- *
- * @author Valentin Martinet
- */
-public class OperationSetAdHocMultiUserChatMsnImpl
-implements OperationSetAdHocMultiUserChat
-{
- /**
- * The logger used to log messages.
- */
- private static final Logger logger
- = Logger.getLogger(OperationSetAdHocMultiUserChatMsnImpl.class);
-
- /**
- * Listeners that will be notified of changes in our status in the room.
- */
- private Vector<LocalUserAdHocChatRoomPresenceListener> presenceListeners
- = new Vector<LocalUserAdHocChatRoomPresenceListener>();
-
- /**
- * The currently valid MSN protocol provider service implementation.
- */
- private ProtocolProviderServiceMsnImpl provider = null;
-
- /**
- * The ad-hoc rooms we currently are in.
- */
- private Hashtable<MsnSwitchboard, AdHocChatRoomMsnImpl> adHocChatRoomCache
- = new Hashtable<MsnSwitchboard, AdHocChatRoomMsnImpl>();
-
- /**
- * A list of listeners subscribed for invitations multi user chat events.
- */
- private Vector<AdHocChatRoomInvitationListener> invitationListeners
- = new Vector<AdHocChatRoomInvitationListener>();
-
- /**
- * A list of listeners subscribed for events indicating rejection of a multi
- * user chat invitation sent by us.
- */
- private Vector<AdHocChatRoomInvitationRejectionListener>
- invitationRejectionListeners
- = new Vector<AdHocChatRoomInvitationRejectionListener>();
-
- /**
- * A list of the ad-hoc rooms that are currently open and created by this
- * account.
- */
- private Hashtable<Object, AdHocChatRoom> pendingAdHocChatRoomList
- = new Hashtable<Object, AdHocChatRoom>();
-
- /**
- * Creates an <tt>OperationSetAdHocMultiUserChatMsnImpl</tt> by specifying
- * the parent provider.
- * @param provider the Msn provider
- */
- public OperationSetAdHocMultiUserChatMsnImpl(
- ProtocolProviderServiceMsnImpl provider)
- {
- this.provider = provider;
- this.provider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
- /**
- * Adds the given presence listener to existing presence listeners list.
- *
- * @param listener the listener to add
- */
- public void addPresenceListener(
- LocalUserAdHocChatRoomPresenceListener listener)
- {
- synchronized(presenceListeners)
- {
- if(!presenceListeners.contains(listener))
- presenceListeners.add(listener);
- }
- }
-
- /**
- * Adds a listener to invitation notifications.
- *
- * @param listener an invitation listener.
- */
- public void addInvitationListener(AdHocChatRoomInvitationListener listener)
- {
- synchronized (invitationListeners)
- {
- if (!invitationListeners.contains(listener))
- invitationListeners.add(listener);
- }
- }
-
- /**
- * Removes <tt>listener</tt> from the list of invitation listeners
- * registered to receive invitation events.
- *
- * @param listener the invitation listener to remove.
- */
- public void removeInvitationListener(
- AdHocChatRoomInvitationListener listener)
- {
- synchronized (invitationListeners)
- {
- invitationListeners.remove(listener);
- }
- }
-
- /**
- * Adds a listener to invitation notifications.
- *
- * @param listener an invitation listener.
- */
- public void addInvitationRejectionListener(
- AdHocChatRoomInvitationRejectionListener listener)
- {
- synchronized (invitationRejectionListeners)
- {
- if (!invitationRejectionListeners.contains(listener))
- invitationRejectionListeners.add(listener);
- }
- }
-
- /**
- * Removes <tt>listener</tt> from the list of invitation listeners
- * registered to receive invitation events.
- *
- * @param listener the invitation listener to remove.
- */
- public void removeInvitationRejectionListener(
- AdHocChatRoomInvitationRejectionListener listener)
- {
- synchronized (invitationRejectionListeners)
- {
- invitationRejectionListeners.remove(listener);
- }
- }
-
- /**
- * Creates a message by a given message text.
- *
- * @param messageText The message text.
- * @return the newly created message.
- */
- public Message createMessage(String messageText)
- {
- return new MessageMsnImpl(messageText,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING, null);
- }
-
- /**
- * Creates an ad-hoc room with the named <tt>adHocRoomName</tt> and in
- * including to the specified <tt>contacts</tt>.
- *
- * @param adHocRoomName the name of the ad-hoc room
- * @param contacts the list of contacts ID
- * @param reason the reason (will not be used since MSN does not support
- * invitation with the possibility to reject it)
- *
- * @return the ad-hoc room that has been just created
- * @throws OperationFailedException
- * @throws OperationNotSupportedException
- */
- public AdHocChatRoom createAdHocChatRoom(String adHocRoomName,
- List<String> contacts,
- String reason)
- throws OperationFailedException, OperationNotSupportedException
- {
- AdHocChatRoom adHocChatRoom = createAdHocChatRoom(
- adHocRoomName, new Hashtable<String, Object>());
-
- if (adHocChatRoom != null && contacts != null)
- {
- for (String address : contacts)
- {
- adHocChatRoom.invite(address, reason);
- }
- }
-
- return adHocChatRoom;
- }
-
- /**
- * Creates an <tt>AdHocChatRoom</tt> whose name is adHocRoomName with the
- * properties contained in adHocRoomProperties
- *
- * @param adHocRoomName the name of the ad-hoc room
- * @param adHocRoomProperties the ad-hoc room's properties
- *
- * @return the created ad-hoc room
- * @throws OperationFailedException
- * @throws OperationNotSupportedException
- */
- public AdHocChatRoom createAdHocChatRoom(String adHocRoomName,
- Map<String, Object> adHocRoomProperties)
- throws OperationFailedException, OperationNotSupportedException
- {
- AdHocChatRoom adHocRoom = adHocChatRoomCache.get(adHocRoomName);
-
- if (adHocRoom == null)
- {
- assertConnected();
-
- // we create an identifier object and create a new switchboard
- // we need to track this object to identify this chatRoom
- Object id = new Object();
- this.provider.getMessenger().newSwitchboard(id);
-
- // when the room hasn't been created, we create it.
- adHocRoom = createLocalAdHocChatRoomInstance(adHocRoomName, id);
- }
-
- return adHocRoom;
- }
-
- /**
- * Creates a <tt>ChatRoom</tt> from the specified chatRoomName.
- *
- * @param adHocChatRoomName the specific ad-hoc chat room name.
- * @param switchboardId the identifier of the switchboard
- * @return the ad-hoc chat room that we've just created.
- */
- private AdHocChatRoomMsnImpl createLocalAdHocChatRoomInstance(
- String adHocChatRoomName, Object switchboardId)
- {
- synchronized (this.pendingAdHocChatRoomList)
- {
- AdHocChatRoomMsnImpl adHocChatRoom =
- new AdHocChatRoomMsnImpl(adHocChatRoomName, this.provider);
-
- // We put it to the pending ad hoc chat rooms, waiting for the
- // switchboard to be created.
- this.pendingAdHocChatRoomList.put(switchboardId, adHocChatRoom);
-
- adHocChatRoom.join();
-
- return adHocChatRoom;
- }
- }
-
- /**
- * Returns the <tt>AdHocChatRoomMsnImpl</tt> corresponding to the given
- * <tt>switchboard</tt>, if one exists, otherwise returns null.
- *
- * @param switchboard the Msn switchboard corresponding to a chat room
- *
- * @return the <tt>AdHocChatRoomMsnImpl</tt> corresponding to the given
- * <tt>switchboard</tt>, otherwise null
- */
- private AdHocChatRoomMsnImpl getLocalAdHocChatRoomInstance(
- MsnSwitchboard switchboard)
- {
- return adHocChatRoomCache.get(switchboard);
- }
-
- /**
- * Creates an <tt>AdHocChatRoomMsnImpl</tt> corresponding to the given
- * <tt>switchboard</tt>.
- * @param switchboard the Msn switchboard that will correspond to the
- * created chat room
- * @return an <tt>AdHocChatRoomMsnImpl</tt> corresponding to the given
- * <tt>switchboard</tt>
- */
- private AdHocChatRoomMsnImpl createLocalAdHocChatRoomInstance(
- MsnSwitchboard switchboard)
- {
- AdHocChatRoomMsnImpl adHocChatRoom
- = adHocChatRoomCache.get(switchboard);
-
- if (adHocChatRoom == null)
- {
- String name = String.valueOf(switchboard.hashCode());
- adHocChatRoom
- = new AdHocChatRoomMsnImpl(name, provider, switchboard);
-
- this.adHocChatRoomCache.put(switchboard, adHocChatRoom);
-
- Object attachment = switchboard.getAttachment();
- if (attachment != null && pendingAdHocChatRoomList
- .containsKey(attachment))
- {
- pendingAdHocChatRoomList.remove(attachment);
- }
- }
- adHocChatRoom.join();
-
- return adHocChatRoom;
- }
-
- /**
- * Delivers a <tt>LocalUserAdHocChatRoomPresenceChangeEvent</tt> to all
- * registered <tt>LocalUserAdHocChatRoomPresenceListener</tt>s.
- *
- * @param adHocChatRoom the <tt>AdHocChatRoom</tt> which has been joined,
- * left, etc.
- * @param eventType the type of this event; one of LOCAL_USER_JOINED,
- * LOCAL_USER_LEFT, etc.
- * @param reason the reason
- */
- public void fireLocalUserPresenceEvent( AdHocChatRoom adHocChatRoom,
- String eventType,
- String reason)
- {
- LocalUserAdHocChatRoomPresenceChangeEvent evt
- = new LocalUserAdHocChatRoomPresenceChangeEvent(this,
- adHocChatRoom,
- eventType,
- reason);
-
- Iterator<LocalUserAdHocChatRoomPresenceListener> listeners = null;
- synchronized(this.presenceListeners)
- {
- listeners = new ArrayList<LocalUserAdHocChatRoomPresenceListener>
- (this.presenceListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- LocalUserAdHocChatRoomPresenceListener listener = listeners.next();
-
- listener.localUserAdHocPresenceChanged(evt);
- }
- }
-
- /**
- * Checks if an incoming message is a multi user chat message. This is done
- * by the switchboard, if it is not created by the user, its an active file
- * transfer switchboard or the user count is too low then this method return
- * false.
- *
- * @param switchboard The corresponding MSNswitchboard.
- * @return true if it is a group chat message or false in the other case.
- */
- public boolean isGroupChatMessage(MsnSwitchboard switchboard)
- {
- if (getLocalAdHocChatRoomInstance(switchboard) != null)
- return true;
- else
- {
- Object attachment = switchboard.getAttachment();
-
- if (attachment != null)
- {
- return pendingAdHocChatRoomList.containsKey(attachment);
- }
- else
- { // the user did not created the chat room by him/her self,
- // the only way to figure out if this is a group chat message
- // is to check the user count
- return (switchboard.getAllContacts().length > 1);
- }
- }
- }
-
- /**
- * Removes the given listener from presence listeners' list.
- *
- * @param listener the listener to remove
- */
- public void removePresenceListener(
- LocalUserAdHocChatRoomPresenceListener listener)
- {
- synchronized (this.presenceListeners)
- {
- if(this.presenceListeners.contains(listener))
- {
- this.presenceListeners.remove(listener);
- }
- }
- }
-
- /**
- * Makes sure that we are properly connected.
- *
- * @throws OperationFailedException if the provider is not connected.
- * @throws OperationNotSupportedException if the service is not supported by
- * the server.
- */
- private void assertConnected()
- throws OperationFailedException,
- OperationNotSupportedException
- {
- if (this.provider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- + "service before being able to communicate.");
- if (!this.provider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- + "being able to communicate.");
- }
-
- /**
- * Our listener that will tell us when we're registered to msn.
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever a
- * change in the registration state of the corresponding provider had
- * occurred.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- if(provider.getMessenger() != null)
- {
- provider.getMessenger().addSwitchboardListener(
- new MsnSwitchboardListener());
- provider.getMessenger().addMessageListener(
- new MsnMessageListener());
- }
- else if(logger.isInfoEnabled())
- logger.info("Registered but msnMessenger is missing!",
- new Exception());
- }
- }
-
- }
-
- /**
- * Our group chat message listener, it extends the MsnMessageAdapter from
- * the the jml library.
- */
- private class MsnMessageListener
- extends MsnMessageAdapter
- implements MsnEmailListener
- {
- /**
- * Indicates that an instant message has been received.
- * @param switchboard the switchboard
- * @param message the message
- * @param contact the contact sending the message
- */
- @Override
- public void instantMessageReceived( MsnSwitchboard switchboard,
- MsnInstantMessage message,
- MsnContact contact)
- {
- if (!isGroupChatMessage(switchboard))
- return;
-
- Message newMessage = createMessage(message.getContent());
-
- if (logger.isDebugEnabled())
- logger.debug("Group chat message received.");
-
- AdHocChatRoomMsnImpl chatRoom
- = getLocalAdHocChatRoomInstance(switchboard);
-
- if (chatRoom == null)
- {
- chatRoom = createLocalAdHocChatRoomInstance(switchboard);
- }
-
- Contact participant =
- chatRoom.getAdHocChatRoomParticipant(contact.getId());
-
- AdHocChatRoomMessageReceivedEvent msgReceivedEvent =
- new AdHocChatRoomMessageReceivedEvent(
- chatRoom,
- participant,
- new Date(),
- newMessage,
- AdHocChatRoomMessageReceivedEvent
- .CONVERSATION_MESSAGE_RECEIVED);
-
- chatRoom.fireMessageEvent(msgReceivedEvent);
- }
-
- /**
- * Not interested in this event.
- */
- public void initialEmailNotificationReceived(
- MsnSwitchboard switchboard, MsnEmailInitMessage message,
- MsnContact contact)
- {}
-
- /**
- * Not interested in this event.
- */
- public void initialEmailDataReceived(MsnSwitchboard switchboard,
- MsnEmailInitEmailData message, MsnContact contact)
- {}
-
- /**
- * Not interested in this event.
- */
- public void newEmailNotificationReceived(MsnSwitchboard switchboard,
- MsnEmailNotifyMessage message, MsnContact contact)
- {}
-
- /**
- * Not interested in this event.
- */
- public void activityEmailNotificationReceived(
- MsnSwitchboard switchboard, MsnEmailActivityMessage message,
- MsnContact contact)
- {}
- }
-
- /**
- * The Switchboard Listener, listens to all four switchboard events:
- * Switchboard started/closed and User joins/left.
- *
- */
- private class MsnSwitchboardListener
- extends MsnSwitchboardAdapter
- {
- /**
- * Indicates that the given <tt>msnContact</tt> has joined the given
- * <tt>switchboard</tt>.
- * @param switchboard the switchboard
- * @param msnContact the contact that has joined
- */
- @Override
- public void contactJoinSwitchboard( MsnSwitchboard switchboard,
- MsnContact msnContact)
- {
- if (!isGroupChatMessage(switchboard))
- return;
-
- try
- {
- AdHocChatRoomMsnImpl chatRoom
- = getLocalAdHocChatRoomInstance(switchboard);
-
- if (chatRoom == null)
- {
- chatRoom = createLocalAdHocChatRoomInstance(switchboard);
- }
-
- OperationSetPersistentPresenceMsnImpl presenceOpSet
- = (OperationSetPersistentPresenceMsnImpl) provider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- ContactMsnImpl contact
- = presenceOpSet.getServerStoredContactList()
- .findContactById(
- msnContact.getEmail().getEmailAddress());
-
- if (contact == null)
- contact = new ContactMsnImpl(
- msnContact,
- presenceOpSet.getServerStoredContactList(),
- false,
- false);
-
- chatRoom.addAdHocChatRoomParticipant( msnContact.getId(),
- contact);
- }
- catch (Exception e)
- {
- logger.error("Failed to join switchboard.", e);
- }
- }
-
- /**
- * Indicates that the given <tt>contact</tt> has left the given
- * <tt>switchboard</tt>.
- * @param switchboard the switchboard
- * @param contact the contact that has left
- */
- @Override
- public void contactLeaveSwitchboard(MsnSwitchboard switchboard,
- MsnContact contact)
- {
- logger
- .debug(contact.getDisplayName() + " has left the Switchboard");
-
- AdHocChatRoomMsnImpl chatRoom
- = getLocalAdHocChatRoomInstance(switchboard);
-
- if (chatRoom == null)
- return;
-
- String participantId = contact.getId();
-
- Contact participant
- = chatRoom.getAdHocChatRoomParticipant(participantId);
-
- if (participant != null)
- {
- chatRoom.removeParticipant(participantId);
- }
- }
-
- /**
- * Indicates that a switchboard has been closed.
- * @param switchboard the switchboard that has been closed
- */
- @Override
- public void switchboardClosed(MsnSwitchboard switchboard)
- {
- AdHocChatRoomMsnImpl adHocChatRoom
- = getLocalAdHocChatRoomInstance(switchboard);
-
- if (adHocChatRoom == null)
- return;
- else
- {
- adHocChatRoom.setSwitchboard(null);
-
- adHocChatRoom.leave();
- fireLocalUserPresenceEvent(adHocChatRoom,
- LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED ,
- "Switchboard closed.");
- }
- }
-
- /**
- * Indicates that a switchboard has been started.
- * @param switchboard the switchboard that has been started
- */
- @Override
- public void switchboardStarted(MsnSwitchboard switchboard)
- {
- Object switchboardID = switchboard.getAttachment();
-
- AdHocChatRoomMsnImpl adHocChatRoom = null;
- if (switchboardID != null
- && pendingAdHocChatRoomList.containsKey(switchboardID))
- {
- adHocChatRoom
- = (AdHocChatRoomMsnImpl) pendingAdHocChatRoomList
- .get(switchboardID);
-
- // Remove this room from the list of pending chat rooms.
- pendingAdHocChatRoomList.remove(switchboardID);
-
- adHocChatRoom.setSwitchboard(switchboard);
- adHocChatRoom.updateParticipantsList(switchboard);
-
- // Add this room to the list of created chat rooms.
- adHocChatRoomCache.put(switchboard, adHocChatRoom);
- }
- }
- }
-
- /**
- * Supposed to reject an invitation for MUC.
- * Note: Not supported inside the MSN.
- */
- public void rejectInvitation(AdHocChatRoomInvitation invitation,
- String rejectReason)
- {
- // there is no way to block invitations, because there arn't any
- // invitations.
- // the only way would be to block the Friend and that shouldn't be done
- // here.
- return;
- }
-
- /**
- * Returns a list of all currently joined <tt>AdHocChatRoom</tt>-s.
- *
- * @return a list of all currently joined <tt>AdHocChatRoom</tt>-s
- */
- public List<AdHocChatRoom> getAdHocChatRooms()
- {
- return new ArrayList<AdHocChatRoom>(adHocChatRoomCache.values());
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAvatarMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAvatarMsnImpl.java
deleted file mode 100644
index e5b9fbf..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetAvatarMsnImpl.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A simple implementation of the <tt>OperationSetAvatar</tt> interface for the
- * msn protocol.
- *
- * @author Damian Minkov
- */
-public class OperationSetAvatarMsnImpl
- extends AbstractOperationSetAvatar<ProtocolProviderServiceMsnImpl>
-{
- public OperationSetAvatarMsnImpl(
- ProtocolProviderServiceMsnImpl parentProvider,
- OperationSetServerStoredAccountInfo accountInfoOpSet)
- {
- super(parentProvider, accountInfoOpSet, 0, 0, 0);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetBasicInstantMessagingMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetBasicInstantMessagingMsnImpl.java
deleted file mode 100644
index e09d9c1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetBasicInstantMessagingMsnImpl.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.text.*;
-import java.util.*;
-
-import net.java.sip.communicator.impl.protocol.msn.mail.utils.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-import net.sf.jml.event.*;
-import net.sf.jml.message.*;
-
-/**
- * A straightforward implementation of the basic instant messaging operation
- * set.
- *
- * @author Damian Minkov
- */
-public class OperationSetBasicInstantMessagingMsnImpl
- extends AbstractOperationSetBasicInstantMessaging
-{
- private static final Logger logger
- = Logger.getLogger(OperationSetBasicInstantMessagingMsnImpl.class);
-
- /**
- * The provider that created us.
- */
- private final ProtocolProviderServiceMsnImpl msnProvider;
-
- /**
- * A reference to the persistent presence operation set that we use
- * to match incoming messages to <tt>Contact</tt>s and vice versa.
- */
- private OperationSetPersistentPresenceMsnImpl opSetPersPresence = null;
-
- private final OperationSetAdHocMultiUserChatMsnImpl opSetMuc;
-
- /**
- * The thread that will send messages.
- */
- private SenderThread senderThread = null;
-
- /**
- * Creates an instance of this operation set.
- * @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt>
- * that created us and that we'll use for retrieving the underlying aim
- * connection.
- */
- OperationSetBasicInstantMessagingMsnImpl(
- ProtocolProviderServiceMsnImpl provider)
- {
- this.msnProvider = provider;
- opSetMuc
- = (OperationSetAdHocMultiUserChatMsnImpl)
- msnProvider
- .getOperationSet(OperationSetAdHocMultiUserChat.class);
- provider.addRegistrationStateChangeListener(new RegistrationStateListener());
- }
-
- /**
- * Determines whether the protocol provider (or the protocol itself) support
- * sending and receiving offline messages. Most often this method would
- * return true for protocols that support offline messages and false for
- * those that don't. It is however possible for a protocol to support these
- * messages and yet have a particular account that does not (i.e. feature
- * not enabled on the protocol server). In cases like this it is possible
- * for this method to return true even when offline messaging is not
- * supported, and then have the sendMessage method throw an
- * OperationFailedException with code - OFFLINE_MESSAGES_NOT_SUPPORTED.
- *
- * @return <tt>true</tt> if the protocol supports offline messages and
- * <tt>false</tt> otherwise.
- */
- public boolean isOfflineMessagingSupported()
- {
- return true;
- }
-
- /**
- * Determines 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)
- {
- return DEFAULT_MIME_TYPE.equals(contentType);
- }
-
- @Override
- public Message createMessage(String content, String contentType,
- String encoding, String subject)
- {
- return new MessageMsnImpl(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 java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- * @throws java.lang.IllegalArgumentException if <tt>to</tt> is not an
- * instance of ContactImpl.
- */
- public void sendInstantMessage(final Contact to, final Message message)
- throws IllegalStateException, IllegalArgumentException
- {
- assertConnected();
-
- if( !(to instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an MSN contact."
- + to);
-
- MessageDeliveredEvent[] transformedEvents = messageDeliveryPendingTransform(
- new MessageDeliveredEvent(message, to));
-
- if (transformedEvents == null || transformedEvents.length == 0)
- return;
-
- MessageDeliveredEvent msgDeliveredEvt =
- new MessageDeliveredEvent(message, to);
-
- fireMessageEvent(msgDeliveredEvt);
-
- // send message in separate thread so we won't block ui if it takes
- // time.
- if (senderThread == null)
- {
- senderThread = new SenderThread();
- senderThread.start();
- }
-
- for (MessageDeliveredEvent event : transformedEvents)
- {
- senderThread.sendMessage((ContactMsnImpl) to, event
- .getSourceMessage().getContent());
- }
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected() throws IllegalStateException
- {
- if (msnProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- +"service before being able to communicate.");
- if (!msnProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to communicate.");
- }
-
- /**
- * Our listener that will tell us when we're registered to
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- opSetPersPresence =
- (OperationSetPersistentPresenceMsnImpl) msnProvider
- .getOperationSet(OperationSetPersistentPresence.class);
-
- MsnMessenger msnMessenger = msnProvider.getMessenger();
-
- if(msnMessenger != null)
- {
- MsnMessageListener listener = new MsnMessageListener();
- msnMessenger.addMessageListener(listener);
- msnMessenger.addEmailListener(listener);
- }
- else if(logger.isInfoEnabled())
- logger.info("Registered but msnMessenger is missing!",
- new Exception());
- }
- else if(evt.getNewState() == RegistrationState.UNREGISTERED
- || evt.getNewState() == RegistrationState.CONNECTION_FAILED
- || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED)
- {
- if(senderThread != null)
- {
- senderThread.stopRunning();
- senderThread = null;
- }
- }
- }
- }
-
- private class MsnMessageListener
- extends MsnMessageAdapter
- implements MsnEmailListener
- {
- @Override
- public void instantMessageReceived(MsnSwitchboard switchboard,
- MsnInstantMessage message,
- MsnContact contact)
- {
- // FILTER OUT THE GROUP MESSAGES
- if (opSetMuc.isGroupChatMessage(switchboard))
- return;
-
- Message newMessage = createMessage(message.getContent());
- Contact sourceContact = opSetPersPresence.
- findContactByID(contact.getEmail().getEmailAddress());
-
- if(sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("received a message from an unknown contact: "
- + contact);
- //create the volatile contact
- sourceContact = opSetPersPresence.
- createVolatileContact(contact);
- }
-
- MessageReceivedEvent msgReceivedEvt
- = new MessageReceivedEvent(
- newMessage, sourceContact , new Date());
-
- // msgReceivedEvt = messageReceivedTransform(msgReceivedEvt);
-
- if (msgReceivedEvt != null)
- fireMessageEvent(msgReceivedEvt);
- }
-
- /**
- * Received offline text message.
- *
- * @param body of message
- * @param contentType of message
- * @param encoding of message
- * @param contact the user who sent this message
- */
- public void offlineMessageReceived(String body,
- String contentType,
- String encoding,
- MsnContact contact)
- {
- Message newMessage =
- createMessage(body, contentType, encoding, null);
-
- Contact sourceContact = opSetPersPresence.
- findContactByID(contact.getEmail().getEmailAddress());
-
- if(sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("received a message from an unknown contact: "
- + contact);
- //create the volatile contact
- sourceContact = opSetPersPresence.
- createVolatileContact(contact);
- }
-
- MessageReceivedEvent msgReceivedEvt
- = new MessageReceivedEvent(
- newMessage, sourceContact , new Date());
-
- fireMessageEvent(msgReceivedEvt);
- }
-
- public void initialEmailNotificationReceived(MsnSwitchboard switchboard,
- MsnEmailInitMessage message,
- MsnContact contact)
- {
- }
-
- public void initialEmailDataReceived(MsnSwitchboard switchboard,
- MsnEmailInitEmailData message,
- MsnContact contact)
- {
- }
-
- public void newEmailNotificationReceived(MsnSwitchboard switchboard,
- MsnEmailNotifyMessage message,
- MsnContact contact)
- {
- // we don't process incoming event without email.
- String messageFromAddr = message.getFromAddr();
- if ((messageFromAddr == null)
- || (messageFromAddr.indexOf('@') < 0))
- return;
-
- String subject = message.getSubject();
-
- try
- {
- subject = MimeUtility.decodeText(subject);
- }
- catch (Exception ex)
- {
- logger.warn("Failed to decode the subject of a new e-mail", ex);
- }
-
- // FIXME Escape HTML!
- String messageFrom = message.getFrom();
- Message newMailMessage = new MessageMsnImpl(
- MessageFormat.format(
- MsnActivator.getResources()
- .getI18NString("service.gui.NEW_MAIL"),
- messageFrom,
- messageFromAddr,
- subject,
- "" /*
- * TODO What is {3} meant for? The Yahoo! protocol
- * implementation seems to put a link to a mail login
- * page.
- */),
- HTML_MIME_TYPE,
- DEFAULT_MIME_ENCODING,
- subject);
-
- Contact sourceContact
- = opSetPersPresence.findContactByID(messageFromAddr);
-
- if (sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("received a new mail from an unknown contact: "
- + messageFrom
- + " &lt;" + messageFromAddr + "&gt;");
- //create the volatile contact
- String id = contact.getId();
- Email email = contact.getEmail();
- String displayName = contact.getDisplayName();
-
- if (id == null)
- id = messageFromAddr;
- if (email == null)
- email = Email.parseStr(messageFromAddr);
- if (displayName == null)
- displayName = messageFrom;
- sourceContact
- = opSetPersPresence.createVolatileContact(id, email, displayName);
- }
-
- MessageReceivedEvent msgReceivedEvt
- = new MessageReceivedEvent(
- newMailMessage,
- sourceContact,
- new Date(),
- MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
-
- fireMessageEvent(msgReceivedEvt);
- }
-
- public void activityEmailNotificationReceived(MsnSwitchboard switchboard,
- MsnEmailActivityMessage message,
- MsnContact contact)
- {
- }
- }
-
- /**
- * Sends instant messages in separate thread so we don't block
- * our calling thread.
- * When sending offline messages msn uses soap
- * and http and xml exchange can be time consuming.
- */
- private class SenderThread
- extends Thread
- {
- /**
- * start/stop indicator.
- */
- private boolean stopped = true;
-
- /**
- * List of messages queued to be sent.
- */
- private List<MessageToSend> messagesToSend =
- new ArrayList<MessageToSend>();
-
- /**
- * Sends instant messages in separate thread so we don't block
- * our calling thread.
- */
- @Override
- public void run()
- {
- stopped = false;
-
- while(!stopped)
- {
- MessageToSend msgToSend = null;
-
- synchronized(this)
- {
- if(messagesToSend.isEmpty())
- {
- try
- {
- wait();
-
- }
- catch (InterruptedException iex)
- {
- }
- }
-
- if(!messagesToSend.isEmpty())
- msgToSend = messagesToSend.remove(0);
- }
-
- if(msgToSend != null)
- {
- try
- {
- msnProvider.getMessenger().sendText(
- msgToSend.to.getSourceContact().getEmail(),
- msgToSend.content);
- }
- catch(Throwable t)
- {
- fireMessageDeliveryFailed(
- createMessage(msgToSend.content,
- DEFAULT_MIME_TYPE,
- DEFAULT_MIME_ENCODING,
- null),
- msgToSend.to,
- MessageDeliveryFailedEvent.UNKNOWN_ERROR);
- }
- }
- }
- }
-
- /**
- * Interrupts this sender so that it would no longer send messages.
- */
- public synchronized void stopRunning()
- {
- stopped = true;
- notifyAll();
- }
-
- /**
- * Schedule new message to be sent.
- * @param to destination.
- * @param content content.
- */
- public synchronized void sendMessage(ContactMsnImpl to, String content)
- {
- messagesToSend.add(new MessageToSend(to , content));
- notifyAll();
- }
-
- /**
- * Structure used to store data to be sent.
- */
- private class MessageToSend
- {
- /**
- * Message sent to.
- */
- private ContactMsnImpl to;
-
- /**
- * Content of message.
- */
- private String content;
-
- /**
- * Creates MessageToSend.
- * @param to contact to.
- * @param content content to be sent.
- */
- MessageToSend(ContactMsnImpl to, String content)
- {
- this.to = to;
- this.content = content;
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java
deleted file mode 100644
index 3992d20..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetFileTransferMsnImpl.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-import net.sf.jml.event.*;
-
-/**
- * The Msn protocol filetransfer OperationSet.
- *
- * @author Damian Minkov
- */
-public class OperationSetFileTransferMsnImpl
- implements OperationSetFileTransfer
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetFileTransferMsnImpl.class);
-
- /**
- * A call back to the Msn provider that created us.
- */
- private ProtocolProviderServiceMsnImpl msnProvider = null;
-
- /**
- * A list of listeners registered for file transfer events.
- */
- private ArrayList<FileTransferListener> fileTransferListeners
- = new ArrayList<FileTransferListener>();
-
- /**
- * A list of active fileTransfers.
- */
- private Hashtable<String, Object> activeFileTransfers
- = new Hashtable<String, Object>();
-
- /**
- * Create a new FileTransfer OperationSet over the specified Msn provider
- * @param msnProvider MSN protocol provider service
- */
- public OperationSetFileTransferMsnImpl(
- ProtocolProviderServiceMsnImpl msnProvider)
- {
- this.msnProvider = msnProvider;
-
- msnProvider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
-
- /**
- * Sends a file transfer request to the given <tt>toContact</tt> by
- * specifying the local and remote file path and the <tt>fromContact</tt>,
- * sending the file.
- *
- * @param toContact the contact that should receive the file
- * @param file the file to send
- *
- * @return the transfer object
- *
- * @throws IllegalStateException if the protocol provider is not registered
- * or connected
- * @throws IllegalArgumentException if some of the arguments doesn't fit the
- * protocol requirements
- */
- public FileTransfer sendFile( Contact toContact,
- File file)
- throws IllegalStateException,
- IllegalArgumentException
- {
- assertConnected();
-
- if(file.length() > getMaximumFileLength())
- throw new IllegalArgumentException(
- "File length exceeds the allowed one for this protocol");
-
- if( !(toContact instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an msn contact." + toContact);
-
- MsnFileTransfer ft = msnProvider.getMessenger().
- getFileTransferManager().
- sendFile(
- ((ContactMsnImpl)toContact).getSourceContact().getEmail(),
- file);
-
- if(ft == null)
- throw new IllegalStateException(
- "A problem occured sending file, contact not found or offline");
-
- FileTransferImpl outFileTransfer = new FileTransferImpl(
- ft, toContact, file, FileTransfer.OUT);
-
-
- // Notify all interested listeners that a file transfer has been
- // created.
- FileTransferCreatedEvent event
- = new FileTransferCreatedEvent(outFileTransfer, new Date());
-
- fireFileTransferCreated(event);
-
- outFileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.PREPARING);
-
- return outFileTransfer;
- }
-
- /**
- * Sends a file transfer request to the given <tt>toContact</tt> by
- * specifying the local and remote file path and the <tt>fromContact</tt>,
- * sending the file.
- *
- * @param toContact the contact that should receive the file
- * @param fromContact the contact sending the file
- * @param remotePath the remote file path
- * @param localPath the local file path
- *
- * @return the transfer object
- *
- * @throws IllegalStateException if the protocol provider is not registered
- * or connected
- * @throws IllegalArgumentException if some of the arguments doesn't fit the
- * protocol requirements
- */
- public FileTransfer sendFile( Contact toContact,
- Contact fromContact,
- String remotePath,
- String localPath)
- throws IllegalStateException,
- IllegalArgumentException
- {
- return this.sendFile(toContact, new File(localPath));
- }
-
- /**
- * Adds the given <tt>FileTransferListener</tt> that would listen for
- * file transfer requests and created file transfers.
- *
- * @param listener the <tt>FileTransferListener</tt> to add
- */
- public void addFileTransferListener(
- FileTransferListener listener)
- {
- synchronized(fileTransferListeners)
- {
- if(!fileTransferListeners.contains(listener))
- {
- this.fileTransferListeners.add(listener);
- }
- }
- }
-
- /**
- * Removes the given <tt>FileTransferListener</tt> that listens for
- * file transfer requests and created file transfers.
- *
- * @param listener the <tt>FileTransferListener</tt> to remove
- */
- public void removeFileTransferListener(
- FileTransferListener listener)
- {
- synchronized(fileTransferListeners)
- {
- this.fileTransferListeners.remove(listener);
- }
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected()
- throws IllegalStateException
- {
- if (msnProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the "
- +"service before being able to send a file.");
- else if (!msnProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the service before "
- +"being able to send a file.");
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- private void fireFileTransferRequest(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestReceived(event);
- }
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- void fireFileTransferRequestRejected(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestRejected(event);
- }
- }
-
- /**
- * Delivers the specified event to all registered file transfer listeners.
- *
- * @param event the <tt>EventObject</tt> that we'd like delivered to all
- * registered file transfer listeners.
- */
- void fireFileTransferRequestCanceled(FileTransferRequestEvent event)
- {
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
-
- listener.fileTransferRequestCanceled(event);
- }
- }
-
- /**
- * Delivers the file transfer to all registered listeners.
- *
- * @param event the <tt>FileTransferEvent</tt> that we'd like delivered to
- * all registered file transfer listeners.
- */
- void fireFileTransferCreated(FileTransferCreatedEvent event)
- {
- activeFileTransfers.put(
- event.getFileTransfer().getID(), event.getFileTransfer());
-
- Iterator<FileTransferListener> listeners = null;
- synchronized (fileTransferListeners)
- {
- listeners = new ArrayList<FileTransferListener>
- (fileTransferListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- FileTransferListener listener = listeners.next();
- listener.fileTransferCreated(event);
- }
- }
-
- /**
- * Returns the maximum file length supported by the protocol in bytes.
- * Supports up to 2GB.
- *
- * @return the file length that is supported.
- */
- public long getMaximumFileLength()
- {
- return 2147483648l;// = 2048*1024*1024;
- }
-
- /**
- * Our listener that will tell us when we're registered to
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- if(msnProvider.getMessenger() != null)
- {
- msnProvider.getMessenger().addFileTransferListener(
- new FileTransferProtocolListener());
- }
- else if(logger.isInfoEnabled())
- logger.info("Registered but msnMessenger is missing!",
- new Exception());
- }
- }
- }
-
- /**
- * Receives notifications from the slick about new filetransfers
- * and filetransfer changes.
- */
- private class FileTransferProtocolListener
- implements MsnFileTransferListener
- {
- public void fileTransferRequestReceived(MsnFileTransfer ft)
- {
- OperationSetPersistentPresenceMsnImpl opSetPersPresence
- = (OperationSetPersistentPresenceMsnImpl)
- msnProvider.getOperationSet(
- OperationSetPersistentPresence.class);
-
- Contact sender = opSetPersPresence.findContactByID(
- ft.getContact().getEmail().getEmailAddress());
-
- if(sender == null)
- return;
-
- Date recvDate = new Date();
-
- IncomingFileTransferRequest req =
- new IncomingFileTransferRequestMsnImpl(
- OperationSetFileTransferMsnImpl.this,
- ft, sender, recvDate);
-
- activeFileTransfers.put(ft.getID(), req);
-
- fireFileTransferRequest(
- new FileTransferRequestEvent(
- OperationSetFileTransferMsnImpl.this, req, recvDate));
- }
-
- public void fileTransferStarted(MsnFileTransfer ft)
- {
- Object ftObj = activeFileTransfers.get(ft.getID());
-
- if(ftObj != null && ftObj instanceof FileTransferImpl)
- {
- FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
-
- fileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.IN_PROGRESS);
- }
- }
-
- public void fileTransferProcess(MsnFileTransfer ft)
- {
- Object ftObj = activeFileTransfers.get(ft.getID());
-
- if(ftObj != null && ftObj instanceof FileTransferImpl)
- {
- FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
-
- fileTransfer.setTransferedBytes(ft.getTransferredSize());
- fileTransfer.fireProgressChangeEvent(
- System.currentTimeMillis(), ft.getTransferredSize());
- }
- }
-
- public void fileTransferFinished(MsnFileTransfer ft)
- {
- Object ftObj = activeFileTransfers.get(ft.getID());
-
- if(ftObj == null)
- return;
-
- if(ftObj instanceof FileTransferImpl)
- {
- FileTransferImpl fileTransfer = (FileTransferImpl)ftObj;
-
- if(ft.getState() == MsnFileTransferState.COMPLETED)
- fileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.COMPLETED);
- else if(ft.getState() == MsnFileTransferState.CANCELED)
- fileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.CANCELED);
- else if(ft.getState() == MsnFileTransferState.REFUSED)
- fileTransfer.fireStatusChangeEvent(
- FileTransferStatusChangeEvent.REFUSED);
- }
- else if(ftObj instanceof IncomingFileTransferRequest)
- {
- IncomingFileTransferRequestMsnImpl inReq =
- (IncomingFileTransferRequestMsnImpl)ftObj;
-
- if(!inReq.isRejected()
- && ft.getState() == MsnFileTransferState.CANCELED)
- fireFileTransferRequestCanceled(
- new FileTransferRequestEvent(
- OperationSetFileTransferMsnImpl.this,
- inReq,
- inReq.getDate()));
- }
-
- activeFileTransfers.remove(ft.getID());
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java
deleted file mode 100644
index e872eed..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java
+++ /dev/null
@@ -1,913 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.protocol.msnconstants.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-import net.sf.jml.event.*;
-
-/**
- * The Msn implementation of a Persistent Presence Operation set. This class
- * manages our own presence status as well as subscriptions for the presence
- * status of our buddies. It also offers methods for retrieving and modifying
- * the buddy contact list and adding listeners for changes in its layout.
- *
- * @author Damian Minkov
- */
-public class OperationSetPersistentPresenceMsnImpl
- extends AbstractOperationSetPersistentPresence<ProtocolProviderServiceMsnImpl>
-{
- private static final Logger logger =
- Logger.getLogger(OperationSetPersistentPresenceMsnImpl.class);
-
- /**
- * Contains our current status message. Note that this field would only
- * be changed once the server has confirmed the new status message and
- * not immediately upon setting a new one..
- */
- private String currentStatusMessage = "";
-
- /**
- * The presence status that we were last notified of entering.
- * The initial one is OFFLINE
- */
- private PresenceStatus currentStatus = MsnStatusEnum.OFFLINE;
-
- /**
- * Sometimes status changes are received before the contact list is inited
- * here we store such events so we can show them correctly
- */
- private Hashtable<String, MsnUserStatus> earlyStatusChange
- = new Hashtable<String, MsnUserStatus>();
-
- private AuthorizationHandler authorizationHandler = null;
-
- /**
- * The array list we use when returning from the getSupportedStatusSet()
- * method.
- */
- private static final List<PresenceStatus> supportedPresenceStatusSet
- = new ArrayList<PresenceStatus>();
- static{
- supportedPresenceStatusSet.add(MsnStatusEnum.AWAY);
- supportedPresenceStatusSet.add(MsnStatusEnum.BE_RIGHT_BACK);
- supportedPresenceStatusSet.add(MsnStatusEnum.BUSY);
- supportedPresenceStatusSet.add(MsnStatusEnum.HIDE);
- supportedPresenceStatusSet.add(MsnStatusEnum.IDLE);
- supportedPresenceStatusSet.add(MsnStatusEnum.OFFLINE);
- supportedPresenceStatusSet.add(MsnStatusEnum.ONLINE);
- supportedPresenceStatusSet.add(MsnStatusEnum.ON_THE_PHONE);
- supportedPresenceStatusSet.add(MsnStatusEnum.IN_A_MEETING);
- supportedPresenceStatusSet.add(MsnStatusEnum.OUT_TO_LUNCH);
- }
-
- /**
- * A map containing bindings between SIP Communicator's msn presence status
- * instances and Msn status codes
- */
- private static Map<MsnStatusEnum, MsnUserStatus> scToMsnModesMappings
- = new Hashtable<MsnStatusEnum, MsnUserStatus>();
- static{
- scToMsnModesMappings.put(MsnStatusEnum.AWAY,
- MsnUserStatus.AWAY);
- scToMsnModesMappings.put(MsnStatusEnum.BE_RIGHT_BACK,
- MsnUserStatus.BE_RIGHT_BACK);
- scToMsnModesMappings.put(MsnStatusEnum.BUSY,
- MsnUserStatus.BUSY);
- scToMsnModesMappings.put(MsnStatusEnum.HIDE,
- MsnUserStatus.HIDE);
- scToMsnModesMappings.put(MsnStatusEnum.IDLE,
- MsnUserStatus.IDLE);
- scToMsnModesMappings.put(MsnStatusEnum.OFFLINE,
- MsnUserStatus.OFFLINE);
- scToMsnModesMappings.put(MsnStatusEnum.ONLINE,
- MsnUserStatus.ONLINE);
- scToMsnModesMappings.put(MsnStatusEnum.ON_THE_PHONE,
- MsnUserStatus.ON_THE_PHONE);
- scToMsnModesMappings.put(MsnStatusEnum.OUT_TO_LUNCH,
- MsnUserStatus.OUT_TO_LUNCH);
- }
-
- /**
- * The server stored contact list that will be encapsulating msn's
- * buddy list.
- */
- private ServerStoredContactListMsnImpl ssContactList = null;
-
- public OperationSetPersistentPresenceMsnImpl(
- ProtocolProviderServiceMsnImpl provider)
- {
- super(provider);
-
- ssContactList = new ServerStoredContactListMsnImpl( this , provider);
-
- parentProvider.addRegistrationStateChangeListener(
- new RegistrationStateListener());
- }
-
- /**
- * Registers a listener that would receive events upon changes in server
- * stored groups.
- *
- * @param listener a ServerStoredGroupChangeListener impl that would
- * receive events upon group changes.
- */
- @Override
- public void addServerStoredGroupChangeListener(ServerStoredGroupListener
- listener)
- {
- ssContactList.addGroupListener(listener);
- }
-
- /**
- * Creates a group with the specified name and parent in the server
- * stored contact list.
- *
- * @param parent the group where the new group should be created
- * @param groupName the name of the new group to create.
- * @throws OperationFailedException if such group already exists
- */
- public void createServerStoredContactGroup(ContactGroup parent,
- String groupName)
- throws OperationFailedException
- {
- assertConnected();
-
- if (!parent.canContainSubgroups())
- throw new IllegalArgumentException(
- "The specified contact group cannot contain child groups. Group:"
- + parent );
-
- ssContactList.createGroup(groupName);
- }
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. The volatile contact would
- * remain in the list until it is really added to the contact list or
- * until the application is terminated.
- * @param contact the msn contact.
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- public ContactMsnImpl createVolatileContact(MsnContact contact)
- {
- return ssContactList.createVolatileContact(contact);
- }
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. The volatile contact would
- * remain in the list until it is really added to the contact list or until
- * the application is terminated.
- *
- * @param id the id of the MSN contact
- * @param email the e-mail address of the MSN contact
- * @param displayName the display name of the MSN contact
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- public ContactMsnImpl createVolatileContact(
- String id,
- Email email,
- String displayName)
- {
- return ssContactList.createVolatileContact(id, email, displayName);
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @param parentGroup the group where the unresolved contact is supposed
- * to belong to.
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(String address,
- String persistentData,
- ContactGroup parentGroup)
- {
- if(! (parentGroup instanceof ContactGroupMsnImpl ||
- parentGroup instanceof RootContactGroupMsnImpl) )
- throw new IllegalArgumentException(
- "Argument is not an msn contact group (group="
- + parentGroup + ")");
-
- ContactMsnImpl contact =
- ssContactList.createUnresolvedContact(parentGroup, address);
-
- contact.setPersistentData(persistentData);
-
- return contact;
- }
-
- /**
- * Creates and returns a unresolved contact from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param address an identifier of the contact that we'll be creating.
- * @param persistentData a String returned Contact's getPersistentData()
- * method during a previous run and that has been persistently stored
- * locally.
- * @return the unresolved <tt>Contact</tt> created from the specified
- * <tt>address</tt> and <tt>persistentData</tt>
- */
- public Contact createUnresolvedContact(String address,
- String persistentData)
- {
- return createUnresolvedContact( address
- , persistentData
- , getServerStoredContactListRoot());
- }
-
- /**
- * Creates and returns a unresolved contact group from the specified
- * <tt>address</tt> and <tt>persistentData</tt>.
- *
- * @param groupUID an identifier, returned by ContactGroup's
- * getGroupUID, that the protocol provider may use in order to create
- * the group.
- * @param persistentData a String returned ContactGroups's
- * getPersistentData() method during a previous run and that has been
- * persistently stored locally.
- * @param parentGroup the group under which the new group is to be
- * created or null if this is group directly underneath the root.
- * @return the unresolved <tt>ContactGroup</tt> created from the
- * specified <tt>uid</tt> and <tt>persistentData</tt>
- */
- public ContactGroup createUnresolvedContactGroup(String groupUID,
- String persistentData, ContactGroup parentGroup)
- {
- return ssContactList.createUnresolvedContactGroup(groupUID);
- }
-
- /**
- * Returns a reference to the contact with the specified ID in case we
- * have a subscription for it and null otherwise/
- *
- * @param contactID a String identifier of the contact which we're
- * seeking a reference of.
- * @return a reference to the Contact with the specified
- * <tt>contactID</tt> or null if we don't have a subscription for the
- * that identifier.
- */
- public Contact findContactByID(String contactID)
- {
- return ssContactList.findContactById(contactID);
- }
-
- /**
- * Returns the status message that was confirmed by the server
- *
- * @return the last status message that we have requested and the aim
- * server has confirmed.
- */
- public String getCurrentStatusMessage()
- {
- return currentStatusMessage;
- }
-
- /**
- * Returns the protocol specific contact instance representing the local
- * user.
- *
- * @return the Contact (address, phone number, or uin) that the Provider
- * implementation is communicating on behalf of.
- */
- public Contact getLocalContact()
- {
- return null;
- }
-
- /**
- * Returns a PresenceStatus instance representing the state this provider
- * is currently in.
- *
- * @return the PresenceStatus last published by this provider.
- */
- public PresenceStatus getPresenceStatus()
- {
- return currentStatus;
- }
-
- /**
- * Returns the root group of the server stored contact list.
- *
- * @return the root ContactGroup for the ContactList stored by this
- * service.
- */
- public ContactGroup getServerStoredContactListRoot()
- {
- return ssContactList.getRootGroup();
- }
-
- /**
- * Returns the set of PresenceStatus objects that a user of this service
- * may request the provider to enter.
- *
- * @return Iterator a PresenceStatus array containing "enterable" status
- * instances.
- */
- public Iterator<PresenceStatus> getSupportedStatusSet()
- {
- return supportedPresenceStatusSet.iterator();
- }
-
- /**
- * Removes the specified contact from its current parent and places it
- * under <tt>newParent</tt>.
- *
- * @param contactToMove the <tt>Contact</tt> to move
- * @param newParent the <tt>ContactGroup</tt> where <tt>Contact</tt>
- * would be placed.
- */
- public void moveContactToGroup(Contact contactToMove,
- ContactGroup newParent)
- {
- assertConnected();
-
- if( !(contactToMove instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an msn contact." + contactToMove);
- if( !(newParent instanceof ContactGroupMsnImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an msn contact group."
- + newParent);
-
- ssContactList.moveContact((ContactMsnImpl)contactToMove,
- (ContactGroupMsnImpl)newParent);
- }
-
- /**
- * Requests the provider to enter into a status corresponding to the
- * specified parameters.
- *
- * @param status the PresenceStatus as returned by
- * getRequestableStatusSet
- * @param statusMessage the message that should be set as the reason to
- * enter that status
- * @throws IllegalArgumentException if the status requested is not a
- * valid PresenceStatus supported by this provider.
- * @throws IllegalStateException if the provider is not currently
- * registered.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * publishing the status fails due to a network error.
- */
- public void publishPresenceStatus(PresenceStatus status,
- String statusMessage) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- if (!(status instanceof MsnStatusEnum))
- throw new IllegalArgumentException(
- status + " is not a valid Msn status");
-
- if(status.equals(MsnStatusEnum.OFFLINE))
- {
- parentProvider.unregister();
- return;
- }
-
- // if the contact list is inited set the state
- // otherwise just set the init status
- //(as if set the status too early the server does not provide
- // any status information about the contacts in our list)
- if(ssContactList.isInitialized())
- {
- parentProvider.getMessenger().getOwner().
- setStatus(scToMsnModesMappings.get(status));
-
- if(statusMessage != null)
- parentProvider.getMessenger().getOwner()
- .setPersonalMessage(statusMessage);
- }
- else
- {
- parentProvider.getMessenger().getOwner().
- setInitStatus(scToMsnModesMappings.get(status));
-
- if(statusMessage != null)
- parentProvider.getMessenger().getOwner()
- .setInitPersonalMessage(statusMessage);
- }
- }
-
- /**
- * 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
- {
- ContactMsnImpl contact = ssContactList.findContactById(contactIdentifier);
- if(contact == null)
- {
- if (logger.isInfoEnabled())
- logger.info("Contact not found id :" + contactIdentifier);
- return null;
- }
- else
- return msnStatusToPresenceStatus(contact.getSourceContact().getStatus());
- }
-
- /**
- * Removes the specified group from the server stored contact list.
- *
- * @param group the group to remove.
- */
- public void removeServerStoredContactGroup(ContactGroup group)
- {
- assertConnected();
-
- if( !(group instanceof ContactGroupMsnImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an msn contact group: " + group);
-
- ssContactList.removeGroup(((ContactGroupMsnImpl)group));
- }
-
- /**
- * Removes the specified group change listener so that it won't receive
- * any further events.
- *
- * @param listener the ServerStoredGroupChangeListener to remove
- */
- @Override
- public void removeServerStoredGroupChangeListener(ServerStoredGroupListener
- listener)
- {
- ssContactList.removeGroupListener(listener);
- }
-
- /**
- * Renames the specified group from the server stored contact list.
- *
- * @param group the group to rename.
- * @param newName the new name of the group.
- */
- public void renameServerStoredContactGroup(ContactGroup group,
- String newName)
- {
- assertConnected();
-
- if( !(group instanceof ContactGroupMsnImpl) )
- throw new IllegalArgumentException(
- "The specified group is not an msn contact group: " + group);
-
- ssContactList.renameGroup((ContactGroupMsnImpl)group, newName);
- }
-
- /**
- * Handler for incoming authorization requests.
- *
- * @param handler an instance of an AuthorizationHandler for
- * authorization requests coming from other users requesting
- * permission add us to their contact list.
- */
- public void setAuthorizationHandler(AuthorizationHandler handler)
- {
- this.authorizationHandler = handler;
- }
-
- /**
- * Returns the AuthorizationHandler.
- * @return AuthorizationHandler
- */
- AuthorizationHandler getAuthorizationHandler()
- {
- return this.authorizationHandler;
- }
-
- /**
- * Persistently adds a subscription for the presence status of the
- * contact corresponding to the specified contactIdentifier and indicates
- * that it should be added to the specified group of the server stored
- * contact list.
- *
- * @param parent the parent group of the server stored contact list
- * where the contact should be added. <p>
- * @param contactIdentifier the contact whose status updates we are
- * subscribing for.
- * @throws IllegalArgumentException if <tt>contact</tt> or
- * <tt>parent</tt> are not a contact known to the underlying protocol
- * provider.
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(ContactGroup parent, String contactIdentifier) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- if(! (parent instanceof ContactGroupMsnImpl) )
- throw new IllegalArgumentException(
- "Argument is not an msn contact group (group=" + parent + ")");
-
- ssContactList.addContact((ContactGroupMsnImpl)parent, contactIdentifier);
- }
-
- /**
- * Adds a subscription for the presence status of the contact
- * corresponding to the specified contactIdentifier.
- *
- * @param contactIdentifier the identifier of the contact whose status
- * updates we are subscribing for. <p>
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * subscribing fails due to errors experienced during network
- * communication
- */
- public void subscribe(String contactIdentifier) throws
- IllegalArgumentException, IllegalStateException,
- OperationFailedException
- {
- assertConnected();
-
- ssContactList.addContact(contactIdentifier);
- }
-
- /**
- * Removes a subscription for the presence status of the specified
- * contact.
- *
- * @param contact the contact whose status updates we are unsubscribing
- * from.
- * @throws IllegalArgumentException if <tt>contact</tt> is not a contact
- * known to the underlying protocol provider
- * @throws IllegalStateException if the underlying protocol provider is
- * not registered/signed on a public service.
- * @throws OperationFailedException with code NETWORK_FAILURE if
- * unsubscribing fails due to errors experienced during network
- * communication
- */
- public void unsubscribe(Contact contact) throws IllegalArgumentException,
- IllegalStateException, OperationFailedException
- {
- assertConnected();
-
- if(! (contact instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "Argument is not an msn contact (contact=" + contact + ")");
-
- ssContactList.removeContact((ContactMsnImpl)contact);
- }
-
- /**
- * Converts the specified msn status to one of the status fields of the
- * MsnStatusEnum class.
- *
- * @param status the msn Status
- * @return a PresenceStatus instance representation of the Msn Status
- * parameter. The returned result is one of the MsnStatusEnum fields.
- */
- MsnStatusEnum msnStatusToPresenceStatus(MsnUserStatus status)
- {
- if(status.equals(MsnUserStatus.ONLINE))
- return MsnStatusEnum.ONLINE;
- else if(status.equals(MsnUserStatus.AWAY))
- return MsnStatusEnum.AWAY;
- else if(status.equals(MsnUserStatus.BE_RIGHT_BACK))
- return MsnStatusEnum.BE_RIGHT_BACK;
- else if(status.equals(MsnUserStatus.BUSY))
- return MsnStatusEnum.BUSY;
- else if(status.equals(MsnUserStatus.HIDE))
- return MsnStatusEnum.HIDE;
- else if(status.equals(MsnUserStatus.IDLE))
- return MsnStatusEnum.IDLE;
- else if(status.equals(MsnUserStatus.ON_THE_PHONE))
- return MsnStatusEnum.ON_THE_PHONE;
- else if(status.equals(MsnUserStatus.OUT_TO_LUNCH))
- return MsnStatusEnum.OUT_TO_LUNCH;
- else return MsnStatusEnum.OFFLINE;
- }
-
- /**
- * Utility method throwing an exception if the stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- */
- private void assertConnected() throws IllegalStateException
- {
- if (parentProvider == null)
- throw new IllegalStateException(
- "The provider must be non-null and signed on the msn "
- +"service before being able to communicate.");
- if (!parentProvider.isRegistered())
- throw new IllegalStateException(
- "The provider must be signed on the msn service before "
- +"being able to communicate.");
- }
-
- /**
- * Notify all provider presence listeners of the corresponding event change
- *
- * @param oldStatus
- * the status our stack had so far
- * @param newStatus
- * the status we have from now on
- */
- @Override
- protected void fireProviderStatusChangeEvent(
- PresenceStatus oldStatus,
- PresenceStatus newStatus)
- {
- if (!oldStatus.equals(newStatus)) {
- currentStatus = newStatus;
-
- super.fireProviderStatusChangeEvent(oldStatus, newStatus);
- }
- }
-
- /**
- * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
- * <p>
- * @param contact the <tt>Contact</tt> that we are renaming
- * @param newName a <tt>String</tt> containing the new display name for
- * <tt>metaContact</tt>.
- * @throws IllegalArgumentException if <tt>contact</tt> is not an
- * instance that belongs to the underlying implementation.
- */
- @Override
- public void setDisplayName(Contact contact, String newName)
- throws IllegalArgumentException
- {
- assertConnected();
-
- if( !(contact instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an msn contact." + contact);
-
- ssContactList.setDisplayName((ContactMsnImpl)contact, newName);
- }
-
- /**
- * Our listener that will tell us when we're registered to server
- * and is ready to accept us as a listener.
- */
- private class RegistrationStateListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The msn provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
-
- if(evt.getNewState() == RegistrationState.REGISTERED)
- {
- if(parentProvider.getMessenger() != null)
- {
- parentProvider.getMessenger().
- addContactListListener(new StatusChangedListener());
- }
- else if(logger.isInfoEnabled())
- logger.info("Registered but msnMessenger is missing!",
- new Exception());
- }
- else if(evt.getNewState() == RegistrationState.UNREGISTERED
- || evt.getNewState() == RegistrationState.AUTHENTICATION_FAILED
- || evt.getNewState() == RegistrationState.CONNECTION_FAILED)
- {
- //since we are disconnected, we won't receive any further status
- //updates so we need to change by ourselves our own status as
- //well as set to offline all contacts in our contact list that
- //were online
- PresenceStatus oldStatus = currentStatus;
- currentStatus = MsnStatusEnum.OFFLINE;
-
- fireProviderStatusChangeEvent(oldStatus, currentStatus);
-
- //send event notifications saying that all our buddies are
- //offline.
- Iterator<Contact> rootContactsIter
- = getServerStoredContactListRoot().contacts();
- while(rootContactsIter.hasNext())
- {
- ContactMsnImpl contact
- = (ContactMsnImpl)rootContactsIter.next();
-
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if(!oldContactStatus.isOnline())
- continue;
-
- contact.updatePresenceStatus(MsnStatusEnum.OFFLINE);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus, MsnStatusEnum.OFFLINE);
- }
-
- Iterator<ContactGroup> groupsIter
- = getServerStoredContactListRoot().subgroups();
- while(groupsIter.hasNext())
- {
- ContactGroupMsnImpl group
- = (ContactGroupMsnImpl)groupsIter.next();
-
- Iterator<Contact> contactsIter = group.contacts();
-
- while(contactsIter.hasNext())
- {
- ContactMsnImpl contact
- = (ContactMsnImpl)contactsIter.next();
-
- PresenceStatus oldContactStatus
- = contact.getPresenceStatus();
-
- if(!oldContactStatus.isOnline())
- continue;
-
- contact.updatePresenceStatus(MsnStatusEnum.OFFLINE);
-
- fireContactPresenceStatusChangeEvent(
- contact
- , contact.getParentContactGroup()
- , oldContactStatus, MsnStatusEnum.OFFLINE);
- }
- }
- }
- }
- }
-
- /**
- * Sets the messenger instance impl of the lib
- * which communicates with the server
- * @param messenger MsnMessenger
- */
- void setMessenger(MsnMessenger messenger)
- {
- ssContactList.setMessenger(messenger);
- }
-
- /**
- * Fires all the saved statuses which were received before
- * contact list init
- */
- void earlyStatusesDispatch()
- {
- Iterator<String> iter = earlyStatusChange.keySet().iterator();
- while (iter.hasNext())
- {
- String contactEmail = iter.next();
-
- ContactMsnImpl sourceContact
- = ssContactList.findContactById(contactEmail);
-
- if (sourceContact == null)
- {
- return;
- }
-
- PresenceStatus oldStatus
- = sourceContact.getPresenceStatus();
-
- PresenceStatus newStatus
- = msnStatusToPresenceStatus(earlyStatusChange.get(contactEmail));
-
- // when old and new status are the same do nothing
- // no change
- if(oldStatus.equals(newStatus))
- return;
-
- sourceContact.updatePresenceStatus(newStatus);
-
- ContactGroup parent
- = ssContactList.findContactGroup(sourceContact);
-
- if (logger.isDebugEnabled())
- logger.debug("Will Dispatch the contact status event.");
- fireContactPresenceStatusChangeEvent(sourceContact, parent,
- oldStatus, newStatus);
- }
- earlyStatusChange.clear();
- }
-
- /**
- * Returns the server stored contact list registered in this operation set.
- * @return the server stored contact list registered in this operation set.
- */
- ServerStoredContactListMsnImpl getServerStoredContactList()
- {
- return ssContactList;
- }
-
- /**
- * Waits for status changes from the contacts in the list
- * or own account
- */
- private class StatusChangedListener
- extends MsnContactListAdapter
- {
- /**
- * Indicates that owner status changed
- * @param messenger the messenger changing the status
- */
- @Override
- public void ownerStatusChanged(MsnMessenger messenger)
- {
- if (logger.isTraceEnabled())
- logger.trace("Own status changed to " + messenger.getOwner().getStatus());
- PresenceStatus oldStatus = currentStatus;
- currentStatus =
- msnStatusToPresenceStatus(messenger.getOwner().getStatus());
- fireProviderStatusChangeEvent(oldStatus, currentStatus);
- }
-
- /**
- * Called from the lib when a contact status changes
- * @param messenger MsnMessenger
- * @param contact MsnContact
- */
- @Override
- public void contactStatusChanged( MsnMessenger messenger,
- MsnContact contact)
- {
- if (logger.isDebugEnabled())
- logger.debug("Received a status update for contact=" + contact);
-
- ContactMsnImpl sourceContact
- = ssContactList
- .findContactById(contact.getEmail().getEmailAddress());
-
- if (sourceContact == null)
- {
- if (logger.isDebugEnabled())
- logger.debug("No source contact found for msncontact=" + contact);
-
- // maybe list is not inited yet will store till init
- earlyStatusChange.put(contact.getEmail().getEmailAddress(),
- contact.getStatus());
-
- return;
- }
-
- PresenceStatus oldStatus
- = sourceContact.getPresenceStatus();
-
- PresenceStatus newStatus
- = msnStatusToPresenceStatus(contact.getStatus());
-
- // when old and new status are the same do nothing
- // no change
- if(oldStatus.equals(newStatus))
- return;
-
- sourceContact.updatePresenceStatus(newStatus);
-
- ContactGroup parent
- = ssContactList.findContactGroup(sourceContact);
-
- if (logger.isDebugEnabled())
- logger.debug("Will Dispatch the contact status event.");
- fireContactPresenceStatusChangeEvent(sourceContact, parent,
- oldStatus, newStatus);
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java
deleted file mode 100644
index 706caf7..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetServerStoredAccountInfoMsnImpl.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-import java.util.*;
-
-import javax.imageio.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.DisplayNameDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.ImageDetail;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-
-import org.jitsi.service.fileaccess.*;
-
-/**
- * Saves account avatar image. If one is already saved we set it as initial one
- * for the MsnOwner.
- *
- * @author SR
- * @author Damian Minkov
- */
-public class OperationSetServerStoredAccountInfoMsnImpl
- extends AbstractOperationSetServerStoredAccountInfo
- implements RegistrationStateChangeListener
-{
- /**
- * Logger for this class.
- */
- private static final Logger logger =
- Logger.getLogger(OperationSetServerStoredAccountInfoMsnImpl.class);
-
- /**
- * The msn provider that created us.
- */
- private ProtocolProviderServiceMsnImpl msnProvider = null;
- /**
- * Our account uin=email address.
- */
- private String uin = null;
-
- /**
- * A place to store our own picture.
- */
- private static final String STORE_DIR = "avatarcache" + File.separator;
-
- /**
- * Here is kept all the details retrieved so far.
- */
- private Hashtable<String,List<GenericDetail>> retrievedDetails
- = new Hashtable<String,List<GenericDetail>>();
-
- /**
- * Constructor.
- * @param msnProvider MSN service provider
- * @param uin MSN UIN
- */
- protected OperationSetServerStoredAccountInfoMsnImpl(
- ProtocolProviderServiceMsnImpl msnProvider,
- String uin)
- {
- this.msnProvider = msnProvider;
- this.uin = uin;
-
- this.msnProvider.addRegistrationStateChangeListener(this);
- }
-
- /**
- * Returns an iterator over all details that are instances or descendants of
- * the specified class. If for example an our account has a work address
- * and an address detail, a call to this method with AddressDetail.class
- * would return both of them.
- * <p>
- * @param detailClass one of the detail classes defined in the
- * ServerStoredDetails class, indicating the kind of details we're
- * interested in.
- * <p>
- * @return a java.util.Iterator over all details that are instances or
- * descendants of the specified class.
- */
- public <T extends GenericDetail> Iterator<T> getDetailsAndDescendants(
- Class<T> detailClass)
- {
- assertConnected();
-
- List<GenericDetail> details = getContactDetails(uin);
- List<T> result = new LinkedList<T>();
-
- Iterator<GenericDetail> iter = details.iterator();
- while (iter.hasNext())
- {
- GenericDetail item = iter.next();
- if (detailClass.isInstance(item))
- {
- @SuppressWarnings("unchecked")
- T t = (T) item;
-
- result.add(t);
- }
- }
-
- return result.iterator();
- }
-
- /**
- * request the full info for the given contactAddress
- * waits and return this details
- *
- * @param contactAddress String
- * @return Vector the details
- */
- List<GenericDetail> getContactDetails(String contactAddress)
- {
- List<GenericDetail> result = retrievedDetails.get(contactAddress);
-
- if (result == null)
- {
- result = new LinkedList<GenericDetail>();
- try
- {
- MsnMessenger messenger = msnProvider.getMessenger();
-
- if (messenger == null)
- {
- return null;
- }
-
- Email email = Email.parseStr(contactAddress);
-
- String tmp = null;
- byte[] imageBytes;
- if (messenger.getOwner().getEmail().equals(email))
- {
- MsnOwner owner = messenger.getOwner();
- tmp = owner.getDisplayName();
- result.add(new ServerStoredDetails.DisplayNameDetail(tmp));
-
- MsnObject image = owner.getDisplayPicture();
- if (image != null)
- {
- imageBytes = image.getMsnObj();
- if (imageBytes != null && imageBytes.length > 0)
- {
- result.add(new ServerStoredDetails.ImageDetail(
- "Image", imageBytes));
- }
- }
- } else
- {
- MsnContact contact =
- messenger.getContactList().getContactByEmail(email);
- tmp = contact.getDisplayName();
- result.add(new ServerStoredDetails.DisplayNameDetail(tmp));
- imageBytes = contact.getAvatar().getMsnObj();
- if (imageBytes != null && imageBytes.length > 0)
- {
- result.add(new ServerStoredDetails.ImageDetail(
- "Image", imageBytes));
- }
- }
-
- } catch (Exception exc)
- {
- logger.error("Cannot load details for contact " + this
- + " : " + exc.getMessage(), exc);
- }
- }
-
- retrievedDetails.put(contactAddress, result);
-
- return new LinkedList<GenericDetail>(result);
- }
-
- /**
- * Returns an iterator over all details that are instances of exactly the
- * same class as the one specified. Not that, contrary to the
- * getDetailsAndDescendants() method this one would only return details
- * that are instances of the specified class and not only its descendants.
- * If for example our account has both a work address and an address detail,
- * a call to this method with AddressDetail.class would return only the
- * AddressDetail instance and not the WorkAddressDetail instance.
- * <p>
- * @param detailClass one of the detail classes defined in the
- * ServerStoredDetails class, indicating the kind of details we're
- * interested in.
- * <p>
- * @return a java.util.Iterator over all details of specified class.
- */
- public Iterator<GenericDetail> getDetails(
- Class<? extends GenericDetail> detailClass)
- {
- assertConnected();
-
- return getDetails(uin, detailClass);
- }
-
- /**
- * Returns all details currently available and set for our account.
- * <p>
- * @return a java.util.Iterator over all details currently set our account.
- */
- public Iterator<GenericDetail> getAllAvailableDetails()
- {
- assertConnected();
-
- return getContactDetails(uin).iterator();
- }
-
- /**
- * Returns all detail Class-es that the underlying implementation supports
- * setting. Note that if you call one of the modification methods (add
- * remove or replace) with a detail not contained by the iterator returned
- * by this method, an IllegalArgumentException will be thrown.
- * <p>
- * @return a java.util.Iterator over all detail classes supported by the
- * implementation.
- */
- public Iterator<Class<? extends GenericDetail>> getSupportedDetailTypes()
- {
- List<GenericDetail> details = getContactDetails(uin);
- List<Class<? extends GenericDetail>> result
- = new LinkedList<Class<? extends GenericDetail>>();
-
- Iterator<GenericDetail> iter = details.iterator();
- while (iter.hasNext())
- {
- GenericDetail obj = iter.next();
- result.add(obj.getClass());
- }
-
- return result.iterator();
- }
-
- /**
- * Determines whether a detail class represents a detail supported by the
- * underlying implementation or not. Note that if you call one of the
- * modification methods (add remove or replace) with a detail that this
- * method has determined to be unsupported (returned false) this would lead
- * to an IllegalArgumentException being thrown.
- * <p>
- * @param detailClass the class the support for which we'd like to
- * determine.
- * <p>
- * @return true if the underlying implementation supports setting details of
- * this type and false otherwise.
- */
- public boolean isDetailClassSupported(
- Class<? extends GenericDetail> detailClass)
- {
- return ImageDetail.class.isAssignableFrom(detailClass) ||
- DisplayNameDetail.class.isAssignableFrom(detailClass);
- }
-
- /**
- * Determines whether the underlying implementation supports edition
- * of this detail class.
- * <p>
- * @param detailClass the class whose edition we'd like to determine if it's
- * possible
- * @return true if the underlying implementation supports edition of this
- * type of detail and false otherwise.
- */
- public boolean isDetailClassEditable(
- Class<? extends GenericDetail> detailClass)
- {
- return
- isDetailClassSupported(detailClass)
- && ImageDetail.class.isAssignableFrom(detailClass);
- }
-
- /**
- * The method returns the number of instances supported for a particular
- * detail type. Some protocols offer storing multiple values for a
- * particular detail type. Spoken languages are a good example.
- * @param detailClass the class whose max instance number we'd like to find
- * out.
- * <p>
- * @return int the maximum number of detail instances.
- */
- public int getMaxDetailInstances(Class<? extends GenericDetail> detailClass)
- {
- return 1;
- }
-
- /**
- * returns the user details from the specified class
- * exactly that class not its descendants
- *
- * @param uin String
- * @param detailClass Class
- * @return Iterator
- */
- private Iterator<GenericDetail> getDetails(String uin,
- Class<? extends GenericDetail> detailClass)
- {
- List<GenericDetail> details = getContactDetails(uin);
- List<GenericDetail> result = new LinkedList<GenericDetail>();
-
- Iterator<GenericDetail> iter = details.iterator();
- while (iter.hasNext())
- {
- GenericDetail item = iter.next();
- if (detailClass.equals(item.getClass()))
- {
- result.add(item);
- }
- }
-
- return result.iterator();
- }
-
- /**
- * Adds the specified detail to the list of details registered on-line
- * for this account. If such a detail already exists its max instance number
- * is consulted and if it allows it - a second instance is added or otherwise
- * and illegal argument exception is thrown. An IllegalArgumentException is
- * also thrown in case the class of the specified detail is not supported by
- * the underlying implementation, i.e. its class name was not returned by the
- * getSupportedDetailTypes() method.
- * <p>
- * @param detail the detail that we'd like registered on the server.
- * <p>
- * @throws IllegalArgumentException if such a detail already exists and its
- * max instances number has been attained or if the underlying
- * implementation does not support setting details of the corresponding
- * class.
- * @throws OperationFailedException with code Network Failure if putting the
- * new value online has failed
- * @throws java.lang.ArrayIndexOutOfBoundsException if the number of
- * instances currently registered by the application is already equal to the
- * maximum number of supported instances (@see getMaxDetailInstances())
- */
- public void addDetail(ServerStoredDetails.GenericDetail detail)
- throws IllegalArgumentException,
- OperationFailedException,
- ArrayIndexOutOfBoundsException
- {
- assertConnected();
-
- /*Currently as the function only provied the list of classes that currently have data associatd with them
- * in Jabber InfoRetreiver we have to skip this check*/
-// if (!isDetailClassSupported(detail.getClass())) {
-// throw new IllegalArgumentException(
-// "implementation does not support such details " +
-// detail.getClass());
-// }
-
- Iterator<GenericDetail> iter = getDetails(detail.getClass());
- int currentDetailsSize = 0;
- while (iter.hasNext())
- {
- currentDetailsSize++;
- }
- if (currentDetailsSize >= getMaxDetailInstances(detail.getClass())) {
- throw new ArrayIndexOutOfBoundsException(
- "Max count for this detail is already reached");
- }
-
- MsnOwner owner = msnProvider.getMessenger().getOwner();
-
- if (detail instanceof ImageDetail)
- {
- try
- {
- String path = storePicture(((ImageDetail) detail).getBytes());
-
- FileInputStream in = new FileInputStream(path);
- byte[] b = new byte[in.available()];
- in.read(b);
- in.close();
-
- owner.setDisplayPicture(MsnObject.getInstance(
- owner.getEmail().getEmailAddress(),
- b));
- } catch(Exception e)
- {
- logger.error("Error setting own avatar.", e);
-
- // on error return to skip details change
- return;
- }
- }
-
- fireServerStoredDetailsChangeEvent(msnProvider,
- ServerStoredDetailsChangeEvent.DETAIL_ADDED,
- null,
- detail);
- }
-
- /**
- * Stores the picture.
- * @param data data to store
- * @return the picture path.
- * @throws Exception if the storage of the picture failed
- */
- private String storePicture(byte[] data)
- throws Exception
- {
- String imagePath = STORE_DIR
- + msnProvider.getAccountID().getAccountUniqueID() + ".jpg";
-
- File storeDir = MsnActivator.getFileAccessService()
- .getPrivatePersistentDirectory(STORE_DIR, FileCategory.CACHE);
-
- // if dir doesn't exist create it
- storeDir.mkdirs();
-
- File file = MsnActivator.getFileAccessService()
- .getPrivatePersistentFile(imagePath, FileCategory.CACHE);
-
- ImageIO.write(
- ImageIO.read(new ByteArrayInputStream(data)),
- "jpg",
- file);
-
- return file.getPath();
- }
-
- /**
- * Removes the specified detail from the list of details stored online for
- * this account. The method returns a boolean indicating if such a detail
- * was found (and removed) or not.
- * <p>
- * @param detail the detail to remove
- * @return true if the specified detail existed and was successfully removed
- * and false otherwise.
- * @throws OperationFailedException with code Network Failure if removing the
- * detail from the server has failed
- */
- public boolean removeDetail(ServerStoredDetails.GenericDetail detail)
- throws OperationFailedException
- {
- return false;
- }
-
- /**
- * Replaces the currentDetailValue detail with newDetailValue and returns
- * true if the operation was a success or false if currentDetailValue did
- * not previously exist (in this case an additional call to addDetail is
- * required).
- * <p>
- * @param currentDetailValue the detail value we'd like to replace.
- * @param newDetailValue the value of the detail that we'd like to replace
- * currentDetailValue with.
- * @return true if the operation was a success or false if
- * currentDetailValue did not previously exist (in this case an additional
- * call to addDetail is required).
- * @throws ClassCastException if newDetailValue is not an instance of the
- * same class as currentDetailValue.
- * @throws OperationFailedException with code Network Failure if putting the
- * new value back online has failed
- */
- public boolean replaceDetail(
- ServerStoredDetails.GenericDetail currentDetailValue,
- ServerStoredDetails.GenericDetail newDetailValue)
- throws ClassCastException, OperationFailedException
- {
- assertConnected();
-
- if (!newDetailValue.getClass().equals(currentDetailValue.getClass()))
- {
- throw new ClassCastException("New value to be replaced is not " +
- "as the current one");
- }
- // if values are the same no change
- if (currentDetailValue.equals(newDetailValue))
- {
- return true;
- }
-
- boolean isFound = false;
- Iterator<GenericDetail> iter = getDetails(uin, currentDetailValue.getClass());
- while (iter.hasNext())
- {
- GenericDetail item = iter.next();
- if (item.equals(currentDetailValue))
- {
- isFound = true;
- break;
-
- }
- }
- // current detail value does not exist
- if (!isFound)
- {
- return false;
- }
-
- MsnOwner owner = msnProvider.getMessenger().getOwner();
-
- if (newDetailValue instanceof ImageDetail)
- {
- try
- {
- String path = storePicture(
- ((ImageDetail) newDetailValue).getBytes());
-
- FileInputStream in = new FileInputStream(path);
- byte[] b = new byte[in.available()];
- in.read(b);
- in.close();
-
- owner.setDisplayPicture(MsnObject.getInstance(
- owner.getEmail().getEmailAddress(),
- b));
-
- fireServerStoredDetailsChangeEvent(msnProvider,
- ServerStoredDetailsChangeEvent.DETAIL_REPLACED,
- currentDetailValue,
- newDetailValue);
-
- return true;
- } catch(Exception e)
- {
- logger.error("Error setting own avatar.", e);
- }
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see net.java.sip.communicator.service.protocol.OperationSetServerStoredAccountInfo#save()
- * This method is currently unimplemented.
- * The idea behind this method is for users to call it only once, meaning
- * that all ServerStoredDetails previously modified by addDetail/removeDetail
- * and/or replaceDetail will be saved online on the server in one step.
- * Currently, addDetail/removeDetail/replaceDetail methods are doing the
- * actual saving but in the future the saving part must be carried here.
- */
- public void save() throws OperationFailedException {}
-
- /**
- * Utility method throwing an exception if the icq stack is not properly
- * initialized.
- * @throws java.lang.IllegalStateException if the underlying ICQ stack is
- * not registered and initialized.
- */
- private void assertConnected()
- throws IllegalStateException
- {
- if (msnProvider == null)
- {
- throw new IllegalStateException(
- "The msn provider must be non-null and signed on "
- + "before being able to communicate.");
- }
-
- if (!msnProvider.isRegistered())
- {
- throw new IllegalStateException(
- "The msn provider must be signed on before "
- + "being able to communicate.");
- }
- }
-
- /**
- * The method is called by a <code>ProtocolProviderService</code>
- * implementation whenever a change in the registration state of the
- * corresponding provider had occurred.
- *
- * @param evt the event describing the status change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if(evt.getNewState() == RegistrationState.REGISTERING)
- {
- try
- {
- String imagePath = STORE_DIR
- + msnProvider.getAccountID().getAccountUniqueID() + ".jpg";
-
- File file = MsnActivator.getFileAccessService()
- .getPrivatePersistentFile(imagePath, FileCategory.CACHE);
-
- if(file.exists())
- {
- FileInputStream in = new FileInputStream(file);
- byte[] b = new byte[in.available()];
- in.read(b);
- in.close();
-
- if(msnProvider.getMessenger() != null)
- {
- MsnOwner owner = msnProvider.getMessenger().getOwner();
-
- owner.setInitDisplayPicture(MsnObject.getInstance(
- owner.getEmail().getEmailAddress(),
- b));
- }
- }
- }
- catch(Exception ex)
- {
- logger.error("Cannot obtain own avatar image.", ex);
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetTypingNotificationsMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetTypingNotificationsMsnImpl.java
deleted file mode 100644
index ebca1ea..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetTypingNotificationsMsnImpl.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-import net.sf.jml.event.*;
-import net.sf.jml.message.*;
-
-/**
- * Maps SIP Communicator typing notifications to those going and coming from
- * smack lib.
- *
- * @author Damian Minkov
- */
-public class OperationSetTypingNotificationsMsnImpl
- extends AbstractOperationSetTypingNotifications<ProtocolProviderServiceMsnImpl>
-{
- /**
- * This class logger.
- */
- private static final Logger logger =
- Logger.getLogger(OperationSetTypingNotificationsMsnImpl.class);
-
- /**
- * An active instance of the opSetPersPresence operation set. We're using
- * it to map incoming events to contacts in our contact list.
- */
- private OperationSetPersistentPresenceMsnImpl opSetPersPresence = null;
-
- /**
- * The messenger.
- */
- private MsnMessenger messenger = null;
-
- /**
- * @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt>
- * that created us and that we'll use for retrieving the underlying aim
- * connection.
- */
- OperationSetTypingNotificationsMsnImpl(
- ProtocolProviderServiceMsnImpl provider)
- {
- super(provider);
-
- provider.addRegistrationStateChangeListener(new ProviderRegListener());
- }
-
- /**
- * Sends a notification to <tt>notifiedContatct</tt> that we have entered
- * <tt>typingState</tt>.
- *
- * @param notifiedContact the <tt>Contact</tt> to notify
- * @param typingState the typing state that we have entered.
- *
- * @throws java.lang.IllegalStateException if the underlying stack is
- * not registered and initialized.
- * @throws java.lang.IllegalArgumentException if <tt>notifiedContact</tt> is
- * not an instance belonging to the underlying implementation.
- */
- public void sendTypingNotification(Contact notifiedContact, int typingState)
- throws IllegalStateException, IllegalArgumentException
- {
- assertConnected();
-
- if( !(notifiedContact instanceof ContactMsnImpl) )
- throw new IllegalArgumentException(
- "The specified contact is not an MSN contact."
- + notifiedContact);
-
- if(typingState == OperationSetTypingNotifications.STATE_TYPING)
- {
- MsnControlMessage msg = new MsnControlMessage();
- msg.setTypingUser(messenger.getOwner().getEmail().getEmailAddress());
-
- Email targetContactEmail =
- ( (ContactMsnImpl) notifiedContact).getSourceContact().getEmail();
-
- MsnSwitchboard[] activSB = messenger.getActiveSwitchboards();
-
- MsnSwitchboard tempSB = null;
- for (int i = 0; i < activSB.length; i++)
- {
- tempSB = activSB[i];
-
- if (tempSB.containContact(targetContactEmail))
- tempSB.sendMessage(msg, true);
- }
- }
- }
-
- /**
- * Sets the messenger instance impl of the lib which communicates with the
- * server
- *
- * @param messenger
- * MsnMessenger
- */
- void setMessenger(MsnMessenger messenger)
- {
- this.messenger = messenger;
-
- if(messenger != null)
- messenger.addMessageListener(new TypingListener());
- }
-
- /**
- * Listens for typing notifications coming from the protocol.
- */
- private class TypingListener
- extends MsnAdapter
- {
- /**
- * Control message may indicate typing notification.
- * @param switchboard
- * @param message
- * @param contact
- */
- @Override
- public void controlMessageReceived(MsnSwitchboard switchboard,
- MsnControlMessage message,
- MsnContact contact)
- {
- String typingUserID = message.getTypingUser();
-
- if(typingUserID != null)
- {
- Contact sourceContact = opSetPersPresence.findContactByID(typingUserID);
-
- if(sourceContact == null)
- return;
-
- fireTypingNotificationsEvent(sourceContact, STATE_TYPING);
- }
- }
- }
-
- /**
- * Our listener that will tell us when we're registered and
- * ready to accept us as a listener.
- */
- private class ProviderRegListener
- implements RegistrationStateChangeListener
- {
- /**
- * The method is called by a ProtocolProvider implementation whenever
- * a change in the registration state of the corresponding provider had
- * occurred.
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if (logger.isDebugEnabled())
- logger.debug("The provider changed state from: "
- + evt.getOldState()
- + " to: " + evt.getNewState());
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- opSetPersPresence =
- (OperationSetPersistentPresenceMsnImpl) parentProvider
- .getOperationSet(OperationSetPersistentPresence.class);
- }
- }
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolIconMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolIconMsnImpl.java
deleted file mode 100644
index b8e7bb2..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolIconMsnImpl.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Represents the MSN protocol icon. Implements the <tt>ProtocolIcon</tt>
- * interface in order to provide a MSN icon image in two different sizes.
- *
- * @author Yana Stamcheva
- */
-public class ProtocolIconMsnImpl
- implements ProtocolIcon
-{
- private static Logger logger = Logger.getLogger(ProtocolIconMsnImpl.class);
-
- /**
- * A hash table containing the protocol icon in different sizes.
- */
- private static Hashtable<String, byte[]> iconsTable
- = new Hashtable<String, byte[]>();
- static
- {
- iconsTable.put(ProtocolIcon.ICON_SIZE_16x16,
- getImageInBytes("service.protocol.msn.MSN_16x16"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- getImageInBytes("service.protocol.msn.MSN_32x32"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- getImageInBytes("service.protocol.msn.MSN_48x48"));
-
- iconsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- getImageInBytes("service.protocol.msn.MSN_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,
- MsnActivator.getResources().getImagePath(
- "service.protocol.msn.MSN_16x16"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_32x32,
- MsnActivator.getResources().getImagePath(
- "service.protocol.msn.MSN_32x32"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_48x48,
- MsnActivator.getResources().getImagePath(
- "service.protocol.msn.MSN_48x48"));
-
- iconPathsTable.put(ProtocolIcon.ICON_SIZE_64x64,
- MsnActivator.getResources().getImagePath(
- "service.protocol.msn.MSN_64x64"));
- }
-
- /**
- * Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns
- * an iterator to a set containing the supported icon sizes.
- * @return an iterator to a set containing the supported icon sizes
- */
- public Iterator<String> getSupportedSizes()
- {
- return iconsTable.keySet().iterator();
- }
-
- /**
- * Returne TRUE if a icon with the given size is supported, FALSE-otherwise.
- */
- public boolean isSizeSupported(String iconSize)
- {
- return iconsTable.containsKey(iconSize);
- }
-
- /**
- * Returns the icon image in the given size.
- * @param iconSize the icon size; one of ICON_SIZE_XXX constants
- */
- public byte[] getIcon(String iconSize)
- {
- return iconsTable.get(iconSize);
- }
-
- /**
- * Returns a path to the icon with the given size.
- * @param iconSize the size of the icon we're looking for
- * @return the path to the icon with the given size
- */
- public String getIconPath(String iconSize)
- {
- return iconPathsTable.get(iconSize);
- }
-
- /**
- * Returns the icon image used to represent the protocol connecting state.
- * @return the icon image used to represent the protocol connecting state
- */
- public byte[] getConnectingIcon()
- {
- return getImageInBytes("msnConnectingIcon");
- }
-
- /**
- * Returns the byte representation of the image corresponding to the given
- * identifier.
- *
- * @param imageID the identifier of the image
- * @return the byte representation of the image corresponding to the given
- * identifier.
- */
- private static byte[] getImageInBytes(String imageID)
- {
- InputStream in = MsnActivator.getResources().
- getImageInputStream(imageID);
-
- if (in == null)
- return null;
- byte[] image = null;
- try
- {
- image = new byte[in.available()];
-
- in.read(image);
- }
- catch (IOException e)
- {
- logger.error("Failed to load image:" + imageID, e);
- }
-
- return image;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java
deleted file mode 100644
index de27968..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderFactoryMsnImpl.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-/**
- * The Msn implementation of the ProtocolProviderFactory.
- * @author Damian Minkov
- */
-public class ProtocolProviderFactoryMsnImpl
- extends ProtocolProviderFactory
-{
-
- /**
- * Creates an instance of the ProtocolProviderFactoryMsnImpl.
- */
- protected ProtocolProviderFactoryMsnImpl()
- {
- super(MsnActivator.getBundleContext(), ProtocolNames.MSN);
- }
-
- /**
- * Initializes and creates an account corresponding to the specified
- * accountProperties and registers the resulting ProtocolProvider in the
- * <tt>context</tt> BundleContext parameter. This method has a persistent
- * effect. Once created the resulting account will remain installed until
- * removed through the uninstall account method.
- *
- * @param userIDStr the user identifier for the new account
- * @param accountProperties a set of protocol (or implementation)
- * specific properties defining the new account.
- * @return the AccountID of the newly created account
- */
- @Override
- public AccountID installAccount( String userIDStr,
- Map<String, String> accountProperties)
- {
- BundleContext context
- = MsnActivator.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 MsnAccountID(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 (trhgough the UI) a call to
- //the register() method and it needs to acces the configuration service
- //and check for a password.
- this.storeAccount(accountID, false);
-
- accountID = loadAccount(accountProperties);
-
- return accountID;
- }
-
- @Override
- protected AccountID createAccountID(String userID, Map<String, String> accountProperties)
- {
- return new MsnAccountID(userID, accountProperties);
- }
-
- @Override
- protected ProtocolProviderService createService(String userID,
- AccountID accountID)
- {
- ProtocolProviderServiceMsnImpl service =
- new ProtocolProviderServiceMsnImpl();
-
- service.initialize(userID, accountID);
- return service;
- }
-
- @Override
- public void modifyAccount( ProtocolProviderService protocolProvider,
- Map<String, String> accountProperties)
- throws NullPointerException
- {
- BundleContext context
- = MsnActivator.getBundleContext();
-
- if (context == null)
- throw new NullPointerException(
- "The specified BundleContext was null");
-
- if (protocolProvider == null)
- throw new NullPointerException(
- "The specified Protocol Provider was null");
-
- MsnAccountID accountID = (MsnAccountID) protocolProvider.getAccountID();
-
- // If the given accountID doesn't correspond to an existing account
- // we return.
- if(!registeredAccounts.containsKey(accountID))
- return;
-
- ServiceRegistration registration = registeredAccounts.get(accountID);
-
- // kill the service
- if (registration != null)
- registration.unregister();
-
- if (accountProperties == null)
- throw new NullPointerException(
- "The specified property map was null");
-
- accountProperties.put(USER_ID, accountID.getUserID());
-
- if (!accountProperties.containsKey(PROTOCOL))
- accountProperties.put(PROTOCOL, ProtocolNames.MSN);
-
- accountID.setAccountProperties(accountProperties);
-
- // First store the account and only then load it as the load generates
- // an osgi event, the osgi event triggers (through the UI) a call to
- // the register() method and it needs to access the configuration service
- // and check for a password.
- this.storeAccount(accountID);
-
- Hashtable<String, String> properties = new Hashtable<String, String>();
- properties.put(PROTOCOL, ProtocolNames.MSN);
- properties.put(USER_ID, accountID.getUserID());
-
- ((ProtocolProviderServiceMsnImpl)protocolProvider)
- .initialize(accountID.getUserID(), accountID);
-
- // We store again the account in order to store all properties added
- // during the protocol provider initialization.
- this.storeAccount(accountID);
-
- registration
- = context.registerService(
- ProtocolProviderService.class.getName(),
- protocolProvider,
- properties);
-
- registeredAccounts.put(accountID, registration);
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
deleted file mode 100644
index 9b8d1e9..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.net.*;
-import java.nio.channels.*;
-
-import net.java.sip.communicator.service.dns.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-import net.sf.jml.*;
-import net.sf.jml.event.*;
-import net.sf.jml.exception.*;
-import net.sf.jml.impl.*;
-
-/**
- * An implementation of the protocol provider service over the Msn protocol
- *
- * @author Damian Minkov
- * @author Lubomir Marinov
- */
-public class ProtocolProviderServiceMsnImpl
- extends AbstractProtocolProviderService
-{
- /**
- * Logger of this class
- */
- private static final Logger logger
- = Logger.getLogger(ProtocolProviderServiceMsnImpl.class);
-
- /**
- * The lib messenger.
- */
- private MsnMessenger messenger = null;
-
- /**
- * We use this to lock access to initialization.
- */
- private final Object initializationLock = new Object();
-
- /**
- * The identifier of the account that this provider represents.
- */
- private AccountID accountID = null;
-
- /**
- * Used when we need to re-register
- */
- private SecurityAuthority authority = null;
-
- /**
- * Operation set for persistent presence.
- */
- private OperationSetPersistentPresenceMsnImpl persistentPresence = null;
-
- /**
- * Operation set for typing notifications.
- */
- private OperationSetTypingNotificationsMsnImpl typingNotifications = null;
-
- /**
- * The icon corresponding to the msn protocol.
- */
- private final ProtocolIconMsnImpl msnIcon = new ProtocolIconMsnImpl();
-
- /**
- * The indicator which determines whether
- * {@link MsnMessengerListener#logout(MsnMessenger)} has been received for
- * {@link #messenger} and it is thus an error to call
- * {@link MsnMessenger#logout()} on it.
- */
- private boolean logoutReceived = false;
-
- /**
- * Returns the state of the registration of this protocol provider
- * @return the <tt>RegistrationState</tt> that this provider is
- * currently in or null in case it is in a unknown state.
- */
- public RegistrationState getRegistrationState()
- {
- if(messenger == null || messenger.getConnection() == null)
- return RegistrationState.UNREGISTERED;
- else
- return RegistrationState.REGISTERED;
- }
-
- /**
- * Starts the registration process. Connection details such as
- * registration server, user name/number are provided through the
- * configuration service through implementation specific properties.
- *
- * @param authority the security authority that will be used for resolving
- * any security challenges that may be returned during the
- * registration or at any moment while wer're registered.
- * @throws OperationFailedException with the corresponding code it the
- * registration fails for some reason (e.g. a networking error or an
- * implementation problem).
- */
- public void register(final SecurityAuthority authority)
- throws OperationFailedException
- {
- if(authority == null)
- throw new IllegalArgumentException(
- "The register method needs a valid non-null authority impl "
- + " in order to be able and retrieve passwords.");
-
- this.authority = authority;
-
- connectAndLogin(authority, SecurityAuthority.AUTHENTICATION_REQUIRED);
- }
-
- /**
- * Reconnects if fails fire connection failed.
- * @param reasonCode the appropriate <tt>SecurityAuthority</tt> reasonCode,
- * which would specify the reason for which we're re-calling the login.
- */
- void reconnect(int reasonCode)
- {
- try
- {
- connectAndLogin(authority, reasonCode);
- }
- catch (OperationFailedException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
- null);
- }
- }
-
- /**
- * Connects and logins to the server
- * @param authority SecurityAuthority
- * @param reasonCode
- * @throws OperationFailedException if login parameters
- * as server port are not correct
- */
- private void connectAndLogin(SecurityAuthority authority, int reasonCode)
- throws OperationFailedException
- {
- synchronized(initializationLock)
- {
- //verify whether a password has already been stored for this account
- ProtocolProviderFactory protocolProviderFactory
- = MsnActivator.getProtocolProviderFactory();
- AccountID accountID = getAccountID();
- String password = protocolProviderFactory.loadPassword(accountID);
-
- //decode
- if (password == null)
- {
- //create a default credentials object
- UserCredentials credentials = new UserCredentials();
- credentials.setUserName(accountID.getUserID());
-
- //request a password from the user
- credentials
- = authority
- .obtainCredentials(
- accountID.getDisplayName(),
- credentials,
- reasonCode);
-
- // in case user has canceled the login window
- if(credentials == null)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- "");
- return;
- }
-
- //extract the password the user passed us.
- char[] pass = credentials.getPassword();
-
- // the user didn't provide us a password (canceled the operation)
- if(pass == null)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- "");
- return;
- }
- password = new String(pass);
-
- if (credentials.isPasswordPersistent())
- protocolProviderFactory.storePassword(accountID, password);
- }
-
- messenger
- = MsnMessengerFactory
- .createMsnMessenger(accountID.getUserID(), password);
-
- /*
- * We've just created the messenger so we're sure we haven't
- * received a logout for it.
- */
- logoutReceived = false;
- messenger.addMessengerListener(new MsnConnectionListener());
-
- persistentPresence.setMessenger(messenger);
- typingNotifications.setMessenger(messenger);
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.REGISTERING,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
- null);
-
- try
- {
- messenger.login();
- }
- catch (UnresolvedAddressException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND,
- null);
- }
- catch(DnssecRuntimeException ex)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
- }
- }
- }
-
- /**
- * Ends the registration of this protocol provider with the service.
- */
- public void unregister()
- {
- unregisterInternal(true);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see net.java.sip.communicator.service.protocol.ProtocolProviderService#
- * isSignallingTransportSecure()
- */
- public boolean isSignalingTransportSecure()
- {
- return false;
- }
-
- /**
- * Returns the "transport" protocol of this instance used to carry the
- * control channel for the current protocol service.
- *
- * @return The "transport" protocol of this instance: TCP.
- */
- public TransportProtocol getTransportProtocol()
- {
- return TransportProtocol.TCP;
- }
-
- /**
- * Unregister and fire the event if requested
- * @param fireEvent boolean
- */
- void unregisterInternal(boolean fireEvent)
- {
- RegistrationState currRegState = getRegistrationState();
-
- if(fireEvent)
- fireRegistrationStateChanged(
- currRegState,
- RegistrationState.UNREGISTERING,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
-
- // The synchronization is for logoutReceived at least.
- synchronized (initializationLock)
- {
- if((messenger != null) && !logoutReceived)
- messenger.logout();
-
- persistentPresence.setMessenger(null);
- typingNotifications.setMessenger(null);
- }
-
- // if messenger is null we have already fired unregister
- if(fireEvent && messenger != null)
- fireRegistrationStateChanged(
- currRegState,
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_USER_REQUEST,
- null);
- }
-
- /**
- * Returns the short name of the protocol that the implementation of this
- * provider is based upon (like SIP, Msn, ICQ/AIM, or others for
- * example).
- *
- * @return a String containing the short name of the protocol this
- * service is taking care of.
- */
- public String getProtocolName()
- {
- return ProtocolNames.MSN;
- }
-
- /**
- * Initialized the service implementation, and puts it in a sate where it
- * could interoperate with other services. It is strongly recomended that
- * properties in this Map be mapped to property names as specified by
- * <tt>AccountProperties</tt>.
- *
- * @param screenname the account id/uin/screenname of the account that
- * we're about to create
- * @param accountID the identifier of the account that this protocol
- * provider represents.
- *
- * @see net.java.sip.communicator.service.protocol.AccountID
- */
- protected void initialize(String screenname, AccountID accountID)
- {
- synchronized(initializationLock)
- {
- this.accountID = accountID;
-
- addSupportedOperationSet(
- OperationSetInstantMessageTransform.class,
- new OperationSetInstantMessageTransformImpl());
-
- //initialize the presence operationset
- persistentPresence = new OperationSetPersistentPresenceMsnImpl(this);
- addSupportedOperationSet(
- OperationSetPersistentPresence.class,
- persistentPresence);
- //register it once again for those that simply need presence
- addSupportedOperationSet(
- OperationSetPresence.class,
- persistentPresence);
-
- //initialize AccountInfo
- OperationSetServerStoredAccountInfoMsnImpl accountInfo
- = new OperationSetServerStoredAccountInfoMsnImpl(
- this, screenname);
- addSupportedOperationSet(
- OperationSetServerStoredAccountInfo.class,
- accountInfo);
- addSupportedOperationSet(
- OperationSetAvatar.class,
- new OperationSetAvatarMsnImpl(this, accountInfo));
-
- addSupportedOperationSet(
- OperationSetAdHocMultiUserChat.class,
- new OperationSetAdHocMultiUserChatMsnImpl(this));
-
- // initialize the IM operation set
- addSupportedOperationSet(
- OperationSetBasicInstantMessaging.class,
- new OperationSetBasicInstantMessagingMsnImpl(this));
-
- //initialize the typing notifications operation set
- typingNotifications
- = new OperationSetTypingNotificationsMsnImpl(this);
- addSupportedOperationSet(
- OperationSetTypingNotifications.class,
- typingNotifications);
-
- addSupportedOperationSet(
- OperationSetFileTransfer.class,
- new OperationSetFileTransferMsnImpl(this));
- }
- }
-
- /**
- * Makes the service implementation close all open sockets and release
- * any resources that it might have taken and prepare for
- * shutdown/garbage collection.
- */
- public void shutdown()
- {
- synchronized(initializationLock)
- {
- unregisterInternal(false);
- messenger = null;
- }
- }
-
- /**
- * 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 <tt>XMPPConnection</tt>opened by this provider
- * @return a reference to the <tt>XMPPConnection</tt> last opened by this
- * provider.
- */
- MsnMessenger getMessenger()
- {
- return messenger;
- }
-
- /**
- * Creates a RegistrationStateChange event corresponding to the specified
- * old and new states and notifies all currently registered listeners.
- *
- * @param oldState the state that the provider had before the change
- * occurred
- * @param newState the state that the provider is currently in.
- * @param reasonCode a value corresponding to one of the REASON_XXX fields
- * of the RegistrationStateChangeEvent class, indicating the reason for
- * this state transition.
- * @param reason a String further explaining the reason code or null if
- * no such explanation is necessary.
- */
- @Override
- public void fireRegistrationStateChanged(RegistrationState oldState,
- RegistrationState newState,
- int reasonCode,
- String reason)
- {
- if (newState.equals(RegistrationState.UNREGISTERED)
- || newState.equals(RegistrationState.CONNECTION_FAILED))
- messenger = null;
-
- super.fireRegistrationStateChanged(oldState, newState, reasonCode, reason);
- }
-
- /**
- * Listens when we are logged in or out from the server or incoming
- * exception in the lib impl.
- */
- private class MsnConnectionListener
- implements MsnMessengerListener
- {
- /**
- * Fired when login has completed.
- * @param msnMessenger
- */
- public void loginCompleted(MsnMessenger msnMessenger)
- {
- if (logger.isTraceEnabled())
- logger.trace("loginCompleted " + msnMessenger.getActualMsnProtocol());
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.REGISTERED,
- RegistrationStateChangeEvent.REASON_NOT_SPECIFIED,
- null);
- }
-
- /**
- * Fire when lib logs out.
- * @param msnMessenger
- */
- public void logout(MsnMessenger msnMessenger)
- {
- if (logger.isTraceEnabled())
- logger.trace("logout");
-
- // The synchronization is for logoutReceived at least.
- synchronized (initializationLock)
- {
- logoutReceived = true;
- unregisterInternal(true);
- }
- }
-
- /**
- * Fired when an exception has occurred.
- * @param msnMessenger
- * @param throwable
- */
- public void exceptionCaught(MsnMessenger msnMessenger,
- Throwable throwable)
- {
- if(throwable instanceof IncorrectPasswordException)
- {
- unregisterInternal(false);
- MsnActivator.getProtocolProviderFactory().
- storePassword(getAccountID(), null);
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED,
- "Incorrect Password");
-
- // We try to reconnect and ask user to retype password.
- reconnect(SecurityAuthority.WRONG_PASSWORD);
- }
- else if(throwable instanceof SocketException)
- {
- // in case of SocketException just fire event and not trigger
- // unregister it will cause SocketException again and will loop
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_INTERNAL_ERROR,
- null);
- }
- else if(throwable instanceof UnknownHostException)
- {
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.CONNECTION_FAILED,
- RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND,
- "A network error occured. Could not connect to server.");
- }
- else if(throwable instanceof MsnProtocolException)
- {
- MsnProtocolException exception =
- (MsnProtocolException)throwable;
-
- logger.error("Error in Msn lib ", exception);
-
- switch(exception.getErrorCode())
- {
- case 500:
- case 540:
- case 601:
- if(isRegistered())
- {
- unregisterInternal(false);
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_INTERNAL_ERROR,
- null);
- }
- break;
- case 911:
- if(isRegistered())
- {
- unregisterInternal(false);
- MsnActivator.getProtocolProviderFactory().
- storePassword(getAccountID(), null);
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent
- .REASON_AUTHENTICATION_FAILED,
- null);
-
- // We try to reconnect and ask user to retype
- // password.
- reconnect(SecurityAuthority.WRONG_PASSWORD);
- }
- break;
- }
- }
- else
- {
- logger.error("Error in Msn lib ", throwable);
-
- if(throwable instanceof LoginException)
- {
- MsnActivator.getProtocolProviderFactory().
- storePassword(getAccountID(), null);
-
- fireRegistrationStateChanged(
- getRegistrationState(),
- RegistrationState.AUTHENTICATION_FAILED,
- RegistrationStateChangeEvent
- .REASON_AUTHENTICATION_FAILED,
- null);
- // We try to reconnect and ask user to retype
- // password.
- reconnect(SecurityAuthority.WRONG_PASSWORD);
- }
-
-// We don't want to disconnect on any error, that's why we're
-// commenting the following lines for now.
-//
-// if(isRegistered())
-// {
-// unregister(false);
-// fireRegistrationStateChanged(
-// getRegistrationState(),
-// RegistrationState.UNREGISTERED,
-// RegistrationStateChangeEvent.REASON_NOT_SPECIFIED, null);
-// }
- }
- }
- }
-
- /**
- * Returns the msn protocol icon.
- * @return the msn protocol icon
- */
- public ProtocolIcon getProtocolIcon()
- {
- return msnIcon;
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ReferenceURLStreamHandlerService.java b/src/net/java/sip/communicator/impl/protocol/msn/ReferenceURLStreamHandlerService.java
deleted file mode 100644
index b483c92..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ReferenceURLStreamHandlerService.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-import org.osgi.service.url.*;
-
-/**
- * Implements {@link URLStreamHandlerService} for the &quot;reference&quot;
- * protocol used inside felix.client.run.properties in order to fix issue #647
- * (MalformedURLException in java-jml) by translating the URL to the
- * &quot;jar&quot; protocol which is natively supported by Java.
- *
- * @author Lubomir Marinov
- */
-public class ReferenceURLStreamHandlerService
- extends AbstractURLStreamHandlerService
-{
-
- /**
- * The <tt>Logger</tt> instance used by the
- * <tt>ReferenceURLStreamHandlerService</tt> class and instances for logging
- * output.
- */
- private static final Logger logger
- = Logger.getLogger(ReferenceURLStreamHandlerService.class);
-
- /**
- * Registers a new <tt>ReferenceURLStreamHandlerService</tt> instance as an
- * implementation of {@link URLStreamHandlerService} in a specific
- * <tt>BundleContext</tt> for the &quot;reference&quot; protocol if there is
- * no such registered implementation already. Otherwise, the existing
- * registered implementation is considered to be more complete in terms of
- * features than <tt>ReferenceURLStreamHandlerService</tt> and this method
- * does nothing.
- *
- * @param bundleContext the <tt>BundleContext</tt> in which a new
- * <tt>ReferenceURLStreamHandlerService</tt> instance is to be registered
- */
- public static void registerService(BundleContext bundleContext)
- {
- ServiceReference[] serviceReferences;
- String clazz = URLStreamHandlerService.class.getName();
- String propertyName = URLConstants.URL_HANDLER_PROTOCOL;
- String propertyValue = "reference";
-
- try
- {
- serviceReferences
- = bundleContext
- .getServiceReferences(
- clazz,
- "(" + propertyName + "=" + propertyValue + ")");
- }
- catch (InvalidSyntaxException ise)
- {
- logger
- .warn(
- "Failed to determine whether there are registered "
- + "URLStreamHandlerService implementations for the "
- + "\"reference\" protocol",
- ise);
- serviceReferences = null;
- }
-
- if ((serviceReferences != null) && (serviceReferences.length > 0))
- return;
-
- Dictionary<String, String> properties = new Hashtable<String, String>();
-
- properties.put(propertyName, propertyValue);
- bundleContext
- .registerService(
- clazz,
- new ReferenceURLStreamHandlerService(),
- properties);
- }
-
- /**
- * Implements <tt>AbstractURLStreamHandlerService#openConnection(URL)</tt>.
- * Opens a connection to the object referenced by the <tt>URL</tt> argument
- * by rewriting the &quot;reference&quot; protocol in it with the
- * &quot;jar&quot; protocol and then handing it for opening to
- * {@link JarURLConnection}.
- *
- * @param url the <tt>URL</tt> that <tt>this</tt> connects to
- * @return an <tt>URLConnection</tt> instance for the specified <tt>URL</tt>
- * @throws IOException if an I/O error occurs while opening the connection
- */
- @Override
- public URLConnection openConnection(URL url)
- throws IOException
- {
- String referenceSpec = url.toString();
- String jarSpec = referenceSpec.replaceFirst("reference:", "jar:");
- String jarSeparator = "!/";
-
- // JarURLConnection mandates jarSeparator.
- if (!jarSpec.contains(jarSeparator))
- jarSpec += jarSeparator;
-
- return new URL(jarSpec).openConnection();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/RootContactGroupMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/RootContactGroupMsnImpl.java
deleted file mode 100644
index c0c5b4a..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/RootContactGroupMsnImpl.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A dummy ContactGroup implementation representing the ContactList root for
- * Msn contact lists.
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class RootContactGroupMsnImpl
- extends AbstractContactGroupMsnImpl
-{
- private String ROOT_CONTACT_GROUP_NAME = "ContactListRoot";
- private List<ContactGroup> subGroups = new LinkedList<ContactGroup>();
- private boolean isResolved = false;
-
- private List<Contact> contacts = new LinkedList<Contact>();
-
- private final ProtocolProviderServiceMsnImpl protocolProvider;
-
- /**
- * Creates a ContactGroup instance.
- */
- RootContactGroupMsnImpl(ProtocolProviderServiceMsnImpl protocolProvider)
- {
- this.protocolProvider = protocolProvider;
- }
-
- /**
- * The ContactListRoot is the only group that can contain subgroups.
- *
- * @return true (always)
- */
- public boolean canContainSubgroups()
- {
- return true;
- }
-
- /**
- * Returns the name of this group which is always
- * <tt>ROOT_CONTACT_GROUP_NAME</tt>.
- *
- * @return a String containing the name of this group.
- */
- public String getGroupName()
- {
- return ROOT_CONTACT_GROUP_NAME;
- }
-
- /**
- * Removes the specified contact from this contact group
- * @param contact the contact to remove.
- */
- void removeContact(ContactMsnImpl contact)
- {
- contacts.remove(contact);
- }
-
- /**
- * Adds the specified contact to the end of this group.
- * @param contact the new contact to add to this group
- */
- void addContact(ContactMsnImpl contact)
- {
- contacts.add(contact);
- }
-
- /**
- * Adds the specified group to the end of the list of sub groups.
- * @param group the group to add.
- */
- void addSubGroup(ContactGroupMsnImpl group)
- {
- subGroups.add(group);
- }
-
- /**
- * Removes the specified from the list of sub groups
- * @param group the group to remove.
- */
- void removeSubGroup(ContactGroupMsnImpl group)
- {
- removeSubGroup(subGroups.indexOf(group));
- }
-
- /**
- * Removes the sub group with the specified index.
- * @param index the index of the group to remove
- */
- void removeSubGroup(int index)
- {
- subGroups.remove(index);
- }
-
- /**
- * Returns the number of subgroups contained by this
- * <tt>RootContactGroupImpl</tt>.
- *
- * @return an int indicating the number of subgroups that this
- * ContactGroup contains.
- */
- public int countSubgroups()
- {
- return subGroups.size();
- }
-
- /**
- * Returns null as this is the root contact group.
- * @return null as this is the root contact group.
- */
- public ContactGroup getParentContactGroup()
- {
- return null;
- }
-
- /**
- * Returns the subgroup with the specified index.
- *
- * @param index the index of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(int index)
- {
- return subGroups.get(index);
- }
-
- /**
- * Returns the subgroup with the specified name.
- * @param groupName the name of the <tt>ContactGroup</tt> to retrieve.
- * @return the <tt>ContactGroup</tt> with the specified index.
- */
- public ContactGroup getGroup(String groupName)
- {
- Iterator<ContactGroup> subgroups = subgroups();
- while (subgroups.hasNext())
- {
- ContactGroup grp = subgroups.next();
-
- if (grp.getGroupName().equals(groupName))
- return grp;
- }
-
- return null;
- }
-
- /**
- * Returns an iterator over the sub groups that this
- * <tt>ContactGroup</tt> contains.
- *
- * @return a java.util.Iterator over the <tt>ContactGroup</tt>
- * children of this group (i.e. subgroups).
- */
- public Iterator<ContactGroup> subgroups()
- {
- return subGroups.iterator();
- }
-
- /**
- * Returns the number, which is always 0, of <tt>Contact</tt> members
- * of this <tt>ContactGroup</tt>
- * @return an int indicating the number of <tt>Contact</tt>s, members
- * of this <tt>ContactGroup</tt>.
- */
- public int countContacts()
- {
- return contacts.size();
- }
-
- /**
- * Returns an Iterator over all contacts, member of this
- * <tt>ContactGroup</tt>.
- * @return a java.util.Iterator over all contacts inside this
- * <tt>ContactGroup</tt>
- */
- public Iterator<Contact> contacts()
- {
- return contacts.iterator();
- }
-
- /**
- * Returns the <tt>Contact</tt> with the specified address or
- * identifier.
- * @param id the addres or identifier of the <tt>Contact</tt> we are
- * looking for.
- * @return the <tt>Contact</tt> with the specified id or address.
- */
- public Contact getContact(String id)
- {
- //no contacts in the root group for this msn impl.
- return null;
- }
-
-
- /**
- * Returns a string representation of the root contact group that contains
- * all subgroups and subcontacts of this group.
- *
- * @return a string representation of this root contact group.
- */
- @Override
- public String toString()
- {
- StringBuffer buff = new StringBuffer(getGroupName());
- buff.append(".subGroups=" + countSubgroups() + ":\n");
-
- Iterator<ContactGroup> subGroups = subgroups();
- while (subGroups.hasNext())
- {
- ContactGroup group = subGroups.next();
- buff.append(group.toString());
- if (subGroups.hasNext())
- buff.append("\n");
- }
- return buff.toString();
- }
-
- /**
- * Returns the protocol provider that this group belongs to.
- * @return a regerence to the ProtocolProviderService instance that this
- * ContactGroup belongs to.
- */
- public ProtocolProviderService getProtocolProvider()
- {
- return protocolProvider;
- }
-
- /**
- * Determines whether or not this contact group is being stored by the
- * server. Non persistent contact groups exist for the sole purpose of
- * containing non persistent contacts.
- * @return true if the contact group is persistent and false otherwise.
- */
- public boolean isPersistent()
- {
- return true;
- }
-
- /**
- * Returns null as no persistent data is required and the group name is
- * sufficient for restoring the contact.
- * <p>
- * @return null as no such data is needed.
- */
- public String getPersistentData()
- {
- return null;
- }
-
- /**
- * Determines whether or not this group has been resolved against the
- * server. Unresolved groups are used when initially loading a contact
- * list that has been stored in a local file until the presence operation
- * set has managed to retrieve all the contact list from the server and has
- * properly mapped groups to their on-line buddies.
- * @return true if the group has been resolved (mapped against a buddy)
- * and false otherwise.
- */
- public boolean isResolved()
- {
- return isResolved;
- }
-
- /**
- * Returns a <tt>String</tt> that uniquely represnets the group. In this we
- * use the name of the group as an identifier. This may cause problems
- * though, in clase the name is changed by some other application between
- * consecutive runs of the sip-communicator.
- *
- * @return a String representing this group in a unique and persistent
- * way.
- */
- public String getUID()
- {
- return getGroupName();
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java
deleted file mode 100644
index bbae5be..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java
+++ /dev/null
@@ -1,1484 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-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 net.sf.jml.*;
-import net.sf.jml.impl.*;
-import net.sf.jml.message.p2p.*;
-
-/**
- * This class encapsulates the Roster class. Once created, it will
- * register itself as a listener to the encapsulated Roster and modify it's
- * local copy of Contacts and ContactGroups every time an event is generated
- * by the underlying framework. The class would also generate
- * corresponding sip-communicator events to all events coming from smack.
- *
- * @author Damian Minkov
- * @author Emil Ivov
- */
-public class ServerStoredContactListMsnImpl
-{
- private static final Logger logger =
- Logger.getLogger(ServerStoredContactListMsnImpl.class);
-
- /**
- * The root group. The container for all msn buddies and groups.
- */
- private final RootContactGroupMsnImpl rootGroup;
-
- /**
- * The operation set that created us and that we could use when dispatching
- * subscription events.
- */
- private OperationSetPersistentPresenceMsnImpl parentOperationSet = null;
-
- /**
- * The provider that is on top of us.
- */
- private final ProtocolProviderServiceMsnImpl msnProvider;
-
- private MsnMessenger messenger = null;
-
- /**
- * Listeners that would receive event notifications for changes in group
- * names or other properties, removal or creation of groups.
- */
- private Vector<ServerStoredGroupListener> serverStoredGroupListeners
- = new Vector<ServerStoredGroupListener>();
-
- /**
- * Manages and fires contact list modifications
- */
- private EventManager contactListModManager = null;
-
- private ContactListModListenerImpl contactListModListenerImpl
- = new ContactListModListenerImpl();
-
- /**
- * indicates whether or not the contactlist is initialized and ready.
- */
- private boolean isInitialized = false;
-
- private Vector<String> skipAddEvent = new Vector<String>();
-
- /**
- * Contact list listener.
- */
- ContactListListener contactListListener = null;
-
- /**
- * Creates a ServerStoredContactList wrapper for the specified BuddyList.
- *
- * @param parentOperationSet the operation set that created us and that
- * we could use for dispatching subscription events
- * @param provider the provider that has instantiated us.
- */
- ServerStoredContactListMsnImpl(
- OperationSetPersistentPresenceMsnImpl parentOperationSet,
- ProtocolProviderServiceMsnImpl provider)
- {
- //We need to init these as early as possible to ensure that the provider
- //and the operationsset would not be null in the incoming events.
- this.parentOperationSet = parentOperationSet;
-
- this.msnProvider = provider;
- this.rootGroup = new RootContactGroupMsnImpl(this.msnProvider);
-
- // listens for provider registered events to set the isInitialized state
- // of the contact list
- provider.addRegistrationStateChangeListener(
- new RegistrationStateChangeListener()
- {
- public void registrationStateChanged(
- RegistrationStateChangeEvent evt)
- {
- if (evt.getNewState() == RegistrationState.UNREGISTERED
- || evt.getNewState()
- == RegistrationState.AUTHENTICATION_FAILED
- || evt.getNewState()
- == RegistrationState.CONNECTION_FAILED)
- {
- isInitialized = false;
- }
- }
- }
- );
- }
-
- /**
- * Returns the root group of the contact list.
- *
- * @return the root ContactGroup for the ContactList
- */
- public ContactGroup getRootGroup()
- {
- return rootGroup;
- }
-
- /**
- * Registers the specified group listener so that it would receive events
- * on group modification/creation/destruction.
- * @param listener the ServerStoredGroupListener to register for group
- * events
- */
- void addGroupListener(ServerStoredGroupListener listener)
- {
- synchronized(serverStoredGroupListeners)
- {
- if(!serverStoredGroupListeners.contains(listener))
- this.serverStoredGroupListeners.add(listener);
- }
- }
-
- /**
- * Removes the specified group listener so that it won't receive further
- * events on group modification/creation/destruction.
- * @param listener the ServerStoredGroupListener to unregister
- */
- void removeGroupListener(ServerStoredGroupListener listener)
- {
- synchronized(serverStoredGroupListeners)
- {
- this.serverStoredGroupListeners.remove(listener);
- }
- }
-
- /**
- * Creates the corresponding event and notifies all
- * <tt>ServerStoredGroupListener</tt>s that the source group has been
- * removed, changed, renamed or whatever happened to it.
- * @param group the ContactGroup that has been created/modified/removed
- * @param eventID the id of the event to generate.
- */
- private void fireGroupEvent(ContactGroupMsnImpl group, int eventID)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- ServerStoredGroupEvent evt = new ServerStoredGroupEvent(
- group
- , eventID
- , parentOperationSet.getServerStoredContactListRoot()
- , msnProvider
- , parentOperationSet);
-
- if (logger.isTraceEnabled())
- logger.trace("Will dispatch the following grp event: " + evt);
-
- Iterator<ServerStoredGroupListener> listeners = null;
- synchronized (serverStoredGroupListeners)
- {
- listeners = new ArrayList<ServerStoredGroupListener>(
- serverStoredGroupListeners).iterator();
- }
-
- while (listeners.hasNext())
- {
- ServerStoredGroupListener listener = listeners.next();
-
- if (eventID == ServerStoredGroupEvent.GROUP_REMOVED_EVENT)
- listener.groupRemoved(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_RENAMED_EVENT)
- listener.groupNameChanged(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_CREATED_EVENT)
- listener.groupCreated(evt);
- else if (eventID == ServerStoredGroupEvent.GROUP_RESOLVED_EVENT)
- listener.groupResolved(evt);
- }
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * removed event.
- * @param parentGroup the group where that the removed contact belonged to.
- * @param contact the contact that was removed.
- */
- private void fireContactRemoved( ContactGroup parentGroup,
- ContactMsnImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_REMOVED);
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a subscription
- * moved event.
- * @param oldParentGroup the group where the source contact was located
- * before being moved
- * @param newParentGroup the group that the source contact is currently in.
- * @param contact the contact that was added
- */
- private void fireContactMoved( ContactGroup oldParentGroup,
- ContactGroup newParentGroup,
- ContactMsnImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionMovedEvent(
- contact, oldParentGroup, newParentGroup);
- }
-
- /**
- * Returns a reference to the provider that created us.
- * @return a reference to a ProtocolProviderServiceImpl instance.
- */
- ProtocolProviderServiceMsnImpl getParentProvider()
- {
- return msnProvider;
- }
-
- /**
- * Returns the ConntactGroup with the specified name or null if no such
- * group was found.
- * <p>
- * @param name the name of the group we're looking for.
- * @return a reference to the ContactGroupMsnImpl instance we're looking for
- * or null if no such group was found.
- */
- public ContactGroupMsnImpl findContactGroup(String name)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
-
- while(contactGroups.hasNext())
- {
- ContactGroup contactGroup = contactGroups.next();
-
- if (contactGroup.getGroupName().equals(name))
- return (ContactGroupMsnImpl)contactGroup;
- }
-
- return null;
- }
-
- /**
- * Returns the Contact with the specified id or null if
- * no such id was found.
- *
- * @param id the id of the contact to find.
- * @return the <tt>Contact</tt> carrying the specified
- * <tt>screenName</tt> or <tt>null</tt> if no such contact exits.
- */
- public ContactMsnImpl findContactById(String id)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
- ContactMsnImpl result = null;
-
- while(contactGroups.hasNext())
- {
- ContactGroupMsnImpl contactGroup
- = (ContactGroupMsnImpl)contactGroups.next();
-
- result = contactGroup.findContact(id);
-
- if (result != null)
- return result;
-
- }
-
- Iterator<Contact> rootContacts = rootGroup.contacts();
- while (rootContacts.hasNext())
- {
- Contact item = rootContacts.next();
-
- if(item.getAddress().equals(id))
- return (ContactMsnImpl)item;
- }
-
- return null;
- }
-
- /**
- * Returns the ContactGroup containing the specified contact or null
- * if no such group or contact exist.
- *
- * @param child the contact whose parent group we're looking for.
- * @return the <tt>ContactGroup</tt> containing the specified
- * <tt>contact</tt> or <tt>null</tt> if no such group or contact
- * exist.
- */
- public ContactGroup findContactGroup(ContactMsnImpl child)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
-
- while(contactGroups.hasNext())
- {
- ContactGroupMsnImpl contactGroup
- = (ContactGroupMsnImpl)contactGroups.next();
-
- if( contactGroup.findContact(child.getAddress())!= null)
- return contactGroup;
- }
-
- Iterator<Contact> contacts = rootGroup.contacts();
-
- while(contacts.hasNext())
- {
- Contact contact = contacts.next();
-
- if( contact.equals(child))
- return rootGroup;
- }
-
- return null;
- }
-
- /**
- * Adds a new contact with the specified screenname to the list under a
- * default location.
- * @param id the id of the contact to add.
- * @throws OperationFailedException
- */
- public void addContact(String id)
- throws OperationFailedException
- {
- addContact(null, id);
- }
-
- /**
- * Adds a new contact with the specified screenname to the list under the
- * specified group.
- * @param id the id of the contact to add.
- * @param parent the group under which we want the new contact placed.
- * @throws OperationFailedException if the contact already exist
- */
- public void addContact(final ContactGroupMsnImpl parent, final String id)
- throws OperationFailedException
- {
- if (logger.isTraceEnabled())
- logger.trace("Adding contact " + id + " to parent=" + parent);
-
- //if the contact is already in the contact list and is not volatile,
- //then only broadcast an event
- ContactMsnImpl existingContact = findContactById(id);
-
- if( existingContact != null
- && existingContact.isPersistent() )
- {
- if (logger.isDebugEnabled())
- logger.debug("Contact " + id + " already exists.");
- throw new OperationFailedException(
- "Contact " + id + " already exists.",
- OperationFailedException.SUBSCRIPTION_ALREADY_EXISTS);
- }
-
- if(parent != null)
- {
- // add the buddy to the list as its not there
- msnProvider.getMessenger().unblockFriend(Email.parseStr(id));
- skipAddEvent.add(id);
- msnProvider.getMessenger().addFriend(Email.parseStr(id), id);
- msnProvider.getMessenger().copyFriend(
- Email.parseStr(id),
- parent.getSourceGroup().getGroupId());
- }
- else
- {
- // add the buddy to the list as its not there
-// msnProvider.getMessenger().unblockFriend(Email.parseStr(id));
- msnProvider.getMessenger().addFriend(Email.parseStr(id), id);
- }
- }
-
- /**
- * 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 contact the address of the contact to create.
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- ContactMsnImpl createVolatileContact(MsnContact contact)
- {
- return
- createVolatileContact(
- contact.getId(),
- contact.getEmail(),
- contact.getDisplayName());
- }
-
- /**
- * Creates a non persistent contact for the specified address. This would
- * also create (if necessary) a group for volatile contacts that would not
- * be added to the server stored contact list. This method would have no
- * effect on the server stored contact list.
- *
- * @param id the id of the contact to create
- * @param email the e-mail address of the contact to create
- * @param displayName the display name of the contact to create
- * @return the newly created volatile <tt>ContactImpl</tt>
- */
- ContactMsnImpl createVolatileContact(
- String id,
- Email email,
- String displayName)
- {
- //First create the new volatile contact;
- VolatileContact volatileBuddy
- = new VolatileContact(id, email, displayName);
- ContactMsnImpl newVolatileContact
- = new ContactMsnImpl(volatileBuddy, this, false, false);
-
- //Check whether a volatile group already exists and if not create one.
- ContactGroupMsnImpl theVolatileGroup = getNonPersistentGroup();
-
- //if the parent group is null then add necessary create the group
- if (theVolatileGroup == null)
- {
- MsnContact[] emptyBuddies = new MsnContact[]{};
-
- theVolatileGroup = new ContactGroupMsnImpl(
- new VolatileGroup(), emptyBuddies, this, false, false);
- theVolatileGroup.addContact(newVolatileContact);
-
- this.rootGroup.addSubGroup(theVolatileGroup);
-
- fireGroupEvent(theVolatileGroup,
- ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
- else
- {
- theVolatileGroup.addContact(newVolatileContact);
- fireContactAdded(theVolatileGroup, newVolatileContact);
- }
-
- return newVolatileContact;
- }
-
-
- /**
- * Creates a non resolved contact for the specified address and inside the
- * specified group. The newly created contact would be added to the local
- * contact list as a standard contact but when an event is received from the
- * server concerning this contact, then it will be reused and only its
- * isResolved field would be updated instead of creating the whole contact
- * again.
- *
- * @param parentGroup the group where the unresolved contact is to be
- * created
- * @param id the Address of the contact to create.
- * @return the newly created unresolved <tt>ContactImpl</tt>
- */
- ContactMsnImpl createUnresolvedContact(ContactGroup parentGroup, String id)
- {
- //First create the new volatile contact;
- VolatileContact volatileBuddy = new VolatileContact(id);
-
- ContactMsnImpl newUnresolvedContact
- = new ContactMsnImpl(volatileBuddy, this, false, false);
-
- if(parentGroup instanceof ContactGroupMsnImpl)
- ((ContactGroupMsnImpl)parentGroup).
- addContact(newUnresolvedContact);
- else if(parentGroup instanceof RootContactGroupMsnImpl)
- ((RootContactGroupMsnImpl)parentGroup).
- addContact(newUnresolvedContact);
-
- fireContactAdded( parentGroup
- , newUnresolvedContact);
-
- return newUnresolvedContact;
- }
-
- /**
- * Creates a non resolved contact group for the specified name. The newly
- * created group would be added to the local contact list as any other group
- * but when an event is received from the server concerning this group, then
- * it will be reused and only its isResolved field would be updated instead
- * of creating the whole group again.
- * <p>
- * @param groupName the name of the group to create.
- * @return the newly created unresolved <tt>ContactGroupImpl</tt>
- */
- ContactGroupMsnImpl createUnresolvedContactGroup(String groupName)
- {
- //First create the new volatile contact;
- MsnContact[] emptyBuddies = new MsnContact[]{};
- ContactGroupMsnImpl newUnresolvedGroup = new ContactGroupMsnImpl(
- new VolatileGroup(groupName), emptyBuddies, this, false, true);
-
- this.rootGroup.addSubGroup(newUnresolvedGroup);
-
- fireGroupEvent(newUnresolvedGroup
- , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
-
- return newUnresolvedGroup;
- }
-
- /**
- * Creates the specified group on the server stored contact list.
- * @param groupName a String containing the name of the new group.
- * @throws OperationFailedException with code CONTACT_GROUP_ALREADY_EXISTS
- * if the group we're trying to create is already in our contact list.
- */
- public void createGroup(String groupName)
- throws OperationFailedException
- {
- if (logger.isTraceEnabled())
- logger.trace("Creating group: " + groupName);
-
- ContactGroupMsnImpl existingGroup = findContactGroup(groupName);
-
- if( existingGroup != null && existingGroup.isPersistent() )
- {
- if (logger.isDebugEnabled())
- logger.debug("ContactGroup " + groupName + " already exists.");
- throw new OperationFailedException(
- "ContactGroup " + groupName + " already exists.",
- OperationFailedException.CONTACT_GROUP_ALREADY_EXISTS);
- }
-
- msnProvider.getMessenger().addGroup(groupName);
- }
-
- /**
- * Removes the specified group from the buddy list.
- * @param groupToRemove the group that we'd like removed.
- */
- public void removeGroup(ContactGroupMsnImpl groupToRemove)
- {
- // there is a default group in the msn lib. we cannot remove it
- // as server doesn't know about it
- if(groupToRemove.getSourceGroup().getGroupId().equals("0"))
- return;
-
- if (logger.isTraceEnabled())
- logger.trace("removing group " + groupToRemove);
- MsnContact[] contacts = groupToRemove.getSourceGroup().getContacts();
-
- ModListenerRemoveGroup removedContactsListener =
- new ModListenerRemoveGroup(contacts.length);
- contactListModManager.addModificationListener(removedContactsListener);
-
- for (int i = 0; i < contacts.length; i++)
- {
- if (logger.isTraceEnabled())
- logger.trace("removing contact from group " + contacts[i]);
-
- msnProvider.getMessenger().removeFriend(contacts[i].getEmail(),
- groupToRemove.getSourceGroup().getGroupId());
- }
-
- // wait max seconds or the last removed contact
- removedContactsListener.waitForLastEvent(contacts.length*1000);
- contactListModManager.removeModificationListener(removedContactsListener);
-
- msnProvider.getMessenger().
- removeGroup(groupToRemove.getSourceGroup().getGroupId());
- }
-
- /**
- * Removes a contact from the serverside list
- * Event will come for successful operation
- * @param contactToRemove ContactMsnImpl
- */
- void removeContact(ContactMsnImpl contactToRemove)
- {
- if (logger.isTraceEnabled())
- logger.trace("Removing msn contact "
- + contactToRemove.getSourceContact());
-
- Email contactsEmail = contactToRemove.getSourceContact().getEmail();
-
- MsnGroup[] belongGroups =
- contactToRemove.getSourceContact().getBelongGroups();
- if(belongGroups != null)
- for (int i = 0; i < belongGroups.length; i++)
- {
- msnProvider.getMessenger().
- removeFriend(contactsEmail, belongGroups[i].getGroupId());
- }
-
- msnProvider.getMessenger().
- removeFriend(contactsEmail, false);
- }
-
-
- /**
- * Renames the specified group according to the specified new name..
- * @param groupToRename the group that we'd like removed.
- * @param newName the new name of the group
- */
- public void renameGroup(ContactGroupMsnImpl groupToRename, String newName)
- {
- //printList();
- msnProvider.getMessenger().
- renameGroup(groupToRename.getSourceGroup().getGroupId(), newName);
- }
-
- /**
- * Moves the specified <tt>contact</tt> to the group indicated by
- * <tt>newParent</tt>.
- * @param contact the contact that we'd like moved under the new group.
- * @param newParent the group where we'd like the parent placed.
- */
- public void moveContact(ContactMsnImpl contact,
- ContactGroup newParent)
- {
- ContactGroup oldParent = contact.getParentContactGroup();
-
- if(oldParent instanceof RootContactGroupMsnImpl)
- {
- if (logger.isTraceEnabled())
- logger.trace("Will Move from root " + contact);
- msnProvider.getMessenger().
- copyFriend(
- contact.getSourceContact().getEmail(),
- ((ContactGroupMsnImpl)newParent).getSourceGroup()
- .getGroupId());
- }
- else
- {
- if(newParent instanceof RootContactGroupMsnImpl &&
- !contact.isPersistent())
- {
- try
- {
- addContact(contact.getAddress());
- }
- catch (OperationFailedException ex)
- {
- logger.error("Failed to add contact from " +
- MsnActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME") +
- " group to new group: " + newParent, ex);
- }
-
- return;
- }
-
- if( !contact.isPersistent() &&
- !contact.getParentContactGroup().isPersistent())
- {
- try
- {
- addContact(
- (ContactGroupMsnImpl)newParent, contact.getAddress());
- }
- catch (OperationFailedException ex)
- {
- logger.error("Failed to add contact from " +
- MsnActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME") +
- " group to new group: " + newParent, ex);
- }
- }
- else
- {
- if (logger.isTraceEnabled())
- logger.trace("Will Move from "
- + contact.getParentContactGroup()
- + " to : " + newParent + " - contact: " + contact);
-// contactListModListenerImpl.waitForMove(contact.getAddress());
- msnProvider.getMessenger().moveFriend(
- contact.getSourceContact().getEmail(),
- ( (ContactGroupMsnImpl) contact.getParentContactGroup()).
- getSourceGroup().getGroupId(),
- ((ContactGroupMsnImpl)newParent).getSourceGroup()
- .getGroupId());
- }
- }
- }
-
- /**
- * Returns the volatile group
- *
- * @return ContactGroupMsnImpl
- */
- private ContactGroupMsnImpl getNonPersistentGroup()
- {
- for (int i = 0; i < getRootGroup().countSubgroups(); i++)
- {
- ContactGroupMsnImpl gr =
- (ContactGroupMsnImpl)getRootGroup().getGroup(i);
-
- if(!gr.isPersistent())
- return gr;
- }
-
- return null;
- }
-
- /**
- * Finds Group by provided its msn ID
- * @param id String
- * @return ContactGroupMsnImpl
- */
- private ContactGroupMsnImpl findContactGroupByMsnId(String id)
- {
- Iterator<ContactGroup> contactGroups = rootGroup.subgroups();
-
- while(contactGroups.hasNext())
- {
- ContactGroupMsnImpl contactGroup
- = (ContactGroupMsnImpl)contactGroups.next();
-
- if (contactGroup.getSourceGroup().getGroupId().equals(id))
- return contactGroup;
- }
-
- return null;
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * added event.
- * @param parentGroup the group where the new contact was added
- * @param contact the contact that was added
- */
- void fireContactAdded( ContactGroup parentGroup,
- ContactMsnImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_CREATED);
-
- // sometimes when adding msn contact
- // status updates comes before event for adding contact and so
- // statuses are not dispatched, we check this here
- MsnUserStatus msnStatus =
- contact.getSourceContact().getStatus();
-
- // for some reason when creating unresolved contact this status is null
- if(msnStatus == null)
- return;
-
- PresenceStatus oldStatus
- = contact.getPresenceStatus();
-
- PresenceStatus newStatus
- = parentOperationSet.msnStatusToPresenceStatus(
- contact.getSourceContact().getStatus());
-
- if(oldStatus.equals(newStatus))
- return;
-
- contact.updatePresenceStatus(newStatus);
-
- parentOperationSet.fireContactPresenceStatusChangeEvent(
- contact,
- parentGroup,
- oldStatus,
- newStatus
- );
- }
-
- /**
- * Make the parent persistent presence operation set dispatch a contact
- * resolved event.
- * @param parentGroup the group that the resolved contact belongs to.
- * @param contact the contact that was resolved
- */
- void fireContactResolved( ContactGroup parentGroup,
- ContactMsnImpl contact)
- {
- //bail out if no one's listening
- if(parentOperationSet == null){
- if (logger.isDebugEnabled())
- logger.debug("No presence op. set available. Bailing out.");
- return;
- }
-
- //dispatch
- parentOperationSet.fireSubscriptionEvent(
- contact, parentGroup, SubscriptionEvent.SUBSCRIPTION_RESOLVED);
- }
-
- /**
- * Returns true if the contact list is initialized and
- * ready for use, and false otherwise.
- *
- * @return true if the contact list is initialized and ready for use and
- * false otherwise
- */
- boolean isInitialized()
- {
- return isInitialized;
- }
-
- /**
- * Changes the contact display name on the server.
- * @param contact the contact to change,
- * @param newName the new name.
- */
- void setDisplayName(ContactMsnImpl contact, String newName)
- {
- messenger.renameFriend(contact.getSourceContact().getEmail(), newName);
- }
-
- /**
- * Waits for init in the contact list and populates the contacts and fills
- * or resolves our contact list
- */
- private class ContactListListener
- implements net.sf.jml.event.MsnContactListListener
- {
- public void contactPersonalMessageChanged(MsnMessenger messenger ,
- MsnContact contact)
- {
- ContactMsnImpl contactImpl =
- findContactById(contact.getEmail().getEmailAddress());
-
- if (contactImpl == null)
- return;
-
- contactImpl.setStatusMessage(contact.getPersonalMessage());
- }
-
- public void contactListSyncCompleted(MsnMessenger messenger)
- {
- }
-
- public void contactListInitCompleted(MsnMessenger messenger)
- {
- if (logger.isTraceEnabled())
- logger.trace("contactListInitCompleted");
- isInitialized = true;
-
- if(logger.isDebugEnabled())
- printList();
-
- // first init groups
- MsnContactList contactList = messenger.getContactList();
- MsnGroup[] groups = contactList.getGroups();
- for (int i = 0; i < groups.length; i++)
- {
- MsnGroup item = groups[i];
-
- if(item.isDefaultGroup())
- continue;
-
- ContactGroupMsnImpl group
- = findContactGroup(item.getGroupName());
-
- if (group == null)
- {
- // create the group as it doesn't exist
- ContactGroupMsnImpl newGroup =
- new ContactGroupMsnImpl(
- item,
- item.getContacts(),
- ServerStoredContactListMsnImpl.this,
- true,
- true);
-
- rootGroup.addSubGroup(newGroup);
-
- //tell listeners about the added group
- fireGroupEvent(newGroup,
- ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
- else
- {
- // the group exist so just resolved. The group will check and
- // create or resolve its entries
- group.setResolved(item);
-
- //fire an event saying that the group has been resolved
- fireGroupEvent(group,
- ServerStoredGroupEvent.GROUP_RESOLVED_EVENT);
-
- /** @todo if something to delete . delete it */
- }
- }
-
- // so all groups and its contacts are created
- // lets create the users that are not in a group
- MsnContact[] contacts =
- messenger.getContactList().getContactsInList(MsnList.FL);
- for (int i = 0; i < contacts.length; i++)
- {
- MsnContact item = contacts[i];
-
- if(item.getBelongGroups().length == 0)
- {
- ContactMsnImpl contact =
- findContactById(item.getEmail().getEmailAddress());
-
- if (contact == null)
- {
- // if there is no such contact create it
- contact = new ContactMsnImpl(
- item,
- ServerStoredContactListMsnImpl.this,
- true,
- true);
- rootGroup.addContact(contact);
-
- fireContactAdded(rootGroup, contact);
- }
- else
- {
- // if contact exist so resolve it
- contact.setResolved(item);
- }
- }
- }
-
- // if we have received status before we have inited the list
- // sho them correctly
- parentOperationSet.earlyStatusesDispatch();
-
- // retreive offline messages
- messenger.retreiveOfflineMessages();
- }
-
- public void contactStatusChanged(MsnMessenger messenger,
- MsnContact contact)
- {
- }
-
- public void ownerStatusChanged(MsnMessenger messenger)
- {
- }
-
- public void contactAddedMe(MsnMessenger messenger,
- MsnContactPending[] pendingContacts)
- {
- if (logger.isTraceEnabled())
- logger.trace("Contact add us ");
- /**
- * TODO this method introduced for msn15 currently used.
- * the old one below no more used.
- */
- }
-
- public void contactAddedMe(MsnMessenger messenger, MsnContact contact)
- {
-// try
-// {
- if (logger.isTraceEnabled())
- logger.trace("Contact add us " + contact);
-
- if(parentOperationSet.getAuthorizationHandler() == null)
- return;
-
- ContactMsnImpl contactImpl =
- findContactById(contact.getEmail().getEmailAddress());
-
- if (contactImpl != null)
- return;
-
- contactImpl = createVolatileContact(contact);
-
- AuthorizationRequest authRequest = new AuthorizationRequest();
-
- AuthorizationResponse authResponse =
- parentOperationSet.getAuthorizationHandler()
- .processAuthorisationRequest( authRequest, contactImpl);
-
- if (authResponse.getResponseCode()
- == AuthorizationResponse.IGNORE)
- {
- return;
- }
- else if (authResponse.getResponseCode()
- == AuthorizationResponse.REJECT)
- {
- msnProvider.getMessenger().blockFriend(contact.getEmail());
- }
- else if (authResponse.getResponseCode()
- == AuthorizationResponse.ACCEPT)
- {
- moveContact(contactImpl, rootGroup);
-// addContact(contact.getEmail().getEmailAddress());
-// msnProvider.getMessenger()
-// .unblockFriend(contact.getEmail());
- }
-// }
-// catch (OperationFailedException ex)
-// {
-// logger.error("cannot add ", ex);
-// }
- }
-
- public void contactRemovedMe(MsnMessenger messenger, MsnContact contact)
- {
- }
-
- public void contactAddCompleted(MsnMessenger messenger,
- MsnContact contact,
- MsnList list)
- {
- String contactID = contact.getEmail().getEmailAddress();
-
- if(!skipAddEvent.remove(contactID))
- {
- ContactMsnImpl contactToAdd =
- findContactById(contact.getEmail().getEmailAddress());
-
- if(contactToAdd == null)
- {
- contactToAdd =
- new ContactMsnImpl(
- contact,
- ServerStoredContactListMsnImpl.this, true, true);
- rootGroup.addContact(contactToAdd);
- fireContactAdded(rootGroup, contactToAdd);
- }
- else
- {
- ContactGroup oldGroup = contactToAdd.getParentContactGroup();
-
- fireContactMoved(oldGroup, rootGroup, contactToAdd);
- }
- }
- }
-
- public void contactRemoveCompleted(MsnMessenger messenger,
- MsnContact contact,
- MsnList list)
- {
- ContactMsnImpl contactToRemove =
- findContactById(contact.getEmail().getEmailAddress());
-
- if(contactToRemove == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Contact not found!" + contact);
- return;
- }
-
- if(contactToRemove.getParentContactGroup()
- instanceof RootContactGroupMsnImpl)
- {
- rootGroup.removeContact(contactToRemove);
- fireContactRemoved(rootGroup, contactToRemove);
- }
- else
- {
- ContactGroupMsnImpl parentGroup = (ContactGroupMsnImpl)
- contactToRemove.getParentContactGroup();
- parentGroup.removeContact(contactToRemove);
- fireContactRemoved(parentGroup, contactToRemove);
- }
- }
-
- public void groupAddCompleted(MsnMessenger messenger, MsnGroup group)
- {
- if (logger.isTraceEnabled())
- logger.trace("groupAdded " + group);
- ContactGroupMsnImpl newGroup =
- new ContactGroupMsnImpl(group,
- new MsnContact[]{},
- ServerStoredContactListMsnImpl.this,
- true,
- true);
-
- rootGroup.addSubGroup(newGroup);
- fireGroupEvent(newGroup, ServerStoredGroupEvent.GROUP_CREATED_EVENT);
- }
- public void groupRemoveCompleted(MsnMessenger messenger, MsnGroup g)
- {
- ContactGroupMsnImpl group = findContactGroupByMsnId(g.getGroupId());
-
- if(group == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Group not found!" + g);
- return;
- }
-
- rootGroup.removeSubGroup(group);
- fireGroupEvent(group, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
- }
-
- /**
- * Called when a contact has been added to a group. Note that this
- * method would also be called after moving a contact.
- *
- * @param messenger a reference to the currently valid messenger
- * @param c the contact that has been added
- * @param g the group that the contact was added to
- */
- public void contactAddInGroupCompleted( MsnMessenger messenger,
- MsnContact c,
- MsnGroup g)
- {
- ContactMsnImpl contactToAdd =
- findContactById(c.getEmail().getEmailAddress());
-
- if(contactToAdd == null)
- {
- //this is really a new contact
- contactToAdd =
- new ContactMsnImpl(
- c,
- ServerStoredContactListMsnImpl.this, true, true);
-
- ContactGroupMsnImpl group =
- findContactGroupByMsnId(g.getGroupId());
-
- if(group == null)
- {
- logger.error("Group is missing!");
- return;
- }
-
- group.addContact(contactToAdd);
-
- fireContactAdded(group, contactToAdd);
- }
- else
- {
- //the contact was added here.
- ContactGroup oldGroup =
- contactToAdd.getParentContactGroup();
-
- ContactGroupMsnImpl group =
- findContactGroupByMsnId(g.getGroupId());
-
- if(group == null)
- {
- logger.error("Group is missing!");
- return;
- }
-
- group.addContact(contactToAdd);
-
-
- if(oldGroup instanceof RootContactGroupMsnImpl)
- {
- ((RootContactGroupMsnImpl)oldGroup)
- .removeContact(contactToAdd);
- }
- else
- {
- ((ContactGroupMsnImpl)oldGroup).removeContact(contactToAdd);
- }
-
- fireContactMoved(oldGroup, group, contactToAdd);
- }
- }
-
- public void contactRemoveFromGroupCompleted(MsnMessenger messenger,
- MsnContact c, MsnGroup g)
- {
- String contactID = c.getEmail().getEmailAddress();
- ContactMsnImpl contactToRemove = findContactById(contactID);
-
- if(g == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Group is null! ");
- return;
- }
-
- ContactGroupMsnImpl dstGroup =
- findContactGroupByMsnId(g.getGroupId());
-
- if(contactToRemove == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Contact not found " + c);
- return;
- }
-
- if(dstGroup == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Group not found " + g);
- return;
- }
-
- //make sure that the contact was really in the group because when
- //moving contacts with multiple parent groups we get multiple
- //removal events. That's a problem because we don't support multiple
- //parent groups and we only show a single parent so all remove
- //events for the parent groups we are not displaying will cause
- //exceptions
- if(dstGroup.removeContact(contactToRemove))
- fireContactRemoved(dstGroup, contactToRemove);
- }
-
- public void ownerDisplayNameChanged(MsnMessenger arg0)
- {
- }
- }
-
- /**
- * Waits for removing a group
- */
- private static class ModListenerRemoveGroup
- extends EventAdapter
- {
- private int contactCount = 0;
-
- public ModListenerRemoveGroup(int c)
- {
- this.contactCount = c;
- }
-
- public void contactRemoved(MsnContact contact)
- {
- synchronized(this)
- {
- contactCount--;
-
- if(contactCount == 0)
- notifyAll();
- }
- }
-
- public void waitForLastEvent(long waitFor)
- {
- synchronized(this)
- {
- if(contactCount == 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- if (logger.isDebugEnabled())
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
- }
-
- /**
- * Emulates firing adding contact in group and moving contact to group.
- * When moving contact it is first adding to the new group then
- * it is removed from the old one.
- */
- private class ContactListModListenerImpl
- extends EventAdapter
- {
- @Override
- public void groupRenamed(MsnGroup group)
- {
- ContactGroupMsnImpl groupToRename =
- findContactGroupByMsnId(group.getGroupId());
-
- if(groupToRename == null)
- {
- if (logger.isTraceEnabled())
- logger.trace("Group not found!" + group);
- return;
- }
-
- groupToRename.setSourceGroup(group);
-
- fireGroupEvent(groupToRename,
- ServerStoredGroupEvent.GROUP_RENAMED_EVENT);
- }
-
- @Override
- public void loggingFromOtherLocation()
- {
- msnProvider.unregisterInternal(false);
- msnProvider.fireRegistrationStateChanged(
- msnProvider.getRegistrationState(),
- RegistrationState.UNREGISTERED,
- RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS, null);
- }
- }
-
- /**
- * Sets the messenger instance impl of the lib
- * which communicates with the server
- * @param messenger MsnMessenger
- */
- void setMessenger(MsnMessenger messenger)
- {
- if (this.messenger == messenger)
- return;
-
- if (this.messenger != null)
- {
- if (contactListModManager != null)
- {
- contactListModManager.removeModificationListener(
- contactListModListenerImpl);
- contactListModManager = null;
- }
- if (contactListListener != null)
- {
- this.messenger.removeContactListListener(contactListListener);
- contactListListener = null;
- }
- }
-
- this.messenger = messenger;
-
- if (this.messenger != null)
- {
- contactListModManager
- = new EventManager(
- msnProvider,
- (BasicMessenger) this.messenger);
- contactListModManager.addModificationListener(
- contactListModListenerImpl);
-
- contactListListener = new ContactListListener();
- this.messenger.addContactListListener(contactListListener);
- }
- }
-
- /**
- * when there is no image for contact we must retrieve it
- * add contacts for image update
- *
- * @param c ContactMsnImpl
- */
- protected void addContactForImageUpdate(ContactMsnImpl c)
- {
- if (messenger != null)
- {
- // Get the MsnObject
- MsnObject avatar = c.getSourceContact().getAvatar();
-
- if (avatar != null)
- {
- messenger.retrieveDisplayPicture(
- avatar,
- new ImageUpdater(c));
- }
- }
- }
-
- /**
- * used for debugging. Printing the serverside lists that msn supports
- */
- public void printList()
- {
- MsnMessenger messenger = msnProvider.getMessenger();
-
- if (logger.isInfoEnabled())
- logger.info("---=Start Printing contact list=---");
-
- MsnContactList list = messenger.getContactList();
-
- if (logger.isInfoEnabled())
- logger.info("Forward list");
- MsnContact[] c = list.getContactsInList(MsnList.FL);
- for(int i = 0; i < c.length; i++)
- {
- if (logger.isInfoEnabled())
- logger.info("c : " + c[i]);
- MsnGroup[] groups = c[i].getBelongGroups();
- for(int j = 0; j < groups.length; j++)
- {
- if (logger.isInfoEnabled())
- logger.info("in group " + groups[j]);
- }
- }
-
- if (logger.isInfoEnabled())
- logger.info("Allow list");
- c = list.getContactsInList(MsnList.AL);
- for(int i = 0; i < c.length; i++)
- {
- if (logger.isInfoEnabled())
- logger.info("c : " + c[i] + " g:" + c[i].getBelongGroups().length);
- }
-
- if (logger.isInfoEnabled())
- logger.info("Block list");
- c = list.getContactsInList(MsnList.BL);
- for(int i = 0; i < c.length; i++)
- {
- if (logger.isInfoEnabled())
- logger.info("c : " + c[i] + " g:" + c[i].getBelongGroups().length);
- }
-
- if (logger.isInfoEnabled())
- logger.info("pending list");
- c = list.getContactsInList(MsnList.PL);
- for(int i = 0; i < c.length; i++)
- {
- if (logger.isInfoEnabled())
- logger.info("c : " + c[i] + " g:" + c[i].getBelongGroups().length);
- }
-
- if (logger.isInfoEnabled())
- logger.info("Reverse list");
- c = list.getContactsInList(MsnList.RL);
- for(int i = 0; i < c.length; i++)
- {
- if (logger.isInfoEnabled())
- logger.info("c : " + c[i] + " g:" +
- c[i].getBelongGroups().length);
- }
-
- if (logger.isInfoEnabled())
- logger.info("Number of groups : "
- + messenger.getContactList().getGroups().length);
- MsnGroup[] groups = messenger.getContactList().getGroups();
- for(int j = 0; j < groups.length; j++)
- {
- if (logger.isInfoEnabled())
- logger.info("group " + groups[j]);
- }
- if (logger.isInfoEnabled())
- logger.info("---=End Printing contact list=---");
- }
-
- private class ImageUpdater
- implements DisplayPictureListener
- {
- private ContactMsnImpl contact;
- ImageUpdater(ContactMsnImpl contact)
- {
- this.contact = contact;
- }
-
- public void notifyMsnObjectRetrieval(
- MsnMessenger arg0messenger,
- DisplayPictureRetrieveWorker worker,
- MsnObject msnObject,
- ResultStatus result,
- byte[] resultBytes,
- Object context)
- {
- if (result == ResultStatus.GOOD)
- {
- byte[] oldImage = contact.getImage(false);
-
- contact.setImage(resultBytes);
-
- parentOperationSet.fireContactPropertyChangeEvent(
- ContactPropertyChangeEvent.PROPERTY_IMAGE,
- contact, oldImage, resultBytes);
- }
- }
-
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/VolatileContact.java b/src/net/java/sip/communicator/impl/protocol/msn/VolatileContact.java
deleted file mode 100644
index 992a111..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/VolatileContact.java
+++ /dev/null
@@ -1,75 +0,0 @@
-
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.sf.jml.*;
-
-/**
- * The Msn implementation for Volatile Contact
- * @author Damian Minkov
- */
-public class VolatileContact
- implements MsnContact
-{
- private final String contactId;
- private final String displayName;
- private Email email;
-
- VolatileContact(String id, Email email, String displayName)
- {
- this.contactId = id;
- this.email = email;
- this.displayName = displayName;
- }
-
- VolatileContact(String id)
- {
- this(id, null, id);
- }
-
- public MsnContactList getContactList(){return null;}
-
- public String getId()
- {
- return contactId;
- }
-
- public String getFriendlyName()
- {
- return displayName;
- }
-
- public boolean isInList(MsnList msnList){return false;}
-
- public MsnGroup[] getBelongGroups(){return null;}
-
- public boolean belongGroup(MsnGroup msnGroup){return false;}
-
- public Email getEmail()
- {
- if (email == null)
- email = Email.parseStr(contactId);
- return email;
- }
-
- public String getDisplayName(){return displayName;}
-
- public MsnUserStatus getStatus(){return null;}
-
- public MsnClientId getClientId(){return null;}
-
- public MsnUserProperties getProperties(){return null;}
-
- public String getOldDisplayName(){return "";}
-
- public MsnUserStatus getOldStatus(){return null;}
-
- public String getPersonalMessage(){return "";}
-
- public MsnObject getAvatar(){return null;}
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/VolatileGroup.java b/src/net/java/sip/communicator/impl/protocol/msn/VolatileGroup.java
deleted file mode 100644
index e8fd8aa..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/VolatileGroup.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.impl.protocol.msn;
-
-import net.sf.jml.*;
-
-/**
- * The Msn implementation of the Volatile ContactGroup interface.
- *
- * @author Damian Minkov
- */
-public class VolatileGroup
- implements MsnGroup
-{
- private String groupName = MsnActivator.getResources().getI18NString(
- "service.gui.NOT_IN_CONTACT_LIST_GROUP_NAME");
-
- VolatileGroup(){}
-
- VolatileGroup(String groupName)
- {
- this.groupName = groupName;
- }
-
- public MsnContactList getContactList(){return null;}
-
- public String getGroupId()
- {
- return groupName;
- }
-
- public String getGroupName()
- {
- return getGroupId();
- }
-
- public MsnContact[] getContacts(){return null;}
-
- public boolean containContact(MsnContact contact){return false;}
-
- public boolean isDefaultGroup(){return false;}
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/Base64InputStream.java b/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/Base64InputStream.java
deleted file mode 100644
index 07aaf92..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/Base64InputStream.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Base64InputStream.java
- * Copyright(C) 2002 The Free Software Foundation
- *
- * This file is part of GNU JavaMail, a library.
- *
- * GNU JavaMail is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- *(at your option) any later version.
- *
- * GNU JavaMail is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, if you link this library with other files to
- * produce an executable, this library does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * This exception does not however invalidate any other reasons why the
- * executable file might be covered by the GNU General Public License.
- */
-
-package net.java.sip.communicator.impl.protocol.msn.mail.utils;
-
-import java.io.*;
-
-/**
- * A Base64 content transfer encoding filter stream.
- * <p>
- * From RFC 2045, section 6.8:
- * <p>
- * The Base64 Content-Transfer-Encoding is designed to represent
- * arbitrary sequences of octets in a form that need not be humanly
- * readable. The encoding and decoding algorithms are simple, but the
- * encoded data are consistently only about 33 percent larger than the
- * unencoded data.
- *
- * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
- */
-public class Base64InputStream
- extends FilterInputStream
-{
-
- private byte[] buffer;
- private int buflen;
- private int index;
- private byte[] decodeBuf;
-
- private static final char[] src =
- {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
- 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
- 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
- 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', '+', '/'
- };
- private static final byte[] dst;
-
- private static final int LF = 10, CR = 13, EQ = 61;
-
- static
- {
- dst = new byte[256];
- for (int i = 0; i<255; i++)
- dst[i] = -1;
- for (int i = 0; i<src.length; i++)
- dst[src[i]] = (byte)i;
-
- }
-
- /**
- * Constructs an input stream that decodes an underlying Base64-encoded
- * stream.
- * @param in the Base64-encoded stream
- */
- public Base64InputStream(InputStream in)
- {
- super(in);
- decodeBuf = new byte[4];
- buffer = new byte[3];
- }
-
- /**
- * Reads the next byte of data from the input stream.
- */
- @Override
-public int read()
- throws IOException
- {
- if (index>=buflen)
- {
- decode();
- if (buflen==0)
- return -1;
- index = 0;
- }
- return buffer[index++] & 0xff;
- }
-
- /**
- * Reads up to len bytes of data from the input stream into an array of
- * bytes.
- */
- @Override
-public int read(byte[] b, int off, int len)
- throws IOException
- {
- try
- {
- int l = 0;
- for (; l<len; l++)
- {
- int c;
- if ((c=read())==-1)
- {
- if (l==0)
- l = -1;
- break;
- }
- b[off+l] = (byte)c;
- }
- return l;
- }
- catch (IOException e)
- {
- return -1;
- }
- }
-
- /**
- * Returns the number of bytes that can be read(or skipped over) from this
- * input stream without blocking by the next caller of a method for this
- * input stream.
- */
- @Override
-public int available()
- throws IOException
- {
- return (in.available()*3)/4+(buflen-index);
- }
-
- private void decode()
- throws IOException
- {
- buflen = 0;
- int c;
- do
- {
- c = in.read();
- if (c==-1)
- return;
- }
- while (c==LF || c==CR);
- decodeBuf[0] = (byte)c;
- int j = 3, l;
- for (int k=1;(l=in.read(decodeBuf, k, j))!=j; k += l)
- {
- if (l==-1)
- throw new IOException("Base64 encoding error");
- j -= l;
- }
-
- byte b0 = dst[decodeBuf[0] & 0xff];
- byte b2 = dst[decodeBuf[1] & 0xff];
- buffer[buflen++] = (byte)(b0<<2 & 0xfc | b2>>>4 & 0x3);
- if (decodeBuf[2]!=EQ)
- {
- b0 = b2;
- b2 = dst[decodeBuf[2] & 0xff];
- buffer[buflen++] = (byte)(b0<<4 & 0xf0 | b2>>>2 & 0xf);
- if (decodeBuf[3]!=EQ)
- {
- b0 = b2;
- b2 = dst[decodeBuf[3] & 0xff];
- buffer[buflen++] = (byte)(b0<<6 & 0xc0 | b2 & 0x3f);
- }
- }
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/MimeUtility.java b/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/MimeUtility.java
deleted file mode 100644
index f22df92..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/MimeUtility.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * MimeUtility.java
- * Copyright (C) 2002, 2004, 2005 The Free Software Foundation
- *
- * This file is part of GNU JavaMail, a library.
- *
- * GNU JavaMail is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNU JavaMail is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, if you link this library with other files to
- * produce an executable, this library does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * This exception does not however invalidate any other reasons why the
- * executable file might be covered by the GNU General Public License.
- */
-
-package net.java.sip.communicator.impl.protocol.msn.mail.utils;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * This is a utility class providing micellaneous MIME-related functionality.
- *
- * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
- * @version 1.4
- */
-public class MimeUtility
-{
-
- /*
- * Uninstantiable.
- */
- private MimeUtility()
- {
- }
-
- /**
- * Decodes headers that are defined as '*text' in RFC 822.
- * @param etext the possibly encoded value
- * @return decoded text
- * @exception UnsupportedEncodingException if the charset conversion failed
- */
- public static String decodeText(String etext)
- throws UnsupportedEncodingException
- {
- String delimiters = "\t\n\r ";
- if (etext.indexOf("=?") == -1)
- {
- return etext;
- }
- StringTokenizer st = new StringTokenizer(etext, delimiters, true);
- StringBuffer buffer = new StringBuffer();
- StringBuffer extra = new StringBuffer();
- boolean decoded = false;
- while (st.hasMoreTokens())
- {
- String token = st.nextToken();
- char c = token.charAt(0);
- if (delimiters.indexOf(c) > -1)
- {
- extra.append(c);
- }
- else
- {
- try
- {
- token = decodeWord(token);
- if (!decoded && extra.length() > 0)
- {
- buffer.append(extra);
- }
- decoded = true;
- }
- catch (Exception e)
- {
- if (extra.length() > 0)
- {
- buffer.append(extra);
- }
- decoded = false;
- }
- buffer.append(token);
- extra.setLength(0);
- }
- }
- return buffer.toString();
- }
-
- /**
- * Decodes the specified string using the RFC 2047 rules for parsing an
- * "encoded-word".
- * @param text the possibly encoded value
- * @return decoded word
- * @exception Exception if the string is not an encoded-word
- * @exception UnsupportedEncodingException if the decoding failed
- */
- public static String decodeWord(String text)
- throws Exception, UnsupportedEncodingException
- {
- if (!text.startsWith("=?"))
- {
- throw new Exception();
- }
- int start = 2;
- int end = text.indexOf('?', start);
- if (end < 0)
- {
- throw new Exception();
- }
- String charset = text.substring(start, end);
- // Allow for RFC2231 language
- int si = charset.indexOf('*');
- if (si != -1)
- {
- charset = charset.substring(0, si);
- }
-
- start = end + 1;
- end = text.indexOf('?', start);
- if (end < 0)
- {
- throw new Exception();
- }
- String encoding = text.substring(start, end);
- start = end + 1;
- end = text.indexOf("?=", start);
- if (end < 0)
- {
- throw new Exception();
- }
- text = text.substring(start, end);
-
- InputStream is = null;
-
- try
- {
- // The characters in the remaining string must all be 7-bit clean.
- // Therefore it is safe just to copy them verbatim into a byte array.
- char[] chars = text.toCharArray();
- int len = chars.length;
- byte[] bytes = new byte[len];
- for (int i = 0; i < len; i++)
- {
- bytes[i] = (byte) chars[i];
- }
-
- ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
- if (encoding.equalsIgnoreCase("B"))
- {
- is = new Base64InputStream(bis);
- }
- else if (encoding.equalsIgnoreCase("Q"))
- {
- is = new QInputStream(bis);
- }
- else
- {
- throw new UnsupportedEncodingException(
- "Unknown encoding: " + encoding);
- }
- len = bis.available();
- bytes = new byte[len];
- len = is.read(bytes, 0, len);
- String ret = new String(bytes, 0, len, charset);
- if (text.length() > end + 2)
- ret = ret + /* extra */ text.substring(end + 2);
- return ret;
- }
- catch (IOException e)
- {
- throw new Exception();
- }
- catch (IllegalArgumentException e)
- {
- throw new UnsupportedEncodingException();
- }
- finally
- {
- /*
- * Without knowing whether it is practically necessary, it
- * technically silences a compile-time warning.
- */
- if (is != null)
- is.close();
- }
- }
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QInputStream.java b/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QInputStream.java
deleted file mode 100644
index ce9f550..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QInputStream.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * QInputStream.java
- * Copyright(C) 2002 The Free Software Foundation
- *
- * This file is part of GNU JavaMail, a library.
- *
- * GNU JavaMail is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- *(at your option) any later version.
- *
- * GNU JavaMail is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, if you link this library with other files to
- * produce an executable, this library does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * This exception does not however invalidate any other reasons why the
- * executable file might be covered by the GNU General Public License.
- */
-
-package net.java.sip.communicator.impl.protocol.msn.mail.utils;
-
-import java.io.*;
-
-/**
- * Provides RFC 2047 "B" transfer encoding.
- * See section 4.2:
- * <p>
- * The "Q" encoding is similar to the "Quoted-Printable" content-
- * transfer-encoding defined in RFC 2045. It is designed to allow text
- * containing mostly ASCII characters to be decipherable on an ASCII
- * terminal without decoding.
- * <ol>
- * <li>Any 8-bit value may be represented by a "=" followed by two
- * hexadecimal digits. For example, if the character set in use
- * were ISO-8859-1, the "=" character would thus be encoded as
- * "=3D", and a SPACE by "=20". (Upper case should be used for
- * hexadecimal digits "A" through "F".)
- * <li>The 8-bit hexadecimal value 20(e.g., ISO-8859-1 SPACE) may be
- * represented as "_"(underscore, ASCII 95.). (This character may
- * not pass through some internetwork mail gateways, but its use
- * will greatly enhance readability of "Q" encoded data with mail
- * readers that do not support this encoding.) Note that the "_"
- * always represents hexadecimal 20, even if the SPACE character
- * occupies a different code position in the character set in use.
- * <li>8-bit values which correspond to printable ASCII characters other
- * than "=", "?", and "_"(underscore), MAY be represented as those
- * characters. (But see section 5 for restrictions.) In
- * particular, SPACE and TAB MUST NOT be represented as themselves
- * within encoded words.
- *
- * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
- */
-public class QInputStream
- extends QPInputStream
-{
-
- private static final int SPACE = 32;
- private static final int EQ = 61;
- private static final int UNDERSCORE = 95;
-
- /**
- * Constructor.
- * @param in the underlying input stream.
- */
- public QInputStream(InputStream in)
- {
- super(in);
- }
-
- /**
- * Read a character.
- */
- @Override
-public int read()
- throws IOException
- {
- int c = in.read();
- if (c==UNDERSCORE)
- return SPACE;
- if (c==EQ)
- {
- buf[0] = (byte)in.read();
- buf[1] = (byte)in.read();
- try
- {
- return Integer.parseInt(new String(buf, 0, 2), 16);
- }
- catch (NumberFormatException e)
- {
- throw new IOException("Quoted-Printable encoding error: "+
- e.getMessage());
- }
- }
- return c;
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QPInputStream.java b/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QPInputStream.java
deleted file mode 100644
index caf887b..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/mail/utils/QPInputStream.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * QPInputStream.java
- * Copyright(C) 2002 The Free Software Foundation
- *
- * This file is part of GNU JavaMail, a library.
- *
- * GNU JavaMail is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- *(at your option) any later version.
- *
- * GNU JavaMail is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, if you link this library with other files to
- * produce an executable, this library does not by itself cause the
- * resulting executable to be covered by the GNU General Public License.
- * This exception does not however invalidate any other reasons why the
- * executable file might be covered by the GNU General Public License.
- */
-
-package net.java.sip.communicator.impl.protocol.msn.mail.utils;
-
-import java.io.*;
-
-/**
- * A Quoted-Printable decoder stream.
- *
- * @author <a href="mailto:dog@gnu.org">Chris Burdess</a>
- */
-public class QPInputStream
- extends FilterInputStream
-{
-
- protected byte[] buf;
-
- /**
- * The number of times read() will return a space.
- */
- protected int spaceCount;
-
- private static final int LF = 10;
- private static final int CR = 13;
- private static final int SPACE = 32;
- private static final int EQ = 61;
-
- /**
- * Constructor.
- * @param in the underlying input stream.
- */
- public QPInputStream(InputStream in)
- {
- super(new PushbackInputStream(in, 2));
- buf = new byte[2];
- }
-
- /**
- * Read a character from the stream.
- */
- @Override
-public int read()
- throws IOException
- {
- if (spaceCount>0)
- {
- spaceCount--;
- return SPACE;
- }
-
- int c = in.read();
- if (c==SPACE)
- {
- while ((c = in.read())==SPACE)
- spaceCount++;
- if (c==LF || c==CR || c==-1)
- spaceCount = 0;
- else
- {
- ((PushbackInputStream)in).unread(c);
- c = SPACE;
- }
- return c;
- }
- if (c==EQ)
- {
- int c2 = super.in.read();
- if (c2==LF)
- return read();
- if (c2==CR)
- {
- int peek = in.read();
- if (peek!=LF)
- ((PushbackInputStream)in).unread(peek);
- return read();
- }
- if (c2==-1)
- return c2;
-
- buf[0] = (byte)c2;
- buf[1] = (byte)in.read();
- try
- {
- return Integer.parseInt(new String(buf, 0, 2), 16);
- }
- catch (NumberFormatException e)
- {
- ((PushbackInputStream)in).unread(buf);
- }
- return c;
- }
- else
- return c;
- }
-
- /**
- * Reads from the underlying stream into the specified byte array.
- */
- @Override
-public int read(byte[] bytes, int off, int len)
- throws IOException
- {
- int pos = 0;
- try
- {
- while (pos<len)
- {
- int c = read();
- if (c==-1)
- {
- if (pos==0)
- pos = -1;
- break;
- }
- bytes[off+pos] = (byte)c;
- pos++;
- }
-
- }
- catch (IOException e)
- {
- pos = -1;
- }
- return pos;
- }
-
- /**
- * Mark is not supported.
- */
- @Override
-public boolean markSupported()
- {
- return false;
- }
-
- /**
- * Returns the number of bytes that can be read without blocking.
- */
- @Override
-public int available()
- throws IOException
- {
- return in.available();
- }
-
-}
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf
deleted file mode 100644
index d07b4f1..0000000
--- a/src/net/java/sip/communicator/impl/protocol/msn/msn.provider.manifest.mf
+++ /dev/null
@@ -1,40 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.impl.protocol.msn.MsnActivator
-Bundle-Name: Msn Protocol Provider Implementation
-Bundle-Description: An Msn implementation of the Protocol Provider Service.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.protocol.msn
-Import-Package: org.apache.commons.logging,
- org.apache.http,
- org.apache.http.entity,
- org.apache.http.impl,
- org.apache.http.impl.entity,
- org.apache.http.impl.io,
- org.apache.http.io,
- org.apache.http.message,
- org.apache.http.params,
- org.apache.http.protocol,
- org.apache.http.util,
- org.osgi.framework,
- org.osgi.service.url,
- org.w3c.dom,
- org.xml.sax,
- javax.crypto,
- javax.crypto.spec,
- javax.naming,
- javax.naming.directory,
- javax.net.ssl,
- javax.swing,
- javax.xml.parsers,
- javax.xml.datatype,
- sun.security.action,
- javax.imageio,
- org.jitsi.service.configuration,
- org.jitsi.service.fileaccess,
- org.jitsi.service.resources,
- net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.service.dns,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.msnconstants,
- net.java.sip.communicator.service.protocol.event
diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
index f1f8276..6028bac 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
@@ -1229,12 +1229,6 @@ public class MacOSXAddrBookContactQuery
case kABPhoneProperty:
supportedOpSets.add(OperationSetBasicTelephony.class);
break;
- case kABMSNInstantProperty:
- supportedOpSets.add(OperationSetBasicInstantMessaging.class);
- preferredProtocols.put(
- OperationSetBasicInstantMessaging.class,
- ProtocolNames.MSN);
- break;
case kABYahooInstantProperty:
supportedOpSets.add(OperationSetBasicInstantMessaging.class);
preferredProtocols.put(
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java
deleted file mode 100644
index 8d35c4b..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license. See terms of license at gnu.org.
- */
-package net.java.sip.communicator.plugin.msnaccregwizz;
-
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
- * and the password of the account.
- *
- * @author Yana Stamcheva
- * @author Damian Minkov
- */
-public class FirstWizardPage
- extends TransparentPanel
- implements WizardPage, DocumentListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
-
- public static final String USER_NAME_EXAMPLE = "Ex: johnsmith@hotmail.com";
-
- private JPanel uinPassPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel uinLabel
- = new JLabel(Resources.getString("plugin.msnaccregwizz.USERNAME"));
-
- private JLabel passLabel
- = new JLabel(Resources.getString("service.gui.PASSWORD"));
-
- private JPanel emptyPanel = new TransparentPanel();
-
- private JLabel uinExampleLabel = new JLabel(USER_NAME_EXAMPLE);
-
- private JTextField uinField = new TrimTextField();
-
- private JPasswordField passField = new JPasswordField();
-
- private JCheckBox rememberPassBox =
- new SIPCommCheckBox(
- Resources.getString("service.gui.REMEMBER_PASSWORD"));
-
- private JPanel mainPanel = new TransparentPanel();
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
-
- private MsnAccountRegistrationWizard wizard;
-
- private boolean isCommitted = false;
-
- /**
- * Creates an instance of <tt>FirstWizardPage</tt>.
- *
- * @param wizard the parent wizard
- */
- public FirstWizardPage( MsnAccountRegistrationWizard wizard)
- {
-
- super(new BorderLayout());
-
- this.wizard = wizard;
-
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- this.init();
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.labelsPanel
- .setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
-
- this.valuesPanel
- .setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
- }
-
- /**
- * Initializes all panels, buttons, etc.
- */
- private void init()
- {
- this.mainPanel.setOpaque(false);
- this.labelsPanel.setOpaque(false);
- this.valuesPanel.setOpaque(false);
- this.uinPassPanel.setOpaque(false);
- this.emptyPanel.setOpaque(false);
-
- this.uinField.getDocument().addDocumentListener(this);
- this.rememberPassBox.setSelected(true);
-
- this.uinExampleLabel.setForeground(Color.GRAY);
- this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8));
- this.emptyPanel.setMaximumSize(new Dimension(40, 35));
- this.uinExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8, 0));
-
- labelsPanel.add(uinLabel);
- labelsPanel.add(emptyPanel);
- labelsPanel.add(passLabel);
-
- valuesPanel.add(uinField);
- valuesPanel.add(uinExampleLabel);
- valuesPanel.add(passField);
-
- uinPassPanel.add(labelsPanel, BorderLayout.WEST);
- uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
- uinPassPanel.add(rememberPassBox, BorderLayout.SOUTH);
-
- uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
- .getString("plugin.msnaccregwizz.USERNAME_AND_PASSWORD")));
-
- mainPanel.add(uinPassPanel);
- this.add(mainPanel, BorderLayout.NORTH);
- }
-
- /**
- * Implements the <code>WizardPage.getIdentifier</code> to return this
- * page identifier.
- */
- public Object getIdentifier()
- {
- return FIRST_PAGE_IDENTIFIER;
- }
-
- /**
- * Implements the <code>WizardPage.getNextPageIdentifier</code> to return
- * the next page identifier - the summary page.
- */
- public Object getNextPageIdentifier()
- {
- return nextPageIdentifier;
- }
-
- /**
- * Implements the <code>WizardPage.getBackPageIdentifier</code> to return
- * the back identifier. In this case it's null because this is the first
- * wizard page.
- * @return the identifier of the previous wizard page
- */
- public Object getBackPageIdentifier()
- {
- return null;
- }
-
- /**
- * Implements the <code>WizardPage.getWizardForm</code> to return this
- * panel.
- */
- public Object getWizardForm()
- {
- return this;
- }
-
- /**
- * Before this page is displayed enables or disables the "Next" wizard
- * button according to whether the UIN field is empty.
- */
- public void pageShowing()
- {
- this.setNextButtonAccordingToUIN();
- }
-
- /**
- * Saves the user input when the "Next" wizard buttons is clicked.
- */
- public void commitPage()
- {
- MsnAccountRegistration registration
- = wizard.getRegistration();
-
- String userID = uinField.getText();
-
- if(userID == null || userID.trim().length() == 0)
- throw new IllegalStateException("No user ID provided.");
-
- registration.setUserID(userID);
-
- if (passField.getPassword() != null)
- registration.setPassword(new String(passField.getPassword()));
-
- registration.setRememberPassword(rememberPassBox.isSelected());
-
- nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
-
- isCommitted = true;
- }
-
- /**
- * Enables or disables the "Next" wizard button according to whether the UIN
- * field is empty.
- */
- private void setNextButtonAccordingToUIN()
- {
- if (uinField.getText() == null || uinField.getText().equals(""))
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(false);
- }
- else
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
- * field. Enables or disables the "Next" wizard button according to whether
- * the UIN field is empty.
- */
- public void insertUpdate(DocumentEvent e)
- {
- this.setNextButtonAccordingToUIN();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UIN field. Enables or disables the "Next" wizard button
- * according to whether the UIN field is empty.
- */
- public void removeUpdate(DocumentEvent e)
- {
- this.setNextButtonAccordingToUIN();
- }
-
- public void changedUpdate(DocumentEvent e)
- {
- }
-
- public void pageHiding()
- {
- }
-
- public void pageShown()
- {
- }
-
- public void pageBack()
- {
- }
-
- /**
- * Fills the UIN and Password fields in this panel with the data coming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- AccountID accountID = protocolProvider.getAccountID();
- String password = MsnAccRegWizzActivator.getMsnProtocolProviderFactory()
- .loadPassword(accountID);
-
- this.uinField.setText(accountID.getUserID());
-
- if (password != null)
- {
- this.passField.setText(password);
- this.rememberPassBox.setSelected(true);
- }
- }
-
- public Object getSimpleForm()
- {
- return mainPanel;
- }
-
- public boolean isCommitted()
- {
- return isCommitted;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java
deleted file mode 100644
index 5a31354..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccRegWizzActivator.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.plugin.msnaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>MsnAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Yana Stamcheva
- */
-public class MsnAccRegWizzActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- private static final Logger logger =
- Logger.getLogger(MsnAccRegWizzActivator.class);
-
- private static BrowserLauncherService browserLauncherService;
-
- private static WizardContainer wizardContainer;
-
- private static MsnAccountRegistrationWizard msnWizard;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- */
- @Override
- public void start(Object dependentService)
- {
- uiService = (UIService)dependentService;
-
- wizardContainer = uiService.getAccountRegWizardContainer();
-
- msnWizard = new MsnAccountRegistrationWizard(wizardContainer);
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.MSN);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- msnWizard,
- containerFilter);
- }
-
- /**
- * The dependent class. We are waiting for the ui service.
- * @return the ui service class.
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * The bundle context to use.
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- public void stop(BundleContext bundleContext) throws Exception
- {
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Msn protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the Msn protocol
- */
- public static ProtocolProviderFactory getMsnProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
- String osgiFilter
- = "("
- + ProtocolProviderFactory.PROTOCOL
- + "="
- + ProtocolNames.MSN
- + ")";
-
- try
- {
- serRefs
- = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex){
- logger.error("MsnAccRegWizzActivator : " + ex);
- }
-
- return
- (serRefs == null)
- ? null
- : (ProtocolProviderFactory)
- bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher() {
- if (browserLauncherService == null) {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(BrowserLauncherService.class.getName());
-
- browserLauncherService = (BrowserLauncherService) bundleContext
- .getService(serviceReference);
- }
-
- return browserLauncherService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistration.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistration.java
deleted file mode 100644
index ca7585d..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistration.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license. See terms of license at gnu.org.
- */
-package net.java.sip.communicator.plugin.msnaccregwizz;
-
-/**
- * The <tt>MsnAccountRegistration</tt> is used to store all user input data
- * through the <tt>MsnAccountRegistrationWizard</tt>.
- *
- * @author Yana Stamcheva
- */
-public class MsnAccountRegistration
-{
- private String id;
-
- private String password;
-
- private boolean rememberPassword = true;
-
- /**
- * Returns the password of the msn registration account.
- *
- * @return the password of the msn registration account.
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
- * Sets the password of the msn registration account.
- *
- * @param password the password of the msn registration account.
- */
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- /**
- * Returns TRUE if password has to remembered, FALSE otherwise.
- *
- * @return TRUE if password has to remembered, FALSE otherwise
- */
- public boolean isRememberPassword()
- {
- return rememberPassword;
- }
-
- /**
- * Sets the rememberPassword value of this msn account registration.
- *
- * @param rememberPassword TRUE if password has to remembered, FALSE
- * otherwise
- */
- public void setRememberPassword(boolean rememberPassword)
- {
- this.rememberPassword = rememberPassword;
- }
-
- /**
- * Returns the identifier of the MSN registration account.
- *
- * @return the identifier of the MSN registration account.
- */
- public String getId()
- {
- return id;
- }
-
- /**
- * Sets the identifier of the MSN registration account.
- *
- * @param id the identifier of the MSN registration account.
- */
- public void setUserID(String id)
- {
- this.id = id;
- }
-
-}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java
deleted file mode 100644
index 722d995..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/MsnAccountRegistrationWizard.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license. See terms of license at gnu.org.
- */
-package net.java.sip.communicator.plugin.msnaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>MsnAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Msn protocol. It should allow
- * the user to create and configure a new Msn account.
- *
- * @author Yana Stamcheva
- */
-public class MsnAccountRegistrationWizard
- extends DesktopAccountRegistrationWizard
-{
- private final Logger logger
- = Logger.getLogger(MsnAccountRegistrationWizard.class);
-
- private FirstWizardPage firstWizardPage;
-
- private MsnAccountRegistration registration = new MsnAccountRegistration();
-
- private ProtocolProviderService protocolProvider;
-
- /**
- * Creates an instance of <tt>MsnAccountRegistrationWizard</tt>.
- *
- * @param wizardContainer the wizard container, where this wizard is added
- */
- public MsnAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- setWizardContainer(wizardContainer);
-
- wizardContainer
- .setFinishButtonText(Resources.getString("service.gui.SIGN_IN"));
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- *
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.MSN_LOGO);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code>
- * method. Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- *
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString("plugin.msnaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code>
- * method. Returns the description of the protocol for this wizard.
- *
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString("plugin.msnaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- *
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
- firstWizardPage = new FirstWizardPage(this);
-
- pages.add(firstWizardPage);
-
- return pages.iterator();
- }
-
- /**
- * Returns the set of data that user has entered through this wizard.
- *
- * @return Iterator
- */
- @Override
- public Iterator<Map.Entry<String, String>> getSummary()
- {
- Hashtable<String,String> summaryTable = new Hashtable<String,String>();
-
- summaryTable.put( Resources.getString("plugin.msnaccregwizz.USERNAME"),
- registration.getId());
- summaryTable.put( Resources.getString("service.gui.REMEMBER_PASSWORD"),
- Boolean.toString(registration.isRememberPassword()));
-
- return summaryTable.entrySet().iterator();
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin()
- throws OperationFailedException
- {
- firstWizardPage.commitPage();
-
- return signin( registration.getId(),
- registration.getPassword());
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @param userName the user name to sign in with
- * @param password the password to sign in with
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory =
- MsnAccRegWizzActivator.getMsnProtocolProviderFactory();
-
- return this.installAccount( factory,
- userName,
- password);
- }
-
- /**
- * Creates an account for the given user and password.
- *
- * @param providerFactory the ProtocolProviderFactory which will create the
- * account
- * @param user the user identifier
- * @param passwd the password
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- */
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory, String user, String passwd)
- throws OperationFailedException
- {
-
- Hashtable<String,String> accountProperties
- = new Hashtable<String,String>();
-
- accountProperties.put(ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/msn/msn32x32.png");
-
- if (registration.isRememberPassword())
- {
- accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
- }
-
- if (isModification())
- {
- providerFactory.modifyAccount( protocolProvider,
- accountProperties);
-
- setModification(false);
-
- return protocolProvider;
- }
-
- try
- {
- AccountID accountID =
- providerFactory.installAccount(user, accountProperties);
-
- ServiceReference serRef =
- providerFactory.getProviderForAccount(accountID);
-
- protocolProvider =
- (ProtocolProviderService) MsnAccRegWizzActivator.bundleContext
- .getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
- return protocolProvider;
- }
-
- /**
- * Fills the UIN and Password fields in this panel with the data coming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- @Override
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- setModification(true);
-
- this.protocolProvider = protocolProvider;
-
- this.registration = new MsnAccountRegistration();
-
- this.firstWizardPage.loadAccount(protocolProvider);
- }
-
- /**
- * Returns the registration object, which will store all the data through
- * the wizard.
- *
- * @return the registration object, which will store all the data through
- * the wizard
- */
- public MsnAccountRegistration getRegistration()
- {
- return registration;
- }
-
- /**
- * Returns the size of this wizard.
- * @return the size of this wizard
- */
- @Override
- public Dimension getSize()
- {
- return new Dimension(600, 500);
- }
-
- /**
- * Returns the identifier of the page to show first in the wizard.
- * @return the identifier of the page to show first in the wizard.
- */
- @Override
- public Object getFirstPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns the identifier of the page to show last in the wizard.
- * @return the identifier of the page to show last in the wizard.
- */
- @Override
- public Object getLastPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return FirstWizardPage.USER_NAME_EXAMPLE;
- }
-
- /**
- * Opens the browser on the registration page for MSN.
- */
- @Override
- public void webSignup()
- {
- MsnAccRegWizzActivator.getBrowserLauncher()
- .openURL("https://accountservices.passport.net/reg.srf");
- }
-
- /**
- * Returns <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise.
- * @return <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise
- */
- @Override
- public boolean isWebSignupSupported()
- {
- return true;
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- firstWizardPage = new FirstWizardPage(this);
- return firstWizardPage.getSimpleForm();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java
deleted file mode 100644
index 5c01e88..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/Resources.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.plugin.msnaccregwizz;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Yana Stamcheva
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- /**
- * A constant pointing to the MSN protocol logo image.
- */
- public static ImageID MSN_LOGO
- = new ImageID("service.protocol.msn.MSN_16x16");
-
- /**
- * A constant pointing to the Aim protocol wizard page image.
- */
- public static ImageID PAGE_IMAGE
- = new ImageID("service.protocol.msn.MSN_64x64");
-
- /**
- * Returns an internationalized string corresponding to the given key.
- *
- * @param key The key of the string.
- * @return An internationalized string corresponding to the given key.
- */
- public static String getString(String key)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- *
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return getResources().getImageInBytes(imageID.getId());
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(MsnAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf
deleted file mode 100755
index fc6599a..0000000
--- a/src/net/java/sip/communicator/plugin/msnaccregwizz/msnaccregwizz.manifest.mf
+++ /dev/null
@@ -1,33 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.msnaccregwizz.MsnAccRegWizzActivator
-Bundle-Name: Msn account registration wizard
-Bundle-Description: Msn account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.msnaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- net.java.sip.communicator.service.protocol.icqconstants,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
index 843141e..ae93ef5 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
@@ -17,7 +17,6 @@ import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.jabberconstants.*;
-import net.java.sip.communicator.service.protocol.msnconstants.*;
import net.java.sip.communicator.service.protocol.yahooconstants.*;
import net.java.sip.communicator.util.*;
@@ -1115,11 +1114,6 @@ public class Messenger
{
mistatus = MISTATUS_ON_THE_PHONE;
}
- else if (ProtocolNames.MSN.equalsIgnoreCase(protocolName)
- && MsnStatusEnum.ON_THE_PHONE.equals(presenceStatus))
- {
- mistatus = MISTATUS_ON_THE_PHONE;
- }
else if (ProtocolNames.YAHOO.equalsIgnoreCase(protocolName)
&& YahooStatusEnum.ON_THE_PHONE.equals(presenceStatus))
{
@@ -1132,11 +1126,6 @@ public class Messenger
{
mistatus = MISTATUS_IN_A_MEETING;
}
- else if (ProtocolNames.MSN.equalsIgnoreCase(protocolName)
- && MsnStatusEnum.IN_A_MEETING.equals(presenceStatus))
- {
- mistatus = MISTATUS_IN_A_MEETING;
- }
else if (i < PresenceStatus.ONLINE_THRESHOLD)
mistatus = MISTATUS_OFFLINE;
else if (i < PresenceStatus.AWAY_THRESHOLD)
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolNames.java b/src/net/java/sip/communicator/service/protocol/ProtocolNames.java
index 06a9c94..8f3fbc8 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolNames.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolNames.java
@@ -53,11 +53,6 @@ public interface ProtocolNames
public static final String AIM = "AIM";
/**
- * The MSN messenger protocol.
- */
- public static final String MSN = "MSN";
-
- /**
* The Yahoo! messenger protocol.
*/
public static final String YAHOO = "Yahoo!";
diff --git a/src/net/java/sip/communicator/service/protocol/msnconstants/MsnStatusEnum.java b/src/net/java/sip/communicator/service/protocol/msnconstants/MsnStatusEnum.java
deleted file mode 100644
index 2fbbcec..0000000
--- a/src/net/java/sip/communicator/service/protocol/msnconstants/MsnStatusEnum.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.service.protocol.msnconstants;
-
-import java.io.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * An enumeration containing all status instances that MUST be supported by
- * an implementation of the msn protocol. Implementations may
- * support other forms of PresenceStatus but they MUST ALL support those
- * enumerated here.
- * <p>
- * For testing purposes, this class also provides a <tt>List</tt> containing
- * all of the status fields.
- *
- * @author Damian Minkov
- */
-public class MsnStatusEnum
- extends PresenceStatus
-{
- /**
- * The <tt>Logger</tt> used by the <tt>MsnStatusEnum</tt> class and its
- * instances for logging output.
- */
- private static Logger logger = Logger.getLogger(MsnStatusEnum.class);
-
- /**
- * The Online status. Indicate that the user is able and willing to
- * communicate.
- */
- public static final MsnStatusEnum ONLINE
- = new MsnStatusEnum(65, "Online",
- loadIcon("resources/images/protocol/msn/msn16x16-online.png"));
-
- /**
- * The Away status. Indicates that the user has connectivity but might
- * not be able to immediately act upon initiation of communication.
- */
- public static final MsnStatusEnum AWAY
- = new MsnStatusEnum(48, "Away",
- loadIcon("resources/images/protocol/msn/msn16x16-away.png"));
-
- /**
- * The Idle status. Indicates that the user is not using the messanger.
- */
- public static final MsnStatusEnum IDLE
- = new MsnStatusEnum(46, "Idle",
- loadIcon("resources/images/protocol/msn/msn16x16-na.png"));
-
- /**
- * The Invisible status. Indicates that the user has connectivity even
- * though it may appear otherwise to others, to whom she would appear to be
- * offline.
- */
- public static final MsnStatusEnum HIDE
- = new MsnStatusEnum(45, "Hide",
- loadIcon("resources/images/protocol/msn/msn16x16-invisible.png"));
-
- /**
- * The Out to lunch status. Indicates that the user is eating.
- */
- public static final MsnStatusEnum OUT_TO_LUNCH
- = new MsnStatusEnum(39, "Out to lunch",
- loadIcon("resources/images/protocol/msn/msn16x16-lunch.png"));
-
- /**
- * The Not Available status. Indicates that the user has connectivity
- * but might not be able to immediately act (i.e. even less immediately than
- * when in an Away status ;-P ) upon initiation of communication.
- *
- */
- public static final MsnStatusEnum BE_RIGHT_BACK
- = new MsnStatusEnum(35, "Be Right Back",
- loadIcon("resources/images/protocol/msn/msn16x16-brb.png"));
-
- /**
- * The On the phone status. Indicates that the user is talking to the phone.
- */
- public static final MsnStatusEnum ON_THE_PHONE
- = new MsnStatusEnum(31, "On the phone",
- loadIcon("resources/images/protocol/msn/msn16x16-phone.png"));
-
- /**
- * The In Meeting status. Indicates that the user is in meeting.
- */
- public static final MsnStatusEnum IN_A_MEETING
- = new MsnStatusEnum(32, "In a meeting",
- loadIcon("resources/images/protocol/msn/msn16x16-meeting.png"));
-
- /**
- * The DND status. Indicates that the user has connectivity but prefers
- * not to be contacted.
- */
- public static final MsnStatusEnum BUSY
- = new MsnStatusEnum(30, "Busy",
- loadIcon("resources/images/protocol/msn/msn16x16-busy.png"));
-
- /**
- * The Offline status. Indicates the user does not seem to be connected
- * to the network or at least does not want us to know she is
- */
- public static final MsnStatusEnum OFFLINE
- = new MsnStatusEnum(0, "Offline",
- loadIcon("resources/images/protocol/msn/msn16x16-offline.png"));
-
- /**
- * The minimal set of states that any implementation must support.
- */
- public static final ArrayList<MsnStatusEnum> msnStatusSet
- = new ArrayList<MsnStatusEnum>();
-
- static{
- msnStatusSet.add(OUT_TO_LUNCH);
- msnStatusSet.add(ON_THE_PHONE);
- msnStatusSet.add(IN_A_MEETING);
- msnStatusSet.add(ONLINE);
- msnStatusSet.add(OFFLINE);
- msnStatusSet.add(IDLE);
- msnStatusSet.add(HIDE);
- msnStatusSet.add(BUSY);
- msnStatusSet.add(BE_RIGHT_BACK);
- msnStatusSet.add(AWAY);
- }
-
- /**
- * Creates a status with the specified connectivity coeff, name and icon.
- * @param status the connectivity coefficient for the specified status
- * @param statusName String
- * @param statusIcon the icon associated with this status
- */
- protected MsnStatusEnum(int status, String statusName, byte[] statusIcon)
- {
- super(status, statusName, statusIcon);
- }
-
- /**
- * Loads an image from a given image path.
- * @param imagePath The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] loadIcon(String imagePath) {
- InputStream is = MsnStatusEnum.class.getClassLoader()
- .getResourceAsStream(imagePath);
-
- if(is == null)
- return null;
-
- byte[] icon = null;
- try {
- icon = new byte[is.available()];
- is.read(icon);
- } catch (IOException exc) {
- logger.error("Failed to load icon: " + imagePath, exc);
- }
- return icon;
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java b/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java
deleted file mode 100644
index a240601..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/MsnProtocolProviderServiceLick.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-
-import org.osgi.framework.*;
-
-/**
- * Msn specific testing for a Msn Protocol Provider Service implementation.
- * The test suite registers three accounts for
- *
- * @author Damian Minkov
- * @author Valentin Martinet
- */
-public class MsnProtocolProviderServiceLick
- extends TestSuite
- implements BundleActivator
-{
- /**
- * The prefix used for property names containing settings for our first
- * testing account.
- */
- public static final String ACCOUNT_1_PREFIX
- = "accounts.msn.account1.";
-
- /**
- * The prefix used for property names containing settings for our second
- * testing account.
- */
- public static final String ACCOUNT_2_PREFIX
- = "accounts.msn.account2.";
-
- /**
- * The prefix used for property names containing settings for our third
- * testing account.
- */
- public static final String ACCOUNT_3_PREFIX
- = "accounts.msn.account3.";
-
- /**
- * The name of the property that indicates whether the user would like to
- * only run the offline tests.
- */
- public static final String DISABLE_ONLINE_TESTS_PROPERTY_NAME
- = "accounts.msn.DISABLE_ONLINE_TESTING";
-
- /**
- * The name of the property the value of which is a formatted string that
- * contains the contact list that.
- */
- public static final String CONTACT_LIST_PROPERTY_NAME
- = "accounts.msn.CONTACT_LIST";
-
- /**
- * Initializes and registers all tests that we'll run as a part of this
- * slick.
- *
- * @param context a currently valid bundle context.
- */
- public void start(BundleContext context)
- {
- setName("MsnProtocolProviderSlick");
-
- Hashtable<String, String> properties = new Hashtable<String, String>();
- properties.put("service.pid", getName());
-
- MsnSlickFixture.bc = context;
-
- // verify whether the user wants to avoid online testing
- String offlineMode = System.getProperty(
- DISABLE_ONLINE_TESTS_PROPERTY_NAME, null);
-
- if (offlineMode != null && offlineMode.equalsIgnoreCase("true"))
- MsnSlickFixture.onlineTestingDisabled = true;
-
-
- addTestSuite(TestAccountInstallation.class);
- addTestSuite(TestProtocolProviderServiceMsnImpl.class);
-
- addTest(TestOperationSetPresence.suite());
-
- //the following should only be run when we want online testing.
- if(!MsnSlickFixture.onlineTestingDisabled)
- {
- addTest(TestOperationSetPersistentPresence.suite());
-
- addTest(TestOperationSetBasicInstantMessaging.suite());
-
- addTest(TestOperationSetInstantMessageTransformMsnImpl.suite());
-
- addTest(TestOperationSetTypingNotifications.suite());
-
- addTestSuite(TestOperationSetFileTransferImpl.class);
-
- addTest(TestOperationSetAdHocMultiUserChatMsnImpl.suite());
- }
-
- addTest(TestAccountUninstallation.suite());
- addTestSuite(TestAccountUninstallationPersistence.class);
-
- context.registerService(getClass().getName(), this, properties);
- }
-
- /**
- * Prepares the slick for shutdown.
- *
- * @param context a currently valid bundle context.
- */
- public void stop(BundleContext context)
- {
-
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/MsnSlickFixture.java b/test/net/java/sip/communicator/slick/protocol/msn/MsnSlickFixture.java
deleted file mode 100644
index bfe1a6e..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/MsnSlickFixture.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-import org.osgi.framework.*;
-
-/**
- * Contains fields and methods used by most or all tests in the msn slick.
- *
- * @author Damian Minkov
- * @author Valentin Martinet
- */
-public class MsnSlickFixture
- extends AdHocMultiUserChatSlickFixture
-{
-
- /**
- * Constructor
- */
- public MsnSlickFixture()
- {
- super();
- }
-
- /**
- * Initializes protocol provider references and whatever else there is to
- * initialize.
- *
- * @throws InvalidSyntaxException in case we meet problems while retrieving
- * protocol providers through OSGI
- */
- @Override
- public void setUp() throws InvalidSyntaxException
- {
- // first obtain a reference to the provider factory
- ServiceReference[] serRefs = null;
- String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
- + "="+ProtocolNames.MSN+")";
- try{
- serRefs = bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex){
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + " is not a valid osgi filter");
- }
-
- assertTrue(
- "Failed to find a provider factory service for protocol msn",
- (serRefs != null) && (serRefs.length > 0));
-
- //Keep the reference for later usage.
- providerFactory = (ProtocolProviderFactory)bc.getService(serRefs[0]);
-
- userID1 =
- System.getProperty(
- MsnProtocolProviderServiceLick.ACCOUNT_1_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- userID2 =
- System.getProperty(
- MsnProtocolProviderServiceLick.ACCOUNT_2_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- userID3 =
- System.getProperty(
- MsnProtocolProviderServiceLick.ACCOUNT_3_PREFIX
- + ProtocolProviderFactory.USER_ID);
-
- //find the protocol providers exported for the two accounts
- ServiceReference[] msnProvider1Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.MSN+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID1 +")"
- +")");
-
- //make sure we found a service
- assertNotNull("No Protocol Provider was found for msn account1:"
- + userID1
- , msnProvider1Refs);
- assertTrue("No Protocol Provider was found for msn account1:"+ userID1,
- msnProvider1Refs.length > 0);
-
- ServiceReference[] msnProvider2Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.MSN+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID2 +")"
- +")");
-
- //again make sure we found a service.
- assertNotNull("No Protocol Provider was found for msn account2:"
- + userID2
- , msnProvider2Refs);
- assertTrue("No Protocol Provider was found for msn account2:"+ userID2,
- msnProvider2Refs.length > 0);
-
- ServiceReference[] msnProvider3Refs
- = bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- +"("+ProtocolProviderFactory.PROTOCOL+"="+ProtocolNames.MSN+")"
- +"("+ProtocolProviderFactory.USER_ID+"="
- + userID3 +")"
- +")");
-
- //again make sure we found a service.
- assertNotNull("No Protocol Provider was found for msn account3:"
- + userID3
- , msnProvider3Refs);
- assertTrue("No Protocol Provider was found for msn account3:"+ userID3,
- msnProvider3Refs.length > 0);
-
- //save the service for other tests to use.
- provider1ServiceRef = msnProvider1Refs[0];
- provider1 = (ProtocolProviderService)bc.getService(provider1ServiceRef);
- provider2ServiceRef = msnProvider2Refs[0];
- provider2 = (ProtocolProviderService)bc.getService(provider2ServiceRef);
- provider3ServiceRef = msnProvider3Refs[0];
- provider3 = (ProtocolProviderService)bc.getService(provider3ServiceRef);
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountInstallation.java b/test/net/java/sip/communicator/slick/protocol/msn/TestAccountInstallation.java
deleted file mode 100644
index ea26c41..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountInstallation.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-
-import org.osgi.framework.*;
-
-public class TestAccountInstallation
- extends TestCase
-{
-
- /**
- * Creates the test with the specified method name.
- * @param name the name of the method to execute.
- */
- public TestAccountInstallation(String name)
- {
- super(name);
- }
-
- /**
- * JUnit setup method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * JUnit teardown method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /**
- * Installs an account and verifies whether the installation has gone well.
- */
- public void testInstallAccount()
- {
- // first obtain a reference to the provider factory
- ServiceReference[] serRefs = null;
- String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL
- + "="+ProtocolNames.MSN+")";
- try{
- serRefs = MsnSlickFixture.bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + " is not a valid osgi filter");
- }
-
- assertTrue(
- "Failed to find a provider factory service for protocol Msn",
- serRefs != null && serRefs.length > 0);
-
- //Keep the reference for later usage.
- ProtocolProviderFactory msnProviderFactory = (ProtocolProviderFactory)
- MsnSlickFixture.bc.getService(serRefs[0]);
-
- //make sure the account is empty
- assertTrue("There was an account registered with the account mananger "
- +"before we've installed any",
- msnProviderFactory.getRegisteredAccounts().size() == 0);
-
-
- //Prepare the properties of the first msn account.
-
- Hashtable<String, String> msnAccount1Properties = getAccountProperties(
- MsnProtocolProviderServiceLick.ACCOUNT_1_PREFIX);
- Hashtable<String, String> msnAccount2Properties = getAccountProperties(
- MsnProtocolProviderServiceLick.ACCOUNT_2_PREFIX);
- Hashtable<String, String> msnAccount3Properties = getAccountProperties(
- MsnProtocolProviderServiceLick.ACCOUNT_3_PREFIX);
-
- //try to install an account with a null account id
- try{
- msnProviderFactory.installAccount(
- null, msnAccount1Properties);
- fail("installing an account with a null account id must result "
- +"in a NullPointerException");
- }catch(NullPointerException exc)
- {
- //that's what had to happen
- }
-
- //now really install the accounts
- msnProviderFactory.installAccount(
- msnAccount1Properties.get(ProtocolProviderFactory.USER_ID)
- , msnAccount1Properties);
- msnProviderFactory.installAccount(
- msnAccount2Properties.get(ProtocolProviderFactory.USER_ID)
- , msnAccount2Properties);
- msnProviderFactory.installAccount(
- msnAccount3Properties.get(ProtocolProviderFactory.USER_ID)
- , msnAccount3Properties);
-
-
- //try to install one of the accounts one more time and verify that an
- //exception is thrown.
- try{
- msnProviderFactory.installAccount(
- msnAccount1Properties.get(ProtocolProviderFactory.USER_ID)
- , msnAccount1Properties);
-
- fail("An IllegalStateException must be thrown when trying to "+
- "install a duplicate account");
-
- }catch(IllegalStateException exc)
- {
- //that's what supposed to happen.
- }
-
- //Verify that the provider factory is aware of our installation
- assertTrue(
- "The newly installed account was not in the acc man's "
- +"registered accounts!",
- msnProviderFactory.getRegisteredAccounts().size() == 3);
-
- //Verify protocol providers corresponding to the new account have
- //been properly registered with the osgi framework.
-
- osgiFilter =
- "(&("+ProtocolProviderFactory.PROTOCOL +"="+ProtocolNames.MSN+")"
- +"(" + ProtocolProviderFactory.USER_ID
- + "=" + msnAccount1Properties.get(
- ProtocolProviderFactory.USER_ID)
- + "))";
-
- try
- {
- serRefs = MsnSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- //this really shouldhn't occur as the filter expression is static.
- fail(osgiFilter + "is not a valid osgi filter");
- }
-
- assertTrue("An protocol provider was apparently not installed as "
- + "requested."
- , serRefs != null && serRefs.length > 0);
-
- Object msnProtocolProvider
- = MsnSlickFixture.bc.getService(serRefs[0]);
-
- assertTrue("The installed protocol provider does not implement "
- + "the protocol provider service."
- ,msnProtocolProvider instanceof ProtocolProviderService);
- }
-
- /**
- * Returns all properties necessary for the intialization of the account
- * with <tt>accountPrefix</tt>.
- * @param accountPrefix the prefix contained by all property names for the
- * the account we'd like to initialized
- * @return a Hashtable that can be used when creating the account in a
- * protocol provider factory.
- */
- private Hashtable<String, String> getAccountProperties(String accountPrefix)
- {
- Hashtable<String, String> table = new Hashtable<String, String>();
-
- String userID = System.getProperty(
- accountPrefix + ProtocolProviderFactory.USER_ID, null);
-
- assertNotNull(
- "The system property named "
- + accountPrefix + ProtocolProviderFactory.USER_ID
- +" has to tontain a valid msn address that could be used during "
- +"SIP Communicator's tests."
- , userID);
-
- table.put(ProtocolProviderFactory.USER_ID, userID);
-
- String passwd = System.getProperty(
- accountPrefix + ProtocolProviderFactory.PASSWORD, null );
-
- assertNotNull(
- "The system property named "
- + accountPrefix + ProtocolProviderFactory.PASSWORD
- +" has to contain the password corresponding to the account "
- + "specified in "
- + accountPrefix + ProtocolProviderFactory.USER_ID
- , passwd);
-
- table.put(ProtocolProviderFactory.PASSWORD, passwd);
-
- String serverAddress = System.getProperty(
- accountPrefix + ProtocolProviderFactory.SERVER_ADDRESS, null);
-
- // optional
- if(serverAddress != null)
- table.put(ProtocolProviderFactory.SERVER_ADDRESS, serverAddress);
-
- String serverPort = System.getProperty(
- accountPrefix + ProtocolProviderFactory.SERVER_PORT, null);
-
- // optional
- if(serverPort != null)
- table.put(ProtocolProviderFactory.SERVER_PORT, serverPort);
-
- return table;
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallation.java b/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallation.java
deleted file mode 100644
index 394d1b1..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallation.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-import org.osgi.framework.*;
-
-/**
- * Tests whether accounts are uninstalled properly. It is important that
- * tests from this class be called last since they will install the accounts
- * that have been used to test the implementations. Apart from uninstallation
- * tests the class also contains tests that remove and reinstall the protocol
- * provider bundle in order to verify that accounts are persistent.
- *
- * @author Emil Ivov
- */
-public class TestAccountUninstallation
- extends TestCase
-{
- private MsnSlickFixture fixture = new MsnSlickFixture();
-
- /**
- * Constructs a test instance
- * @param name The name of the test.
- */
- public TestAccountUninstallation(String name)
- {
- super(name);
- }
-
- /**
- * JUnit setup method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
- }
-
- /**
- * JUnit teardown method.
- * @throws Exception in case anything goes wrong.
- */
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Returns a suite containing tests in this class in the order that we'd
- * like them executed.
- * @return a Test suite containing tests in this class in the order that
- * we'd like them executed.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(
- new TestAccountUninstallation("testInstallationPersistency"));
- suite.addTest(
- new TestAccountUninstallation("testUninstallAccount"));
-
- return suite;
- }
-
- /**
- * Stops and removes the tested bundle, verifies that it has unregistered
- * its provider, then reloads and restarts the bundle and verifies that
- * the protocol provider is reRegistered in the bundle context.
- *
- * @throws java.lang.Exception if an exception occurs during testing.
- */
- public void testInstallationPersistency() throws Exception
- {
- Bundle providerBundle
- = AdHocMultiUserChatSlickFixture.findProtocolProviderBundle(fixture.provider1);
-
- //set the global providerBundle reference that we will be using
- //in the last series of tests (Account uninstallation persistency)
- MsnSlickFixture.providerBundle = providerBundle;
-
- assertNotNull("Couldn't find a bundle for the tested provider"
- , providerBundle);
-
- providerBundle.stop();
-
- assertTrue("Couldn't stop the protocol provider bundle. State was "
- + providerBundle.getState()
- , Bundle.ACTIVE != providerBundle.getState()
- && Bundle.STOPPING != providerBundle.getState());
-
- providerBundle.uninstall();
-
- assertEquals("Couldn't stop the protocol provider bundle."
- , Bundle.UNINSTALLED, providerBundle.getState());
-
- //verify that the provider is no longer available
- ServiceReference[] msnProviderRefs = null;
- try
- {
- msnProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.MSN + ")"
- + "(" + ProtocolProviderFactory.USER_ID
- + "="+ fixture.userID1 + ")"
- + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong: " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was still regged as an osgi service "
- +"for msn URI:" + fixture.userID1
- + "After it was explicitly uninstalled"
- ,msnProviderRefs == null || msnProviderRefs.length == 0);
-
- //verify that the provider factory knows that we have uninstalled the
- //provider.
- assertTrue(
- "The msn provider factory kept a reference to the provider we just "
- +"uninstalled (uri="+fixture.userID1+")",
- fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- == null);
-
- //Now reinstall the bundle
- providerBundle = AdHocMultiUserChatSlickFixture.bc.installBundle(providerBundle.getLocation());
-
- //set the global providerBundle reference that we will be using
- //in the last series of tests (Account uninstallation persistency)
- MsnSlickFixture.providerBundle = providerBundle;
-
- assertEquals("Couldn't re-install protocol provider bundle."
- , Bundle.INSTALLED, providerBundle.getState());
-
- AccountManagerUtils.startBundleAndWaitStoredAccountsLoaded(AdHocMultiUserChatSlickFixture.bc,
- providerBundle, ProtocolNames.MSN);
- assertEquals("Couldn't re-start protocol provider bundle."
- , Bundle.ACTIVE, providerBundle.getState());
-
- //Make sure that the provider is there again.
- //verify that the provider is no longer available
- try
- {
- msnProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(&"
- + "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.MSN + ")"
- + "(" + ProtocolProviderFactory.USER_ID
- + "="+ fixture.userID1 + ")"
- + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was not restored after being"
- +"reinstalled. msn URI:" + fixture.userID1
- ,msnProviderRefs != null && msnProviderRefs.length > 0);
-
- ServiceReference[] msnFactoryRefs = null;
- try
- {
- msnFactoryRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.MSN + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //we're the ones who've reinstalled the factory so it's our
- //responsibility to update the fixture.
- fixture.providerFactory
- = (ProtocolProviderFactory)AdHocMultiUserChatSlickFixture.bc.getService(msnFactoryRefs[0]);
- fixture.provider1
- = (ProtocolProviderService)AdHocMultiUserChatSlickFixture.bc.getService(msnProviderRefs[0]);
-
-
- //verify that the provider is also restored in the provider factory
- //itself
- assertTrue(
- "The msn provider did not restore its own reference to the provider "
- +"that we just reinstalled (URI="+fixture.userID1+")",
- !fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- != null);
-
- }
-
- /**
- * Uinstalls our test account and makes sure it really has been removed.
- *
- */
- public void testUninstallAccount()
- {
- assertFalse("No installed accounts found",
- fixture.providerFactory.getRegisteredAccounts().isEmpty());
-
- assertNotNull(
- "Found no provider corresponding to URI " + fixture.userID1
- ,fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID()));
-
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID1
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider1.getAccountID()));
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID2
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider2.getAccountID()));
- assertTrue(
- "Failed to remove a provider corresponding to URI "
- + fixture.userID3
- ,fixture.providerFactory.uninstallAccount(
- fixture.provider3.getAccountID()));
-
- //make sure no providers have remained installed.
- ServiceReference[] msnProviderRefs = null;
- try
- {
- msnProviderRefs = AdHocMultiUserChatSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.MSN + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't see a service
- assertTrue("A Protocol Provider Service was still regged as an osgi "
- + "service for msn URI:" + fixture.userID1
- + "After it was explicitly uninstalled"
- ,msnProviderRefs == null || msnProviderRefs.length == 0);
-
- //verify that the provider factory knows that we have uninstalled the
- //provider.
- assertTrue(
- "The msn provider factory kept a reference to the provider we just "
- +"uninstalled (uri="+fixture.userID1+")",
- fixture.providerFactory.getRegisteredAccounts().isEmpty()
- && fixture.providerFactory.getProviderForAccount(
- fixture.provider1.getAccountID())
- == null);
-
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java b/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java
deleted file mode 100644
index bb46946..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestAccountUninstallationPersistence.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-
-import org.jitsi.service.configuration.*;
-import org.osgi.framework.*;
-
-/**
- * Contains tests verifying persistence of account uninstallation. In other
- * words we try to make sure that once uninstalled an account remains
- * uninstalled.
- *
- * @author Emil Ivov
- */
-public class TestAccountUninstallationPersistence
- extends TestCase
-{
- /**
- * Creates a new test instance wrapper around the test with the specified
- * name.
- * @param testName the name of the test that we will be executing.
- */
- public TestAccountUninstallationPersistence(String testName)
- {
- super(testName);
- }
-
- /**
- * Retrieves a reference to the msn bundle, stops it and uninstalls it and
- * then reinstalls it in order to make sure that accounts are not reloaded
- * once removed.
- *
- * @throws java.lang.Exception if something goes wrong while manipulating
- * the bundles.
- */
- public void testAccountUninstallationPersistence()
- throws Exception
- {
- Bundle providerBundle = MsnSlickFixture.providerBundle;
-
- providerBundle.stop();
-
- assertTrue("Couldn't stop the protocol provider bundle. State was "
- + providerBundle.getState()
- , Bundle.ACTIVE != providerBundle.getState()
- && Bundle.STOPPING != providerBundle.getState());
-
- providerBundle.uninstall();
-
- assertEquals("Couldn't stop the protocol provider bundle."
- , Bundle.UNINSTALLED, providerBundle.getState());
-
- //Now reinstall the bundle and restart the provider
- providerBundle
- = MsnSlickFixture.bc.installBundle(providerBundle.getLocation());
-
- assertEquals("Couldn't re-install protocol provider bundle."
- , Bundle.INSTALLED, providerBundle.getState());
-
- AccountManagerUtils.startBundleAndWaitStoredAccountsLoaded(
- MsnSlickFixture.bc, providerBundle, ProtocolNames.MSN);
- assertEquals("Couldn't re-start protocol provider bundle."
- , Bundle.ACTIVE, providerBundle.getState());
-
-
- //verify that the provider is not reinstalled
- ServiceReference[] msnProviderRefs = null;
- try
- {
- msnProviderRefs = MsnSlickFixture.bc.getServiceReferences(
- ProtocolProviderService.class.getName(),
- "(" + ProtocolProviderFactory.PROTOCOL
- + "=" +ProtocolNames.MSN + ")");
- }
- catch (InvalidSyntaxException ex)
- {
- fail("We apparently got our filter wrong " + ex.getMessage());
- }
-
- //make sure we didn't retrieve a service
- assertTrue("A msn Protocol Provider Service was still regged as an "
- +"osgi service after it was explicitly uninstalled"
- ,msnProviderRefs == null || msnProviderRefs.length == 0);
-
- //and a nasty hack at the end - delete the configuration file so that
- //we get a fresh start on next run.
- ServiceReference confReference
- = MsnSlickFixture.bc.getServiceReference(
- ConfigurationService.class.getName());
- ConfigurationService configurationService
- = (ConfigurationService) MsnSlickFixture.bc.getService(confReference);
-
- configurationService.purgeStoredConfiguration();
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetAdHocMultiUserChatMsnImpl.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetAdHocMultiUserChatMsnImpl.java
deleted file mode 100644
index 5249b8c..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetAdHocMultiUserChatMsnImpl.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-
-/**
- * Tests for the MSN ad-hoc multi-user chat operation set.
- *
- * @author Valentin Martinet
- */
-public class TestOperationSetAdHocMultiUserChatMsnImpl
-extends TestOperationSetAdHocMultiUserChat
-{
- /**
- * Creates the test with the specified method name.
- *
- * @param name the name of the method to execute.
- */
- public TestOperationSetAdHocMultiUserChatMsnImpl(String name)
- {
- super(name);
- }
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- *
- * @return Test a tests suite containing all tests to execute.
- */
- public static TestSuite suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "testRegisterAccount3"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "prepareContactList"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "testCreateRoom"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "testPeerJoined"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "testSendIM"));
- suite.addTest(new TestOperationSetAdHocMultiUserChatMsnImpl(
- "testPeerLeaved"));
-
- return suite;
- }
-
- public void testRegisterAccount3() throws OperationFailedException
- {
- fixture.provider3.register(
- new SecurityAuthorityImpl(
- System.getProperty(
- MsnProtocolProviderServiceLick.ACCOUNT_3_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
-
- assertEquals(fixture.provider3.getRegistrationState(),
- RegistrationState.REGISTERED);
- }
-
- @Override
- public void start() throws Exception
- {
- fixture = new MsnSlickFixture();
- fixture.setUp();
-
- // Supported operation sets by each protocol provider.
- Map<String, OperationSet>
- supportedOpSets1, supportedOpSets2, supportedOpSets3;
-
- supportedOpSets1 = fixture.provider1.getSupportedOperationSets();
- supportedOpSets2 = fixture.provider2.getSupportedOperationSets();
- supportedOpSets3 = fixture.provider3.getSupportedOperationSets();
-
- //
- // Initialization of operation sets for the first testing account:
- //
-
- if (supportedOpSets1 == null || supportedOpSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC1 = (OperationSetAdHocMultiUserChat) supportedOpSets1.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC1 == null)
- throw new NullPointerException(
- "No implementation for multi user chat was found");
-
- opSetPresence1 = (OperationSetPresence) supportedOpSets1.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence1 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
-
-
- //
- // Initialization of operation sets for the second testing account:
- //
-
- if (supportedOpSets2 == null || supportedOpSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC2 = (OperationSetAdHocMultiUserChat) supportedOpSets2.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC2 == null)
- throw new NullPointerException(
- "No implementation for ad hoc multi user chat was found");
-
- opSetPresence2 = (OperationSetPresence) supportedOpSets2.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence2 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
-
-
- //
- // Initialization of operation sets for the third testing account:
- //
-
- if (supportedOpSets3 == null || supportedOpSets3.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by " +
- "this implementation. ");
-
- opSetAHMUC3 = (OperationSetAdHocMultiUserChat) supportedOpSets3.get(
- OperationSetAdHocMultiUserChat.class.getName());
-
- if (opSetAHMUC3 == null)
- throw new NullPointerException(
- "No implementation for ad hoc multi user chat was found");
-
- opSetPresence3 = (OperationSetPresence) supportedOpSets3.get(
- OperationSetPresence.class.getName());
-
- if (opSetPresence3 == null)
- throw new NullPointerException(
- "An implementation of the service must provide an " +
- "implementation of at least one of the PresenceOperationSets");
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetBasicInstantMessaging.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetBasicInstantMessaging.java
deleted file mode 100644
index bd0376b..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetBasicInstantMessaging.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Performs testing of the basic instant messaging operation set. Tests include
- * going over basic functionality such as sending a message from the tested
- * implementation and asserting reception by the tester agent and vice versa.
- * @author Emil Ivov
- */
-public class TestOperationSetBasicInstantMessaging
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetBasicInstantMessaging.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
-
- private OperationSetBasicInstantMessaging opSetBasicIM1 = null;
- private OperationSetBasicInstantMessaging opSetBasicIM2 = null;
-
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- public TestOperationSetBasicInstantMessaging(String name)
- {
- super(name);
- }
-
- /**
- * Get a reference to the basic IM operation set.
- * @throws Exception if this is not a good day.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetBasicIM1 =
- (OperationSetBasicInstantMessaging)supportedOperationSets1.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM1 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetBasicIM2 =
- (OperationSetBasicInstantMessaging)supportedOperationSets2.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM2 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- opSetPresence2 =
- (OperationSetPresence) supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- * We'll first execute tests beginning with the "test" prefix and then go to
- * ordered tests.We first execture tests for receiving messagese, so that
- * a volatile contact is created for the sender. we'll then be able to
- * retrieve this volatile contact and send them a message on our turn.
- * We need to do things this way as the contact corresponding to the tester
- * agent has been removed in the previous test and we no longer have it
- * in our contact list.
- *
- * @return Test a testsuite containing all tests to execute.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "prepareContactList"));
-
- suite.addTestSuite(TestOperationSetBasicInstantMessaging.class);
-
- //the following 2 need to be run in the specified order.
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "firstTestReceiveMessage"));
- suite.addTest(new TestOperationSetBasicInstantMessaging(
- "thenTestSendMessage"));
-
- return suite;
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- fixture.clearProvidersLists();
-
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
-
- try
- {
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex)
- {
- // the contact already exist its OK
- }
-
- try
- {
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1)
- {
- // the contact already exist its OK
- }
-
- synchronized(o)
- {
- o.wait(2000);
- }
- }
-
- /**
- * Send an instant message from the tested operation set and assert
- * reception by the tester agent.
- */
- public void firstTestReceiveMessage()
- {
- String body = "This is an IM coming from the tester agent"
- + " on " + new Date().toString();
-
- ImEventCollector evtCollector = new ImEventCollector();
-
- //add a msg listener and register to the op set and send an instant
- //msg from the tester agent.
- opSetBasicIM1.addMessageListener(evtCollector);
-
- Contact testerAgentContact
- = opSetPresence2.findContactByID(fixture.userID1);
-
- logger.debug("Will send message " + body + " to: " + testerAgentContact);
-
- opSetBasicIM2.sendInstantMessage(testerAgentContact,
- opSetBasicIM2.createMessage(body));
-
- evtCollector.waitForEvent(10000);
-
- opSetBasicIM1.removeMessageListener(evtCollector);
-
- //assert reception of a message event
- assertTrue( "No events delivered upon a received message"
- , evtCollector.collectedEvents.size() > 0);
-
- //assert event instance of Message Received Evt
- assertTrue( "Received evt was not an instance of "
- + MessageReceivedEvent.class.getName()
- , evtCollector.collectedEvents.get(0)
- instanceof MessageReceivedEvent);
-
- //assert source contact == testAgent.uin
- MessageReceivedEvent evt
- = (MessageReceivedEvent)evtCollector.collectedEvents.get(0);
- assertEquals("message sender "
- , evt.getSourceContact().getAddress()
- , fixture.userID2);
-
- //assert messageBody == body
- assertEquals("message body", body, evt.getSourceMessage().getContent());
- }
-
- /**
- * Send an instant message from the tester agent and assert reception by
- * the tested implementation
- */
- public void thenTestSendMessage()
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
-
- //create the message
- net.java.sip.communicator.service.protocol.Message msg
- = opSetBasicIM1.createMessage(body);
-
- //register a listener in the op set
- ImEventCollector imEvtCollector1 = new ImEventCollector();
- opSetBasicIM1.addMessageListener(imEvtCollector1);
-
- //register a listener in the tester agent
- ImEventCollector imEvtCollector2 = new ImEventCollector();
- opSetBasicIM2.addMessageListener(imEvtCollector2);
-
- Contact testerAgentContact
- = opSetPresence1.findContactByID(fixture.userID2);
-
- opSetBasicIM1.sendInstantMessage(testerAgentContact, msg);
-
- imEvtCollector1.waitForEvent(10000);
- imEvtCollector2.waitForEvent(10000);
-
- opSetBasicIM1.removeMessageListener(imEvtCollector1);
- opSetBasicIM2.removeMessageListener(imEvtCollector2);
-
- //verify that the message delivered event was dispatched
- assertTrue( "No events delivered when sending a message"
- , imEvtCollector1.collectedEvents.size() > 0);
-
- assertTrue( "Received evt was not an instance of "
- + MessageDeliveredEvent.class.getName()
- , imEvtCollector1.collectedEvents.get(0)
- instanceof MessageDeliveredEvent);
-
- MessageDeliveredEvent evt
- = (MessageDeliveredEvent)imEvtCollector1.collectedEvents.get(0);
- assertEquals("message destination "
- , evt.getDestinationContact().getAddress()
- , fixture.userID2);
-
- assertSame("source message", msg, evt.getSourceMessage());
-
-
- //verify that the message has successfully arived at the destination
- assertTrue( "No messages received by the tester agent"
- , imEvtCollector2.collectedEvents.size() > 0);
- String receivedBody =
- ((MessageReceivedEvent)imEvtCollector2.collectedEvents
- .get(0)).getSourceMessage().getContent();
-
- assertEquals("received message body", msg.getContent(), receivedBody);
- }
-
- /**
- * Creates an Message through the simple createMessage() method and inspects
- * its parameters.
- */
- public void testCreateMessage1()
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
- net.java.sip.communicator.service.protocol.Message msg
- = opSetBasicIM1.createMessage(body);
-
- assertEquals("message body", body, msg.getContent());
- assertTrue("message body bytes"
- , Arrays.equals(body.getBytes(), msg.getRawData()));
- assertEquals("message length", body.length(), msg.getSize());
- assertEquals("message content type"
- , OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE
- , msg.getContentType());
-
- assertEquals("message encoding"
- , OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING
- , msg.getEncoding());
-
- assertNotNull("message uid", msg.getMessageUID());
-
- //a further test on message uid.
- net.java.sip.communicator.service.protocol.Message msg2
- = opSetBasicIM1.createMessage(body);
- assertFalse("message uid", msg.getMessageUID().equals(
- msg2.getMessageUID()));
- }
-
- /**
- * Creates an Message through the advance createMessage() method and
- * inspects its parameters.
- */
- public void testCreateMessage2()
- throws UnsupportedEncodingException
- {
- String body = "This is an IM coming from the tested implementation"
- + " on " + new Date().toString();
- String contentType = "text/html";
- String encoding = "UTF-16";
- String subject = "test message";
- net.java.sip.communicator.service.protocol.Message msg =
- opSetBasicIM1.createMessage(body, contentType, encoding, subject);
- byte[] bodyBytes = body.getBytes(encoding);
-
- assertEquals("message body", body, msg.getContent());
- assertTrue("message body bytes"
- , Arrays.equals(bodyBytes, msg.getRawData()));
- assertEquals("message length", bodyBytes.length, msg.getSize());
- assertEquals("message content type", contentType, msg.getContentType());
- assertEquals("message encoding", encoding, msg.getEncoding());
- assertNotNull("message uid", msg.getMessageUID());
-
- //a further test on message uid.
- net.java.sip.communicator.service.protocol.Message msg2
- = opSetBasicIM1.createMessage(body);
- assertFalse("message uid", msg.getMessageUID().equals(
- msg2.getMessageUID()));
- }
-
- /**
- * Collects instant messaging events.
- */
- private class ImEventCollector implements MessageListener
- {
- private List<EventObject> collectedEvents = new LinkedList<EventObject>();
- /**
- * Called when a new incoming <tt>Message</tt> has been received.
- * @param evt the <tt>MessageReceivedEvent</tt> containing the newly
- * received message, its sender and other details.
- */
- public void messageReceived(MessageReceivedEvent evt)
- {
- logger.debug("Received a MessageReceivedEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called to indicated that delivery of a message sent earlier has failed.
- * Reason code and phrase are contained by the <tt>MessageFailedEvent</tt>
- * @param evt the <tt>MessageFailedEvent</tt> containing the ID of the
- * message whose delivery has failed.
- */
- public void messageDeliveryFailed(MessageDeliveryFailedEvent evt)
- {
- logger.debug("Received a MessageDeliveryFailedEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
-
- /**
- * Called when the underlying implementation has received an indication
- * that a message, sent earlier has been successfully received by the
- * destination.
- * @param evt the MessageDeliveredEvent containing the id of the message
- * that has caused the event.
- */
- public void messageDelivered(MessageDeliveredEvent evt)
- {
- logger.debug("Received a MessageDeliveredEvent: " + evt);
-
- synchronized(this)
- {
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
-
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a message evt", ex);
- }
- }
- }
- }
-
- /**
- * A method that would simply send messages to a group of people so that
- * they would get notified that tests are being run.
- */
- public void testSendFunMessages()
- {
- String hostname = "";
-
- try{
- hostname = java.net.InetAddress.getLocalHost().getHostName() + ": ";
- }catch (UnknownHostException ex){}
-
- String message = hostname
- + "Hello this is the SIP Communicator (version "
- + System.getProperty("sip-communicator.version")
- + ") build on: "
- + new Date().toString()
- + ". Have a very nice day!";
-
- String list = System.getProperty("accounts.reporting.MSN_REPORT_LIST");
-
- logger.debug("Will send message " + message + " to: " + list);
-
- //if no property is specified - return
- if(list == null || list.trim().length() == 0)
- return;
-
- StringTokenizer tokenizer = new StringTokenizer(list, " ");
-
- while(tokenizer.hasMoreTokens())
- {
- String contactID = tokenizer.nextToken();
- Contact contact
- = opSetPresence2.findContactByID(contactID);
-
- if(contact == null)
- {
- //contact is not in our contact list
- continue;
- }
-
- contact
- = opSetPresence2.findContactByID(contactID);
-
- opSetBasicIM2.sendInstantMessage(contact,
- opSetBasicIM2.createMessage(message));
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java
deleted file mode 100644
index ea29d75..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetFileTransferImpl.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Implementation for generic file transfer.
- * @author Damian Minkov
- */
-public class TestOperationSetFileTransferImpl
- extends TestOperationSetFileTransfer
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetFileTransferImpl.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
-
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- private OperationSetFileTransfer opSetFT1 = null;
- private OperationSetFileTransfer opSetFT2 = null;
-
- private static Contact contact1 = null;
- private static Contact contact2 = null;
-
- @Override
- public Contact getContact1()
- {
- if(contact1 == null)
- {
- contact1 = opSetPresence1.findContactByID(fixture.userID2);
- }
-
- return contact1;
- }
-
- @Override
- public Contact getContact2()
- {
- if(contact2 == null)
- {
- contact2 = opSetPresence2.findContactByID(fixture.userID1);
- }
-
- return contact2;
- }
-
- @Override
- public void start()
- throws Exception
- {
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- opSetFT1 =
- (OperationSetFileTransfer)supportedOperationSets1.get(
- OperationSetFileTransfer.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetFT1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the FileTransferOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- opSetPresence2 =
- (OperationSetPresence) supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- opSetFT2 =
- (OperationSetFileTransfer)supportedOperationSets2.get(
- OperationSetFileTransfer.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetFT2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the FileTransferOperationSets");
- }
-
- prepareContactList();
- }
-
- @Override
- public void stop()
- throws Exception
- {
- fixture.tearDown();
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- // clear the provider the first time we run a filetransfer list
- if(contact1 == null && contact2 == null)
- {
- fixture.clearProvidersLists();
- }
-
- if(getContact1() == null)
- {
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
-
- try
- {
- opSetPresence1.setAuthorizationHandler(new AuthHandler());
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex)
- {
- // the contact already exist its OK
- }
- }
-
- if(getContact2() == null)
- {
- try
- {
- opSetPresence2.setAuthorizationHandler(new AuthHandler());
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1)
- {
- // the contact already exist its OK
- }
-
- logger.info("will wait till the list prepare is completed");
- Object o = new Object();
- synchronized(o)
- {
- o.wait(2000);
- }
- }
- }
-
- @Override
- public OperationSetFileTransfer getOpSetFilTransfer1()
- {
- return opSetFT1;
- }
-
- @Override
- public OperationSetFileTransfer getOpSetFilTransfer2()
- {
- return opSetFT2;
- }
-
- @Override
- public BundleContext getContext()
- {
- return AdHocMultiUserChatSlickFixture.bc;
- }
-
- @Override
- public boolean enableTestSendAndReceive()
- {
- // as this is the first test to be executed
- // make it wait for a while in order user to become online
- Object o = new Object();
- synchronized(o)
- {
- try{o.wait(4000);}catch (Exception e){}
- }
-
- return true;
- }
-
- @Override
- public boolean enableTestSenderCancelBeforeAccepted()
- {
- return true;
- }
-
- @Override
- public boolean enableTestReceiverDecline()
- {
- return true;
- }
-
- @Override
- public boolean enableTestReceiverCancelsWhileTransfering()
- {
- return true;
- }
-
- @Override
- public boolean enableTestSenderCancelsWhileTransfering()
- {
- return true;
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetInstantMessageTransformMsnImpl.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetInstantMessageTransformMsnImpl.java
deleted file mode 100644
index e3246d8..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetInstantMessageTransformMsnImpl.java
+++ /dev/null
@@ -1,275 +0,0 @@
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-public class TestOperationSetInstantMessageTransformMsnImpl
- extends TestCase
-{
-
- private static final Logger logger =
- Logger.getLogger(TestOperationSetInstantMessageTransformMsnImpl.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
-
- private OperationSetBasicInstantMessaging opSetBasicIM1 = null;
-
- private OperationSetBasicInstantMessaging opSetBasicIM2 = null;
-
- private OperationSetInstantMessageTransform opSetTransform1 = null;
-
- private OperationSetInstantMessageTransform opSetTransform2 = null;
-
- private OperationSetPresence opSetPresence1 = null;
-
- private OperationSetPresence opSetPresence2 = null;
-
- public TestOperationSetInstantMessageTransformMsnImpl(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if (supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- + "this implementation. ");
-
- // get the operation set presence here.
- opSetBasicIM1 =
- (OperationSetBasicInstantMessaging) supportedOperationSets1
- .get(OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM1 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- // we also need the presence op set in order to retrieve contacts.
- opSetTransform1 =
- (OperationSetInstantMessageTransform) supportedOperationSets1
- .get(OperationSetInstantMessageTransform.class.getName());
-
- // if the op set is null show that we're not happy.
- if (opSetTransform1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an OperationSetInstantMessageTransform implementation");
- }
-
- // we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence) supportedOperationSets1
- .get(OperationSetPresence.class.getName());
-
- // if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if (supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- + "this implementation. ");
-
- // get the operation set presence here.
- opSetBasicIM2 =
- (OperationSetBasicInstantMessaging) supportedOperationSets2
- .get(OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM2 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
- opSetTransform2 =
- (OperationSetInstantMessageTransform) supportedOperationSets2
- .get(OperationSetInstantMessageTransform.class.getName());
-
- // if the op set is null show that we're not happy.
- if (opSetTransform2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an OperationSetInstantMessageTransform implementation");
- }
-
- opSetPresence2 =
- (OperationSetPresence) supportedOperationSets2
- .get(OperationSetPresence.class.getName());
-
- // if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetInstantMessageTransformMsnImpl(
- "firstTestTransformLayerInstallation"));
-
- suite
- .addTestSuite(TestOperationSetInstantMessageTransformMsnImpl.class);
-
- return suite;
- }
-
- public void firstTestTransformLayerInstallation()
- {
- PredictableTransformLayer transformLayer =
- new PredictableTransformLayer();
-
- opSetTransform1.addTransformLayer(transformLayer);
- if (!opSetTransform1.containsLayer(transformLayer))
- fail("Transform layer did not install.");
-
- opSetTransform2.addTransformLayer(transformLayer);
- if (!opSetTransform2.containsLayer(transformLayer))
- fail("Transform layer did not install.");
- }
-
- public void testMessageReceivedTransform()
- {
- String body =
- "This is an IM coming from the tester agent" + " on "
- + new Date().toString();
-
- // We expect out message to be transformed only from the
- // MessageDelivered Event.
- String expectedReceivedBody = "__RECEIVED____DELIVERY_PENDING__" + body;
-
- ImEventCollector receiversEventCollector = new ImEventCollector();
-
- opSetBasicIM1.addMessageListener(receiversEventCollector);
-
- Contact contact1 = opSetPresence2.findContactByID(fixture.userID1);
-
- logger.debug("Will send message \"" + body + "\" to: \"" + contact1
- + "\". We expect to get back: \"" + expectedReceivedBody + "\"");
-
- opSetBasicIM2.sendInstantMessage(contact1, opSetBasicIM2
- .createMessage(body));
-
- receiversEventCollector.waitForEvent(timeout);
-
- opSetBasicIM1.removeMessageListener(receiversEventCollector);
-
- // assert reception of a message event
- assertTrue("No events delivered upon a received message",
- receiversEventCollector.collectedEvents.size() > 0);
-
- // assert event instance of Message Received Evt
- assertTrue(
- "Received evt was not an instance of "
- + MessageReceivedEvent.class.getName(),
- receiversEventCollector.collectedEvents.get(0) instanceof MessageReceivedEvent);
-
- // assert source contact == testAgent.uin
- MessageReceivedEvent evt =
- (MessageReceivedEvent) receiversEventCollector.collectedEvents
- .get(0);
- assertEquals("message sender ", evt.getSourceContact().getAddress(),
- fixture.userID2);
-
- logger.debug("We got back: \"" + evt.getSourceMessage().getContent()
- + "\"");
-
- // assert messageBody == body
- assertEquals("message body", expectedReceivedBody, evt
- .getSourceMessage().getContent());
-
- }
-
- private static final long timeout = 1000;
-
- public void testMessageDeliveredTransform()
- {
- String body =
- "This is an IM coming from the tester agent" + " on "
- + new Date().toString();
-
- // The message will be transformed prior to sending and after being
- // received, we expect two underscores to be prepended and two
- // underscores to be appended.
- String expectedReceivedBody = "__DELIVERED__" + body;
-
- ImEventCollector sendersEventCollector = new ImEventCollector();
- opSetBasicIM2.addMessageListener(sendersEventCollector);
-
- Contact contact1 = opSetPresence2.findContactByID(fixture.userID1);
-
- logger.debug("Will send message \"" + body + "\" to: \"" + contact1
- + "\". We expect to get back: \"" + expectedReceivedBody + "\"");
-
- opSetBasicIM2.sendInstantMessage(contact1, opSetBasicIM2
- .createMessage(body));
-
- sendersEventCollector.waitForEvent(timeout);
- opSetBasicIM2.removeMessageListener(sendersEventCollector);
-
- // assert reception of a message event
- assertTrue("No events delivered upon a sent message",
- sendersEventCollector.collectedEvents.size() > 0);
-
- // assert event instance of Message Received Evt
- assertTrue(
- "Received evt was not an instance of "
- + MessageDeliveredEvent.class.getName(),
- sendersEventCollector.collectedEvents.get(0) instanceof MessageDeliveredEvent);
-
- // assert source contact == testAgent.uin
- MessageDeliveredEvent evtDelivered =
- (MessageDeliveredEvent) sendersEventCollector.collectedEvents
- .get(0);
- assertEquals("message sender ", evtDelivered.getDestinationContact()
- .getAddress(), fixture.userID1);
-
- logger.debug("We got back: \""
- + evtDelivered.getSourceMessage().getContent() + "\"");
- // assert messageBody == body
- assertEquals("message body", expectedReceivedBody, evtDelivered
- .getSourceMessage().getContent());
- }
-
- public void testMessageDeliveryFailedTransform()
- {
- // TODO not sure how this can be implemented.
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPersistentPresence.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPersistentPresence.java
deleted file mode 100644
index 82741ed..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPersistentPresence.java
+++ /dev/null
@@ -1,707 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * @author Damian Minkov
- */
-public class TestOperationSetPersistentPresence
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetPersistentPresence.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
- private OperationSetPersistentPresence opSetPersPresence1 = null;
- private OperationSetPersistentPresence opSetPersPresence2 = null;
- private static final String testGroupName = "NewGroup";
- private static final String testGroupName2 = "Renamed";
-
- public TestOperationSetPersistentPresence(String name)
- {
- super(name);
- }
-
- /**
- * Creates a test suite containing all tests of this class followed by
- * test methods that we want executed in a specified order.
- * @return the Test suite to run
- */
- public static Test suite()
- {
- TestSuite suite =
- new TestSuite();
-
- //the following 2 need to be run in the specified order.
- //(postTestRemoveGroup() needs the group created from
- //postTestCreateGroup() )
- suite.addTest(
- new TestOperationSetPersistentPresence("postTestCreateGroup"));
-
- //rename
-// suite.addTest( new TestOperationSetPersistentPresence(
-// "postTestRenameGroup"));
-
- suite.addTest(
- new TestOperationSetPersistentPresence("postTestRemoveGroup"));
-
- // create the contact list
- suite.addTest(
- new TestOperationSetPersistentPresence("prepareContactList"));
-
- suite.addTestSuite(TestOperationSetPersistentPresence.class);
-
- return suite;
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this Msn implementation. ");
-
- //get the operation set presence here.
- opSetPersPresence1 =
- (OperationSetPersistentPresence)supportedOperationSets1.get(
- OperationSetPersistentPresence.class.getName());
-
- //if still null then the implementation doesn't offer a presence
- //operation set which is unacceptable for msn.
- if (opSetPersPresence1 == null)
- throw new NullPointerException(
- "An implementation of the Msn service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
-
- // lets do it once again for the second provider
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if (supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- + "this Msn implementation. ");
-
- //get the operation set presence here.
- opSetPersPresence2 =
- (OperationSetPersistentPresence) supportedOperationSets2.get(
- OperationSetPersistentPresence.class.getName());
-
- //if still null then the implementation doesn't offer a presence
- //operation set which is unacceptable for msn.
- if (opSetPersPresence2 == null)
- throw new NullPointerException(
- "An implementation of the msn service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Retrieves a server stored contact list and checks whether it contains
- * all contacts that have been added there during the initialization
- * phase by the testerAgent.
- */
- public void testRetrievingServerStoredContactList()
- throws Exception
- {
- waitFor(5000);
-
- ContactGroup rootGroup
- = opSetPersPresence1.getServerStoredContactListRoot();
-
- logger.debug("=========== Server Stored Contact List =================");
-
- logger.debug("rootGroup="+rootGroup.getGroupName()
- +" rootGroup.childContacts="+rootGroup.countContacts()
- + "rootGroup.childGroups="+rootGroup.countSubgroups()
- + "Printing rootGroupContents=\n"+rootGroup.toString());
-
- Hashtable<String, List<String>> expectedContactList
- = AdHocMultiUserChatSlickFixture.preInstalledBuddyList;
-
- logger.debug("============== Expected Contact List ===================");
- logger.debug(expectedContactList);
-
- //Go through the contact list retrieved by the persistence presence set
- //and remove the name of every contact and group that we find there from
- //the expected contact list hashtable.
- Iterator<ContactGroup> groups = rootGroup.subgroups();
- while (groups.hasNext() )
- {
- ContactGroup group = groups.next();
- List<String> expectedContactsInGroup
- = expectedContactList.get(group.getGroupName());
-
- // When sending the offline message
- // the sever creates a group NotInContactList,
- // beacuse the buddy we are sending message to is not in
- // the contactlist. So this group must be ignored
- // Also we must ignore the group created by default
- // from the msn lib
- if(!group.getGroupName().equals("NotInContactList") &&
- !group.getGroupName().equals("Default group"))
- {
- assertNotNull("Group " + group.getGroupName() +
- " was returned by "
- +
- "the server but was not in the expected contact list."
- , expectedContactsInGroup);
-
- Iterator<Contact> contactsIter = group.contacts();
- while(contactsIter.hasNext())
- {
- String contactID = contactsIter.next().getAddress();
- expectedContactsInGroup.remove(contactID);
- }
-
- //If we've removed all the sub contacts, remove the group too.
- if(expectedContactsInGroup.size() == 0)
- expectedContactList.remove(group.getGroupName());
- }
- }
-
- //whatever we now have in the expected contact list snapshot are groups,
- //that have been added by the testerAgent but that were not retrieved
- //by the persistent presence operation set.
- assertTrue("The following contacts were on the server sidec contact "
- +"list, but were not returned by the pers. pres. op. set"
- + expectedContactList.toString()
- , expectedContactList.isEmpty());
- }
-
- /**
- * Creates a group in the server stored contact list, makes sure that the
- * corresponding event has been generated and verifies that the group is
- * in the list.
- *
- * @throws java.lang.Exception
- */
- public void postTestCreateGroup()
- throws Exception
- {
- // first clear the list
- fixture.clearProvidersLists();
-
- waitFor(5000);
-
- logger.trace("testing creation of server stored groups");
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- //create the group
- opSetPersPresence1.createServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot(), testGroupName);
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- // check whether we got group created event
- assertEquals("Collected Group Change events: ",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is retrievable
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNotNull("A newly created group was not in the contact list.",
- group);
-
- assertEquals("New group name", testGroupName, group.getGroupName());
-
- // when opearting with groups . the group must have entries
- // so changes to take effect. Otherwise group will be lost after loggingout
- try
- {
- opSetPersPresence1.subscribe(group, fixture.userID2);
-
- waitFor(1500);
- }
- catch (Exception ex)
- {
- fail("error adding entry to group : " +
- group.getGroupName() + " " +
- ex.getMessage());
- }
- }
-
-
- /**
- * Removes the group created in the server stored contact list by the create
- * group test, makes sure that the corresponding event has been generated
- * and verifies that the group is not in the list any more.
- */
- public void postTestRemoveGroup()
- {
- logger.trace("testing removal of server stored groups");
-
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- try
- {
- //remove the group
- opSetPersPresence1.removeServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName));
- }
- catch(OperationFailedException ex)
- {
- logger.error("error removing group", ex);
- }
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- // check whether we got group created event
- assertEquals("Collected Group Change event",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is still on the contact list
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNull("A freshly removed group was still on the contact list.",
- group);
- }
-
- /**
- * Renames our test group and checks whether corresponding events are
- * triggered. Verifies whether the group has really changed its name and
- * whether it is findable by its new name. Also makes sure that it does
- * not exist under its previous name any more.
- */
- public void postTestRenameGroup()
- {
- logger.trace("Testing renaming groups.");
-
- ContactGroup group = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- //first add a listener
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1
- .addServerStoredGroupChangeListener(groupChangeCollector);
-
- //change the name and wait for a confirmation event
- opSetPersPresence1.renameServerStoredContactGroup(group, testGroupName2);
-
- groupChangeCollector.waitForEvent(10000);
-
- opSetPersPresence1
- .removeServerStoredGroupChangeListener(groupChangeCollector);
-
- //examine the event
- assertEquals("Collected Group Change event",
- 1, groupChangeCollector.collectedEvents.size());
-
- assertEquals("Group name.", testGroupName2,
- ((ServerStoredGroupEvent)groupChangeCollector.collectedEvents
- .get(0)).getSourceGroup().getGroupName());
-
- // check whether the group is still on the contact list
- ContactGroup oldGroup = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName);
-
- assertNull("A group was still findable by its old name after renaming.",
- oldGroup);
-
- //make sure that we could find the group by its new name.
- ContactGroup newGroup = opSetPersPresence1.getServerStoredContactListRoot()
- .getGroup(testGroupName2);
-
- assertNotNull("Could not find a renamed group by its new name.",
- newGroup);
- }
-
- /**
- * Create the contact list. Later will be test to be sure that creating is ok
- * @throws Exception
- */
- public void prepareContactList()
- throws Exception
- {
- fixture.clearProvidersLists();
-
- waitFor(3000);
-
- String contactList = System.getProperty(
- MsnProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME, null);
-
- logger.debug("The "
- + MsnProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME
- + " property is set to=" + contactList);
-
- if( contactList == null
- || contactList.trim().length() < 6)//at least 4 for a UIN, 1 for the
- // dot and 1 for the grp name
- throw new IllegalArgumentException(
- "The " +
- MsnProtocolProviderServiceLick.CONTACT_LIST_PROPERTY_NAME +
- " property did not contain a contact list.");
- StringTokenizer tokenizer = new StringTokenizer(contactList, " \n\t");
-
- logger.debug("tokens contained by the CL tokenized="
- +tokenizer.countTokens());
-
- Hashtable<String, List<String>> contactListToCreate = new Hashtable<String, List<String>>();
-
- //go over all group.uin tokens
- while (tokenizer.hasMoreTokens())
- {
- String groupUinToken = tokenizer.nextToken();
- int dotIndex = groupUinToken.indexOf(".");
-
- if ( dotIndex == -1 )
- {
- throw new IllegalArgumentException(groupUinToken
- + " is not a valid Group.UIN token");
- }
-
- String groupName = groupUinToken.substring(0, dotIndex);
- String uin = groupUinToken.substring(dotIndex + 1);
-
- if( groupName.trim().length() < 1
- || uin.trim().length() < 4 )
- {
- throw new IllegalArgumentException(
- groupName + " or " + uin +
- " are not a valid group name or msn UIN.");
- }
-
- //check if we've already seen this group and if not - add it
- List<String> uinInThisGroup = contactListToCreate.get(groupName);
- if (uinInThisGroup == null)
- {
- uinInThisGroup = new ArrayList<String>();
- contactListToCreate.put(groupName, uinInThisGroup);
- }
-
- uinInThisGroup.add(uin);
- }
-
- // now init the list
- Enumeration <String>newGroupsEnum = contactListToCreate.keys();
-
- GroupChangeCollector groupChangeCollector = new GroupChangeCollector();
- opSetPersPresence1.addServerStoredGroupChangeListener(groupChangeCollector);
-
- //go over all groups in the contactsToAdd table
- while (newGroupsEnum.hasMoreElements())
- {
- String groupName = newGroupsEnum.nextElement();
- logger.debug("Will add group " + groupName);
-
- groupChangeCollector.collectedEvents.clear();
-
- opSetPersPresence1.createServerStoredContactGroup(
- opSetPersPresence1.getServerStoredContactListRoot(), groupName);
-
- groupChangeCollector.waitForEvent(3000);
-
- ContactGroup newlyCreatedGroup =
- opSetPersPresence1.getServerStoredContactListRoot().getGroup(groupName);
-
- Iterator<String> contactsToAddToThisGroup
- = contactListToCreate.get(groupName).iterator();
- while (contactsToAddToThisGroup.hasNext())
- {
- String id = contactsToAddToThisGroup.next();
-
- logger.debug("Will add buddy " + id);
- opSetPersPresence1.subscribe(newlyCreatedGroup, id);
- }
- }
-
- waitFor(2000);
-
- //store the created contact list for later reference
- MsnSlickFixture.preInstalledBuddyList = contactListToCreate;
- }
-
- private void waitFor(long time)
- throws Exception
- {
- Object o = new Object();
- synchronized(o)
- {
- o.wait(time);
- }
- }
-
- /**
- * The class would listen for and store received events delivered to
- * <tt>ServerStoredGroupListener</tt>s.
- */
- private class GroupChangeCollector implements ServerStoredGroupListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
-
- /**
- * Blocks until at least one event is received or until waitFor
- * milliseconds pass (whichever happens first).
- *
- * @param waitFor the number of milliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Called whenever an indication is received that a new server stored
- * group is created.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to
- * the newly created group.
- */
- public void groupCreated(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called when an indication is received that the name of a server stored
- * contact group has changed.
- * @param evt a ServerStoredGroupChangeEvent containing the details of the
- * name change.
- */
- public void groupNameChanged(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called whenever an indication is received that an existing server stored
- * group has been removed.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to the
- * newly created group.
- */
- public void groupRemoved(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Called whenever an indication is received that an existing server
- * stored group has been resolved.
- * @param evt a ServerStoredGroupChangeEvent containing a reference to
- * the resolved group.
- */
- public void groupResolved(ServerStoredGroupEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
- }
-
- /**
- * The class would listen for and store received subscription modification
- * events.
- */
- private class SubscriptionEventCollector implements SubscriptionListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
-
- /**
- * Blocks until at least one event is received or until waitFor
- * milliseconds pass (whichever happens first).
- *
- * @param waitFor the number of milliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- logger.trace("Waiting for a persistent subscription event");
-
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- {
- logger.trace("SubEvt already received. " + collectedEvents);
- return;
- }
-
- try{
- wait(waitFor);
- if(collectedEvents.size() > 0)
- logger.trace("Received a SubEvt in provider status.");
- else
- logger.trace("No SubEvt received for "+waitFor+"ms.");
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionCreated(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionRemoved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionFailed(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionResolved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionMoved(SubscriptionMovedEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subscription and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void contactModified(ContactPropertyChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPresence.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPresence.java
deleted file mode 100644
index 8d69435..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetPresence.java
+++ /dev/null
@@ -1,971 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.beans.*;
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.protocol.msnconstants.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Tests msn implementations of a Presence Operation Set. Tests in this class
- * verify functionality such as: Changing local (our own) status and
- * corresponding event dispatching; Querying status of contacts, Subscribing
- * for presence notifications upong status changes of specific contacts.
- * <p>
- * Using a custom suite() method, we make sure that apart from standard test
- * methods (those with a <tt>test</tt> prefix) we also execute those that
- * we want run in a specific order like for example - postTestSubscribe() and
- * postTestUnsubscribe().
- * <p>
- * @author Damian Minkov
- */
-public class TestOperationSetPresence
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetPresence.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
- private OperationSetPresence operationSetPresence1 = null;
- private OperationSetPresence operationSetPresence2 = null;
-
- public TestOperationSetPresence(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- operationSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null then the implementation doesn't offer a presence
- //operation set which is unacceptable for msn.
- if (operationSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the msn service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
-
- // do it once again for the second provider
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this msn implementation. ");
-
- //get the operation set presence here.
- operationSetPresence2 =
- (OperationSetPresence)supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null then the implementation doesn't offer a presence
- //operation set which is unacceptable for msn.
- if (operationSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the msn service must provide an "
- + "implementation of at least the one of the Presence "
- + "Operation Sets");
- }
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing all tests of this class followed by
- * test methods that we want executed in a specified order.
- * @return Test
- */
- public static Test suite()
- {
- //return an (almost) empty suite if we're running in offline mode.
- if(MsnSlickFixture.onlineTestingDisabled)
- {
- TestSuite suite = new TestSuite();
- //the only test around here that we could run without net
- //connectivity
- suite.addTest(
- new TestOperationSetPresence(
- "testSupportedStatusSetForCompleteness"));
- return suite;
- }
-
- TestSuite suite = new TestSuite();
-
- // clear the lists before subscribing users
- suite.addTest(new TestOperationSetPresence("clearLists"));
-
- // first postTestSubscribe. to be sure that contacts are in the
- // list so we can further continue and test presences each other
- suite.addTest(new TestOperationSetPresence("postTestSubscribe"));
-
- // add other tests
- suite.addTestSuite(TestOperationSetPresence.class);
-
- // now test unsubscribe
- suite.addTest(new TestOperationSetPresence("postTestUnsubscribe"));
-
- return suite;
- }
-
- /**
- * Verifies that all necessary msn test states are supported by the
- * implementation.
- */
- public void testSupportedStatusSetForCompleteness()
- {
- //first create a local list containing the presence status instances
- //supported by the underlying implementation.
- Iterator<PresenceStatus> supportedStatusSetIter =
- operationSetPresence1.getSupportedStatusSet();
-
- List<PresenceStatus> supportedStatusSet = new LinkedList<PresenceStatus>();
- while (supportedStatusSetIter.hasNext()){
- supportedStatusSet.add(supportedStatusSetIter.next());
- }
-
- //create a copy of the MUST status set and remove any matching status
- //that is also present in the supported set.
- List<?> requiredStatusSetCopy
- = (List<?>) MsnStatusEnum.msnStatusSet.clone();
-
- requiredStatusSetCopy.removeAll(supportedStatusSet);
-
- //if we have anything left then the implementation is wrong.
- int unsupported = requiredStatusSetCopy.size();
- assertTrue( "There are " + unsupported + " statuses as follows:"
- + requiredStatusSetCopy,
- unsupported == 0);
- }
-
- /**
- * Verify that changing state to AWAY works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToAway() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.AWAY);
- }
-
- /**
- * Verify that changing state to NOT_AVAILABLE works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToNotAvailable() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.BE_RIGHT_BACK);
- }
-
- /**
- * Verify that changing state to DND works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToDnd() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.BUSY);
- }
-
- /**
- * Verify that changing state to FREE_FOR_CHAT works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToIdle() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.IDLE);
- }
-
- /**
- * Verify that changing state to ONLINE works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToOnline() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.ONLINE);
- }
-
- /**
- * Verify that changing state to OUT_TO_LUNCH works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToOutToLunch() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.OUT_TO_LUNCH);
- }
-
- /**
- * Verify that changing state to ON_THE_PHONE works as supposed to and that it
- * generates the corresponding event.
- * @throws Exception in case a failure occurs while the operation set
- * is switching to the new state.
- */
- public void testChangingStateToOnThePhone() throws Exception
- {
- subtestStateTransition(MsnStatusEnum.ON_THE_PHONE);
- }
-
- /**
- * Used by methods testing state transiotions
- *
- * @param newStatus the MsnStatusEnum field corresponding to the status
- * that we'd like the opeation set to enter.
- *
- * @throws Exception in case changing the state causes an exception
- */
- public void subtestStateTransition( MsnStatusEnum newStatus)
- throws Exception
- {
- logger.trace(" --=== beginning state transition test ===--");
-
- PresenceStatus oldStatus = operationSetPresence1.getPresenceStatus();
-
- logger.debug( "old status is=" + oldStatus.getStatusName()
- + " new status=" + newStatus.getStatusName());
-
- //First register a listener to make sure that all corresponding
- //events have been generated.
- PresenceStatusEventCollector statusEventCollector
- = new PresenceStatusEventCollector();
- ContactPresenceEventCollector contactStatusEventCollector
- = new ContactPresenceEventCollector(fixture.userID1, newStatus);
- operationSetPresence1.addProviderPresenceStatusListener(
- statusEventCollector);
- operationSetPresence2.addContactPresenceStatusListener(
- contactStatusEventCollector);
-
- //change the status
- operationSetPresence1.publishPresenceStatus(newStatus, null);
- pauseAfterStateChanges();
-
- //test provider event notification.
- statusEventCollector.waitForPresEvent(10000);
-
- // wait for status change in other provider
- // as later its not actually queryed but the last received
- // status is returned
- contactStatusEventCollector.waitForEvent(10000);
-
- operationSetPresence1.removeProviderPresenceStatusListener(
- statusEventCollector);
- operationSetPresence2.removeContactPresenceStatusListener(
- contactStatusEventCollector);
-
- assertEquals("Events dispatched during an event transition.",
- 1, statusEventCollector.collectedPresEvents.size());
- assertEquals("A status changed event contained wrong old status.",
- oldStatus,
- ((ProviderPresenceStatusChangeEvent)
- statusEventCollector.collectedPresEvents.get(0))
- .getOldStatus());
- assertEquals("A status changed event contained wrong new status.",
- newStatus,
- ((ProviderPresenceStatusChangeEvent)
- statusEventCollector.collectedPresEvents.get(0))
- .getNewStatus());
-
- // verify that the operation set itself is aware of the status change
- assertEquals("opSet.getPresenceStatus() did not return properly.",
- newStatus,
- operationSetPresence1.getPresenceStatus());
-
- logger.trace("will query for contact(" + fixture.userID1 + ") status!");
-
- MsnStatusEnum actualStatus = (MsnStatusEnum)
- operationSetPresence2.queryContactStatus(fixture.userID1);
-
- assertEquals("The underlying implementation did not switch to the "
- +"requested presence status.",
- newStatus,
- actualStatus);
-
- logger.trace(" --=== finished test ===--");
- }
-
- /**
- * Give time changes to take effect
- */
- private void pauseAfterStateChanges()
- {
- try
- {
- Thread.sleep(3000);
- }
- catch (InterruptedException ex)
- {
- logger.debug("Pausing between state changes was interrupted", ex);
- }
- }
- /**
- * Verifies that querying status works fine. The tester agent would
- * change status and the operation set would have to return the right status
- * after every change.
- *
- * @throws java.lang.Exception if one of the transitions fails
- */
- public void testQueryContactStatus()
- throws Exception
- {
- // --- AWAY ---
- logger.debug("Will Query an AWAY contact.");
- subtestQueryContactStatus(MsnStatusEnum.AWAY,
- MsnStatusEnum.AWAY);
-
- // --- NA ---
- logger.debug("Will Query an BRB contact.");
- subtestQueryContactStatus(MsnStatusEnum.BE_RIGHT_BACK,
- MsnStatusEnum.BE_RIGHT_BACK);
-
- // --- DND ---
- logger.debug("Will Query a Busy contact.");
- subtestQueryContactStatus(MsnStatusEnum.BUSY,
- MsnStatusEnum.BUSY);
-
- // --- FFC ---
- logger.debug("Will Query a Idle contact.");
- subtestQueryContactStatus(MsnStatusEnum.IDLE,
- MsnStatusEnum.IDLE);
-
- // --- INVISIBLE ---
- logger.debug("Will Query an Invisible contact.");
- subtestQueryContactStatus(MsnStatusEnum.HIDE,
- MsnStatusEnum.OFFLINE);
-
- // --- Online ---
- logger.debug("Will Query an Online contact.");
- subtestQueryContactStatus(MsnStatusEnum.ONLINE,
- MsnStatusEnum.ONLINE);
- }
-
- /**
- * Used by functions testing the queryContactStatus method of the
- * presence operation set.
- * @param status the status as specified, that
- * the tester agent should switch to.
- * @param expectedReturn the PresenceStatus that the presence operation
- * set should see the tester agent in once it has switched to taStatusLong.
- *
- * @throws java.lang.Exception if querying the status causes some exception.
- */
- public void subtestQueryContactStatus(PresenceStatus status,
- PresenceStatus expectedReturn)
- throws Exception
- {
- operationSetPresence2.publishPresenceStatus(status, "status message");
-
- pauseAfterStateChanges();
-
- logger.trace("will query for contact("+ fixture.userID2 + ") status!");
- PresenceStatus actualReturn
- = operationSetPresence1.queryContactStatus(fixture.userID2);
-
- // sometimes happens that no status are received
- // will change the status and try again
- if(!actualReturn.equals(expectedReturn))
- {
- logger.info("subtestQueryContactStatus for " + status +
- " Failed - trying again!");
-
- // reset the status so we can change it once again
- operationSetPresence2.publishPresenceStatus(status, "status message");
-
- pauseAfterStateChanges();
-
- // now try again
- operationSetPresence2.publishPresenceStatus(status, "status message");
-
- pauseAfterStateChanges();
-
- actualReturn
- = operationSetPresence1.queryContactStatus(fixture.userID2);
- }
-
- assertEquals("Querying a "
- + expectedReturn.getStatusName()
- + " state did not return as expected"
- , expectedReturn, actualReturn);
- }
-
- /**
- * The method would add a subscription for a contact, wait for a
- * subscription event confirming the subscription, then change the status
- * of the newly added contact (which is actually the testerAgent) and
- * make sure that the corresponding notification events have been generated.
- *
- * @throws java.lang.Exception if an exception occurs during testing.
- */
- public void postTestSubscribe()
- throws Exception
- {
- logger.debug("Testing Subscription and Subscription Event Dispatch.");
-
- SubscriptionEventCollector subEvtCollector
- = new SubscriptionEventCollector();
- operationSetPresence1.addSubscriptionListener(subEvtCollector);
-
-
- synchronized (subEvtCollector){
- operationSetPresence1.subscribe(fixture.userID2);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector.waitForEvent(10000);
- operationSetPresence1.removeSubscriptionListener(subEvtCollector);
- }
-
- SubscriptionEventCollector subEvtCollector2
- = new SubscriptionEventCollector();
- operationSetPresence2.addSubscriptionListener(subEvtCollector2);
-
-
- synchronized (subEvtCollector2){
- operationSetPresence2.subscribe(fixture.userID1);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector2.waitForEvent(10000);
- operationSetPresence2.removeSubscriptionListener(subEvtCollector2);
- }
-
- assertEquals("Subscription event dispatching failed."
- , 1, subEvtCollector.collectedEvents.size());
- SubscriptionEvent subEvt =
- (SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
-
- assertEquals("SubscriptionEvent Source:",
- fixture.userID2,
- ((Contact)subEvt.getSource()).getAddress());
- assertEquals("SubscriptionEvent Source Contact:",
- fixture.userID2,
- subEvt.getSourceContact().getAddress());
- assertSame("SubscriptionEvent Source Provider:",
- fixture.provider1,
- subEvt.getSourceProvider());
-
- subEvtCollector.collectedEvents.clear();
-
- // make the user agent tester change its states and make sure we are
- // notified
- logger.debug("Testing presence notifications.");
- MsnStatusEnum oldStatus
- = (MsnStatusEnum)operationSetPresence2.getPresenceStatus();
-
-
- MsnStatusEnum newStatus = MsnStatusEnum.IDLE;
-
- //in case we are by any chance already in a FREE_FOR_CHAT status, we'll
- //be changing to something else
- if(oldStatus.equals(newStatus)){
- newStatus = MsnStatusEnum.BUSY;
- }
-
- //now do the actual status notification testing
- ContactPresenceEventCollector contactPresEvtCollector
- = new ContactPresenceEventCollector(
- fixture.userID2, newStatus);
- operationSetPresence1.addContactPresenceStatusListener(
- contactPresEvtCollector);
-
- synchronized (contactPresEvtCollector){
- operationSetPresence2.publishPresenceStatus(newStatus, "new status");
- //we may already have the event, but it won't hurt to check.
- contactPresEvtCollector.waitForEvent(10000);
- operationSetPresence1
- .removeContactPresenceStatusListener(contactPresEvtCollector);
- }
-
- assertEquals("Presence Notif. event dispatching failed."
- , 1, contactPresEvtCollector.collectedEvents.size());
- ContactPresenceStatusChangeEvent presEvt =
- (ContactPresenceStatusChangeEvent)
- contactPresEvtCollector.collectedEvents.get(0);
-
- assertEquals("Presence Notif. event Source:",
- fixture.userID2,
- ((Contact)presEvt.getSource()).getAddress());
- assertEquals("Presence Notif. event Source Contact:",
- fixture.userID2,
- presEvt.getSourceContact().getAddress());
- assertSame("Presence Notif. event Source Provider:",
- fixture.provider1,
- presEvt.getSourceProvider());
-
- PresenceStatus reportedNewStatus = presEvt.getNewStatus();
- PresenceStatus reportedOldStatus = presEvt.getOldStatus();
-
- assertEquals( "Reported new PresenceStatus: ",
- newStatus, reportedNewStatus );
-
- //don't require equality between the reported old PresenceStatus and
- //the actual presence status of the tester agent because a first
- //notification is not supposed to have the old status as it really was.
- assertNotNull( "Reported old PresenceStatus: ", reportedOldStatus );
-
- try
- {
- // add the the user to the reverse side needed for status tests
- subEvtCollector.collectedEvents.clear();
- operationSetPresence2.addSubscriptionListener(subEvtCollector);
-
- synchronized (subEvtCollector)
- {
- operationSetPresence2.subscribe(fixture.userID1);
- //we may already have the event, but it won't hurt to check.
- subEvtCollector.waitForEvent(10000);
- operationSetPresence2.removeSubscriptionListener(
- subEvtCollector);
- }
- }
- catch (OperationFailedException ex)
- {
- // happens if the user is already subscribed
- }
-
- Object lock = new Object();
- synchronized(lock)
- {
- logger.info("Will wait all subscriptioin events to be received by lib");
- lock.wait(3000);
- logger.info("Stopped waiting");
- }
- }
-
- /**
- * We unsubscribe from presence notification deliveries concerning
- * testerAgent's presence status and verify that we receive the
- * subscription removed event. We then make the tester agent change status
- * and make sure that no notifications are delivered.
- *
- * @throws java.lang.Exception in case unsubscribing fails.
- */
- public void postTestUnsubscribe()
- throws Exception
- {
- logger.debug("Testing Unsubscribe and unsubscription event dispatch.");
-
- // First create a subscription and verify that it really gets created.
- SubscriptionEventCollector subEvtCollector
- = new SubscriptionEventCollector();
- operationSetPresence1.addSubscriptionListener(subEvtCollector);
-
- Contact msnTesterAgentContact = operationSetPresence1
- .findContactByID(fixture.userID2);
-
- assertNotNull(
- "Failed to find an existing subscription for the tester agent"
- , msnTesterAgentContact);
-
- synchronized(subEvtCollector){
- operationSetPresence1.unsubscribe(msnTesterAgentContact);
- subEvtCollector.waitForEvent(10000);
- //don't want any more events
- operationSetPresence1.removeSubscriptionListener(subEvtCollector);
- }
-
- assertEquals("Subscription event dispatching failed."
- , 1, subEvtCollector.collectedEvents.size());
- SubscriptionEvent subEvt =
- (SubscriptionEvent)subEvtCollector.collectedEvents.get(0);
-
- assertEquals("SubscriptionEvent Source:",
- msnTesterAgentContact, subEvt.getSource());
-
- assertEquals("SubscriptionEvent Source Contact:",
- msnTesterAgentContact, subEvt.getSourceContact());
-
- assertSame("SubscriptionEvent Source Provider:",
- fixture.provider1,
- subEvt.getSourceProvider());
-
- subEvtCollector.collectedEvents.clear();
-
- // make the user agent tester change its states and make sure we don't
- // get notifications as we're now unsubscribed.
- logger.debug("Testing (lack of) presence notifications.");
- MsnStatusEnum oldStatus
- = (MsnStatusEnum)operationSetPresence2.getPresenceStatus();
- MsnStatusEnum newStatus = MsnStatusEnum.IDLE;
-
- //in case we are by any chance already in a FREE_FOR_CHAT status, we'll
- //be changing to something else
- if(oldStatus.equals(newStatus)){
- newStatus = MsnStatusEnum.BUSY;
- }
-
- //now do the actual status notification testing
- ContactPresenceEventCollector contactPresEvtCollector
- = new ContactPresenceEventCollector(fixture.userID2, null);
- operationSetPresence1.addContactPresenceStatusListener(
- contactPresEvtCollector);
-
- synchronized (contactPresEvtCollector){
- operationSetPresence2.publishPresenceStatus(newStatus, "new status");
-
- //we may already have the event, but it won't hurt to check.
- contactPresEvtCollector.waitForEvent(10000);
- operationSetPresence1
- .removeContactPresenceStatusListener(contactPresEvtCollector);
- }
-
- assertEquals("Presence Notifications were received after unsubscibing."
- , 0, contactPresEvtCollector.collectedEvents.size());
- }
-
- public void clearLists()
- throws Exception
- {
- logger.debug("Clear the two lists before tests");
-
- Object o = new Object();
- synchronized (o)
- {
- o.wait(10000);
- }
- // wait for a moment
- // give time the impl to get the lists
- logger.debug("start clearing");
- fixture.clearProvidersLists();
- synchronized(o)
- {
- o.wait(3000);
- }
- }
-
- /**
- * An event collector that would collect all events generated by a
- * provider after a status change. The collector would also do a notidyAll
- * every time it receives an event.
- */
- private class PresenceStatusEventCollector
- implements ProviderPresenceStatusListener
- {
- public ArrayList<EventObject> collectedPresEvents = new ArrayList<EventObject>();
- public ArrayList<EventObject> collectedStatMsgEvents = new ArrayList<EventObject>();
-
- public void providerStatusChanged(ProviderPresenceStatusChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedPresEvents.size()+")= "+evt);
- collectedPresEvents.add(evt);
- notifyAll();
- }
- }
-
- public void providerStatusMessageChanged(PropertyChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected stat.msg. evt("
- +collectedPresEvents.size()+")= "+evt);
- collectedStatMsgEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForPresEvent(long waitFor)
- {
- logger.trace("Waiting for a change in provider status.");
- synchronized(this)
- {
- if(collectedPresEvents.size() > 0){
- logger.trace("Change already received. " + collectedPresEvents);
- return;
- }
-
- try{
- wait(waitFor);
- if(collectedPresEvents.size() > 0)
- logger.trace("Received a change in provider status.");
- else
- logger.trace("No change received for "+waitFor+"ms.");
- }
- catch (InterruptedException ex){
- logger.debug("Interrupted while waiting for a provider evt"
- , ex);
- }
- }
- }
-
- /**
- * Blocks until at least one staus message event is received or until
- * waitFor miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for a status message event before simply bailing out.
- */
- public void waitForStatMsgEvent(long waitFor)
- {
- logger.trace("Waiting for a provider status message event.");
- synchronized(this)
- {
- if(collectedStatMsgEvents.size() > 0){
- logger.trace("Stat msg. evt already received. "
- + collectedStatMsgEvents);
- return;
- }
-
- try{
- wait(waitFor);
- if(collectedStatMsgEvents.size() > 0)
- logger.trace("Received a prov. stat. msg. evt.");
- else
- logger.trace("No prov. stat msg. received for "
- +waitFor+"ms.");
- }
- catch (InterruptedException ex){
- logger.debug("Interrupted while waiting for a status msg evt"
- , ex);
- }
- }
- }
- }
-
- /**
- * The class would listen for and store received subscription modification
- * events.
- */
- private class SubscriptionEventCollector implements SubscriptionListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- {
- logger.trace("Change already received. " + collectedEvents);
- return;
- }
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionCreated(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionRemoved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void contactModified(ContactPropertyChangeEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionMoved(SubscriptionMovedEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionFailed(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- /**
- * Stores the received subsctiption and notifies all waiting on this
- * object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void subscriptionResolved(SubscriptionEvent evt)
- {
- synchronized(this)
- {
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
-
- }
-
- /**
- * The class would listen for and store received events caused by changes
- * in contact presence states.
- */
- private class ContactPresenceEventCollector
- implements ContactPresenceStatusListener
- {
- public ArrayList<EventObject> collectedEvents = new ArrayList<EventObject>();
- private String trackedScreenName = null;
- private MsnStatusEnum status = null;
-
- ContactPresenceEventCollector(String screenname,
- MsnStatusEnum wantedStatus)
- {
- this.trackedScreenName = screenname;
- this.status = wantedStatus;
- }
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this)
- {
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
-
- /**
- * Stores the received status change event and notifies all waiting on
- * this object
- * @param evt the SubscriptionEvent containing the corresponding contact
- */
- public void contactPresenceStatusChanged(
- ContactPresenceStatusChangeEvent evt)
- {
- synchronized(this)
- {
- //if the user has specified event details and the received
- //event does not match - then ignore it.
- if( this.trackedScreenName != null
- && !evt.getSourceContact().getAddress()
- .equals(trackedScreenName))
- return;
- if( status != null
- && status != evt.getNewStatus())
- return;
-
- logger.debug("Collected evt("+collectedEvents.size()+")= "+evt);
- collectedEvents.add(evt);
- notifyAll();
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetTypingNotifications.java b/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetTypingNotifications.java
deleted file mode 100644
index 5a79cc1..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestOperationSetTypingNotifications.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Tests functionality of the typing notifications operation set.
- *
- * @author Damian Minkov
- */
-public class TestOperationSetTypingNotifications
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestOperationSetTypingNotifications.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
- private OperationSetTypingNotifications opSetTypingNotifs1 = null;
- private OperationSetPresence opSetPresence1 = null;
- private OperationSetTypingNotifications opSetTypingNotifs2 = null;
- private OperationSetPresence opSetPresence2 = null;
-
- private OperationSetBasicInstantMessaging opSetBasicIM1 = null;
- private OperationSetBasicInstantMessaging opSetBasicIM2 = null;
-
-
- public TestOperationSetTypingNotifications(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
-
- Map<String, OperationSet> supportedOperationSets1 =
- fixture.provider1.getSupportedOperationSets();
-
- if ( supportedOperationSets1 == null
- || supportedOperationSets1.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetTypingNotifs1 =
- (OperationSetTypingNotifications)supportedOperationSets1.get(
- OperationSetTypingNotifications.class.getName());
-
- //if the op set is null then the implementation doesn't offer a typing.n
- //operation set which is unacceptable.
- if (opSetTypingNotifs1 == null)
- {
- throw new NullPointerException(
- "No implementation for typing notifications was found");
- }
-
- opSetBasicIM1 =
- (OperationSetBasicInstantMessaging)supportedOperationSets1.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM1 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence1 =
- (OperationSetPresence)supportedOperationSets1.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence1 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
-
- Map<String, OperationSet> supportedOperationSets2 =
- fixture.provider2.getSupportedOperationSets();
-
- if ( supportedOperationSets2 == null
- || supportedOperationSets2.size() < 1)
- throw new NullPointerException(
- "No OperationSet implementations are supported by "
- +"this implementation. ");
-
- //get the operation set presence here.
- opSetTypingNotifs2 =
- (OperationSetTypingNotifications)supportedOperationSets2.get(
- OperationSetTypingNotifications.class.getName());
-
- //if the op set is null then the implementation doesn't offer a typing.n
- //operation set which is unacceptable for.
- if (opSetTypingNotifs2 == null)
- {
- throw new NullPointerException(
- "No implementation for typing notifications was found");
- }
-
- opSetBasicIM2 =
- (OperationSetBasicInstantMessaging)supportedOperationSets2.get(
- OperationSetBasicInstantMessaging.class.getName());
-
- if (opSetBasicIM2 == null)
- {
- throw new NullPointerException(
- "No implementation for basic IM was found");
- }
-
-
- //we also need the presence op set in order to retrieve contacts.
- opSetPresence2 =
- (OperationSetPresence)supportedOperationSets2.get(
- OperationSetPresence.class.getName());
-
- //if the op set is null show that we're not happy.
- if (opSetPresence2 == null)
- {
- throw new NullPointerException(
- "An implementation of the service must provide an "
- + "implementation of at least one of the PresenceOperationSets");
- }
- }
-
- /**
- * Create the list to be sure that contacts exchanging messages
- * exists in each other lists
- * @throws Exception
- */
- public void prepareContactList() throws Exception
- {
- // be sure that contacts are in their lists
- try{
- opSetPresence1.subscribe(fixture.userID2);
- }
- catch (OperationFailedException ex){
- // the contact already exist its OK
- }
-
- try{
- opSetPresence2.subscribe(fixture.userID1);
- }
- catch (OperationFailedException ex1){
- // the contact already exist its OK
- }
-
- Object o = new Object();
- synchronized (o)
- {
- o.wait(2000);
- }
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- fixture.tearDown();
- }
-
- /**
- * Creates a test suite containing tests of this class in a specific order.
- * We'll first execute a test where we receive a typing notification, and
- * a volatile contact is created for the sender. we'll then be able to
- * retrieve this volatile contact and them a notification on our turn.
- * We need to do things this way as the contact corresponding to the tester
- * agent has been removed in the previous test and we no longer have it
- * in our contact list.
- *
- * @return Test a testsuite containing all tests to execute.
- */
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new TestOperationSetTypingNotifications(
- "prepareContactList"));
-
- //the following 2 need to be run in the specified order.
- suite.addTest(new TestOperationSetTypingNotifications(
- "testTypingNotificationsEventDelivery"));
- return suite;
- }
-
- /**
- * Sends a typing notification and verifies
- * whether it is properly received by the tested implementation
- */
- public void testTypingNotificationsEventDelivery()
- {
- TypingEventCollector evtCollector = new TypingEventCollector();
-
- // send message so request for receiving notifications also to be set
- Contact notifingContact =
- opSetPresence1.findContactByID(fixture.userID2);
- opSetBasicIM1.sendInstantMessage(notifingContact,
- opSetBasicIM1.createMessage("ping"));
-
- opSetTypingNotifs1.addTypingNotificationsListener(evtCollector);
-
- Contact contactToNotify =
- opSetPresence2.findContactByID(fixture.userID1);
-
- opSetBasicIM2.sendInstantMessage(contactToNotify,
- opSetBasicIM2.createMessage("pong"));
-
- opSetTypingNotifs2.sendTypingNotification(
- contactToNotify, OperationSetTypingNotifications.STATE_TYPING);
-
- evtCollector.waitForEvent(10000);
-
- opSetTypingNotifs1.removeTypingNotificationsListener(evtCollector);
-
- //check event dispatching
- assertTrue("Number of typing events received was zero."
- , evtCollector.collectedEvents.size() > 0);
-
- TypingNotificationEvent evt = (TypingNotificationEvent)evtCollector
- .collectedEvents.get(0);
-
- assertEquals("Source of the typing notification event"
- , fixture.userID2
- , evt.getSourceContact().getAddress() );
-
- assertEquals("Source of the typing notification event"
- , OperationSetTypingNotifications.STATE_TYPING
- , evt.getTypingState());
- }
-
- /**
- * Simply collects allre received events and provides a mechanisim for
- * waiting for the next event.
- */
- private class TypingEventCollector implements TypingNotificationsListener
- {
- private List<EventObject> collectedEvents = new LinkedList<EventObject>();
- /**
- * Called to indicate that a remote <tt>Contact</tt> has sent us a typing
- * notification. The method adds the <tt>event</tt> to the list of
- * captured events.
- * @param event a <tt>TypingNotificationEvent</tt> containing the sender
- * of the notification and its type.
- */
- public void typingNotificationReceived(TypingNotificationEvent event)
- {
- logger.debug("Received a typing notification: " + event);
- synchronized (this)
- {
- collectedEvents.add(event);
- notifyAll();
- }
- }
-
- /**
- * Called to indicate that sending typing notification has failed.
- *
- * @param event a <tt>TypingNotificationEvent</tt> containing the sender
- * of the notification and its type.
- */
- public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
- {}
-
- /**
- * Blocks until at least one event is received or until waitFor
- * miliseconds pass (whicever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- synchronized(this){
-
- if(collectedEvents.size() > 0)
- return;
-
- try{
- wait(waitFor);
- }
- catch (InterruptedException ex){
- logger.debug(
- "Interrupted while waiting for a subscription evt", ex);
- }
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/TestProtocolProviderServiceMsnImpl.java b/test/net/java/sip/communicator/slick/protocol/msn/TestProtocolProviderServiceMsnImpl.java
deleted file mode 100644
index fa0f269..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/TestProtocolProviderServiceMsnImpl.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package net.java.sip.communicator.slick.protocol.msn;
-
-import java.util.*;
-
-import junit.framework.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.slick.protocol.generic.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Performs testing on protocol provider methods.
- * @todo add more detailed docs once the tests are written.
- * @author Damian Minkov
- * @author Valentin Martinet
- */
-public class TestProtocolProviderServiceMsnImpl
- extends TestCase
-{
- private static final Logger logger =
- Logger.getLogger(TestProtocolProviderServiceMsnImpl.class);
-
- private MsnSlickFixture fixture = new MsnSlickFixture();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector1
- = new RegistrationEventCollector();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector2
- = new RegistrationEventCollector();
-
- /**
- * An event adapter that would collec registation state change events
- */
- public RegistrationEventCollector regEvtCollector3
- = new RegistrationEventCollector();
-
- /**
- * Creates a test encapsulator for the method with the specified name.
- * @param name the name of the method this test should run.
- */
- public TestProtocolProviderServiceMsnImpl(String name)
- {
- super(name);
- }
-
- /**
- * Initializes the fixture.
- * @throws Exception if super.setUp() throws one.
- */
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
- fixture.setUp();
- }
-
- /**
- * Tears the fixture down.
- * @throws Exception if fixture.tearDown() fails.
- */
- @Override
- protected void tearDown() throws Exception
- {
- fixture.tearDown();
- super.tearDown();
- }
-
- /**
- * Makes sure that the instance of the Msn protocol provider that we're
- * going to use for testing is properly initialized and registered with
- * a Msn registrar. This MUST be called before any other online testing
- * of the Msn provider so that we won't have to reregister for every single
- * test.
- * <p>
- * The method also verifies that a registration event is fired upon
- * succesful registration and collected by our event collector.
- *
- * @throws OperationFailedException if provider.register() fails.
- */
- public void testRegister()
- throws OperationFailedException
- {
- //add an event collector that will collect all events during the
- //registration and allow us to later inspect them and make sure
- //they were properly dispatched.
- fixture.provider1.addRegistrationStateChangeListener(regEvtCollector1);
- fixture.provider2.addRegistrationStateChangeListener(regEvtCollector2);
-
- //register all of our providers
- fixture.provider1.register(new SecurityAuthorityImpl(
- System.getProperty(MsnProtocolProviderServiceLick.ACCOUNT_1_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
- fixture.provider2.register(new SecurityAuthorityImpl(
- System.getProperty(MsnProtocolProviderServiceLick.ACCOUNT_2_PREFIX
- + ProtocolProviderFactory.PASSWORD).toCharArray()));
-
- //give it enough time to register. We won't really have to wait all this
- //time since the registration event collector would notify us the moment
- //we get signed on.
- logger.debug("Waiting for registration to complete ...");
-
- regEvtCollector1.waitForEvent(15000);
- regEvtCollector2.waitForEvent(40000);
-
- //make sure that the registration process trigerred the corresponding
- //events.
- assertTrue(
- "No events were dispatched during the registration process."
- ,regEvtCollector1.collectedNewStates.size() > 0);
-
- assertTrue(
- "No registration event notifying of registration was dispatched. "
- +"All events were: " + regEvtCollector1.collectedNewStates
- ,regEvtCollector1.collectedNewStates
- .contains(RegistrationState.REGISTERED));
-
- //now the same for provider 2
- assertTrue(
- "No events were dispatched during the registration process "
- +"of provider2."
- ,regEvtCollector2.collectedNewStates.size() > 0);
-
- assertTrue(
- "No registration event notifying of registration was dispatched. "
- +"All events were: " + regEvtCollector2.collectedNewStates
- ,regEvtCollector2.collectedNewStates
- .contains(RegistrationState.REGISTERED));
-
- //now the same for provider 3
-// assertTrue(
-// "No events were dispatched during the registration process "
-// +"of provider3."
-// ,regEvtCollector3.collectedNewStates.size() > 0);
-//
-// assertTrue(
-// "No registration event notifying of registration was dispatched. "
-// +"All events were: " + regEvtCollector3.collectedNewStates
-// ,regEvtCollector3.collectedNewStates
-// .contains(RegistrationState.REGISTERED));
-
-
- fixture.provider1
- .removeRegistrationStateChangeListener(regEvtCollector1);
- fixture.provider2
- .removeRegistrationStateChangeListener(regEvtCollector2);
-// fixture.provider3
-// .removeRegistrationStateChangeListener(regEvtCollector3);
- }
-
-
- /**
- * Verifies that all operation sets have the type they are declarded to
- * have.
- *
- * @throws java.lang.Exception if a class indicated in one of the keys
- * could not be forName()ed.
- */
- public void testOperationSetTypes() throws Exception
- {
- Map<String, OperationSet> supportedOperationSets =
- fixture.provider1.getSupportedOperationSets();
-
- // make sure that keys (which are supposed to be class names) correspond
- // what the class of the values recorded against them.
- for (Map.Entry<String, OperationSet> entry : supportedOperationSets
- .entrySet())
- {
- String setName = entry.getKey();
- Object opSet = entry.getValue();
-
- assertTrue(opSet + " was not an instance of " + setName
- + " as declared", Class.forName(setName).isInstance(opSet));
- }
- }
-
- /**
- * A class that would plugin as a registration listener to a protocol
- * provider and simply record all events that it sees and notifyAll()
- * if it sees an event that notifies us of a completed
- * registration.
- */
- public class RegistrationEventCollector
- implements RegistrationStateChangeListener
- {
- public List<RegistrationState> collectedNewStates = new LinkedList<RegistrationState>();
-
- /**
- * The method would simply register all received events so that they
- * could be available for later inspection by the unit tests. In the
- * case where a registraiton event notifying us of a completed
- * registration is seen, the method would call notifyAll().
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- logger.debug("Received a RegistrationStateChangeEvent: " + evt);
-
- collectedNewStates.add(evt.getNewState());
-
- if (evt.getNewState().equals(RegistrationState.REGISTERED))
- {
- logger.debug("We're registered and will notify those who wait");
- synchronized (this)
- {
- notifyAll();
- }
- }
- }
-
- /**
- * Blocks until an event notifying us of the awaited state change is
- * received or until waitFor miliseconds pass (whichever happens first).
- *
- * @param waitFor the number of miliseconds that we should be waiting
- * for an event before simply bailing out.
- */
- public void waitForEvent(long waitFor)
- {
- logger.trace("Waiting for a RegistrationStateChangeEvent ");
-
- synchronized (this)
- {
- if (collectedNewStates.contains(RegistrationState.REGISTERED))
- {
- logger.trace("Event already received. "
- + collectedNewStates);
- return;
- }
-
- try
- {
- wait(waitFor);
-
- if (collectedNewStates.size() > 0)
- logger.trace(
- "Received a RegistrationStateChangeEvent.");
- else
- logger.trace(
- "No RegistrationStateChangeEvent received for "
- + waitFor + "ms.");
-
- }
- catch (InterruptedException ex)
- {
- logger.debug(
- "Interrupted while waiting for a "
- +"RegistrationStateChangeEvent"
- , ex);
- }
- }
- }
- }
-}
diff --git a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf b/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf
deleted file mode 100644
index 7e7cc92..0000000
--- a/test/net/java/sip/communicator/slick/protocol/msn/msn.provider.slick.manifest.mf
+++ /dev/null
@@ -1,17 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.slick.protocol.msn.MsnProtocolProviderServiceLick
-Bundle-Name: Msn Protocol Provider Service Leveraging Implementation Compatibility Kit
-Bundle-Description: A Service Leveraging Implementation Compatibility Kit for the Msn implementation of the ProtocolProvider Service
-Bundle-Vendor: sip-communicator.org
-Bundle-Version: 0.0.1
-System-Bundle: yes
-Import-Package: junit.framework,
- org.osgi.framework,
- javax.net.ssl,
- javax.xml.parsers,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,org.jitsi.service.protocol.event,
- net.java.sip.communicator.service.protocol.msnconstants,
- net.java.sip.communicator.util,
- net.java.sip.communicator.service.dns,
- org.jitsi.service.fileaccess