Extending IBM Lotus Sametime Connect V7.5 with an SMS messaging plug-in

Learn how to extend the new Eclipse-based IBM Lotus Sametime Connect V7.5 client by building an SMS messaging plug-in that allows you to send Short Message Service (SMS) text messages directly from your Lotus Sametime client to a Sametime partner's mobile phone or device.

Share:

Kulvir Singh Bhogal, e-business Consultant, IBM

Kulvir Singh Bhogal works as an IBM Software Services for WebSphere consultant, devising and implementing J2EE-centric solutions at customer sites across the nation. You can reach Kulvir at kbhogal@us.ibm.com.



Mark Talbot (talbotm@us.ibm.com), Developer, Industry Solutions, IBM

Mark Talbot works for IBM as a developer for Industry Solutions. You can reach Mark at talbotm@us.ibm.com.



22 August 2006 (First published 08 August 2006)

Also available in Chinese

IBM Lotus Sametime Connect V7.5 is based on the Eclipse platform. Consequently, if you are familiar with Java and Eclipse plug-in development, you can extend the Lotus Sametime client. In this article, we teach you some of the concepts related to tapping into the extensibility of the Lotus Sametime client. More specifically, we guide you through the development of a Sametime plug-in known as the SMS Message plug-in. This plug-in can send Short Message Service (SMS) messages to a Sametime partner’s mobile phone. We thought you would appreciate a more real-world, useful example over the popular "Hello world!" example.

Some short words about the Short Message Service (SMS)

The Short Message Service (SMS) is a service available on most modern digital mobile phones. SMS allows a mobile phone user to send short messages (a.k.a. text messages) to other mobile phone users. Mobile users find SMS to be a fast, discrete way to keep in touch with friends, family, coworkers, and other mobile correspondents. The popularity of sending SMS messages can be witnessed first-hand as you see mobile phone users thumbing away at their keypads.

In the Short Message Service, messages are sent using a store-and-forward mechanism to a Short Message Service Center (SMSC). The center then attempts to send the message to the designated recipient. There is no delivery guarantee in the SMS world as the message delivery is described as a "best effort." Despite this shortcoming, SMSing (as it is sometimes referred to) has developed a massive following. It is estimated that SMS messages were being sent at an astounding rate of 500 billion messages per year by mid-2004.

Sending SMS messages through email

At this point, you may be wondering how the SMS Message plug-in for Lotus Sametime Connect can send messages through email. It does so by tapping into the fact that the major mobile phone companies of the U.S. allow you to send messages using an email address that is associated with the correspondent's mobile phone number. The following is a breakdown of the email address formats for some of the major U.S. mobile phone providers:

  • T-Mobile:phonenumber @tmomail.net
  • Virgin Mobile:phonenumber @vmobl.com
  • Cingular:phonenumber @cingularme.com
  • Sprint PCS:phonenumber @messaging.sprintpcs.com
  • Verizon:phonenumber @vtext.com
  • Nextel:phonenumber @messaging.nextel.com

For example, let’s say we want to send an SMS message to a fictitious Sprint PCS mobile phone number 512-555-5555. To do so, we can send an email to 5125555555@messaging.sprintpcs.com. The SMS Message plug-in leverages the ability to send SMS messages through email. Throughout this article, we refer to email addresses that can be used to send SMS messages as SMS email addresses.


A preview of the SMS Message plug-in

Before you embark on this journey to build the SMS Message plug-in, you may benefit from a preview of how the plug-in appears. Figure 1 shows the SMS Message plug-in in action. This plug-in allows you to register an email address from which to send out SMS messages to a Sametime partner.

Figure 1. Registering an email address
Registering an email address

After you register an SMS email address for a Sametime partner, a Sametime user can send an SMS message to a partner’s mobile phone as shown in figure 2.

Figure 2. Sending an SMS message
Sending an SMS message

Associated with this article is a ZIP file that contains a ZIP archive of our Eclipse project workspace. To use our source, extract our workspace to a directory on your local machine. When starting the Eclipse IDE, start with the data option followed by the workspace location. For example, if you extracted our workspace to a directory named c:\eclipse\smsMessage the command to start the Eclipse IDE is as follows:

