aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/impl/protocol
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2007-04-10 15:29:01 +0000
committerDamian Minkov <damencho@jitsi.org>2007-04-10 15:29:01 +0000
commit214e73f5094eea707603331ce3919968091c2423 (patch)
treef4f6520c9a95af240c39684520116463ec677f05 /src/net/java/sip/communicator/impl/protocol
parent75b88bb5a6b6ea924903fc1092f33caa21bd3ca7 (diff)
downloadjitsi-214e73f5094eea707603331ce3919968091c2423.zip
jitsi-214e73f5094eea707603331ce3919968091c2423.tar.gz
jitsi-214e73f5094eea707603331ce3919968091c2423.tar.bz2
Aim wizard and some improvments on the loading of accounts for the aim/icq protocol.
Diffstat (limited to 'src/net/java/sip/communicator/impl/protocol')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/IcqAccountID.java27
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java39
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java14
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java30
-rw-r--r--src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java37
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ContactJabberImpl.java11
6 files changed, 121 insertions, 37 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/IcqAccountID.java b/src/net/java/sip/communicator/impl/protocol/icq/IcqAccountID.java
index ae90447..df7f6a6 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/IcqAccountID.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/IcqAccountID.java
@@ -13,12 +13,37 @@ public class IcqAccountID
extends AccountID
{
/**
+ * Then name of a property which represenstots is this account icq or aim.
+ */
+ public static final String IS_AIM = "IS_AIM";
+
+ /**
* Creates an icq account id from the specified uin and account properties.
+ * If property IS_AIM is set to true then this is an AIM account, else
+ * an Icq one.
* @param uin the uin identifying this account
* @param accountProperties any other properties necessary for the account.
*/
IcqAccountID(String uin, Map accountProperties )
{
- super(uin, accountProperties, ProtocolNames.ICQ, "icq.com");
+ super(uin, accountProperties,
+ isAIM(accountProperties) ? ProtocolNames.AIM : ProtocolNames.ICQ,
+ isAIM(accountProperties) ? "aim.com" : "icq.com");
+ }
+
+ /**
+ * Checks is the provided properties are for icq or aim account
+ * @param accountProperties account properties for the checked account.
+ */
+ static boolean isAIM(Map accountProperties)
+ {
+ Object isAim = accountProperties.get(IS_AIM);
+
+ if(isAim != null &&
+ isAim instanceof String &&
+ ((String)isAim).equalsIgnoreCase("true"))
+ return true;
+ else
+ return false;
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java b/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java
index 21585b7..255ebeb 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/IcqActivator.java
@@ -16,10 +16,12 @@ public class IcqActivator
implements BundleActivator
{
private ServiceRegistration icqPpFactoryServReg = null;
+ private ServiceRegistration aimPpFactoryServReg = null;
private static BundleContext bundleContext = null;
private static ConfigurationService configurationService = null;
private static ProtocolProviderFactoryIcqImpl icqProviderFactory = null;
+ private static ProtocolProviderFactoryIcqImpl aimProviderFactory = null;
/**
* Called when this bundle is started so the Framework can perform the
@@ -34,19 +36,31 @@ public class IcqActivator
public void start(BundleContext context) throws Exception
{
this.bundleContext = context;
- Hashtable hashtable = new Hashtable();
- hashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.ICQ);
+ Hashtable icqHashtable = new Hashtable();
+ icqHashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.ICQ);
+
+ Hashtable aimHashtable = new Hashtable();
+ aimHashtable.put(ProtocolProviderFactory.PROTOCOL, ProtocolNames.AIM);
- icqProviderFactory = new ProtocolProviderFactoryIcqImpl();
+ icqProviderFactory = new ProtocolProviderFactoryIcqImpl(false);
+ aimProviderFactory = new ProtocolProviderFactoryIcqImpl(true);
//load all icq providers
icqProviderFactory.loadStoredAccounts();
+ //load all aim providers
+ aimProviderFactory.loadStoredAccounts();
+
//reg the icq account man.
icqPpFactoryServReg = context.registerService(
ProtocolProviderFactory.class.getName(),
icqProviderFactory,
- hashtable);
+ icqHashtable);
+
+ aimPpFactoryServReg = context.registerService(
+ ProtocolProviderFactory.class.getName(),
+ aimProviderFactory,
+ aimHashtable);
}
/**
@@ -82,16 +96,27 @@ public class IcqActivator
/**
* Retrurns a reference to the protocol provider factory that we have
- * registered.
+ * registered for icq accounts.
* @return a reference to the <tt>ProtocolProviderFactoryIcqImpl</tt>
* instance that we have registered from this package.
*/
- static ProtocolProviderFactoryIcqImpl getProtocolProviderFactory()
+ static ProtocolProviderFactoryIcqImpl getIcqProtocolProviderFactory()
{
return icqProviderFactory;
}
/**
+ * Retrurns a reference to the protocol provider factory that we have
+ * registered for aim accounts.
+ * @return a reference to the <tt>ProtocolProviderFactoryIcqImpl</tt>
+ * instance that we have registered from this package.
+ */
+ static ProtocolProviderFactoryIcqImpl getAimProtocolProviderFactory()
+ {
+ return aimProviderFactory;
+ }
+
+ /**
* Called when this bundle is stopped so the Framework can perform the
* bundle-specific activities necessary to stop the bundle.
*
@@ -105,5 +130,7 @@ public class IcqActivator
{
icqProviderFactory.stop();
icqPpFactoryServReg.unregister();
+
+ aimPpFactoryServReg.unregister();
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java
index e0406be..845adb7 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java
@@ -323,11 +323,7 @@ public class OperationSetPersistentPresenceIcqImpl
// Fixed order of status checking
// The order does matter, as the icqStatus consists of more than one
// status for example DND = OCCUPIED | DND | AWAY
- if (icqStatus == -1)
- {
- return IcqStatusEnum.OFFLINE;
- }
- else if ( (icqStatus & FullUserInfo.ICQSTATUS_INVISIBLE ) != 0)
+ if ( (icqStatus & FullUserInfo.ICQSTATUS_INVISIBLE ) != 0)
{
return IcqStatusEnum.INVISIBLE;
}
@@ -1358,13 +1354,19 @@ public class OperationSetPersistentPresenceIcqImpl
if(presenceQueryTimer == null)
presenceQueryTimer = new Timer();
else
+ {
+ // cancel any previous jobs and create new timer
presenceQueryTimer.cancel();
+ presenceQueryTimer = new Timer();
+ }
AwaitingAuthorizationContactsPresenceTimer
queryTask = new AwaitingAuthorizationContactsPresenceTimer();
+ // start after 15 seconds. wait for login to be completed and
+ // list and statuses to be gathered
presenceQueryTimer.scheduleAtFixedRate(
- queryTask, PRESENCE_QUERY_INTERVAL, PRESENCE_QUERY_INTERVAL);
+ queryTask, 15000, PRESENCE_QUERY_INTERVAL);
}
}
else if(evt.getNewState() == RegistrationState.UNREGISTERED
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java
index 84b9f40..2391b1b 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderFactoryIcqImpl.java
@@ -27,12 +27,19 @@ public class ProtocolProviderFactoryIcqImpl
* The table that we store our accounts in.
*/
private Hashtable registeredAccounts = new Hashtable();
+
+ /**
+ * Is this factory is created for aim or icq accounts
+ */
+ private boolean isAimFactory = false;
/**
* Creates an instance of the ProtocolProviderFactoryIcqImpl.
+ * @param isAimFactory whether its an aim factory
*/
- protected ProtocolProviderFactoryIcqImpl()
+ protected ProtocolProviderFactoryIcqImpl(boolean isAimFactory)
{
+ this.isAimFactory = isAimFactory;
}
/**
@@ -93,6 +100,10 @@ public class ProtocolProviderFactoryIcqImpl
if (accountProperties == null)
throw new NullPointerException("The specified property map was null");
+ // we are installing new aim account from the wizzard, so mark it as aim
+ if(isAimFactory)
+ accountProperties.put(IcqAccountID.IS_AIM, "true");
+
AccountID accountID = new IcqAccountID(userIDStr, accountProperties);
//make sure we haven't seen this account id before.
@@ -129,6 +140,13 @@ public class ProtocolProviderFactoryIcqImpl
if(context == null)
throw new NullPointerException("The specified BundleContext was null");
+ // there are two factories - one for icq accounts and one for aim ones.
+ // if we are trying to load an icq account in aim factory - skip it
+ // and the same for aim accounts in icq factory
+ if((IcqAccountID.isAIM(accountProperties) && !isAimFactory) ||
+ (!IcqAccountID.isAIM(accountProperties) && isAimFactory))
+ return null;
+
String userIDStr = (String)accountProperties.get(USER_ID);
AccountID accountID = new IcqAccountID(userIDStr, accountProperties);
@@ -136,15 +154,15 @@ public class ProtocolProviderFactoryIcqImpl
//get a reference to the configuration service and register whatever
//properties we have in it.
- Hashtable properties = new Hashtable();
- properties.put(PROTOCOL, ProtocolNames.ICQ);
- properties.put(USER_ID, userIDStr);
-
ProtocolProviderServiceIcqImpl icqProtocolProvider
= new ProtocolProviderServiceIcqImpl();
icqProtocolProvider.initialize(userIDStr, accountID);
-
+
+ Hashtable properties = new Hashtable();
+ properties.put(PROTOCOL, icqProtocolProvider.getProtocolName());
+ properties.put(USER_ID, userIDStr);
+
ServiceRegistration registration
= context.registerService( ProtocolProviderService.class.getName(),
icqProtocolProvider,
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
index d140a98..54122a3 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java
@@ -202,9 +202,15 @@ public class ProtocolProviderServiceIcqImpl
synchronized(initializationLock)
{
+ ProtocolProviderFactoryIcqImpl protocolProviderFactory = null;
+
+ if(USING_ICQ)
+ protocolProviderFactory = IcqActivator.getIcqProtocolProviderFactory();
+ else
+ protocolProviderFactory = IcqActivator.getAimProtocolProviderFactory();
+
//verify whether a password has already been stored for this account
- String password = IcqActivator.getProtocolProviderFactory()
- .loadPassword(getAccountID());
+ String password = protocolProviderFactory.loadPassword(getAccountID());
//decode
if( password == null )
@@ -214,7 +220,7 @@ public class ProtocolProviderServiceIcqImpl
credentials.setUserName(this.getAccountID().getUserID());
//request a password from the user
- credentials = authority.obtainCredentials(ProtocolNames.ICQ
+ credentials = authority.obtainCredentials(getProtocolName()
, credentials);
//extract the password the user passed us.
char[] pass = credentials.getPassword();
@@ -233,7 +239,7 @@ public class ProtocolProviderServiceIcqImpl
if (credentials.isPasswordPersistent())
{
- IcqActivator.getProtocolProviderFactory()
+ protocolProviderFactory
.storePassword(getAccountID(), password);
}
}
@@ -337,7 +343,10 @@ public class ProtocolProviderServiceIcqImpl
*/
public String getProtocolName()
{
- return ProtocolNames.ICQ;
+ if(USING_ICQ)
+ return ProtocolNames.ICQ;
+ else
+ return ProtocolNames.AIM;
}
/**
@@ -387,14 +396,8 @@ public class ProtocolProviderServiceIcqImpl
{
this.accountID = accountID;
- try
- {
- Long.parseLong(accountID.getUserID());
- } catch (NumberFormatException ex)
- {
- // if its icq its number can be parsed
- USING_ICQ = false;
- }
+ if(IcqAccountID.isAIM(accountID.getAccountProperties()))
+ USING_ICQ = false;
//initialize the presence operationset
OperationSetPersistentPresence persistentPresence =
@@ -726,8 +729,12 @@ public class ProtocolProviderServiceIcqImpl
if(reasonCode == RegistrationStateChangeEvent
.REASON_AUTHENTICATION_FAILED)
{
- IcqActivator.getProtocolProviderFactory().storePassword(
- getAccountID(), null);
+ if(USING_ICQ)
+ IcqActivator.getIcqProtocolProviderFactory().storePassword(
+ getAccountID(), null);
+ else
+ IcqActivator.getAimProtocolProviderFactory().storePassword(
+ getAccountID(), null);
}
//now tell all interested parties about what happened.
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ContactJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ContactJabberImpl.java
index 00bcf1f..beaf056 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ContactJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ContactJabberImpl.java
@@ -297,9 +297,15 @@ public class ContactJabberImpl
{
try
{
+ XMPPConnection connection =
+ ssclCallback.getParentProvider().getConnection();
+
+ if(connection == null || !connection.isAuthenticated())
+ return null;
+
VCard card = new VCard();
card.load(
- ssclCallback.getParentProvider().getConnection(),
+ connection,
getAddress());
return card.getAvatar();
@@ -313,5 +319,4 @@ public class ContactJabberImpl
return null;
}
-
-}
+} \ No newline at end of file