1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.im;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  
20  import rath.msnm.MSNMessenger;
21  import rath.msnm.SwitchboardSession;
22  import rath.msnm.entity.MsnFriend;
23  import rath.msnm.event.MsnAdapter;
24  import rath.msnm.msg.MimeMessage;
25  
26  /**
27   * <a href="MSNMessageAdapter.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class MSNMessageAdapter extends MsnAdapter {
32  
33      public MSNMessageAdapter(MSNMessenger msn, String to, String msg) {
34          _msn = msn;
35          _to = to;
36          _msg = msg;
37      }
38  
39      public void whoJoinSession(SwitchboardSession ss, MsnFriend join) {
40          try {
41              if (_to.equals(join.getLoginName())) {
42                  ss.sendInstantMessage(new MimeMessage(_msg));
43                  ss.cleanUp();
44              }
45          }
46          catch (Exception e) {
47              _log.warn(e);
48          }
49  
50          _msn.removeMsnListener(this);
51      }
52  
53      private static Log _log = LogFactoryUtil.getLog(MSNConnector.class);
54  
55      private MSNMessenger _msn;
56      private String _to;
57      private String _msg;
58  
59  }