eclipse –data c:\eclipse\smsMessage


The JavaMail API

The JavaMail API is an optional package for the Java SDK. It allows a Java application to read, compose, and send electronic messages (email). We assume you are familiar with the JavaMail API. If not, we suggest you familiarize yourself with the JavaMail API by reading the developerWorks tutorial, "Fundamentals of the JavaMail API." We use the JavaMail API to send out SMS messages through email. At the time of this article’s writing, version 1.4 of the JavaMail API was available; you can download it from the Sun Developer Network.

In addition to the JavaMail API download, you need to download the JavaBeans Activation Framework standard extension from the Sun Developer Network. At the time of this article’s writing, version 1.1 of the JavaBeans Activation Framework was available; you can download it from the Sun Developer Network.

To send out email using the JavaMail API, two JAR files are required: a JAR of the JavaMail API (specifically mail.jar) and a JAR from the JavaBeans Activation Framework (activation.jar). You create a separate plug-in to house these two JAR files (see the section "Creating a plug-in to house the JavaMail API JAR files" for more information).


Find your local post office (your SMTP server name)

To send out email, your Sametime plug-in must be aware of the SMTP server for sending out email. Make sure you have an SMTP mail server available; you need the server name and port number (you may consider bugging your network administrator to learn this information). If you do not know and/or cannot obtain an SMTP server, you can install your own for testing. The PostCast Server is a good, free choice to use as a mail server program that turns your machine into an outgoing SMTP mail server.


Obtaining and preparing the Eclipse 3.2 IDE

We assume you have the Eclipse 3.2 IDE installed. If not, go to the Eclipse Web site to obtain the application. We use the Eclipse IDE to develop the SMS Message plug-in.

Launch the Eclipse IDE and change the target platform to Lotus Sametime V7.5. Changing the target platform from the Eclipse platform to the Sametime platform allows you to extend the Sametime platform as opposed to extending the Eclipse platform.

To change the target platform to Lotus Sametime V7.5, follow these steps:

  1. In Eclipse, choose Window - Preferences.
  2. In the left-hand pane of the Preferences dialog box, expand the Plug-in Development item, and then select Target Platform.
  3. In the right-hand pane, the Target Platform Preference Page appears. Click Browse to change the location.
  4. Change your target platform to the location of the directory representing the Lotus Sametime V7.5 plug-ins directory on your system. For example, if you installed Lotus Sametime V7.5 in the default location, the target platform location is C:\Program Files\IBM\Sametime Connect 7.5.
  5. Click Reload. You now see the Sametime plug-ins as shown in figure 3.
Figure 3. Sametime specified target platform
Sametime specified target platform

Creating a plug-in project for the SMS Message plug-in

To extend the Sametime GUI with SMS messaging functionality, you need to create a plug-in. To create the SMS Message plug-in, you need a plug-in project to house the plug-in during your development. To create a plug-in project in Eclipse, follow these steps:

  1. Choose File - New - Project.
  2. From the New Plug-in Project wizard, choose Plug-in Development - Plug-in Project. Then click Next.
  3. Specify com.devworks.example.mail as the project name, and then click Next.
  4. For the plug-in name, specify SMS Message. For the plug-in provider, specify DeveloperWorks. See figure 4.
    Figure 4. SMS Message plug-in
    SMS Message plug-in
  5. Notice that the option "This plug-in will make contributions to the UI" is selected. The Sametime APIs provide a means of extending the Sametime UI. If you were just extending the Sametime UI, making a contribution to the Eclipse UI would not be necessary. In this case, you create an Eclipse preference page that extends the Eclipse UI. Accordingly in the New Plug-in Project wizard, specify that the plug-in will make contributions to the UI.
  6. Accept the remaining default values and click Finish.

Creating a plug-in project to house the JavaMail API JAR files

You create a separate plug-in and plug-in project to house the JavaMail API JAR files. By having a separate plug-in for your JavaMail API JAR files, you can separate your auxiliary JavaMail specific JARs from your SMS Message plug-in. Consequently, other plug-ins that need access to the JavaMail API can benefit from the auxiliary plug-in.

