Author: aaf
Date: Sun Jul  8 12:00:38 2012
New Revision: 1358723

URL: http://svn.apache.org/viewvc?rev=1358723&view=rev
Log:
initial commit of jitsi plug-in
Apache License

Added:
    incubator/openmeetings/trunk/plugins/jitsi/
    incubator/openmeetings/trunk/plugins/jitsi/main/
    incubator/openmeetings/trunk/plugins/jitsi/main/java/
    incubator/openmeetings/trunk/plugins/jitsi/main/java/net/
    incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/
    incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/EncryptionEngine.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigManager.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigPanel.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginActivator.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginMenuItem.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginSoapClient.java
    
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/openmeetingsplugin.manifest.mf

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/EncryptionEngine.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/EncryptionEngine.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/EncryptionEngine.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/EncryptionEngine.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,106 @@
+package net.java.sip.communicator.plugin.openmeetings;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.crypto.Cipher;
+
+public class EncryptionEngine {
+       
+//     private static byte[] iv =
+//    { 0x0a, 0x01, 0x02, 0x03, 0x04, 0x0b, 0x0c, 0x0d };
+       
+       public static IvParameterSpec iv = new IvParameterSpec(new
+                       byte[]{1,2,3,4,5,6,7,8});
+       
+       private static String xform = "DES/CBC/PKCS5Padding";
+       //private static SecretKey key;
+       
+       public static SecretKey key = new SecretKeySpec(new
+                       byte[]{1,1,1,1,1,1,1,1},"DES");
+       
+       private static SecretKey getKey() throws NoSuchAlgorithmException{
+               
+               KeyGenerator kg = KeyGenerator.getInstance("DES");
+           kg.init(56); // 56 is the keysize. Fixed for DES
+//         key = kg.generateKey();  
+//         
+//         SecretKeyFactory kf = 
SecretKeyFactory.getInstance("PBEWithMD5AndDES");
+//         SecretKey key = kf.generateSecret(keySpec);
+           
+           return key;
+       }
+       
+       
+       public String encrypt(String message) throws Exception {
+        final MessageDigest md =
+               MessageDigest.getInstance("md5");
+        final byte[] digestOfPassword = md.digest("HG58YZ3CR9"
+                        .getBytes("utf-8"));
+        final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
+        for (int j = 0, k = 16; j < 8;) {
+                keyBytes[k++] = keyBytes[j++];
+        }
+
+        final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
+        final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
+        final Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
+        cipher.init(Cipher.ENCRYPT_MODE, key, iv);
+
+        final byte[] plainTextBytes = message.getBytes("utf-8");
+        final byte[] cipherText = cipher.doFinal(plainTextBytes);
+        
+        final String encodedCipherText = new sun.misc.BASE64Encoder()
+         .encode(cipherText);
+
+        return encodedCipherText;
+    }
+
+    public String decrypt( String messageStr ) throws Exception {
+       byte[] message = new sun.misc.BASE64Decoder().decodeBuffer(messageStr);
+        final MessageDigest md = MessageDigest.getInstance("md5");
+        final byte[] digestOfPassword = md.digest("HG58YZ3CR9"
+                        .getBytes("utf-8"));
+        final byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
+        for (int j = 0, k = 16; j < 8;) {
+                keyBytes[k++] = keyBytes[j++];
+        }
+
+        final SecretKey key = new SecretKeySpec(keyBytes, "DESede");
+        final IvParameterSpec iv = new IvParameterSpec(new byte[8]);
+        final Cipher decipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
+        decipher.init(Cipher.DECRYPT_MODE, key, iv);
+
+        // final byte[] encData = new
+        // sun.misc.BASE64Decoder().decodeBuffer(message);
+        final byte[] plainText = decipher.doFinal(message);
+
+        return new String(plainText, "UTF-8");
+    }
+       
+       
+//     public static String encrypt( String input  ) throws Exception {
+//                     byte[] inpBytes = input.getBytes();
+//                 Cipher cipher = Cipher.getInstance(xform);
+//                // IvParameterSpec ips = new IvParameterSpec(iv);
+//                 cipher.init(Cipher.ENCRYPT_MODE, key, iv);
+//                 String out = cipher.doFinal(inpBytes).toString();
+//                 return out;
+//               }
+//     public static String decrypt(String input ) throws Exception {          
+//                     byte[] inpBytes = input.getBytes();             
+//                 Cipher cipher = Cipher.getInstance(xform);
+//                // IvParameterSpec ips = new IvParameterSpec(iv);
+//                 cipher.init(Cipher.DECRYPT_MODE, key, iv);
+//                 byte[] outb = cipher.doFinal(inpBytes);
+//                 String out = cipher.doFinal(inpBytes).toString(); 
+//                 return out;
+//               }
+                 
+}

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigManager.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigManager.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigManager.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigManager.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,237 @@
+package net.java.sip.communicator.plugin.openmeetings;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.*;
+
+import javax.xml.soap.SOAPException;
+
+import net.java.sip.communicator.impl.protocol.zeroconf.MessageZeroconfImpl;
+import net.java.sip.communicator.service.configuration.ConfigurationService;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+
+public class OpenmeetingsConfigManager {
+       
+       private String server;
+       private String login;
+       private String password;
+       private String stringForHash = "user:";
+       private String hash;
+       OpenmeetingsPluginSoapClient soapClient;
+       private static BundleContext bundleContext;
+       private static ConfigurationService configurationService = null;
+       
+       private static OpenmeetingsConfigManager instance;
+       private EncryptionEngine encryptionEngine;
+       
+       private OpenmeetingsConfigManager(){
+               
+               super();
+               soapClient = new OpenmeetingsPluginSoapClient();
+               encryptionEngine = new EncryptionEngine();
+       }
+
+       public static OpenmeetingsConfigManager getInstance(){
+               if( instance == null ){
+                       instance = new OpenmeetingsConfigManager();
+               }
+               return instance;
+       }
+       
+        private static String convertToHex(byte[] data) { 
+               StringBuffer buf = new StringBuffer();
+               for (int i = 0; i < data.length; i++) { 
+                   int halfbyte = (data[i] >>> 4) & 0x0F;
+                   int two_halfs = 0;
+                   do { 
+                       if ((0 <= halfbyte) && (halfbyte <= 9)) 
+                           buf.append((char) ('0' + halfbyte));
+                       else 
+                           buf.append((char) ('a' + (halfbyte - 10)));
+                       halfbyte = data[i] & 0x0F;
+                   } while(two_halfs++ < 1);
+               } 
+               return buf.toString();
+        } 
+        
+       private String getHash() throws Exception {
+               
+               if( hash != null )
+                       return hash;
+               
+               byte[] bytesOfMessage = null;
+               try {
+                       bytesOfMessage = stringForHash.getBytes("UTF-8");
+               } catch (UnsupportedEncodingException e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+
+               MessageDigest md = MessageDigest.getInstance("MD5");
+               byte[] thedigest = md.digest(bytesOfMessage);
+               
+               final String hash = convertToHex(thedigest);
+               return hash;
+       }
+       private String getMd5Hash( String str ) throws Exception{
+               
+               byte[] bytesOfMessage = null;
+               try {
+                       bytesOfMessage = str.getBytes("UTF-8");
+               } catch (UnsupportedEncodingException e) {
+                       System.out.println( e.getMessage() );                   
+               }
+
+               MessageDigest md = MessageDigest.getInstance("MD5");
+               byte[] thedigest = md.digest(bytesOfMessage);
+               
+               final String hash = convertToHex(thedigest);
+               return hash;            
+       }
+       
+       public String getCreationUrl() throws Exception{
+               
+               final String url = "http://"+ getServer() + 
"/client/username="+getLogin()+"&password="+getPassword()+
+                                                       "&hash=" + getHash();
+               System.out.println( "CREATION URL = " + url );
+               return url;
+       }
+       
+       public String createInvitationUrl( String hash ) throws Exception {
+               final String url = "http://"+ getServer() + 
"/openmeetings/?invitationHash=" + hash;
+               System.out.println( "INVITATION URL = " + url );
+               return url;             
+       }
+       
+       public String getInvitationUrl( String displayedName ) throws Exception{
+               
+               String server = getServer();
+               soapClient.setServer( server );
+               
+               String invitationHash = null;                                   
        
+               
+               try {
+                       invitationHash = soapClient.getInvitationHash( 
getLogin(), getPassword(),displayedName );
+               } catch (Exception e) {                 
+                       System.out.println( e.getMessage());                    
+               }
+               
+               if( invitationHash.equals(null) )
+                       return null;
+               
+               String invitationUrl = createInvitationUrl( invitationHash );
+               
+               return invitationUrl;           
+       }
+       public String sendUrl() throws Exception {
+                               
+               String url = getCreationUrl();
+               HttpURLConnection omURLConnection = null;
+               
+               try {
+                   URL omURL = new URL("http://"; + getServer() );
+                   omURLConnection = (HttpURLConnection) 
omURL.openConnection();
+                   omURLConnection.setRequestMethod("GET");
+                   omURLConnection.setDoInput(true);
+                   omURLConnection.setDoOutput( true );
+                   omURLConnection.connect();
+
+               } catch (MalformedURLException e) {     // new URL() failed
+                       
+                       return null;
+                       
+               } catch (IOException e) {               // openConnection() 
failed
+                       return null;
+               }                                
+               
+               //write to url          
+               OutputStreamWriter out = new OutputStreamWriter(
+                omURLConnection.getOutputStream());
+               out.write( url );
+               out.flush();
+                       
+               out.close();
+        System.out.println("After flushing output stream. ");
+        System.out.println("Getting an input stream...");
+        InputStream is = omURLConnection.getInputStream();
+        // any response?
+        InputStreamReader isr = new InputStreamReader(is);
+        BufferedReader br = new BufferedReader(isr);
+        String line = null;
+        String response = null;
+        while ( (line = br.readLine()) != null)
+        {
+            System.out.println("line: " + line);
+            response += line;            
+        }
+               
+               out.close();
+               hash = null;
+               
+               return response;
+       }
+       
+        public static ConfigurationService getConfigurationService()
+           {
+               if (configurationService == null)
+               {
+                   ServiceReference confReference
+                       = bundleContext.getServiceReference(
+                           ConfigurationService.class.getName());
+                   configurationService
+                       = (ConfigurationService) bundleContext
+                                               .getService(confReference);
+               }
+               return configurationService;
+           }
+        
+       public void setSever( String server ){
+               this.server = server;           
+               getConfigurationService().setProperty( 
"plugin.openmeetings.SERVER", server);
+                          
+       }
+       public String getServer() {
+               String value = (String)getConfigurationService().getProperty( 
"plugin.openmeetings.SERVER" );
+               server = value;
+               return server;
+       }
+
+       public void setLogin( String login ){
+               this.login = login;             
+               getConfigurationService().setProperty( 
"plugin.openmeetings.LOGIN", login);
+       }
+       public String getLogin() {
+               String value = (String)getConfigurationService().getProperty( 
"plugin.openmeetings.LOGIN" );
+               login = value;
+               return login;
+       }
+
+       public void setPassword(String password) throws Exception {
+               this.password = password;
+               if( password == null )
+                       return;
+               String encrypted = encryptionEngine.encrypt( password );
+               getConfigurationService().setProperty( 
"plugin.openmeetings.ENCRYPTED_PASSWORD", encrypted );
+       }
+       public String getPassword() throws Exception {
+               String value = (String)getConfigurationService().getProperty( 
"plugin.openmeetings.ENCRYPTED_PASSWORD" );
+               if( value == null )
+                       return null;
+               password = encryptionEngine.decrypt( value );
+               return password;
+       }
+
+       public void setContext(BundleContext bc_) {
+               this.bundleContext = bc_;               
+       }
+}

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigPanel.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigPanel.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigPanel.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsConfigPanel.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,160 @@
+package net.java.sip.communicator.plugin.openmeetings;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import net.java.sip.communicator.util.swing.*;
+
+import org.osgi.framework.*;
+
+
+public class OpenmeetingsConfigPanel
+        extends TransparentPanel
+{    
+   
+    /**
+        * 
+        */
+       private static final long serialVersionUID = 1L;
+       
+       private final JTextField teServer = new JTextField( 20 );
+       private final JTextField teLogin = new JTextField( 20 );
+       private final JPasswordField tePassword = new JPasswordField( 20 );
+       private final JTextField fakeField = new JTextField( 20 );
+       private final JButton btOk = new 
JButton(OpenmeetingsPluginActivator.resourceService.
+                                                                               
getI18NString("plugin.openmeetings.BUTTON_OK"));
+    
+       private String server;
+    private String login;
+    private String password;
+    
+    public OpenmeetingsConfigPanel() throws Exception
+    {
+        super(new BorderLayout());
+
+        Dimension prefSize = new Dimension( 105, 30 );
+        JPanel headerPanel = new TransparentPanel();
+        headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.LINE_AXIS));
+
+        JLabel lblHeader = new 
JLabel(OpenmeetingsPluginActivator.resourceService.
+                       getI18NString("plugin.openmeetings.CONFIG_HEADER"));
+        
+        headerPanel.setAlignmentX( Component.LEFT_ALIGNMENT );
+        headerPanel.add( lblHeader );
+        lblHeader.setPreferredSize( new Dimension( 200, 30 ));
+        
+        JPanel serverPanel = new TransparentPanel();
+        serverPanel.setLayout(new BoxLayout(serverPanel, 
BoxLayout.LINE_AXIS));        
+        JLabel lblServer = new 
JLabel(OpenmeetingsPluginActivator.resourceService.
+                                                       
getI18NString("plugin.openmeetings.SERVER"));
+        lblServer.setPreferredSize(prefSize);
+        serverPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+        serverPanel.add(lblServer);        
+        serverPanel.add( teServer );
+        
+        JPanel loginPanel = new TransparentPanel();
+        loginPanel.setLayout(new BoxLayout(loginPanel, BoxLayout.LINE_AXIS));  
      
+        JLabel lblLogin = new 
JLabel(OpenmeetingsPluginActivator.resourceService.
+                                                       
getI18NString("plugin.openmeetings.LOGIN"));
+        lblLogin.setPreferredSize(prefSize);
+        loginPanel.setAlignmentX(LEFT_ALIGNMENT);
+        loginPanel.add(lblLogin);
+        loginPanel.add( teLogin );        
+        
+        JPanel passwordPanel = new TransparentPanel();
+        passwordPanel.setLayout(new BoxLayout(passwordPanel, 
BoxLayout.LINE_AXIS));        
+        JLabel lblPassword = new 
JLabel(OpenmeetingsPluginActivator.resourceService.
+                                                       
getI18NString("plugin.openmeetings.PASWWORD"));
+        lblPassword.setPreferredSize(prefSize);
+        passwordPanel.setAlignmentX(LEFT_ALIGNMENT);
+        passwordPanel.add( lblPassword );
+        passwordPanel.add( tePassword );
+        
+        
+        teServer.setText( OpenmeetingsConfigManager.getInstance().getServer() 
);
+        teLogin.setText( OpenmeetingsConfigManager.getInstance().getLogin() );
+        tePassword.setText( 
OpenmeetingsConfigManager.getInstance().getPassword() );
+        
+        JPanel buttonPanel = new TransparentPanel();
+        buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
+        buttonPanel.setAlignmentX( LEFT_ALIGNMENT );
+        btOk.addActionListener(new ButtonOkListener());
+        btOk.setAlignmentX(LEFT_ALIGNMENT);
+        btOk.setPreferredSize(new Dimension( 50, 30 ) );
+        //buttonPanel.add( Box.createRigidArea( new Dimension( 60, 5)));
+        buttonPanel.add(btOk);
+        buttonPanel.add(fakeField);
+        fakeField.setVisible( false );
+
+        JPanel omPanel = new TransparentPanel();        
+        omPanel.setLayout(new BoxLayout(omPanel, BoxLayout.PAGE_AXIS));
+        omPanel.add( headerPanel );
+        omPanel.add( Box.createRigidArea( new Dimension(20, 5)));
+        omPanel.add( serverPanel, BorderLayout.WEST );
+        omPanel.add( Box.createRigidArea( new Dimension(20, 5)));
+        omPanel.add( loginPanel );
+        omPanel.add( Box.createRigidArea( new Dimension(20, 5)));
+        omPanel.add( passwordPanel );
+        omPanel.add( Box.createRigidArea( new Dimension(20, 5)));
+        omPanel.add( buttonPanel );
+
+        add( omPanel, BorderLayout.PAGE_START);
+    }
+    public String getTest(){
+       
+       return "Hello!!!!";
+    }
+    
+    public void setServer(String server) {
+       
+               this.server = server;           
+       }
+    
+       public String getServer() {
+               return server;
+       }
+
+       public void setLogin(String login) {
+               this.login = login;
+       }
+       public String getLogin() {
+               return login;
+       }
+
+       public void setPassword(String password) {
+               this.password = password;
+       }
+       public String getPassword() {
+               return password;
+       }
+
+       private class ButtonOkListener implements ActionListener
+    {
+        /**
+         * Invoked when an action occurs.
+         * @param e <tt>ActionEvent</tt>.
+         */
+        public void actionPerformed(ActionEvent e)
+        {      
+               OpenmeetingsConfigManager.getInstance().setSever( 
teServer.getText() );
+               OpenmeetingsConfigManager.getInstance().setLogin( 
teLogin.getText() );
+               try {
+                               
OpenmeetingsConfigManager.getInstance().setPassword( new String( 
tePassword.getPassword() ) );
+                       } catch (Exception e1) {                                
+                               e1.printStackTrace();
+                       }
+        }
+    }
+    private class ButtonCancelListener implements ActionListener
+    {
+        /**
+         * Invoked when an action occurs.
+         * @param e <tt>ActionEvent</tt>.
+         */
+        public void actionPerformed(ActionEvent e)
+        {
+               
+        }
+    }    
+}

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginActivator.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginActivator.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginActivator.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginActivator.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,81 @@
+/*
+ * 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.plugin.openmeetings;
+
+import java.util.*;
+
+import net.java.sip.communicator.impl.gui.event.PluginComponentEvent;
+import net.java.sip.communicator.impl.gui.main.contactlist.ContactListPane;
+import net.java.sip.communicator.plugin.otr.OtrActivator;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.gui.internal.GuiServiceActivator;
+import net.java.sip.communicator.service.resources.ResourceManagementService;
+import 
net.java.sip.communicator.service.resources.ResourceManagementServiceUtils;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+public class OpenmeetingsPluginActivator
+    implements BundleActivator
+{
+       public static BundleContext bundleContext;
+       
+    public static ResourceManagementService resourceService;
+    
+       Logger logger = Logger.getLogger(OpenmeetingsPluginActivator.class);
+
+    /**
+     * Called when this bundle is started so the Framework can perform the
+     * bundle-specific activities necessary to start this bundle. In the case
+     * of our example plug-in we create our menu item and register it as a
+     * plug-in component in the right button menu of the contact list.
+     */
+    public void start(BundleContext bc)
+        throws Exception
+    {
+       bundleContext = bc;
+       resourceService = 
ResourceManagementServiceUtils.getService(OpenmeetingsPluginActivator.bundleContext);
+                
+        OpenmeetingsPluginMenuItem openMeetingsPlugin = new 
OpenmeetingsPluginMenuItem( bc );
+
+        Hashtable<String, String> containerFilter
+            = new Hashtable<String, String>();
+        containerFilter.put(
+                Container.CONTAINER_ID,
+                Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
+      
+        bc.registerService(  PluginComponent.class.getName(),
+                                                                       
openMeetingsPlugin,
+                                                                       
containerFilter);
+        
+        Dictionary<String, String> properties = new Hashtable<String, 
String>();
+        properties.put( ConfigurationForm.FORM_TYPE,
+                        ConfigurationForm.ADVANCED_TYPE);
+        bc.registerService(
+            ConfigurationForm.class.getName(),
+            new LazyConfigurationForm(
+                
"net.java.sip.communicator.plugin.openmeetings.OpenmeetingsConfigPanel",
+                getClass().getClassLoader(),
+                "plugin.skinmanager.PLUGIN_ICON",
+                "plugin.openmeetings.PLUGIN_NAME",
+                1002, true),
+            properties);        
+             
+        }
+
+    /**
+     * Called when this bundle is stopped so the Framework can perform the
+     * bundle-specific activities necessary to stop the bundle. In the case
+     * of our example plug-in we have nothing to do here.
+     */
+    public void stop(BundleContext bc)
+        throws Exception
+    {
+       
+       
+    }
+}

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginMenuItem.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginMenuItem.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginMenuItem.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginMenuItem.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,172 @@
+/*
+ * 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.plugin.openmeetings;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import net.java.sip.communicator.plugin.otr.OtrActivator;
+import net.java.sip.communicator.service.protocol.Message;
+import net.java.sip.communicator.service.protocol.Contact;
+import 
net.java.sip.communicator.service.protocol.OperationSetBasicInstantMessaging;
+import net.java.sip.communicator.service.protocol.ProtocolProviderService;
+
+import javax.swing.*;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.gui.Container;
+
+
+public class OpenmeetingsPluginMenuItem
+    extends AbstractPluginComponent
+    implements ActionListener
+{
+    private JMenuItem menuItem;
+
+    private MetaContact metaContact;
+    
+    private BundleContext bc;
+
+    /**
+     * Creates an instance of <tt>OpenmeetingsPluginMenuItem</tt>.
+     * @param  
+     */
+    public OpenmeetingsPluginMenuItem( BundleContext bc_)
+    {
+        super(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU);        
+        this.bc = bc_;
+        OpenmeetingsConfigManager.getInstance().setContext( bc_ );
+    }
+ 
+    /**
+     * Listens for events triggered by user clicks on this menu item. Opens
+     * the <tt>PluginDialog</tt>.
+     */
+    public void actionPerformed(ActionEvent e)
+    { 
+       
+       String invitationUrl = null;
+               try {
+                       invitationUrl = 
OpenmeetingsConfigManager.getInstance().getInvitationUrl( 
+                                                                               
        OpenmeetingsConfigManager.getInstance().getLogin() );
+               } catch (Exception e1) {
+                       System.out.println( e1.getMessage() );                  
+               }
+       if( invitationUrl.equals(null)){
+               System.out.println("Can't get invitation URL");
+               return;
+       }
+       
+       openUrl( invitationUrl );       
+       
+       Contact to = metaContact.getDefaultContact();
+       String invitationUrlForSend = null;
+               try {
+                       invitationUrlForSend = 
OpenmeetingsConfigManager.getInstance().getInvitationUrl( to.getDisplayName() );
+               } catch (Exception e1) {
+                       System.out.println( e1.getMessage() );                  
+               }
+       if( invitationUrl.equals(null)){
+               System.out.println("Can't get invitation URL For send");
+               return;
+       }
+               
+       ServiceReference cRef = bc.getServiceReference( 
ProtocolProviderService.class.getName() );
+       ProtocolProviderService jabberProvider =
+               (ProtocolProviderService)bc.getService(cRef);
+       
+       OperationSetBasicInstantMessaging basicInstMsgImpl =
+               
(OperationSetBasicInstantMessaging)jabberProvider.getOperationSet(OperationSetBasicInstantMessaging.class);
+               
+       String message = "I am inviting you to the conference. Please, click 
the link " + invitationUrlForSend;
+       Message msg = basicInstMsgImpl.createMessage( message);
+       basicInstMsgImpl.sendInstantMessage( to ,  msg);        
+
+    }
+
+    private boolean conferenceCreated(String response) {
+               
+       if( response.contains("It works!"))
+               return true;
+       
+               return false;
+       }
+
+       private void openUrl(String url){
+               
+               if( url == null )
+                       return;
+       
+       if( !java.awt.Desktop.isDesktopSupported() ) {
+
+            System.err.println( "Desktop is not supported (fatal)" );
+            System.exit( 1 );
+        }
+
+        if ( url.length() == 0 ) {
+
+            System.out.println( "Usage: OpenURI [URI [URI ... ]]" );
+            System.exit( 0 );
+        }
+
+        java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
+
+        if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
+
+            System.err.println( "Desktop doesn't support the browse action 
(fatal)" );
+            System.exit( 1 );
+        }
+
+        try {
+             java.net.URI uri = new java.net.URI( url );
+              desktop.browse( uri );
+          }
+         catch ( Exception e ) {
+
+             System.err.println( e.getMessage() );
+         }       
+       
+    }
+    /*
+     * Implements PluginComponent#getComponent().
+     */
+    public Object getComponent()
+    {
+        if (menuItem == null)
+        {
+            menuItem = new JMenuItem(getName());
+            menuItem.addActionListener(this);
+        }
+        return menuItem;
+    }
+
+    /*
+     * Implements PluginComponent#getName().
+     */
+    public String getName()
+    {
+        return 
OpenmeetingsPluginActivator.resourceService.getI18NString("plugin.openmeetings.MENU_ITEM");
+    }
+
+    /**
+     * Sets the current <tt>MetaContact</tt>. This in the case of the contact
+     * right button menu container would be the underlying contact in the 
+     * contact list.
+     * 
+     * @param metaContact the <tt>MetaContact</tt> to set.
+     * 
+     * @see PluginComponent#setCurrentContact(MetaContact)
+     */
+    public void setCurrentContact(MetaContact metaContact)
+    {
+        this.metaContact = metaContact;
+    }
+}

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginSoapClient.java
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginSoapClient.java?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginSoapClient.java
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/OpenmeetingsPluginSoapClient.java
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,287 @@
+package net.java.sip.communicator.plugin.openmeetings;
+
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class OpenmeetingsPluginSoapClient {
+
+       String serverUrl;
+       
+       private static final String NAMESPACE_PREFIX = "openmeetings";
+       
+       public OpenmeetingsPluginSoapClient(){
+               super();
+       }
+       
+       public String getSID( String username, String password ) throws 
Exception {
+               final SOAPMessage soapMessage = getSoapMessage();
+               final SOAPBody soapBody = soapMessage.getSOAPBody();
+               final SOAPElement sessionElement = 
soapBody.addChildElement("getSession", NAMESPACE_PREFIX);
+       
+               soapMessage.saveChanges();
+               
+//             System.out.println("\n Soap request:\n");
+//             soapMessage.writeTo(System.out);
+//             System.out.println();
+               
+               final SOAPConnection soapConnection = getSoapConnection();
+               final SOAPMessage soapMessageReply = 
soapConnection.call(soapMessage, getUserServiceUrl());
+//             System.out.println("\n Soap response:\n");
+//             soapMessageReply.writeTo(System.out);
+//             System.out.println();
+               //final String textContent = 
soapMessageReply.getSOAPBody().getChildElement();
+       
+               //System.out.println( "SID = " + textContent);
+               soapConnection.close();
+               
+               SOAPBody responseBody = soapMessageReply.getSOAPBody();
+
+               String sid = null;
+               
+               
+               final Node getSessionResponse = responseBody.getFirstChild();
+               final Node returnResult = getSessionResponse.getFirstChild();
+
+               final NodeList childNodes = returnResult.getChildNodes();
+               sid = childNodes.item(5).getTextContent();              
+
+               return sid;
+       }
+       
+       private String login( final String sid, final String username, final 
String password) throws SOAPException, IOException {
+               final SOAPMessage soapMessage = getSoapMessage();
+               final SOAPBody soapBody = soapMessage.getSOAPBody();
+               final SOAPElement loginElement = 
soapBody.addChildElement("loginUser", NAMESPACE_PREFIX);
+
+               loginElement.addChildElement("SID", 
NAMESPACE_PREFIX).addTextNode(sid);
+               loginElement.addChildElement("username", 
NAMESPACE_PREFIX).addTextNode(username);
+               loginElement.addChildElement("userpass", 
NAMESPACE_PREFIX).addTextNode(password);
+
+//             System.out.println("\nLOGIN REQUEST:\n");
+//             soapMessage.writeTo(System.out);
+//             System.out.println();
+               
+               soapMessage.saveChanges();
+
+               final SOAPConnection soapConnection = getSoapConnection();
+               final SOAPMessage soapMessageReply = 
soapConnection.call(soapMessage, getUserServiceUrl());
+               final String textContent = 
soapMessageReply.getSOAPBody().getFirstChild().getTextContent();
+
+//             System.out.println("\nLOGIN RESPONSE:\n");
+//             soapMessageReply.writeTo(System.out);
+//             System.out.println();
+//             
+//             System.out.println( "LOGIN =  " + textContent);
+//             
+               if( !textContent.equals("1")    )
+                       
JOptionPane.showMessageDialog(null,OpenmeetingsPluginActivator.resourceService.
+                                                               
getI18NString("plugin.openmeetings.ERROR_LOGIN_MSG"));
+       
+               soapConnection.close();
+
+               return textContent;
+       }
+       public String getInvitationHash( final String username, final String 
password, final String displayedName ) throws Exception {
+               final SOAPMessage soapMessage = getSoapMessage();
+               final SOAPBody soapBody = soapMessage.getSOAPBody();
+               final SOAPElement requestElement = 
soapBody.addChildElement("getInvitationHash", NAMESPACE_PREFIX);
+
+               String sid = getSID( username, password );
+               String error_id = null;
+               try {
+                       error_id = login( sid, username, password);
+               } catch (Exception e) {
+                       System.out.println( e.getMessage() );
+               }               
+               
+               if( !error_id.equals( "1" ) ){
+                       System.out.println("User cant login!");
+                       return null;
+               }
+                       
+               String room_id = getAvailableRooms( sid );
+               
+               requestElement.addChildElement("SID", 
NAMESPACE_PREFIX).addTextNode(sid);
+               requestElement.addChildElement("username", 
NAMESPACE_PREFIX).addTextNode( displayedName );
+               requestElement.addChildElement("room_id", 
NAMESPACE_PREFIX).addTextNode(room_id);
+                               
+               soapMessage.saveChanges();
+
+//             System.out.println("\nGET INVITATION REQUEST:\n");
+//             soapMessage.writeTo(System.out);
+//             System.out.println();
+               
+               final SOAPConnection soapConnection = getSoapConnection();
+               final SOAPMessage soapMessageReply = 
soapConnection.call(soapMessage, getJabberServiceUrl());
+               
+//             System.out.println("\nGET INVITATION RESPONSE:\n");
+//             soapMessageReply.writeTo(System.out);
+//             System.out.println();
+               
+               final String textContent = 
soapMessageReply.getSOAPBody().getFirstChild().getTextContent();
+
+//             System.out.println( "INVITATION RESPONSE =  " + textContent);
+               soapConnection.close();         
+
+               return textContent;
+       }
+       
+       private String getAvailableRooms( final String sid ) throws 
SOAPException, IOException, TransformerException {
+               final SOAPMessage soapMessage = getSoapMessage();
+               final SOAPBody soapBody = soapMessage.getSOAPBody();
+                       
+               final SOAPElement elemCodeElement = 
soapBody.addChildElement("getAvailableRooms",NAMESPACE_PREFIX);
+
+               elemCodeElement.addChildElement("SID", 
"rooms").addTextNode(sid);
+               
+//             System.out.println("\nGET_AVAILABLE_ROOMS REQUEST:\n");
+//             soapMessage.writeTo(System.out);
+//             System.out.println();
+               
+               soapMessage.saveChanges();
+
+               final SOAPConnection soapConnection = getSoapConnection();
+               final SOAPMessage soapMessageReply = 
soapConnection.call(soapMessage, getJabberServiceUrl());
+               final String textContent = 
soapMessageReply.getSOAPBody().getTextContent();
+
+//             System.out.println("\nGET_AVAILABLE_ROOMS RESPONSE:\n");
+//             soapMessageReply.writeTo(System.out);
+//             System.out.println();
+               
+               
+               final Node getRoomsResponse = soapMessageReply.getSOAPBody();
+               final Node getFirstRoomResult = 
getRoomsResponse.getFirstChild().getFirstChild();
+
+               String rooms_id = new String();
+               final NodeList childNodes = getFirstRoomResult.getChildNodes();
+               int count = childNodes.getLength();
+               for( int i = 0; i < count; ++i ){
+                   String nodeName = childNodes.item( i ).getNodeName();       
           
+                   if( nodeName.contains("rooms_id")){               
+                       rooms_id = childNodes.item(i).getTextContent();
+                   }                   
+               }
+                                               
+//             System.out.println( "GET_AVAILABLE_ROOMS RESULT =  " + rooms_id 
);
+               soapConnection.close();
+               
+               return rooms_id;
+       }
+
+
+       private String getErrorCode( final String sid, final String error_id ) 
throws SOAPException, IOException {
+               final SOAPMessage soapMessage = getSoapMessage();
+               final SOAPBody soapBody = soapMessage.getSOAPBody();
+               final SOAPElement errorCodeElement = 
soapBody.addChildElement("getErrorByCode", NAMESPACE_PREFIX);
+
+               errorCodeElement.addChildElement("SID", 
NAMESPACE_PREFIX).addTextNode(sid);
+               errorCodeElement.addChildElement("errorid", 
NAMESPACE_PREFIX).addTextNode(error_id);
+               errorCodeElement.addChildElement("language_id", 
NAMESPACE_PREFIX).addTextNode("0");
+
+//             System.out.println("\nERROR CODE REQUEST:\n");
+//             soapMessage.writeTo(System.out);
+//             System.out.println();
+               
+               soapMessage.saveChanges();
+
+               final SOAPConnection soapConnection = getSoapConnection();
+               final SOAPMessage soapMessageReply = 
soapConnection.call(soapMessage, getUserServiceUrl());
+               final String textContent = 
soapMessageReply.getSOAPBody().getFirstChild().getTextContent();
+
+//             System.out.println("\nERROR CODE RESPONSE:\n");
+//             soapMessageReply.writeTo(System.out);
+//             System.out.println();
+//             
+//             System.out.println( "ERROR RESULT =  " + textContent);
+               soapConnection.close();
+               
+               return textContent;
+       }
+
+       private SOAPConnection getSoapConnection() throws 
UnsupportedOperationException, SOAPException {
+               
+               final SOAPConnectionFactory soapConnectionFactory = 
SOAPConnectionFactory.newInstance();
+               final SOAPConnection soapConnection = 
soapConnectionFactory.createConnection();
+
+               return soapConnection;
+       }
+       
+       private SOAPMessage getSoapMessage() throws SOAPException {
+               final MessageFactory messageFactory = 
javax.xml.soap.MessageFactory.newInstance();
+               final SOAPMessage soapMessage = messageFactory.createMessage();
+
+               // Object for message parts
+               final SOAPPart soapPart = soapMessage.getSOAPPart();
+               final SOAPEnvelope envelope = soapPart.getEnvelope();
+
+               envelope.addNamespaceDeclaration("xsd", 
"http://www.w3.org/2001/XMLSchema";);
+               envelope.addNamespaceDeclaration("xsd", 
"http://basic.beans.data.app.openmeetings.org/xsd";);
+               envelope.addNamespaceDeclaration("xsd", 
"http://basic.beans.persistence.app.openmeetings.org/xsd";);
+               envelope.addNamespaceDeclaration("xsi", 
"http://www.w3.org/2001/XMLSchema-instance";);
+               envelope.addNamespaceDeclaration("enc", 
"http://schemas.xmlsoap.org/soap/encoding/";);
+               envelope.addNamespaceDeclaration("env", 
"http://schemas.xmlsoap.org/soap/envelop/";);
+               
+
+               envelope.addNamespaceDeclaration(NAMESPACE_PREFIX, 
"http://services.axis.openmeetings.org";);
+               envelope.addNamespaceDeclaration( "rooms", 
"http://rooms.beans.persistence.app.openmeetings.org/xsd";);
+
+               
envelope.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/";);
+
+               return soapMessage;
+       }
+       
+       private void addSID( final String sid, final SOAPMessage soapMessage) 
+       throws SOAPException {
+               final SOAPHeader header = soapMessage.getSOAPHeader();
+               final SOAPElement sidHeader = header.addChildElement("SID", 
NAMESPACE_PREFIX);
+               sidHeader.addChildElement("SID", 
NAMESPACE_PREFIX).addTextNode(sid);
+       }
+
+
+       
+       public void setServer( String serverUrl_ ){             
+               serverUrl = serverUrl_;         
+       }
+       
+       private String getServer(){
+               return serverUrl;
+       }
+       
+       private String getUserServiceUrl(){             
+               String url = "http://"; + getServer() + 
"/openmeetings/services/UserService?wsdl";
+               System.out.println( "URL = " + url);
+               return url;
+       }
+       private String getJabberServiceUrl(){           
+               String url = "http://"; + getServer() + 
"/openmeetings/services/JabberService?wsdl";
+               System.out.println( "URL = " + url);
+               return url;
+       }
+}
\ No newline at end of file

