Initializes additional message extensions/services in separate thread to avoid blocking provider startup.

deb-src-release-2.8.5426
Damian Minkov 12 years ago
parent 77e622416b
commit f22bdef853

@ -472,7 +472,7 @@ private MessageDeliveredEvent sendMessage( Contact to,
// msg.addExtension(new Version());
if (event.isMessageEncrypted())
if (event.isMessageEncrypted() && isCarbonEnabled)
{
msg.addExtension(new CarbonPacketExtension.PrivateExtension());
}
@ -626,31 +626,14 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
}
else if (evt.getNewState() == RegistrationState.REGISTERED)
{
//subscribe for Google (Gmail or Google Apps) notifications
//for new mail messages.
boolean enableGmailNotifications
= jabberProvider
.getAccountID()
.getAccountPropertyBoolean(
"GMAIL_NOTIFICATIONS_ENABLED",
false);
if (enableGmailNotifications)
subscribeForGmailNotifications();
boolean enableCarbon
= isCarbonSupported() && !jabberProvider.getAccountID()
.getAccountPropertyBoolean(
ProtocolProviderFactory.IS_CARBON_DISABLED,
false);
if(enableCarbon)
new Thread(new Runnable()
{
enableDisableCarbon(true);
}
else
{
isCarbonEnabled = false;
}
@Override
public void run()
{
initAdditionalServices();
}
}).start();
}
else if(evt.getNewState() == RegistrationState.UNREGISTERED
|| evt.getNewState() == RegistrationState.CONNECTION_FAILED
@ -666,9 +649,40 @@ else if(evt.getNewState() == RegistrationState.UNREGISTERED
smackMessageListener = null;
}
}
}
/**
* Initialize additional services, like gmail notifications and message
* carbons.
*/
private void initAdditionalServices()
{
//subscribe for Google (Gmail or Google Apps) notifications
//for new mail messages.
boolean enableGmailNotifications
= jabberProvider
.getAccountID()
.getAccountPropertyBoolean(
"GMAIL_NOTIFICATIONS_ENABLED",
false);
if (enableGmailNotifications)
subscribeForGmailNotifications();
boolean enableCarbon
= isCarbonSupported() && !jabberProvider.getAccountID()
.getAccountPropertyBoolean(
ProtocolProviderFactory.IS_CARBON_DISABLED,
false);
if(enableCarbon)
{
enableDisableCarbon(true);
}
else
{
isCarbonEnabled = false;
}
}
/**
* Sends enable or disable carbon packet to the server.
@ -730,7 +744,6 @@ else if (!(response instanceof IQ)
{
isCarbonEnabled = true;
}
}
/**
@ -748,7 +761,7 @@ private boolean isCarbonSupported()
}
catch (XMPPException e)
{
logger.error("Failed to retrieve carbon support.",e);
logger.warn("Failed to retrieve carbon support." + e.getMessage());
}
return false;
}

Loading…
Cancel
Save