Renames occurrences of callParticipant to callPeer so that it would better reflect our new Call architecture that also includes conferencing and ConferenceMembers

cusax-fix
Emil Ivov 17 years ago
parent 8244fb31f9
commit 224f3da2ca

@ -90,6 +90,13 @@ public class OperationSetBasicInstantMessagingJabberImpl
*/
private static final String CLOSE_BODY_TAG = "</body>";
/**
* Contains the time of the last mail result set that we've received from
* the server. We use this time when sending new queries to the server so
* that it won't return messages that we've already shown to our user.
*/
private long lastResultTime = -1;
/**
* Creates an instance of this operation set.
* @param provider a reference to the <tt>ProtocolProviderServiceImpl</tt>
@ -639,26 +646,23 @@ public boolean accept(Packet packet)
*/
private void subscribeForGmailNotifications()
{
//------listerner mail
try
{
// first check support for the notification service
boolean notificationsAreSupported = ServiceDiscoveryManager
.getInstanceFor(jabberProvider.getConnection())
.includesFeature(NewMailNotification.NAMESPACE);
// first check support for the notification service
boolean notificationsAreSupported = ServiceDiscoveryManager
.getInstanceFor(jabberProvider.getConnection())
.includesFeature(NewMailNotificationIQ.NAMESPACE);
if (!notificationsAreSupported)
return;
if (!notificationsAreSupported)
return;
ProviderManager providerManager = ProviderManager.getInstance();
providerManager.addIQProvider(
Mailbox.ELEMENT_NAME, Mailbox.NAMESPACE, new MailboxProvider());
ProviderManager providerManager = ProviderManager.getInstance();
providerManager.addIQProvider(
MailboxIQ.ELEMENT_NAME, MailboxIQ.NAMESPACE, new MailboxIQProvider());
providerManager.addIQProvider(
NewMailNotification.ELEMENT_NAME, NewMailNotification.NAMESPACE,
NewMailNotificationIQ.ELEMENT_NAME, NewMailNotificationIQ.NAMESPACE,
new NewMailNotificationProvider());
jabberProvider.getConnection().addPacketListener(
new MailNotificationListener(),
new MailboxListener(),
new PacketTypeFilter(
IQ.class));
@ -678,61 +682,44 @@ private void subscribeForGmailNotifications()
+ jabberProvider.getAccountID().getAccountUniqueID());
jabberProvider.getConnection().sendPacket(mailnotification);
}
catch (XMPPException ex)
{
logger.warn("could not retrieve info for "+
jabberProvider.getAccountID().getAccountAddress(),
ex);
}
}
/**
* Receives incoming MailNotification Packets
*/
private class MailNotificationListener
private class MailboxListener
implements PacketListener
{
public void processPacket(Packet packet)
{
if(packet != null && !(packet instanceof Mailbox))
if(packet != null && !(packet instanceof MailboxIQ))
return;
Mailbox mailbox = (Mailbox) packet;
MailboxIQ mailbox = (MailboxIQ) packet;
//check if the date of the most recent mail is the same as that
//of the previous packet. If the last mail is the most recent,
//we notify it to the user
if ( lastDate < mailbox.getDate())
{
lastResultTime = mailbox.getResultTime();
lastDate = mailbox.getDate();
String fromUserID
= StringUtils.parseBareAddress(mailbox.getSender());
String fromUserID =
StringUtils.parseBareAddress(mailbox.getSender());
//create the volatile contact
Contact sourceContact = opSetPersPresence
.createVolatileContact(fromUserID);
//create the volatile contact
Contact sourceContact = opSetPersPresence
.createVolatileContact(fromUserID);
String newMail = JabberActivator.getResources().getI18NString(
"service.gui.NEW_MAIL",
new String[]{mailbox.getSender(),
"&lt;" + mailbox.getSender() + "&gt",
mailbox.getSubject(),
"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""
+ mailbox.getUrl() + "\">" +mailbox.getUrl()+ "</a>"}) ;
String newMail = JabberActivator.getResources().getI18NString(
"service.gui.NEW_MAIL",
new String[]{mailbox.getSender(),
"&lt;" + mailbox.getSender() + "&gt",
mailbox.getSubject(),
"&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""+
mailbox.getUrl() +"\">" +mailbox.getUrl()
+ "</a>"}) ;
Message newMailMessage = new MessageJabberImpl(
newMail, HTML_MIME_TYPE, DEFAULT_MIME_ENCODING, null);
Message newMailMessage = new MessageJabberImpl( newMail,
HTML_MIME_TYPE, DEFAULT_MIME_ENCODING, null);
MessageReceivedEvent msgReceivedEvt = new MessageReceivedEvent(
newMailMessage, sourceContact, System.currentTimeMillis(),
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
MessageReceivedEvent msgReceivedEvt = new MessageReceivedEvent(
newMailMessage, sourceContact, System.currentTimeMillis(),
MessageReceivedEvent.SYSTEM_MESSAGE_RECEIVED);
fireMessageEvent(msgReceivedEvt);
}
fireMessageEvent(msgReceivedEvt);
}
}
@ -744,7 +731,7 @@ private class NewMailNotificationListener
{
public void processPacket(Packet packet)
{
if(packet != null && !(packet instanceof NewMailNotification))
if(packet != null && !(packet instanceof NewMailNotificationIQ))
return;
if(opSetPersPresence.getCurrentStatusMessage()
@ -760,5 +747,4 @@ public void processPacket(Packet packet)
jabberProvider.getConnection().sendPacket(mailnotification);
}
}
}

@ -1,247 +0,0 @@
/*
* SIP Communicator, 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.protocol.jabber.extensions.mailnotification;
import org.jivesoftware.smack.packet.*;
import net.java.sip.communicator.util.*;
/**
* A straightforward extension of the IQ. A Mailbox object is created via the
* MailboxProvider. It contains all the information we need to notify the user
* about a new E-Mail message.
*
* @author Matthieu Helleringer
* @author Alain Knaebel
*/
public class Mailbox extends IQ
{
/**
* Logger for this class
*/
private static final Logger logger =
Logger.getLogger(Mailbox.class);
/**
* The time these results were generated, in milliseconds since the
* UNIX epoch. This value should be cached and sent as the newer-than-time
* attribute in the next email query.
* not used for the moment
*/
private long resultTime;
/**
* Number of unread messages.
*/
private int totalMatched;
/**
* A number indicating whether total-matched is just an estimate:
* 1 indicates it is; 0 or omitted indicates that it is not.
*/
private boolean totalEstimate;
/**
* Contains the address that a message was sent from
*/
private String sender;
/**
* Indicates the subject of an email
*/
private String subject;
/**
* Indicates the URL of the email server
*/
private String url;
/**
* Indicates the date of the most recent email message.
*/
private long date;
/**
* The name space for new mail notification packets.
*/
public static final String NAMESPACE = "google:mail:notify";
/**
* The name of the element that Google use to transport new mail
* notifications.
*/
public static final String ELEMENT_NAME = "mailbox";
/**
* Sets the date of the most recent unread mail content on the mail server,
* in milliseconds since the UNIX epoch.
*
* @param date the date long
*/
public void setDate(long date)
{
this.date = date;
}
/**
* Returns the date of the most recent unread mail content on the mail
* server, in milliseconds since the UNIX epoch.
*
* @return the date of the most recent unread mail content on the mail
* server, in milliseconds since the UNIX epoch.
*/
public long getDate()
{
return this.date;
}
/**
* Returns the time when these results were generated, in milliseconds
* since the UNIX epoch.
*
* @return the time when these results were generated, in milliseconds
* since the UNIX epoch.
*/
public long getResultTime()
{
return resultTime;
}
/**
* Sets the time these results were generated, in milliseconds since the
* UNIX epoch.
*
* @param l the resultTime long
*/
public void setResultTime(long l)
{
this.resultTime = l;
}
/**
* Returns the number of unread mail messages
*
* @return the total number of matched (unread) mail messages
*/
public int getTotalMatched()
{
return totalMatched;
}
/**
* Specifies the number of unread mail messages.
*
* @param totalMatched the number of matched mail messages
*/
public void setTotalMatched(int totalMatched)
{
this.totalMatched = totalMatched;
}
/**
* Determines whether the total of unread mail messages is an estimate or
* not.
*
* @return <tt>true</tt> if the total number of mail messages is an estimate
* and <tt>false</tt> otherwise.
*/
public boolean isTotalEstimate()
{
return totalEstimate;
}
/**
* Specifies whether the total number of unread mail messages contained in
* this object is an estimate or a precise count.
*
* @param totalEstimate <tt>true</tt> if the number of total messages here
* is an estimate and <tt>false</tt> otherwise.
*/
public void setTotalEstimate(boolean totalEstimate)
{
this.totalEstimate = totalEstimate;
}
/**
* Returns the sub-element XML section of the IQ packet, or null if
* there isn't one. Packet extensions must be included, if any are defined.
*
* @return the child element section of the IQ XML.
*/
@Override
public String getChildElementXML()
{
logger.debug("Mailbox.getChildElementXML usage");
String totalString = totalEstimate ? " total-estimate='1' " : "";
return "<mailbox result-time='" + resultTime + "' total-matched='"
+ totalMatched + "'" + totalString + "/>";
}
/**
* Specifies an HTTP URL of the mail server that contains the messages
* indicated in this Mailbox IQ.
*
* @param url the http URL where users could check the messages that this
* IQ refers to.
*/
public void setUrl(String url)
{
this.url = url;
}
/**
* Returns the http URL of the mail server containing the messages that
* this IQ refers to.
*
* @return the http URL of the mail server containing the messages that
* this IQ refers to.
*/
public String getUrl()
{
return url;
}
/**
* Specifies the sender of a mail referred to by this URL.
*
* @param
*/
public void setSender(String sender)
{
this.sender = sender;
}
/**
* Set the subject of the last mail
*
* @param subject the subjet of the email String
*/
public void setSubject(String subject)
{
this.subject = subject;
}
/**
* Return the sender of the last mail
*
* @return the sender of the email String
*/
public String getSender()
{
return this.sender;
}
/**
* Return the subject of the last mail
*
* @return the subject of the email String
*/
public String getSubject()
{
return this.subject;
}
}

@ -1,97 +0,0 @@
/*
* SIP Communicator, 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.protocol.jabber.extensions.mailnotification;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.provider.*;
import org.xmlpull.v1.XmlPullParser;
import net.java.sip.communicator.util.*;
/**
* A straightforward implementation of the IQProvider. Parses custom IQ packets.
* We receive IQ mailbox packets from google mail servers and we use them to
* create <tt>Mailbox</tt> objects which contain all the information from the
* packet.
*
* @author Matthieu Helleringer
* @author Alain Knaebel
*/
public class MailboxProvider
implements IQProvider
{
/**
* Logger for this class
*/
private static final Logger logger =
Logger.getLogger(MailboxProvider.class);
/**
* Return an <tt>IQ</tt> (i.e. <tt>Mailbox</tt>) object which will contain
* the information we get from the parser.
*
* @param parser the <tt>XmlPullParser</tt> that we can use to get
* packet details.
*
* @return a new IQ instance which is the result of the XmlPullParser.
* @throws Exception if an error occurs parsing the XML.
*/
public IQ parseIQ(final XmlPullParser parser) throws Exception
{
logger.debug("Mailbox.getChildElementXML usage");
Mailbox iq = new Mailbox();
iq.setFrom(parser.getAttributeValue("", "from"));
iq.setTo(parser.getAttributeValue("", "to"));
iq.setPacketID(parser.getAttributeValue("", "id"));
iq.setResultTime(Long.parseLong(
parser.getAttributeValue("", "result-time")));
iq.setTotalMatched(Integer.parseInt(
parser.getAttributeValue("", "total-matched")));
iq.setTotalEstimate("1".equals(
parser.getAttributeValue("", "total-estimate")));
iq.setUrl(parser.getAttributeValue("", "url"));
int eventType = parser.next();
String name = parser.getName();
if (eventType == XmlPullParser.START_TAG)
{
if ("mail-thread-info".equals(name))
{
iq.setDate(Long.parseLong(
parser.getAttributeValue("", "date")));
for (int i =0;i<10;i++)
{
eventType = parser.next();
if (eventType == XmlPullParser.START_TAG)
{
name = parser.getName();
if ("sender".equals(name))
{
if ( "1".equals(
parser.getAttributeValue("","originator")))
{
iq.setSender(parser.
getAttributeValue("", "address"));
}
}
}
if (eventType == XmlPullParser.START_TAG)
{
name = parser.getName();
if ("subject".equals(name))
{
name = parser.nextText();
iq.setSubject(name);
}
}
}
}
}
return iq;
}
}

@ -1,65 +0,0 @@
/*
* SIP Communicator, 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.protocol.jabber.extensions.mailnotification;
import org.jivesoftware.smack.packet.*;
import net.java.sip.communicator.util.*;
/**
* A straightforward IQ extension. A <tt>NewMailNotification</tt> object is
* created via the <tt>NewMailNotificationProvider</tt>. It contains the
* information we need in order to determine whether there are new mails waiting
* for us on the mail server.
*
* @author Matthieu Helleringer
* @author Alain Knaebel
* @author Emil Ivov
*/
public class NewMailNotification extends IQ
{
/**
* Logger for this class
*/
private static final Logger logger =
Logger.getLogger(NewMailNotification.class);
/**
* The name space for new mail notification packets.
*/
public static final String NAMESPACE = "google:mail:notify";
/**
* The name of the element that Google use to transport new mail
* notifications.
*/
public static final String ELEMENT_NAME = "new-mail";
/**
* Returns the name space of the new-mail element
*
* @return the XML name space of the new-mail element.
*/
public String getXmlsns()
{
return NAMESPACE;
}
/**
* Returns the sub-element XML section of the IQ packet.
*
* @return the child element section of the IQ XML
*/
@Override
public String getChildElementXML()
{
logger.trace("NewMailNotification.getChildElementXML usage");
return "<iq type='"+"result"+"' "+
"from='"+getFrom()+"' "+
"to='"+getTo()+"' "+
"id='"+getPacketID()+"' />";
}
}

@ -43,7 +43,7 @@ public class NewMailNotificationProvider
public IQ parseIQ(final XmlPullParser parser) throws Exception
{
logger.debug("NewMailNotificationProvider.getChildElementXML usage");
NewMailNotification iq = new NewMailNotification();
NewMailNotificationIQ iq = new NewMailNotificationIQ();
iq.setFrom(parser.getAttributeValue("", "from"));
iq.setTo(parser.getAttributeValue("", "to"));
iq.setPacketID(parser.getAttributeValue("", "id"));

@ -16,6 +16,7 @@
*
* @author Matthieu Helleringer
* @author Alain Knaebel
* @author Emil Ivov
*/
public class QueryNotify extends IQ
{
@ -26,9 +27,19 @@ public class QueryNotify extends IQ
Logger.getLogger(QueryNotify.class);
/**
* the value of the result time of the last packet
* The name space for new mail notification packets.
*/
private long timeResult;
public static final String NAMESPACE = "google:mail:notify";
/**
* The value of the newer-than-time attribute in this query;
*/
private long newerThanTime = -1;
/**
* The value of the newer-than-tid attribute in this query;
*/
private long newerThanTid = -1;
/**
* Returns the sub-element XML section of the IQ packet.
@ -40,18 +51,76 @@ public String getChildElementXML()
{
logger.debug("QueryNotify.getChildElementXML usage");
return "<query xmlns='google:mail:notify'"
+"newer-than-time='" +this.timeResult+"'/>";
StringBuffer xml = new StringBuffer(
"<query xmlns='google:mail:notify'");
if(getNewerThanTime() != -1)
xml.append("newer-than-time='")
.append(getNewerThanTime()).append("'");
if(getNewerThanTid() != -1)
xml.append("newer-than-tid='")
.append(getNewerThanTid()).append("'");
xml.append("/>");
}
/**
* Sets the value of the "newer-than-time" attribute. The value indicates
* the time of the oldest unread email to retrieve, in milliseconds since
* the UNIX epoch (00:00:00 UTC, January 1 1970). When querying for the
* first time, you should omit this attribute (i.e. not call this method or
* call it with a <tt>-1</tt> value) to return a set of the most recent
* unread mail. The sever will return only unread mail received after this
* time. If using this attribute, you should also use newer-than-tid for
* best results.
*
* @param newerThanTime the time of the oldest unread email to retrieve or
* <tt>-1</tt> if the newer-than-time attribute should be omitted.
*/
public void setNewerThanTime(long newerThanTime)
{
this.newerThanTime = newerThanTime;
}
/**
* Returns the value of the "newer-than-time" attribute. The value indicates
* the time of the oldest unread email to retrieve, in milliseconds since
* the UNIX epoch (00:00:00 UTC, January 1 1970). When querying for the
* first time, you should omit this attribute (i.e. not call this method or
* call it with a <tt>-1</tt> value) to return a set of the most recent
* unread mail. The sever will return only unread mail received after this
* time. If using this attribute, you should also use newer-than-tid for
* best results.
*
* @return the time of the oldest unread email to retrieve or <tt>-1</tt> if
* the attribute is to be omitted.
*/
public long getNewerThanTime(long newerThanTime)
{
return this.newerThanTime;
}
/**
* Creates a <tt>QueryNotify</tt> instance with <tt>time</tt> as the value
* of the "newer-than-time" attribute.
* Sets the value of the "newer-than-tid" attribute. The value indicates
* the highest thread number of messages to return, where higher numbers are
* more recent email threads. The server will return only threads newer than
* that specified by this attribute. If using this attribute, you should
* also use newer-than-time for best results. When querying for the first
* time, you should omit this value.
*
* @param time the value of the "newer-than-time" attribute.
* @param newerThanTid the time of the oldest unread email to retrieve or
* <tt>-1</tt> if the newer-than-time attribute should be omitted.
*/
public QueryNotify(long time)
public void setNewerThanTid(long newerThanTid)
{
this.timeResult = time;
this.newerThanTid = newerThanTid;
}
}

Loading…
Cancel
Save