Added: 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/openmeetingsplugin.manifest.mf
URL: 
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/openmeetingsplugin.manifest.mf?rev=1358723&view=auto
==============================================================================
--- 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/openmeetingsplugin.manifest.mf
 (added)
+++ 
incubator/openmeetings/trunk/plugins/jitsi/main/java/net/java/sip/communicator/plugin/openmeetings/openmeetingsplugin.manifest.mf
 Sun Jul  8 12:00:38 2012
@@ -0,0 +1,37 @@
+Bundle-Activator: 
net.java.sip.communicator.plugin.openmeetings.OpenmeetingsPluginActivator
+Bundle-Name: Openmeetings plugin
+Bundle-Description: A plugin for integration with openmeetings.
+Bundle-Vendor: sip-communicator.org
+Bundle-Version: 0.0.1
+System-Bundle: yes
+Import-Package: org.osgi.framework,
+ net.java.sip.communicator.service.contactlist,
+ net.java.sip.communicator.service.contactlist.event,
+ net.java.sip.communicator.service.gui,
+ net.java.sip.communicator.service.gui.event,
+ net.java.sip.communicator.service.protocol,
+ net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.util,
+ net.java.sip.communicator.util.swing,
+ javax.swing,
+ javax.swing.event,
+ javax.swing.table,
+ javax.swing.text,
+ javax.swing.text.html,
+ javax.accessibility,
+ javax.swing.plaf,
+ javax.swing.plaf.metal,
+ javax.swing.plaf.basic,
+ javax.imageio,
+ javax.swing.filechooser,
+ javax.swing.tree,
+ javax.swing.undo,
+ javax.swing.border,
+ javax.xml.soap,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ org.w3c.dom,
+ net.java.sip.communicator.service.configuration,
+ javax.crypto,
+ javax.crypto.spec,
+ sun.misc
\ No newline at end of file


Reply via email to