Home » openjdk-7 » net.bonzoun » cocodonkey » [javadoc | source]

    1   //
    2   //  DonkeyLauncher.java
    3   //  CocoDonkey
    4   //  $Id: DonkeyLauncher.java,v 1.9 2002/09/24 20:52:39 fortun Exp $
    5   //
    6   //  Created by Fred Bonzoun on Sat May 11 2002.
    7   //  Copyright (c) 2002 Bonzoun. All rights reserved.
    8   //
    9   //  This library is free software; you can redistribute it and/or modify
   10   //  it under the terms of the GNU Lesser General Public License as published
   11   //  by the Free Software Foundation; either version 2.1 of the License, or
   12   //  (at your option) any later version.
   13   //
   14   //  This library is distributed in the hope that it will be useful,
   15   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
   16   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17   //  GNU Lesser General Public License for more details.
   18   //
   19   //  You should have received a copy of the GNU Lesser General Public License
   20   //  along with this program; if not, write to the Free Software
   21   //  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   22   //
   23   
   24   package net.bonzoun.cocodonkey;
   25   
   26   import com.apple.cocoa.foundation;
   27   import com.apple.cocoa.application;
   28   
   29   import java.io;
   30   
   31   public class DonkeyLauncher {
   32   
   33       public static void launchLocalDonkey(String daemonDir, DonkeyTalker talker) throws IOException {
   34           new File(daemonDir + "/searches.ini.tmp").delete();
   35           File dir = new File(daemonDir);
   36           Util.launchShell("\"" + daemonDir + "/mldonkey\" </dev/null >/tmp/mldonkey.console &", dir);
   37           //Process p = Runtime.getRuntime().exec(new String[]{daemonDir + "/mldonkey"},
   38           //                                      new String[]{}, dir);
   39           for(int i=0; i<10; i++) {
   40               try {
   41                   talker.connect(10000);
   42                   return;
   43               }
   44               catch(IOException e) {
   45                   try {
   46                       Thread.sleep(1000);
   47                   }
   48                   catch(InterruptedException e2) {
   49                   }
   50               }
   51           }
   52           throw new IOException("Cannot connect");
   53       }
   54   
   55       public static boolean hardKillCore() {
   56           return Util.launchShell("kill `ps axww|grep '/mldonkey'|grep -v grep|awk '{print $1}'`", null);
   57       }
   58   }
   59   
   60   // $Log: DonkeyLauncher.java,v $
   61   // Revision 1.9  2002/09/24 20:52:39  fortun
   62   // Bug if the path to mldonkey contains a space char
   63   //
   64   // Revision 1.8  2002/07/09 22:09:54  fortun
   65   // killCore() is now back to the daemonOptionsController class
   66   //
   67   // Revision 1.7  2002/07/08 22:15:51  fortun
   68   // killCore() now asks before hard killing the core
   69   //
   70   // Revision 1.6  2002/07/07 01:23:14  fortun
   71   // Now uses a provied talker
   72   //
   73   // Revision 1.5  2002/07/05 18:37:50  fortun
   74   // Current dir for shellLauncher
   75   //
   76   // Revision 1.4  2002/07/05 00:00:04  fortun
   77   // Uses a logger to log the output
   78   //
   79   // Revision 1.3  2002/07/04 23:16:30  fortun
   80   // The core is now better launched (output is redirected to a file)
   81   // New killCore and hardKillCore methods
   82   //
   83   // Revision 1.2  2002/05/25 23:38:55  fortun
   84   // launchLocalDonkey has been moved from DonkeyTalker
   85   //
   86   // Revision 1.1.1.1  2002/05/21 21:26:13  fortun
   87   //
   88   //

Home » openjdk-7 » net.bonzoun » cocodonkey » [javadoc | source]