To create the JavaMail plug-in, invoke the New Plug-in Project wizard as described in the previous section. Specify com.devworks.example.javax.mail as the plug-in ID. The plug-in name is JavaMail and the plug-in provider is DeveloperWorks. In the Plug-in Options section, deselect both the "Generate an activator, a Java class that controls the plug-in’s life cycle" and the "This plug-in will make contributions to the UI" options (see figure 5). Accept the rest of the defaults and click Finish.

Figure 5. JavaMail plug-in
JavaMail plug-in

Next, you import the JavaMail JAR files into the JavaMail plug-in. To do this, right-click the com.devworks.example.java.mail plug-in project. From the context menu, choose Import to open the Import wizard. From the Import wizard, choose General - File System, and then click Next. From the following window, click Browse. Navigate to the directory containing the JavaMail JAR files. Select the mail.jar file from the JavaMail package, which you downloaded earlier, and then click Finish (see figure 6).

Figure 6. Importing the JavaMail JAR files
Importing the JavaMail JAR files

Repeat the above process to import activation.jar from the JavaBeans Activation Framework package, which you downloaded earlier.

When you are finished, the two JAR files are imported into your JavaMail plug-in project. Lastly, you need to edit your META-INF/MANIFEST.MF file to expose the JavaMail classes to your external plug-in (namely, the SMS Message plug-in). Replace the contents of the existing MANIFEST.MF file with the contents shown below:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SMS Message
Bundle-SymbolicName: com.devworks.example.javax.mail
Bundle-Version: 1.0.0
Bundle-Vendor: DeveloperWorks
Bundle-Localization: plugin
Bundle-ClassPath: activation.jar,
 mail.jar
Export-Package: javax.activation,
 javax.mail,
 javax.mail.event,
 javax.mail.internet,
 javax.mail.search,
 javax.mail.util

Next, you need to add activation.jar and mail.jar to the build path of your bundle. Right-click the com.devworks.javax.mail plug-in, and from the context menu, choose Properties. The properties for the plug-in appear. From the right-hand pane, select Java Build Path. In the left-hand pane, select the Libraries tab. Click the Add JARs button. Add both the activation.jar and the mail.jar as shown in figure 7.

Figure 7. Adding the JAR files
Adding the JAR files

After editing the JavaMail plug-in manifest file to expose the JavaMail classes, you now need to modify your SMS Message plug-in to import the JavaMail classes from the auxiliary JavaMail plug-in. To do so, edit the META-INF/MANIFEST file of your SMS Message plug-in, so that your MANIFEST file appears as follows:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Send SMS
Bundle-SymbolicName: com.devworks.example.mail;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: com.devworks.example.mail.Activator
Bundle-Vendor: DeveloperWorks
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 com.ibm.collaboration.realtime.people,
 com.devworks.example.javax.mail,
 com.ibm.rcp.realtime.livenames
Eclipse-LazyStart: true

Pay particular attention to the Require-Bundle section, which establishes the dependency between the SMS Message plug-in and the JavaMail plug-in (represented by the project name: com.devworks.example.javax.mail).


The SMTP server preference page

You use a preference page to allow the Sametime client user to specify his or her SMTP server name and port information as shown in figure 8.

Figure 8. Preferences dialog box
Preferences dialog box

The Lotus Sametime client exposes an extension point that allows you to add a preference page to the Sametime client preferences. In your preference page, you have three preferences. The first preference is for the SMTP server name, and the second preference is for the SMTP server port. The value of these preferences is used to send outgoing email. The third preference is for the sender email address. This address states which email address is used to send out SMS messages.

Use the Extension wizard in Eclipse to create your preference page. For more information on how to use the Extension wizard, see the developerWorks article, "Designing a Google Maps plug-in for IBM Lotus Sametime Connect V7.5," which covers the concept of how to create a preference page in depth.

The Extension wizard creates a class named PreferenceConstants used to house constants for the plug-in. Replace the autogenerated code with the code below:

public class PreferenceConstants {
	public static final String SMTP_SERVER = "smtpServer";
	public static final String PORT_NUMBER = "portNumber";
	public static final String SENDER_ADDRESS = "senderAddress";";
}

As you can see, you have string constants for your SMTP server name, SMTP server port, and sender email address.

