When having an unknown contact/number in the search field pressing "Enter" would try to call this contact/number through the most connected telephony provider. On the contrary if we have any results for the search, "Enter" would open a chat window for the first selected contact in the contact list.

cusax-fix
Yana Stamcheva 16 years ago
parent 526d26f0b2
commit f65867e8ca

@ -201,6 +201,59 @@ public static void createCall( ProtocolProviderService protocolProvider,
new CreateCallThread(protocolProvider, contact).start();
}
/**
* Creates a call to the contact represented by the given string through the
* default (most connected) protocol provider. If none of the providers is
* registered or online does nothing.
*
* @param contact the contact to call to
*/
public static void createCall(String contact)
{
ProtocolProviderService telProvider = null;
int status = 0;
Vector<ProtocolProviderService> telProviders = getTelephonyProviders();
for (ProtocolProviderService provider : telProviders)
{
if (!provider.isRegistered())
continue;
OperationSetPresence presence
= provider.getOperationSet(OperationSetPresence.class);
int presenceStatus
= (presence == null)
? PresenceStatus.AVAILABLE_THRESHOLD
: presence.getPresenceStatus().getStatus();
if (status < presenceStatus)
{
status = presenceStatus;
telProvider = provider;
}
}
if (status >= PresenceStatus.ONLINE_THRESHOLD)
new CreateCallThread(telProvider, contact).start();
else
{
logger.error("There's no online telephony"
+ " provider to create this call.");
new ErrorDialog(
null,
GuiActivator.getResources()
.getI18NString("service.gui.WARNING"),
GuiActivator.getResources()
.getI18NString(
"service.gui.NO_ONLINE_TELEPHONY_ACCOUNT"),
ErrorDialog.WARNING)
.showDialog();
}
}
/**
* Creates a call to the given list of contacts.
*

@ -8,6 +8,7 @@
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.call.*;
import net.java.sip.communicator.util.swing.*;
import net.java.sip.communicator.util.swing.plaf.*;
@ -66,8 +67,11 @@ public void actionPerformed(ActionEvent e)
{
public void actionPerformed(ActionEvent e)
{
// Starts a chat with the currently selected contact.
GuiActivator.getContactList().startSelectedContactChat();
if (!lastHasMatching)
CallManager.createCall(getText());
else
// Starts a chat with the currently selected contact.
GuiActivator.getContactList().startSelectedContactChat();
}
});
}

Loading…
Cancel
Save