<commit_before>/*
 * 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.browserlauncher;

import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.util.*;

import com.apple.eio.*;

/**
 * A simple implementation of the BrowserLauncherService. Checks the operating
 * system and launches the appropriate browser.
 * 
 * @author <NAME>
 */
public class BrowserLauncherImpl
    implements BrowserLauncherService
{
    private static Logger logger = Logger.getLogger(
        BrowserLauncherImpl.class.getName());

    public void openURL(String url)
    {
        String osName = System.getProperty("os.name");
        
        try
        {
           if (osName.startsWith("Mac OS"))
           {
               FileManager.openURL(url);
           }
           else if (osName.startsWith("Windows"))
           {
              Runtime.getRuntime().exec(
                  "rundll32 url.dll,FileProtocolHandler " + url);
           }
           else
           {
              String[] browsers = {"firefox", "icedove", "opera", "konqueror",
                  "epiphany", "mozilla", "netscape" };
              
              String browser = null;
              
              for (int i = 0; i < browsers.length && browser == null; i ++)
              {
                 if (Runtime.getRuntime().exec(
                       new String[] {"which", browsers[i]}).waitFor() == 0)
                    browser = browsers[i];
              }
              if (browser == null)
                 throw new Exception("Could not find web browser");
              else
                 Runtime.getRuntime().exec(new String[] {browser, url});
           }
        }
        catch (Exception e) {
           logger.error("Failed to launch browser: " + e);
       }
    }
}<commit_msg>launch browser in a separate thread<commit_after>/*
 * 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.browserlauncher;

import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.util.*;

import com.apple.eio.*;

/**
 * A simple implementation of the BrowserLauncherService. Checks the operating
 * system and launches the appropriate browser.
 * 
 * @author <NAME>
 */
public class BrowserLauncherImpl
    implements BrowserLauncherService
{
    private static Logger logger = Logger.getLogger(
        BrowserLauncherImpl.class.getName());

    public void openURL(String url)
    {
        new LaunchBrowser(url).start();
    }
    
    /**
     * Launch browser in a separate thread.
     */
    private class LaunchBrowser extends Thread
    {
        private String url;
        
        public LaunchBrowser(String url)
        {
            this.url = url;
        }
        
        public void run()
        {
            try
            {
                String osName = System.getProperty("os.name");
                
                if (osName.startsWith("Mac OS"))
                {
                    FileManager.openURL(url);
                }
                else if (osName.startsWith("Windows"))
                {
                   Runtime.getRuntime().exec(
                       "rundll32 url.dll,FileProtocolHandler " + url);
                }
                else
                {
                   String[] browsers = {"firefox", "icedove", "opera", "konqueror",
                       "epiphany", "mozilla", "netscape" };
                   
                   String browser = null;
                   
                   for (int i = 0; i < browsers.length && browser == null; i ++)
                   {
                      if (Runtime.getRuntime().exec(
                            new String[] {"which", browsers[i]}).waitFor() == 0)
                         browser = browsers[i];
                   }
                   if (browser == null)
                      throw new Exception("Could not find web browser");
                   else
                      Runtime.getRuntime().exec(new String[] {browser, url});
                }
            }
            catch (Exception e) {
               logger.error("Failed to launch browser: " + e);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.10465901417960838, 'fraction_numerical': 0.0018005851901868107, 'mean_word_length': 1.499437570303712, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629593', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1102, 'n_words': 289}