diff options
author | Yana Stamcheva <yana@jitsi.org> | 2012-10-15 09:52:10 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2012-10-15 09:52:10 +0000 |
commit | a4e0f832c14a4b5a8e6d67812ed3a7d1d11dd841 (patch) | |
tree | a82e61f71a4471119310f610a62ccdfcab6fbea9 | |
parent | 276d33addb32061b018fd1c5d4a6bf5671c6cde6 (diff) | |
download | jitsi-a4e0f832c14a4b5a8e6d67812ed3a7d1d11dd841.zip jitsi-a4e0f832c14a4b5a8e6d67812ed3a7d1d11dd841.tar.gz jitsi-a4e0f832c14a4b5a8e6d67812ed3a7d1d11dd841.tar.bz2 |
Shows all telephone numbers and different addresses as separate entries in conference and transfer invite dialogs.
Removes invite reason from conference invite dialog.
7 files changed, 322 insertions, 12 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java index 5210cf2..af176d6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/TransferCallDialog.java @@ -8,10 +8,12 @@ package net.java.sip.communicator.impl.gui.main.call; import java.awt.*;
import java.awt.event.*;
+import java.util.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.contactlist.contactsource.*;
import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.service.contactsource.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
@@ -83,6 +85,21 @@ public class TransferCallDialog */
private void initContactListData(ProtocolProviderService protocolProvider)
{
+ Iterator<UIContactSource> sourcesIter
+ = new ArrayList<UIContactSource>(
+ contactList.getContactSources()).iterator();
+
+ contactList.removeAllContactSources();
+
+ while (sourcesIter.hasNext())
+ {
+ ContactSourceService contactSource
+ = sourcesIter.next().getContactSourceService();
+
+ contactList.addContactSource(
+ new DemuxContactSource(contactSource));
+ }
+
contactList.addContactSource(
new ProtocolContactSourceServiceImpl(
protocolProvider, OperationSetBasicTelephony.class));
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java index cf39a2b..c9ce15b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/ConferenceInviteDialog.java @@ -74,7 +74,7 @@ public class ConferenceInviteDialog public ConferenceInviteDialog(CallConference conference) { super(GuiActivator.getResources() - .getI18NString("service.gui.INVITE_CONTACT_TO_CALL")); + .getI18NString("service.gui.INVITE_CONTACT_TO_CALL"), false); this.conference = conference; @@ -259,6 +259,21 @@ public class ConferenceInviteDialog srcContactList.removeContactSource(currentProviderContactSource); srcContactList.removeContactSource(currentStringContactSource); + Iterator<UIContactSource> sourcesIter + = new ArrayList<UIContactSource>( + srcContactList.getContactSources()).iterator(); + + srcContactList.removeAllContactSources(); + + while (sourcesIter.hasNext()) + { + ContactSourceService contactSource + = sourcesIter.next().getContactSourceService(); + + srcContactList.addContactSource( + new DemuxContactSource(contactSource)); + } + currentProviderContactSource = new ProtocolContactSourceServiceImpl( protocolProvider, diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatInviteDialog.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatInviteDialog.java index ac5996d..3d14491 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatInviteDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatInviteDialog.java @@ -38,7 +38,7 @@ public class ChatInviteDialog public ChatInviteDialog (ChatPanel chatPanel) { super(GuiActivator.getResources() - .getI18NString("service.gui.INVITE_CONTACT_TO_CHAT")); + .getI18NString("service.gui.INVITE_CONTACT_TO_CHAT"), true); this.chatPanel = chatPanel; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFilter.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFilter.java index 2287618..b345b93 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFilter.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SearchFilter.java @@ -125,7 +125,7 @@ public class SearchFilter * filter to * @return the <tt>ContactQuery</tt> that tracks this filter */ - public ContactQuery applyFilter(UIContactSource contactSource) + protected ContactQuery applyFilter(UIContactSource contactSource) { ContactSourceService sourceService = contactSource.getContactSourceService(); @@ -233,7 +233,7 @@ public class SearchFilter * Adds the list of <tt>sourceContacts</tt> to the contact list. * @param sourceContacts the list of <tt>SourceContact</tt>s to add */ - private void addMatching(List<SourceContact> sourceContacts) + protected void addMatching(List<SourceContact> sourceContacts) { Iterator<SourceContact> contactsIter = sourceContacts.iterator(); diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java new file mode 100644 index 0000000..8c1d3e9 --- /dev/null +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/DemuxContactSource.java @@ -0,0 +1,272 @@ +/* + * 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.gui.main.contactlist.contactsource; + +import java.util.*; +import java.util.regex.*; + +import net.java.sip.communicator.service.contactsource.*; + +/** + * The <tt>DemuxContactSource</tt> is a contact source that takes as parameter + * another <tt>ContactSourceService</tt> and provides a demultiplexed result. + * Every contact detail like telephone number or protocol contact address is + * represented as a single entry in the query result. + * + * @author Yana Stamcheva + */ +public class DemuxContactSource + implements ContactSourceService +{ + /** + * The underlying contact source service. + */ + private final ContactSourceService contactSource; + + /** + * Create an instance of <tt>DemuxContactSource</tt> by specifying the + * underlying <tt>ContactSourceService</tt> to be demuxed. + * + * @param contactSource the underlying <tt>ContactSourceService</tt> to be + * demuxed + */ + public DemuxContactSource(ContactSourceService contactSource) + { + this.contactSource = contactSource; + } + + /** + * Returns the type of the underlying contact source. + * + * @return the type of this contact source + */ + public int getType() + { + return contactSource.getType(); + } + + /** + * Returns a user-friendly string that identifies the underlying contact + * source. + * + * @return the display name of this contact source + */ + public String getDisplayName() + { + return contactSource.getDisplayName(); + } + + /** + * Queries this search source for the given <tt>queryString</tt>. + * + * @param queryString the string to search for + * @return the created query + */ + public ContactQuery queryContactSource(String queryString) + { + if (contactSource instanceof ExtendedContactSourceService) + return new DemuxContactQuery( + ((ExtendedContactSourceService) contactSource) + .queryContactSource(Pattern.compile( + Pattern.quote(queryString), + Pattern.MULTILINE + | Pattern.CASE_INSENSITIVE + | Pattern.UNICODE_CASE))); + else + return new DemuxContactQuery( + contactSource.queryContactSource(queryString)); + } + + /** + * Queries this search source for the given <tt>queryString</tt>. + * + * @param queryString the string to search for + * @param contactCount the maximum count of result contacts + * @return the created query + */ + public ContactQuery queryContactSource(String queryString, int contactCount) + { + return new DemuxContactQuery( + contactSource.queryContactSource(queryString, contactCount)); + } + + /** + * Returns the index of the contact source in the result list. + * + * @return the index of the contact source in the result list + */ + public int getIndex() + { + return contactSource.getIndex(); + } + + /** + * The <tt>DemuxContactQuery</tt> takes a <tt>ContactQuery</tt> as a + * parameter and provides a demultiplexed result. Every contact detail like + * telephone number or protocol contact address is represented as a + * separate entry in the query result. + */ + private class DemuxContactQuery + extends AbstractContactQuery<ContactSourceService> + implements ContactQueryListener + { + /** + * The underlying query. + */ + private final ContactQuery sourceQuery; + + /** + * Creates an instance of <tt>DemuxContactQuery</tt>. + * + * @param sourceQuery the source <tt>ContactQuery</tt> + */ + public DemuxContactQuery(ContactQuery sourceQuery) + { + super(DemuxContactSource.this); + + this.sourceQuery = sourceQuery; + + sourceQuery.addContactQueryListener(this); + } + + /** + * Gets the <tt>ContactSourceService</tt> which is performing this + * <tt>ContactQuery</tt>. + * + * @return the <tt>ContactSourceService</tt> which is performing this + * <tt>ContactQuery</tt> + * @see ContactQuery#getContactSource() + */ + public ContactSourceService getContactSource() + { + return DemuxContactSource.this; + } + + /** + * Returns the query string, this query was created for. + * + * @return the query string, this query was created for + */ + public String getQueryString() + { + return sourceQuery.getQueryString(); + } + + /** + * Returns the list of <tt>SourceContact</tt>s returned by this query. + * + * @return the list of <tt>SourceContact</tt>s returned by this query + */ + public List<SourceContact> getQueryResults() + { + List<SourceContact> sourceContacts = sourceQuery.getQueryResults(); + + if (sourceContacts == null) + return null; + + List<SourceContact> newSourceContacts + = new ArrayList<SourceContact>(); + + Iterator<SourceContact> contactIter = sourceContacts.iterator(); + while (contactIter.hasNext()) + { + SourceContact sourceContact = contactIter.next(); + + Iterator<ContactDetail> detailsIter + = sourceContact.getContactDetails().iterator(); + + while (detailsIter.hasNext()) + { + ContactDetail detail = detailsIter.next(); + newSourceContacts.add( + createSourceContact(sourceContact, + detail)); + } + } + + return newSourceContacts; + } + + public void cancel() + { + sourceQuery.cancel(); + } + + /** + * Returns the status of this query. One of the static constants + * QUERY_XXXX defined in this class. + * + * @return the status of this query + */ + public int getStatus() + { + return sourceQuery.getStatus(); + } + + /** + * Indicates that a new contact has been received for a search. + * + * @param event the <tt>ContactQueryEvent</tt> containing information + * about the received <tt>SourceContact</tt> + */ + public void contactReceived(ContactReceivedEvent event) + { + SourceContact sourceContact = event.getContact(); + + Iterator<ContactDetail> detailsIter + = sourceContact.getContactDetails().iterator(); + + while (detailsIter.hasNext()) + { + ContactDetail detail = detailsIter.next(); + + fireContactReceived( + createSourceContact(sourceContact, detail)); + } + } + + /** + * Creates a single contact from the given <tt>sourceContact</tt> and + * <tt>contactDetail</tt>. + * + * @param sourceContact the source contact + * @param contactDetail the source contact detail + * @return the created contact + */ + private SourceContact createSourceContact( SourceContact sourceContact, + ContactDetail contactDetail) + { + List<ContactDetail> contactDetails = new ArrayList<ContactDetail>(); + + contactDetails.add(contactDetail); + + GenericSourceContact genericContact + = new GenericSourceContact( DemuxContactSource.this, + sourceContact.getDisplayName(), + contactDetails); + + genericContact.setDisplayDetails(contactDetail.getContactAddress()); + + return genericContact; + } + + /** + * Indicates that the status of a search has been changed. + * + * @param event the <tt>ContactQueryStatusEvent</tt> containing + * information about the status change + */ + public void queryStatusChanged(ContactQueryStatusEvent event) + { + fireQueryStatusChanged(event.getEventType()); + } + + public void contactRemoved(ContactRemovedEvent event) {} + + public void contactChanged(ContactChangedEvent event) {} + } +}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java index 77624d0..bc793e4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ProtocolContactSourceServiceImpl.java @@ -15,7 +15,8 @@ import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.protocol.*; /** - * + * The <tt>ProtocolContactSourceServiceImpl</tt> + * * @author Yana Stamcheva */ public class ProtocolContactSourceServiceImpl diff --git a/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java b/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java index 5b62ed1..f598c9c 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java +++ b/src/net/java/sip/communicator/impl/gui/utils/InviteDialog.java @@ -87,7 +87,7 @@ public class InviteDialog * * @param title the title to show on the top of this dialog */ - public InviteDialog (String title) + public InviteDialog (String title, boolean enableReason) { this.setModal(false); @@ -104,10 +104,6 @@ public class InviteDialog mainPanel.setBorder( BorderFactory.createEmptyBorder(15, 15, 15, 15)); - this.reasonArea.setBorder(BorderFactory.createTitledBorder( - GuiActivator.getResources() - .getI18NString("service.gui.INVITE_REASON"))); - JTextArea infoTextArea = new JTextArea(); infoTextArea.setText(GuiActivator.getResources() @@ -212,10 +208,19 @@ public class InviteDialog centerPanel.add(listPanel, BorderLayout.CENTER); centerPanel.add(addRemoveButtonsPanel, BorderLayout.SOUTH); - TransparentPanel southPanel = new TransparentPanel(new BorderLayout()); - southPanel.add(reasonArea, BorderLayout.CENTER); + TransparentPanel southPanel + = new TransparentPanel(new BorderLayout()); southPanel.add(buttonsPanel, BorderLayout.SOUTH); + if (enableReason) + { + this.reasonArea.setBorder(BorderFactory.createTitledBorder( + GuiActivator.getResources() + .getI18NString("service.gui.INVITE_REASON"))); + + southPanel.add(reasonArea, BorderLayout.CENTER); + } + mainPanel.add(northPanel, BorderLayout.NORTH); mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); |