Fix NPE in Google Contacts service. Redesign Jabber account contact source activation: do all in Google Contacts service. Fix name in Mac OS X Dock when Jitsi is run from the sources.

cusax-fix
Sebastien Vincent 15 years ago
parent 3c582f1102
commit f66ae33f62

@ -716,7 +716,7 @@
<!-- SIP Communicator on Mac OS X uses a JVMTI agent to handle kAEGetURL
AppleScript events. -->
<condition property="jvmarg.line"
value="-agentlib:AEGetURLEventHandlerAgent -Xdock:name='SIP Communicator' -Xdock:icon='resources/images/logo/sc_logo_128x128.icns'"
value="-agentlib:AEGetURLEventHandlerAgent -Xdock:name='Jitsi' -Xdock:icon='resources/images/logo/sc_logo_128x128.icns'"
else="">
<isset property="is.running.macos"/>
</condition>

@ -60,11 +60,11 @@ felix.auto.start.45= \
reference:file:sc-bundles/branding.jar \
reference:file:sc-bundles/provdisc-dhcp.jar \
reference:file:sc-bundles/provdisc-mdns.jar \
reference:file:sc-bundles/googlecontacts.jar \
reference:file:sc-bundles/certificate.jar
felix.auto.start.49= \
reference:file:sc-bundles/provisioning.jar \
reference:file:sc-bundles/googlecontacts.jar \
reference:file:sc-bundles/bouncycastle.jar \
reference:file:sc-bundles/zrtp4j.jar \
reference:file:sc-bundles/protocol.jar \

