More work on GMail nofitications.

cusax-fix
Emil Ivov 17 years ago
parent 89c4d96af4
commit 018500c000

@ -52,6 +52,19 @@ public class OperationSetBasicInstantMessagingJabberImpl
private boolean keepAliveEnabled = false;
/**
* The maximum number of unread threads that we'd be notifying the user of.
*/
private static final String PNAME_MAX_GMAIL_THREADS_PER_NOTIFICATION
= "net.java.sip.communicator.impl.protocol.jabber."
+"MAX_GMAIL_THREADS_PER_NOTIFICATION";
/**
* Determines whether or not we are to deliver GMail notifications to the
* user.
*/
private boolean enableGmailNotifications = false;
/**
* The task sending packets
*/
@ -321,7 +334,8 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
//subscribe for Google (GMail or Google Apps) notifications
//for new mail messages.
subscribeForGmailNotifications();
if (enableGmailNotifications)
subscribeForGmailNotifications();
// run keep alive thread
@ -718,12 +732,41 @@ private String createMailboxDescription(MailboxIQ mailboxIQ)
Iterator<MailThreadInfo> threads = mailboxIQ.threads();
while(threads.hasNext())
String maxThreadsStr = (String)JabberActivator.getConfigurationService()
.getProperty(PNAME_MAX_GMAIL_THREADS_PER_NOTIFICATION);
int maxThreads = 5;
try
{
if(maxThreadsStr != null)
maxThreads = Integer.parseInt(maxThreadsStr);
}
catch (NumberFormatException e)
{
logger.debug("Failed to parse max threads count: "+maxThreads
+". Going for default.");
}
//print a maximum of MAX_THREADS
for (int i = 0; i < maxThreads && threads.hasNext(); i++)
{
message.append(threads.next().createHtmlDescription());
}
message.append("</table><br/><br/>");
int threadCount = mailboxIQ.getThreadCount();
if(threadCount > maxThreads)
{
message.append(threadCount - maxThreads
+ " more unread messages in your "
+ " <a href='" + mailboxIQ.getUrl() +"'>inbox</a>.<br/>");
}
//
return message.toString();
}
/**

@ -156,7 +156,9 @@ public class Sender
public String getFirstName()
{
if(name == null || name.trim().length() == 0)
{
return null;
}
String[] names = name.split("\\s");
@ -601,7 +603,21 @@ private String createParticipantNames()
String name = firstNamesOnly? sender.getFirstName() : sender.name;
if (name == null)
name = sender.address;
{
//if there's no name then use the user part of the address
if (sender.address != null)
{
int atIndex = sender.address.indexOf("@");
if(atIndex != -1)
return sender.address.substring(0, atIndex);
else
name = sender.address;
}
else
name = "unknown";
}
if (!sender.unread && maximumReadAllowed == 0)
continue;

Loading…
Cancel
Save