The PreferenceInitializer class (also autogenerated) sets default values for your preferences. Replace the autogenerated code with the following code. As you can see, the code only sets a value for the SMTP server port number, which by default is 25.

public class PreferenceInitializer 
extends AbstractPreferenceInitializer {

	public void initializeDefaultPreferences() {
		IPreferenceStore store = Activator.getDefault()
				.getPreferenceStore();		
				store.setDefault
				(PreferenceConstants.PORT_NUMBER,
				"25");
	}
}

The SMSPreferencePage class (also autogenerated) is the class that represents our preference page. Again, you need to replace the autogenerated code with the code shown below. In the code below, we create three field editors. There is one field editor for each of our preferences respectively. The SMSPreference class uses a grid layout.

public class SMSPreferencePage
extends FieldEditorPreferencePage
implements IWorkbenchPreferencePage {

	public SMSPreferencePage() {
		super(GRID);
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
		setDescription("Preferences for SMS Messaging.");
	}
	
		public void createFieldEditors() {
		addField(
			new StringFieldEditor(PreferenceConstants.SMTP_SERVER, 
			"SMTP Server:", getFieldEditorParent()));
		addField(
			new StringFieldEditor(PreferenceConstants.PORT_NUMBER, 
			"Port Number:", getFieldEditorParent()));
		addField(
			new StringFieldEditor(PreferenceConstants.SENDER_ADDRESS, 
			"Sender Address:", getFieldEditorParent()));
	}

The code above provides an interface like the one shown in figure 8, enabling the Sametime client user to enter his information.


The PostOffice class and its sendMail method

The seemingly arduous task of sending out SMS messages through email is taken care of by the com.devWorks.example.mail.PostOffice class, which during development, is housed in the com.devworks.example.mail plug-in project. More specifically, its static sendMail method is responsible for the effort.

public static void sendMail(String smtpServer, int port, 
	String body, String sender, String recipient)
	throws AddressException, MessagingException
{
  
  Properties props = System.getProperties();
  props.put("mail.smtp.host", smtpServer);
  props.put("mail.smtp.port", String.valueOf(port));
	    
  Session session = Session.getDefaultInstance(props, null);

  // create a new message
  Message msg = new MimeMessage(session);

  // set sender and recipient
  InternetAddress senderAddress = 
  new InternetAddress(sender);
  msg.setFrom(senderAddress);
  InternetAddress recipientAddress = 
  new InternetAddress(recipient);
  msg.addRecipient(Message.RecipientType.TO,recipientAddress); 
	   
  // populate the message
  msg.setText(body);
  msg.setSentDate(new Date());
  
  // send the message
  Transport.send(msg);
}

The sendMail method leverages the JavaMail API to realize its business function – to send an email to the specified recipient SMS email address (that is the address through which we can send an SMS message). In this method, we create a javax.mail.Session object using the SMTP server information (server name and port). We then create a new javax.mail.internet.MimeMessage object using the Session object. The sender and recipient email address strings become javax.mail.internet.InternetAddress objects. These InternetAddress objects are designated as the sender (using the setFrom method of the Message object) and the recipient (using the addRecipient method of the Message object).

Finally, the message’s body is populated, and the email is sent off using the javax.mail.Transport object.

Notice how the sendMail method throws up the exceptions javax.mail.internet.AddressException and javax.mail.MessagingException. The onus of handling these exceptions is left up to the consumer of the method, the MailUtilities class, which we cover shortly.


The AddressStore class

The SMS email addresses for sending out SMS messages to Sametime partners are stored in a properties file. You can edit the properties file manually.

NOTE: This properties file must reside in the top level directory of the SMS message bundle.

The format of the file is simply the Sametime partner ID followed by an equals (=) sign, which in turn is followed by the email address for SMSing. Below is an example of the contents of a properties file:

#Thu Jun 22 13:07:05 GMT-06:00 2006
talbotm@us.ibm.com=5555553434@cingularme.com
kbhogal@us.ibm.com=5555553434@cingularme.com

To facilitate a more user friendly experience, we allow a Sametime client user to manipulate the contents of the properties file graphically. Updating the SMS email address information for a partner involves a right-click with a subsequent selection of the Associate SMS Email option as shown in figure 9. We cover how to add an item to the context menu that appears when right-clicking a partner in the section "The PersonAction extension point."

Figure 9. Associate SMS Email option in Lotus Sametime Connect
Associate SMS Email option in Lotus Sametime Connect

The properties file described earlier is accessed by the com.devworks.example.mail.AddressStore class. The AddressStore class provides a getter and a setter method for retrieving data from the properties file. The getSMSEmailAddress(String partnerId) method returns an SMS email address given a partner ID. The setSMSEmailAddress(String partnerId, String emailAddress) sets an SMS email address for a given partner ID. The AddressStore class also has a private method initAddressCache, which is called the first time a public method of the AddressStore is invoked. A portion of the AddressStore class is shown in the following code snippet. Notice the presence of a Properties object, which stores the properties file data. Also notice the presence of a Boolean variable named init. This variable represents a flag that is set to true once the AddressStore class is initialized using the initAddressCache method.

public class AddressStore {
	public static Properties properties = new Properties();
	public static boolean init=false;

	private AddressStore() {
	}

Shown below, the initAddressCache() method reads the properties file that stores the name value mappings of partner ID to SMS email address.

private static void initAddressCache() {
		properties = new Properties();
		URL propFile = Activator.getDefault().getBundle().
		_getResource("address.properties");
		try {
			InputStream inStream = propFile.openStream();
			properties.load(inStream);
			inStream.close();
			init = false;
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}

To get the location of the address.properties file, you first get the shared bundle instance. From the shared bundle instance, you get the URL location of address.properties. With the URL location, you can open a stream to read the properties file. Then load the properties from the InputStream object. After loading the Properties object, you close the input stream, and then set your boolean flag variable (init) value to true, demarcating that the AddressStore object has been initialized.

The getSMSEmailAddress(String partnerId) method of the AddressStore class returns an SMS email address for a partner ID. If there is no email address for a given partner, an empty String is returned. In this method, you first check to see if the AddressStore object is initialized. If the AddressStore object isn’t initialized, then you initialize it. Use the getter method of the Properties object to retrieve the partner’s SMS email address.

public static String 
getSMSEmailAddress(String partnerId) {
	String partnerEmail;
	if (!init)
			initAddressCache();
		Object addressObject = properties.get(partnerId);
		if (addressObject != null)
			partnerEmail = (String) addressObject;
		else
			partnerEmail = "";
		return partnerEmail;
	}

The setSMSEmailAddress(String partnerId, String emailAddress) method sets the name-value pairing of partner ID to SMS email address in the cached Properties object. Additionally, this method also updates the address.properties file with the updated or new name-value pair. As with the initAddressCache() method, you get the URL from the getResource method of the shared bundle instance. With that URL, you create a FileOutputStream object. With that FileOutputStream object, you update the address.properties file with the updated properties.

public static boolean 
setSMSEmailAddress(String partnerId, String emailAddress) {
		boolean success = false;
		if (!init)
			initAddressCache();
		properties.setProperty(partnerId, emailAddress);
		URL propURL = Activator.getDefault().getBundle()
		_.getResource("address.properties");
		try {
			if (propURL==null)
			propURL = new URL("file:\\\\\\address.properties");
		} catch (MalformedURLException e1) {
			e1.printStackTrace();
		}
		String bundleLocation = Activator.getDefault()
		_.getBundle().getLocation();
		File propFile = new File(bundleLocation + 
		propURL.getPath());
		FileOutputStream out;
		try {
			out = new FileOutputStream(propFile);
			String header = null;
			properties.setProperty(partnerId, emailAddress);
			properties.store(out, header);
			out.close();
			success = true;
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return success;
	}

The MailUtilities class

The com.devworks.example.MailUtilities class contains a number of methods that power the SMS Message plug-in.

public class MailUtilities {

The showMessage(String message, String text) method is a graphical utility method for showing a message box to the Sametime client user. The text parameter of the method represents the title for the message, and the message parameter represents the body of the message box. In the method (shown below), you create a Shell object with the default constructor. The MessageBox widget takes the Shell object as an argument to its constructor. Then you set the message and the text of the MessageBox object. That message box is then shown to the Sametime client user.

public static void 
	showMessage(String message, String text) {
		Shell shell = new Shell();
		MessageBox messageBox = new MessageBox(shell);
		messageBox.setMessage(message);
		messageBox.setText(text);
		messageBox.open();
	}

The setUserMail(String id) method of the MailUtilities class display’s a dialog box requesting the email address for a partner. The information provided by the user is saved in the properties file. We use the InputDialog widget again to get the SMS email address from the user for the Sametime partner. We then use the AddressStore class’s setSMSEmailAddress method to persist the user-provided SMS email address.

public static void 
	setUserMail(String displayName, String id) {) {
		Shell shell = new Shell();
		String dialogTitle = "Set SMS email address for " 
		_+ displayName;
		String dialogMessage = "Enter the email address.";
		String initialValue = AddressStore.getSMSEmailAddress(id);
		IInputValidator validator = null;
			InputDialog dialog = new InputDialog(shell, 
			dialogTitle, dialogMessage, initialValue, 
		validator);
		dialog.open();
		dialog.create();
		String input = dialog.getValue();
		int returnCode = dialog.getReturnCode();
		if (returnCode == InputDialog.OK)
			AddressStore.setSMSEmailAddress(id, input);
	}

Another worker method of the MailUtilities class is the sendSMSMessage method. This method presents a user with a dialog box in which he can enter an SMS message to be sent to a Sametime partner (see figure 2). To send out an SMS message through email, the method needs to provide the PostOffice’s sendMail method with SMTP server and port information. This information is retrieved from the preference store. The sendSMSMessage method presents the user with an InputDialog widget from which it can collect the SMS message to send.

After the user clicks OK, you get the user provided answer from the InputDialog. Then you check to see if the user clicked OK or Cancel. If the user clicked OK, use the PostOffice.sendMail()method.

public static void 
	sendSMSMessage(String displayName, String id, String emailAddress) {
		String smtpServer = Activator.getDefault().getPreferenceStore()
			.getString(PreferenceConstants.SMTP_SERVER);
		int port = Integer.parseInt(Activator.getDefault().getPreferenceStore()
			.getString(PreferenceConstants.PORT_NUMBER));
		String sender = Activator.getDefault().getPreferenceStore()
			.getString(PreferenceConstants.SENDER_ADDRESS);

		Shell shell = new Shell();
		String dialogTitle = "Send SMS Message to " + displayName;
		String dialogMessage = "Enter an SMS Message.";
		String initialValue = "";
		IInputValidator validator = null;
		InputDialog dialog = new InputDialog(shell, 
			dialogTitle, dialogMessage, initialValue, validator);
		dialog.open();
		dialog.create();
		String body = dialog.getValue();
		int returnCode = dialog.getReturnCode();
		if (returnCode == InputDialog.OK) {
			if (emailAddress == null) {
				MailUtilities.showMessage("No email address 
				found for:" + displayName, 
				"Partner not Found");
			} else if ((smtpServer == null) || 
			(smtpServer.trim().equals(""))) {
				MailUtilities.showMessage("No SMTP Server 
				Specified.","SMTP Error");
			} else if ((body == null) || (body.trim().equals(""))) {
				MailUtilities.showMessage("No Message to 
				Send.","Message Error");
			} else if ((sender == null) || (sender.trim().equals(""))) {
				MailUtilities.showMessage(
						"No Reply to Email Address Specified.",
						"Reply-to Address Error");
			} 
			else {
				try {
					PostOffice.sendMail(smtpServer, 
						port, body, sender, emailAddress);
				} catch (AddressException e) {
					MailUtilities.showMessage(
							"Problem with the specified 
							address.","AddressError");
					e.printStackTrace();
				} catch (MessagingException e) {
					MailUtilities.showMessage("Problem with 
					the message.","MessageError");
					e.printStackTrace();
				}
			}
		}
	}

The org.eclipse.ui.popupMenus extension point

To add menu items to the context menu that appears when you right-click a Sametime partner, create classes that extend the LiveNameActionDelegate class. You also have to add entries to your plugin.xml file. For more information about this topic, we suggest you read the developerWorks Lotus article, "Extending the Lotus Sametime client with an LDAP directory lookup plug-in," which addresses this concept in depth.

The com.devworks.example.mail.AssociateSMSMailDelegate class is responsible for presenting the GUI that allows you to associate an SMS email address through which a Sametime partner can receive an SMS message. When the Associate SMS Email context menu item is invoked, the run method is triggered, which in turn calls the MailUtilities setUserMail method, which presents the user with the interface to enter/update an SMS email address for the selected Sametime partner (see figure 1).

public class AssociateMailDelegate extends LiveNameActionDelegate {
	public void run(IAction arg0) {
        Person persons[] = getSelectedPersons();
		Person person = persons[0];
		if (person != null) {
			String id = person.getContactId();
			String displayName = person.getDisplayName();
			System.out.println("Associating Email for" + id); 
			//$NON-NLS-1$
			MailUtilities.setUserMail(displayName, id);	}
	}
}

To add the Associate SMS Email menu item to the context menu that appears when you right-click a Sametime partner, add the following code to your plugin.xml file. Notice how the extension point definition points to the AssociateMailDelegate class.

<extension
       point="org.eclipse.ui.popupMenus">
    <objectContribution
          adaptable="false"
          id="com.devworks.example.mail.prersonselection"
          objectClass="com.ibm.collaboration.realtime.livenames.PersonSelection">
       <action
             class="com.devworks.example.mail.AssociateMailDelegate"
             enablesFor="1"
             id="com.devworks.example.mail.AssociateMailDelegate"
             label="Associate SMS Email"
             style="push"/>
    </objectContribution>
</extension>

The com.devworks.example.mail.SMSMessageDelegate class is responsible for retrieving the SMS email address for the selected Sametime partner through a call to the getSMSEmailAddress method of the AddressStore object. This occurs when the runWithEvent method of the class is triggered, which happens when the Send SMS Message context menu item is selected. After the SMS email address is discovered, the email message is sent out using the sendSMSMessage method of the MailUtilities class.

public class SMSMessageDelegate extends LiveNameActionDelegate {
	public void run(IAction arg0) {
        Person persons[] = getSelectedPersons();
		Person person = persons[0];
		if (person != null) {
			String id = person.getContactId();
			String displayName = person.getDisplayName();
			System.out.println("Performing Lookup for" + id); 
			//$NON-NLS-1$
			String emailAddress = AddressStore.getSMSEmailAddress(id);
			MailUtilities.sendSMSMessage(displayName, id, emailAddress);
		}
	}
}

The Send SMS Message menu item is added to the context menu that appears when right-clicking a Sametime partner by adding another action to the existing extension point in your plugin.xml file.

<extension
       point="org.eclipse.ui.popupMenus">
    <objectContribution
          adaptable="false"
          id="com.devworks.example.mail.prersonselection"
          objectClass="com.ibm.collaboration.realtime.livenames.PersonSelection">
       <action
             class="com.devworks.example.mail.SMSMessageDelegate"
             enablesFor="1"
             id="com.devworks.example.mail.SMSMessageDelegate"
             label="Send SMS Message"
             style="push"/>       
       <action
             class="com.devworks.example.mail.AssociateMailDelegate"
             enablesFor="1"
             id="com.devworks.example.mail.AssociateMailDelegate"
             label="Associate SMS Email"
             style="push"/>
    </objectContribution>
</extension>

Conclusion

The popularity of the Short Message Service is undeniable. Recently, SMS has been used to send binary content like ringtones between phone users. This article recognizes the popularity of SMS and showed you how you can extend the Lotus Sametime Connect V7.5 client to send SMS messages to Sametime partners' mobile phones and devices. The ability to extend the Sametime client is a virtue of its Eclipse-based architecture. In this article, we showed you how to tap into that extensibility, leveraging the JavaMail API to send SMS messages.


Download

DescriptionNameSize
Sample Eclipse plug-insametime_sms_src.zip10 KB

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into IBM collaboration and social software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Lotus
ArticleID=148445
ArticleTitle=Extending IBM Lotus Sametime Connect V7.5 with an SMS messaging plug-in
publish-date=08222006