@ -208,10 +208,92 @@ public void start(BundleContext bundleContext)
2000, true),
properties);
bundleContext.addServiceListener(new ServiceListener()
{
public void serviceChanged(ServiceEvent serviceEvent)
{
GoogleContactsActivator.this.serviceChanged(serviceEvent);
}
});
if (logger.isDebugEnabled())
logger.debug("Google Contacts Service ... [REGISTERED]");
}
/**
* Implements the <tt>ServiceListener</tt> method. Verifies whether the
* passed event concerns a <tt>ProtocolProviderService</tt> and adds the
* corresponding UI controls.
*
* @param event The <tt>ServiceEvent</tt> object.
*/
private void serviceChanged(ServiceEvent event)
{
ServiceReference serviceRef = event.getServiceReference();
// if the event is caused by a bundle being stopped, we don't want to
// know
if (serviceRef.getBundle().getState() == Bundle.STOPPING)
{
return;
}
Object service = bundleContext.getService(serviceRef);
// we don't care if the source service is not a protocol provider
if (!(service instanceof ProtocolProviderService))
{
return;
}
// we don't care if the protocol provider is not a Jabber ones
if(((ProtocolProviderService)service).getProtocolName() !=
ProtocolNames.JABBER)
{
return;
}
switch (event.getType())
{
case ServiceEvent.REGISTERED:
this.handleProviderAdded((ProtocolProviderService) service);
break;
case ServiceEvent.UNREGISTERING:
this.handleProviderRemoved((ProtocolProviderService) service);
break;
}
}
/**
* Notifies this manager that a specific
* <tt>ProtocolProviderService</tt> has been registered as a service.
*
* @param provider the <tt>ProtocolProviderService</tt> which has been
* registered as a service.
*/
private void handleProviderAdded(ProtocolProviderService provider)
{
String className = provider.getClass().getName();
className = className.substring(0, className.lastIndexOf('.'));
String acc = ProtocolProviderFactory.findAccountPrefix(
bundleContext, provider.getAccountID(), className);
String password = getCredentialsService().loadPassword(acc);
enableContactSource(provider.getAccountID().getAccountAddress(),
password);
}
/**
* Notifies this manager that a specific
* <tt>ProtocolProviderService</tt> has been unregistered as a service.
*
* @param provider the <tt>ProtocolProviderService</tt> which has been
* unregistered as a service.
*/
private void handleProviderRemoved(ProtocolProviderService provider)
{
disableContactSource(provider.getAccountID().getAccountAddress());
}
/**
* Stops the Google Contacts service.
*
@ -373,9 +455,17 @@ public static void disableContactSource(GoogleContactsConnection cnx)
for(Map.Entry<GoogleContactsSourceService, ServiceRegistration> entry :
cssList.entrySet())
{
String cssName =
entry.getKey().getConnection().getLogin();
GoogleContactsConnection cnxEntry = entry.getKey().getConnection();
if(cnx == null)
{
found = entry.getKey();
break;
}
String cssName = cnxEntry.getLogin();
String name = cnx.getLogin();
if(cssName.equals(name))
{
try

@ -22,12 +22,12 @@ public class GoogleContactsConnectionImpl
/**
* Login.
*/
private final String login;
private String login = null;
/**
* Password.
*/
private final String password;
private String password = null;
/**
* If the connection is enabled.
@ -83,6 +83,26 @@ public String getPassword()
return password;
}
/**
* Set login.
*
* @param login login to connect to the service
*/
public void setLogin(String login)
{
this.login = login;
}
/**
* Set password.
*
* @param password password to connect to the service
*/
public void setPassword(String password)
{
this.password = password;
}
/**
* Initialize connection.
*

@ -382,6 +382,10 @@ else if(mail.getRel().contains("#work"))
for(PhoneNumber phone : contact.getPhoneNumbers())
{
if(phone.getRel() == null)
{
homePhones.add(phone.getPhoneNumber());
}
if(phone.getRel().contains("#work"))
{
workPhones.add(phone.getPhoneNumber());

@ -179,11 +179,13 @@ public void loadData(GoogleContactsConnection cnx)
{
this.nameField.setText(cnx.getLogin());
this.passwordField.setText(cnx.getPassword());
this.cnx = cnx;
}
else
{
this.nameField.setText("");
this.passwordField.setText("");
this.cnx = null;
}
}
@ -201,8 +203,16 @@ public void actionPerformed(ActionEvent e)
String login = nameField.getText();
String password = new String(passwordField.getPassword());
if(cnx == null)
{
cnx = GoogleContactsActivator.getGoogleContactsService().
getConnection(login, password);
}
else
{
cnx.setLogin(login);
cnx.setPassword(password);
}
if(!cnx.connect())
{
@ -261,7 +271,6 @@ public int showDialog()
{
retCode = 0;
cnx = null;
setVisible(true);
// this will block until user click on save/cancel/press escape/close

@ -237,13 +237,19 @@ public void actionPerformed(ActionEvent e)
if (e.getActionCommand().equals("modify") && row != -1)
{
settingsForm.setNameFieldEnabled(false);
GoogleContactsConnection cnx = tableModel.getAccountAt(row);
GoogleContactsConnectionImpl cnx = tableModel.getAccountAt(row);
settingsForm.loadData(cnx);
int ret = settingsForm.showDialog();
if(ret == 1)
{
GoogleContactsActivator.getGoogleContactsService().saveConfig(
cnx);
if(cnx.isEnabled())
{
new RefreshContactSourceThread(cnx, cnx).start();
}
refresh();
}
}

@ -22,7 +22,6 @@
import net.java.sip.communicator.impl.protocol.jabber.extensions.inputevt.*;
import net.java.sip.communicator.impl.protocol.jabber.sasl.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.googlecontacts.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.*;
@ -1258,9 +1257,6 @@ protected void initialize(String screenname,
OperationSetGenericNotifications.class,
new OperationSetGenericNotificationsJabberImpl(this));
/* add Google Contacts as contact source if enabled */
registerGoogleContactsSource();
isInitialized = true;
}
}
@ -1277,8 +1273,6 @@ public void shutdown()
if (logger.isTraceEnabled())
logger.trace("Killing the Jabber Protocol Provider.");
unregisterGoogleContactsSource();
//kill all active calls
OperationSetBasicTelephonyJabberImpl telephony
= (OperationSetBasicTelephonyJabberImpl)getOperationSet(
@ -1847,7 +1841,8 @@ public void startJingleNodesDiscovery()
{
// Jingle Nodes Service Initialization
JabberAccountID accID = (JabberAccountID)getAccountID();
final SmackServiceNode service = new SmackServiceNode(connection, 60000);
final SmackServiceNode service = new SmackServiceNode(connection,
60000);
for(JingleNodeDescriptor desc : accID.getJingleNodes())
{
@ -1902,56 +1897,6 @@ public SmackServiceNode getJingleNodesServiceNode()
return jingleNodesServiceNode;
}
/**
* Register Google Contacts as contact source if user has enable it.
*/
private void registerGoogleContactsSource()
{
if(accountID.getAccountPropertyBoolean(
"GOOGLE_CONTACTS_ENABLED",
true))
{
logger.info("Register Google Contacts service as contact source");
GoogleContactsService googleService =
JabberActivator.getGoogleService();
if(googleService != null)
{
googleService.addContactSource(
org.jivesoftware.smack.util.StringUtils.parseName(
getOurJID()) + "@" +
StringUtils.parseServer(getAccountID().getUserID()),
JabberActivator.
getProtocolProviderFactory().loadPassword(
getAccountID()));
}
}
}
/**
* Unregister Google Contacts as contact source.
*/
private void unregisterGoogleContactsSource()
{
if(accountID.getAccountPropertyBoolean(
"GOOGLE_CONTACTS_ENABLED",
true))
{
logger.info("Unregister Google Contacts service as contact source");
GoogleContactsService googleService =
JabberActivator.getGoogleService();
if(googleService != null)
{
googleService.removeContactSource(
org.jivesoftware.smack.util.StringUtils.parseName(
getOurJID()) + "@" +
StringUtils.parseServer(getAccountID().getUserID()));
}
}
}
/**
* Logs a specific message and associated <tt>Throwable</tt> cause as an
* error using the current <tt>Logger</tt> and then throws a new

@ -48,7 +48,6 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.argdelegation,
net.java.sip.communicator.service.certificate,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.googlecontacts,
org.xmlpull.v1,
org.xmlpull.mxp1,
javax.xml.parsers,

@ -21,12 +21,26 @@ public interface GoogleContactsConnection
public String getLogin();
/**
* get password.
* Get password.
*
* @return password to connect to the service
*/
public String getPassword();
/**
* Set login.
*
* @param login login to connect to the service
*/
public void setLogin(String login);
/**
* Set password.
*
* @param password password to connect to the service
*/
public void setPassword(String password);
/**
* Initialize connection.
*

@ -28,18 +28,18 @@ public class ProviderStatusChangeEvent extends PropertyChangeEvent
* <tt>newValue</tt>.
* @param source the provider that generated the event
* @param eventType the type of the newly created event.
* @param oldValue the status the source provider was int before enetering
* @param oldValue the status the source provider was int before entering
* the new state.
* @param newValue the status the source provider is currently in.
*/
public ProviderStatusChangeEvent(ProtocolProviderService source, String eventType,
PresenceStatus oldValue, PresenceStatus newValue)
public ProviderStatusChangeEvent(ProtocolProviderService source,
String eventType, PresenceStatus oldValue, PresenceStatus newValue)
{
super(source, eventType, oldValue, newValue);
}
/**
* Returns the provider that has genereted this event
* Returns the provider that has generated this event
* @return the provider that generated the event.
*/
public ProtocolProviderService getProvider()

Loading…
Cancel
Save