Author: remi
Date: 2009-06-03 10:58:15 +0200 (Wed, 03 Jun 2009)
New Revision: 4729

Modified:
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
Log:
* added throwActuation method to the SimplePlugin class
* added handling of the events from the server

Modified: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
 2009-06-03 08:32:45 UTC (rev 4728)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/SimplePlugin.java
 2009-06-03 08:58:15 UTC (rev 4729)
@@ -64,6 +64,20 @@
                                SimplePlugin.this.throwError(e);
                        }
                }
+               
+               /**
+                * Event on stdin received event from server.
+                */
+               public void serverEvent(String eventName, String[] eventValues)
+               {
+                       try
+                       {
+                               SimplePlugin.this.onPluginEvent(eventName, 
eventValues);
+                       } catch (Throwable e)
+                       {
+                               SimplePlugin.this.throwError(e);
+                       }
+               }
        }
 
        /**
@@ -240,6 +254,14 @@
        protected abstract void onPluginStop() throws Throwable;
        
        /**
+        * On plugin event.
+        * this method should be defined in your plugin class.
+        * @throws Throwable
+        *                              when something go wrong...
+        */
+       protected abstract void onPluginEvent(String eventName, String[] 
eventValues) throws Throwable;
+       
+       /**
         * Stop the plugin.
         */
        public void stop()
@@ -282,6 +304,19 @@
                else resultValue = "false";
                throwNotification("check_result", resultValue);
        }
+       
+       /**
+        * This is a special notification used to send "actuation" to the
+        * server.
+        */
+       public void throwActuation(String actuationName, Object... arguments) {
+               String[] tmp = new String[arguments.length + 1];
+               tmp[0] = actuationName;
+               for (int i = 0; i < arguments.length; i++) {
+                       tmp[i + 1] = String.valueOf(arguments[i]);
+               }
+               throwNotification("actuation", tmp);
+       }
 
        /**
         * When something go wrong, you can use this function to throw an 
exception

Modified: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
     2009-06-03 08:32:45 UTC (rev 4728)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInCom.java
     2009-06-03 08:58:15 UTC (rev 4729)
@@ -125,6 +125,25 @@
                                }
                                this.setRun(false);
                        }
+                       else if (rcvLine.toLowerCase().startsWith("event"))
+                       {
+                               String[] sltLine = rcvLine.split(":");
+                               // Get event name
+                               if (sltLine.length > 1)
+                               {
+                                       String eventName = sltLine[1];
+                                       // Get event values
+                                       String[] eventValues = new 
String[sltLine.length - 2];
+                                       for (int i = 0; i < sltLine.length - 2; 
i++)
+                                       {
+                                               eventValues[i] = sltLine[i + 2];
+                                       }
+                                       if (stdInComListener != null)
+                                       {
+                                               
stdInComListener.serverEvent(eventName, eventValues);
+                                       }
+                               }
+                       }
                        try {
                                this.sleep(100);
                        } catch (InterruptedException e) {}

Modified: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
     2009-06-03 08:32:45 UTC (rev 4728)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/simpleplugin-java-kit/trunk/sources/com/kysoh/tuxdroid/plugin/framework/plugin/StdInComListener.java
     2009-06-03 08:58:15 UTC (rev 4729)
@@ -25,4 +25,6 @@
 public interface StdInComListener
 {
        void stopped();
+       
+       void serverEvent(String eventName, String[] eventValues);
 }


------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to