Author: ulhume
Date: 2008-08-02 13:12:56 +0200 (Sat, 02 Aug 2008)
New Revision: 1440

Removed:
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetExecutionMode.java
Modified:
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetDescription.java
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetInstance.java
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetsContainer.java
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/interpreters/GadgetInterpreter.java
   
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/gadget/SimpleGadget.java
Log:
Added multi command support
Removed "service" mode. Each gadget should now hold there own instance

Modified: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetDescription.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetDescription.java
   2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetDescription.java
   2008-08-02 11:12:56 UTC (rev 1440)
@@ -31,16 +31,6 @@
        private String description;
        private String author;
        private String version;
-       private GadgetExecutionMode executionMode;
-
-       /**
-        * @param executionMode
-        *            the executionMode to set
-        */
-       public void setExecutionMode(GadgetExecutionMode executionMode) {
-               this.executionMode = executionMode;
-       }
-
        private String helpFile;
        private String iconFile;
        private UUID uuid;
@@ -61,13 +51,6 @@
        }
 
        /**
-        * @return the executionMode
-        */
-       public GadgetExecutionMode getExecutionMode() {
-               return executionMode;
-       }
-
-       /**
         * @return the name
         */
        public String getName() {

Deleted: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetExecutionMode.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetExecutionMode.java
 2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetExecutionMode.java
 2008-08-02 11:12:56 UTC (rev 1440)
@@ -1,28 +0,0 @@
-/* This file is part of "TuxDroid Gadget Framework".
- *    Copyright 2008, kysoh
- *    Author : Yoran Brault
- *    eMail  : [EMAIL PROTECTED] (remove _bad_ before sending an email)
- *    Site   : http://www.kysoh.com/
- *
- * "TuxDroid Gadget Framework" is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * "TuxDroid Gadget Framework" is distributed in the hope that it will be 
useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with "TuxDroid Gadget Framework"; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package com.kysoh.tuxdroid.gadget.framework.container;
-
-public enum GadgetExecutionMode {
-       service, command, gui;
-
-}

Modified: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetInstance.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetInstance.java
      2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetInstance.java
      2008-08-02 11:12:56 UTC (rev 1440)
@@ -51,9 +51,11 @@
        private class Worker extends Thread {
                private Shell shell;
                private final GadgetInstanceParameters values;
+               private final GadgetToken command;
 
-               public Worker(GadgetInstanceParameters values) {
+               public Worker(GadgetToken command, GadgetInstanceParameters 
values) {
                        this.values = values;
+                       this.command = command;
                }
 
                public void abort() {
@@ -84,7 +86,7 @@
                                // }
                                shell.setEnvironement(environement.toArray(new 
String[environement.size()]));
                                
gadget.listeners.fire().starting(GadgetInstance.this);
-                               gadget.interpreter.run(shell);
+                               gadget.interpreter.run(shell, command);
                        } catch (Throwable e) {
                                
gadget.listeners.fire().errors(GadgetInstance.this, e.getMessage());
                        } finally {
@@ -140,16 +142,17 @@
                return worker == null ? -1 : worker.getId();
        }
 
-       public void start(GadgetInstanceParameters values) {
+       public void start(GadgetToken command, GadgetInstanceParameters values) 
{
                if (worker != null) {
                        throw new ApplicationError("This instance is already 
running...");
                }
-               worker = new Worker(values);
+               worker = new Worker(command, values);
                worker.start();
 
        }
 
-       public void sendCommand(String name) {
+       // Plus tard, peut-ĂȘtre...
+       private void sendCommand(String name) {
                System.out.println("Sending command : " + name);
                name += "\n";
                try {

Modified: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetsContainer.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetsContainer.java
    2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/GadgetsContainer.java
    2008-08-02 11:12:56 UTC (rev 1440)
@@ -47,9 +47,6 @@
 import 
com.kysoh.tuxdroid.gadget.framework.container.interpreters.GadgetPerlInterpreter;
 import 
com.kysoh.tuxdroid.gadget.framework.container.interpreters.GadgetPythonInterpreter;
 
-import 
com.kysoh.tuxdroid.gadget.framework.container.interpreters.GadgetPerlInterpreter;
-import 
com.kysoh.tuxdroid.gadget.framework.container.interpreters.GadgetPythonInterpreter;
-
 public class GadgetsContainer {
        class AutoDeployerObserver implements AutoDeployerListener {
                public void deployementError(Throwable exception) {
@@ -164,7 +161,6 @@
        public void addGadget(File gadgetPath, Gadget gadget) throws 
GadgetsContainerException {
                GadgetDescription description = gadget.getDescription();
                validate(description, "No description found for this gadget");
-               validate(description.getExecutionMode(), "Execution Mode should 
be defined");
                validate(description.getName(), "Name not defined");
                validate(description.getUuid(), "UUID not defined");
                validate(gadget.getInterpreter().getExecutable(), 
"Interpreter/Excecutable not defined");

Modified: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/interpreters/GadgetInterpreter.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/interpreters/GadgetInterpreter.java
      2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/container/interpreters/GadgetInterpreter.java
      2008-08-02 11:12:56 UTC (rev 1440)
@@ -29,6 +29,8 @@
 import net.karmaLab.shell.transport.ShellTransortException;
 import net.karmaLab.tools.SystemInformation;
 
+import com.kysoh.tuxdroid.gadget.framework.container.GadgetToken;
+
 abstract public class GadgetInterpreter {
        private String executable = "";
        private String parameters = "";
@@ -62,9 +64,12 @@
                return workingPath;
        }
 
-       public final int run(Shell shell) throws ShellTransortException {
+       public final int run(Shell shell, GadgetToken command) throws 
ShellTransortException {
 
                String commandLine = prepareCommandLine();
+               if (command != null) {
+                       commandLine += " " + command.getName();
+               }
                CommandResult result = shell.run(commandLine);
 
                return result.exitStatus();

Modified: 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/gadget/SimpleGadget.java
===================================================================
--- 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/gadget/SimpleGadget.java
   2008-08-01 10:27:21 UTC (rev 1439)
+++ 
software_suite_v2/software/tuxdroid-gadget-framework/trunk/tuxdroid-gadget-framework/sources/com/kysoh/tuxdroid/gadget/framework/gadget/SimpleGadget.java
   2008-08-02 11:12:56 UTC (rev 1440)
@@ -131,13 +131,21 @@
         * 
         * <pre>
         * public static void main(String[] args) throws Exception {
-        *      new MyBeautifulGadget().boot(new MyGadgetConfiguration());
+        *      new MyBeautifulGadget().boot(args, new MyGadgetConfiguration());
         * }
         * </pre>
+        * 
+        * @param arguments
+        *            command line arguments (those you get with main
+        * @param configuration
+        *            a new configuration object
         */
        @SuppressWarnings("deprecation")
-       protected void boot(CONFIGURATION configuration) {
+       protected void boot(String[] arguments, CONFIGURATION configuration) {
                try {
+                       if (arguments.length > 0) {
+                               command = arguments[0];
+                       }
                        this.configuration = configuration;
                        initialize();
                        loadEnvironementData();
@@ -147,7 +155,32 @@
                }
        }
 
+       private String command = null;
+
        /**
+        * @return the command
+        */
+       protected String getCommand() {
+               return command;
+       }
+
+       /**
+        * @param command
+        *            the command to set
+        */
+       protected void setCommand(String command) {
+               this.command = command;
+       }
+
+       /**
+        * User boot with arguments instead
+        */
+       @Deprecated
+       protected void boot(CONFIGURATION configuration) {
+               boot(new String[] {}, configuration);
+       }
+
+       /**
         * This method is used a starting point for the gadget. The standard 
way to
         * use this adding in your inherited gadget class something like this :
         * 


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to