Author: remi
Date: 2009-06-03 12:21:07 +0200 (Wed, 03 Jun 2009)
New Revision: 4733

Added:
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.wiki
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/icon.png
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.pot
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.xml
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonPlugin.java
Removed:
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.png
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.pot
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.xml
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.html
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonGadget.java
Modified:
   
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/pom.xml
Log:
* refactored java plugin skeleton like the python one

Modified: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/pom.xml
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/pom.xml
   2009-06-03 09:55:01 UTC (rev 4732)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/pom.xml
   2009-06-03 10:21:07 UTC (rev 4733)
@@ -2,18 +2,18 @@
     <!--General project informations-->
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.kysoh</groupId>
-    <artifactId>tuxdroid-gadget-javaSkeleton</artifactId>
+    <artifactId>tuxdroid-plugin-javaSkeleton</artifactId>
     <packaging>jar</packaging>
     <version>0.0.1</version>
-    <name>This is a skeleton to build a java gadget.</name>
+    <name>This is a skeleton to build a java plugin.</name>
     <url>http://www.tuxisalive.com</url>
 
     <!--Dependency list-->
     <dependencies>
         <dependency>
             <groupId>com.kysoh</groupId>
-            <artifactId>tuxdroid-gadget-java-kit</artifactId>
-            <version>0.0.2</version>
+            <artifactId>tuxdroid-plugin-java-kit</artifactId>
+            <version>0.0.3</version>
         </dependency>
     </dependencies>
 
@@ -69,10 +69,10 @@
                         <mkdir dir="./libraries"/>
                         <copy 
file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
                             todir="./libraries" />
-                        <zip destfile="./${project.artifactId}.tgf">
+                        <zip destfile="./${project.artifactId}.scp">
                             <zipfileset dir="." includes="resources/*" />
                             <zipfileset dir="." includes="libraries/*" >
-                                <exclude 
name="libraries/tuxdroid-gadget-java-kit*" />
+                                <exclude 
name="libraries/tuxdroid-plugin-java-kit*" />
                                 <exclude name="libraries/karmalab-commons*" />
                                 <exclude name="libraries/tuxdroid-java-api*" />
                             </zipfileset>
@@ -85,13 +85,13 @@
                 </goals>
                 </execution>
 
-                <!--This section clean the ./libraries and the TGF file during 
the 'clean' lifecycle-->
+                <!--This section clean the ./libraries and the SCP file during 
the 'clean' lifecycle-->
                 <execution>
                 <phase>clean</phase>
                 <configuration>
                     <tasks>
                         <delete dir="./libraries"/>
-                        <delete file="./${project.artifactId}.tgf"/>
+                        <delete file="./${project.artifactId}.scp"/>
                     </tasks>
                 </configuration>
                     <goals>

Deleted: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.png
===================================================================
(Binary files differ)

Deleted: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.pot
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.pot
      2009-06-03 09:55:01 UTC (rev 4732)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.pot
      2009-06-03 10:21:07 UTC (rev 4733)
@@ -1,41 +0,0 @@
-msgid "Java gadget skeleton"
-msgstr ""
-
-msgid "Java skeleton."
-msgstr ""
-
-msgid "This is a skeleton to build a java gadget."
-msgstr ""
-
-msgid "Simple string parameter"
-msgstr ""
-
-msgid "Simple integer parameter"
-msgstr ""
-
-msgid "Simple boolean parameter"
-msgstr ""
-
-msgid "Simple enumerated parameter"
-msgstr ""
-
-msgid "Linux only parameter"
-msgstr ""
-
-msgid "Only for Linux"
-msgstr ""
-
-msgid "Windows only parameter"
-msgstr ""
-
-msgid "Only for Windows"
-msgstr ""
-
-msgid "Simple run command"
-msgstr ""
-
-msgid "Daemon run command"
-msgstr ""
-
-msgid "Simple check command"
-msgstr ""

Deleted: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.xml
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.xml
      2009-06-03 09:55:01 UTC (rev 4732)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/gadget.xml
      2009-06-03 10:21:07 UTC (rev 4733)
@@ -1,68 +0,0 @@
-<gadget>
-       <interpreter
-               kind="java">
-               <executable>SkeletonGadget</executable>
-       </interpreter>
-       <description>
-               <name>Java gadget skeleton</name>
-        <ttsName>Java skeleton.</ttsName>
-               <description>This is a skeleton to build a java 
gadget.</description>
-               <author>Kysoh</author>
-               <version>0.0.1</version>
-               <iconFile>resources/gadget.png</iconFile>
-               <uuid>23ab109b-9bad-41cb-bca6-ab6d4bbe632f</uuid>
-        <platform>all</platform>
-       </description>
-       <parameters>
-        <parameter
-                       name="stringParam"
-                       description="Simple string parameter"
-                       type="string"
-                       defaultValue="My string"
-            platform="all"/>
-        <parameter
-                       name="integerParam"
-                       description="Simple integer parameter"
-                       type="integer"
-                       defaultValue="0"
-            platform="all"/>
-        <parameter
-                       name="booleanParam"
-                       description="Simple boolean parameter"
-                       type="boolean"
-                       defaultValue="false"
-            platform="all"/>
-        <parameter
-                       name="enumeratedParam"
-                       description="Simple enumerated parameter"
-                       type="enum(value1,value2,value3,value4,valueN)"
-                       defaultValue="value1"
-            platform="all"/>
-        <parameter
-                       name="linuxParam"
-                       description="Linux only parameter"
-                       type="string"
-                       defaultValue="Only for Linux"
-            platform="linux"/>
-        <parameter
-                       name="windowsParam"
-                       description="Windows only parameter"
-                       type="string"
-                       defaultValue="Only for Windows"
-            platform="windows"/>
-       </parameters>
-       <commands>
-               <command
-                       name="run"
-                       description="Simple run command"
-            daemon="false" />
-        <command
-                       name="run_daemon"
-                       description="Daemon run command"
-            daemon="true" />
-               <command
-                       name="check"
-                       description="Simple check command"
-            daemon="false" />
-       </commands>
-</gadget>

Deleted: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.html
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.html
       2009-06-03 09:55:01 UTC (rev 4732)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.html
       2009-06-03 10:21:07 UTC (rev 4733)
@@ -1,6 +0,0 @@
-<html>
-<body>
-<font size="2" face="Verdana, Arial, Helvetica, sans-serif">This is a skeleton 
to build a java gadget.<br>
-</font> 
-</body>
-</html>

Added: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.wiki
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.wiki
                               (rev 0)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.wiki
       2009-06-03 10:21:07 UTC (rev 4733)
@@ -0,0 +1,25 @@
+= Synopsis =
+This is a skeleton to help developpers to build they first plugin.
+
+== Some markup tests ==
+Some markup tests.
+* a mixed
+* multilevel 
+*1. list
+*1I. with 
+*1I. roman
+*1Ig. and
+*1Ig. greek
+*1. letters
+
+A plugin from the [http://www.kysoh.com, Kysoh] compagny.
+
+; '''Plugin definition''': ''A plugin is a set of functions stored in a scp 
file.''
+
+== An example of table ==
+
+[{>,w:80\%,b}| '''Plugin name''' | '''On demand''' | '''Have alerts''' |
+| Battery monitor | ''No'' | ''Yes'' |
+| Feed RSS | ''Yes'' | ''Yes'' |
+| Webradio | ''Yes'' | ''Yes'' |
+| Clipboard | ''Yes'' | ''No'' |]
\ No newline at end of file


Property changes on: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/help.wiki
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/icon.png
===================================================================
(Binary files differ)


Property changes on: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/icon.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream
Name: svn:keywords
   + Id

Added: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.pot
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.pot
                              (rev 0)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.pot
      2009-06-03 10:21:07 UTC (rev 4733)
@@ -0,0 +1,41 @@
+msgid "Java plugin skeleton"
+msgstr ""
+
+msgid "Java skeleton."
+msgstr ""
+
+msgid "This is a skeleton to build a java plugin."
+msgstr ""
+
+msgid "Simple string parameter"
+msgstr ""
+
+msgid "Simple integer parameter"
+msgstr ""
+
+msgid "Simple boolean parameter"
+msgstr ""
+
+msgid "Simple enumerated parameter"
+msgstr ""
+
+msgid "Linux only parameter"
+msgstr ""
+
+msgid "Only for Linux"
+msgstr ""
+
+msgid "Windows only parameter"
+msgstr ""
+
+msgid "Only for Windows"
+msgstr ""
+
+msgid "Simple run command"
+msgstr ""
+
+msgid "Daemon run command"
+msgstr ""
+
+msgid "Simple check command"
+msgstr ""


Property changes on: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.pot
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.xml
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.xml
                              (rev 0)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.xml
      2009-06-03 10:21:07 UTC (rev 4733)
@@ -0,0 +1,174 @@
+<plugin>
+       <interpreter
+               kind="java">
+               <executable>SkeletonPlugin</executable>
+       </interpreter>
+       <description>
+               <name>Java plugin skeleton</name>
+        <ttsName>Java plugin.</ttsName>
+               <description>This is a skeleton to build a java 
plugin.</description>
+               <author>Kysoh</author>
+               <version>0.0.1</version>
+               <iconFile>resources/icon.png</iconFile>
+               <uuid>23ab109b-9bad-41cb-bca6-ab6d4bbe632f</uuid>
+        <platform>all</platform>
+       </description>
+       <parameters>
+        <parameter
+                       name="stringParam"
+                       description="Simple string parameter"
+                       type="string"
+                       defaultValue="My string"
+            platform="all"/>
+        <parameter
+                       name="integerParam"
+                       description="Simple integer parameter"
+                       type="integer"
+                       defaultValue="0"
+            platform="all"/>
+        <parameter
+                       name="booleanParam"
+                       description="Simple boolean parameter"
+                       type="boolean"
+                       defaultValue="false"
+            platform="all"/>
+        <parameter
+                       name="enumeratedParam"
+                       description="Simple enumerated parameter"
+                       type="enum(value1,value2,value3,value4,valueN)"
+                       defaultValue="value1"
+            platform="all"/>
+        <parameter
+                       name="linuxParam"
+                       description="Linux only parameter"
+                       type="string"
+                       defaultValue="Only for Linux"
+            platform="linux"/>
+        <parameter
+                       name="windowsParam"
+                       description="Windows only parameter"
+                       type="string"
+                       defaultValue="Only for Windows"
+            platform="windows"/>
+       </parameters>
+       <commands>
+               <command
+                       name="run"
+                       description="Simple run command"
+            daemon="false" />
+        <command
+                       name="run_daemon"
+                       description="Daemon run command"
+            daemon="true" />
+               <command
+                       name="check"
+                       description="Simple check command"
+            daemon="false" />
+       </commands>
+    <tasks>
+        <task
+            name="My checker"
+            description="Check a condition every x minutes"
+            command="check"
+            type="every x"
+            activated="false"
+
+            weekMask="true,false,false,false,false,false,false"
+            weekMaskType="exclusive"
+            weekMaskVisible="true"
+
+            date="0000/00/00"
+            dateVisible="false"
+
+            hoursBegin="00:00:00"
+            hoursBeginMask="true,true,false"
+            hoursBeginVisible="true"
+
+            hoursEnd="23:59:00"
+            hoursEndMask="true,true,false"
+            hoursEndVisible="true"
+
+            delay="00:01:00"
+            delayMask="false,true,false"
+            delayVisible="true"
+        />
+        <task
+            name="My daemon"
+            description="Manages my daemon"
+            command="run_daemon"
+            type="daily at"
+            activated="false"
+
+            weekMask="true,true,true,true,true,true,true"
+            weekMaskType="weekpart"
+            weekMaskVisible="true"
+
+            date="2009/10/10"
+            dateVisible="false"
+
+            hoursBegin="07:00:00"
+            hoursBeginMask="true,true,false"
+            hoursBeginVisible="true"
+
+            hoursEnd="10:00:00"
+            hoursEndMask="true,true,false"
+            hoursEndVisible="true"
+
+            delay="00:01:00"
+            delayMask="false,true,false"
+            delayVisible="false"
+        />
+        <task
+            name="Anniversary"
+            description="Don't forget my anniversary !"
+            command="run"
+            type="once at"
+            activated="false"
+
+            weekMask="true,true,true,true,true,true,true"
+            weekMaskType="flat"
+            weekMaskVisible="false"
+
+            date="2009/10/10"
+            dateVisible="true"
+
+            hoursBegin="10:00:00"
+            hoursBeginMask="true,true,false"
+            hoursBeginVisible="true"
+
+            hoursEnd="23:59:00"
+            hoursEndMask="true,true,false"
+            hoursEndVisible="false"
+
+            delay="00:01:00"
+            delayMask="false,true,false"
+            delayVisible="false"
+        />
+        <task
+            name="A complete alert configuration"
+            description="This show a complet alert configuration"
+            command="run"
+            type="daily at"
+            activated="false"
+
+            weekMask="true,true,true,true,true,true,true"
+            weekMaskType="flat"
+            weekMaskVisible="true"
+
+            date="2009/12/31"
+            dateVisible="true"
+
+            hoursBegin="10:00:00"
+            hoursBeginMask="true,true,true"
+            hoursBeginVisible="true"
+
+            hoursEnd="11:59:00"
+            hoursEndMask="true,true,true"
+            hoursEndVisible="true"
+
+            delay="00:01:00"
+            delayMask="true,true,true"
+            delayVisible="true"
+        />
+    </tasks>
+</plugin>


Property changes on: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/resources/plugin.xml
___________________________________________________________________
Name: svn:keywords
   + Id

Deleted: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonGadget.java
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonGadget.java
       2009-06-03 09:55:01 UTC (rev 4732)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonGadget.java
       2009-06-03 10:21:07 UTC (rev 4733)
@@ -1,205 +0,0 @@
-/* This file is part of "Skeleton java gadget".
- *    Copyright 2009, kysoh
- *    Author : Remi Jocaille
- *    eMail  : [email protected]
- *    Site   : http://www.kysoh.com/
- *
- * "Skeleton java gadget" 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.
- *
- * "Skeleton java gadget" 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 "Skeleton java gadget"; 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.
- */
-
-import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadget;
-import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadgetConfiguration;
-import com.kysoh.tuxdroid.gadget.framework.gadget.SimpleGadgetException;
-
-/**
- * This class override the SimpleGadget class to make easy
- * the gadget coding.
- */
-public class SkeletonGadget extends SimpleGadget<SkeletonGadget.Configuration>
-{
-       /**
-        * Enumerator of the parameter "enumeratedParam"
-        */
-       public static enum EnumParameter
-       {
-               value1, value2, value3, value4, valueN;
-       }
-       
-       /**
-        * This class make an access to the gadget parameters.
-     * Parameters are automatically filled by the SimpleGadget class at gadget
-     * starting.
-        */
-       public static class Configuration extends SimpleGadgetConfiguration
-       {
-               private String stringParam = "";
-               private int integerParam = 0;
-               private boolean booleanParam = false;
-               private EnumParameter enumeratedParam = EnumParameter.value1;
-               private String linuxParam = "";
-               private String windowsParam = "";
-
-               public String getStringParam()
-               {
-                       return stringParam;
-               }
-               
-               public void setStringParam(String stringParam)
-               {
-                       this.stringParam = stringParam;
-               }
-               
-               public int getIntegerParam()
-               {
-                       return integerParam;
-               }
-               
-               public void setIntegerParam(int integerParam)
-               {
-                       this.integerParam = integerParam;
-               }
-               
-               public boolean getBooleanParam()
-               {
-                       return booleanParam;
-               }
-               
-               public void setBooleanParam(boolean booleanParam)
-               {
-                       this.booleanParam = booleanParam;
-               }
-               
-               public EnumParameter getEnumeratedParam()
-               {
-                       return enumeratedParam;
-               }
-               
-               public void setEnumeratedParam(EnumParameter enumeratedParam)
-               {
-                       this.enumeratedParam = enumeratedParam;
-               }
-               
-               public String getLinuxParam()
-               {
-                       return linuxParam;
-               }
-               
-               public void setLinuxParam(String linuxParam)
-               {
-                       this.linuxParam = linuxParam;
-               }
-               
-               public String getWindowsParam()
-               {
-                       return windowsParam;
-               }
-               
-               public void setWindowsParam(String windowsParam)
-               {
-                       this.windowsParam = windowsParam;
-               }
-       }
-       
-       private boolean daemonRun = false;
-       
-       /**
-        * Program entry point.
-        */
-       public static void main(String[] args) throws Exception {
-               new SkeletonGadget().boot(args, new Configuration());
-       }
-       
-       /**
-        * Gadget entry point.
-        * This method should be used to dispatch commands.
-        */
-       public void start() throws SimpleGadgetException
-       {
-               if (this.getCommand().equals("run"))
-               {
-                       this.run();
-               }
-               else if (this.getCommand().equals("run_daemon"))
-               {
-                       this.runDaemon();
-               }
-               else if (this.getCommand().equals("check"))
-               {
-                       this.check();
-               }
-               else
-               {
-                       this.run();
-               }
-       }
-       
-       /**
-        * Gadget entry point for the "run" command.
-        */
-       private void run()
-       {
-               if (this.isWindows())
-               {
-                       
this.throwMessage(this.configuration().getWindowsParam());
-               }
-               else
-               {
-                       this.throwMessage(this.configuration().getLinuxParam());
-               }
-               this.throwMessage("I finished my work ...");
-       }
-       
-       /**
-        * Gadget entry point for the "run_daemon" command.
-        */
-       private void runDaemon()
-       {
-               /* Start a fake daemon loop ...
-         * Warning the daemonRun flag is not safe-thread (in order to have a
-         * clean code in this gadget example) */
-               this.daemonRun = true;
-               while (this.daemonRun)
-               {
-                       try
-                       {
-                               Thread.sleep(500);
-                       }
-                       catch (InterruptedException e) {}
-               }
-       }
-       
-       /**
-        * Gadget entry point for the "check" command.
-        */
-       private void check()
-       {
-               /* Check a condition ...
-         * For example get the value of the parameter "booleanParam" */
-               boolean checkResult = this.configuration().getBooleanParam();
-               /* Return the check result */
-               this.throwResult(checkResult);
-               this.throwMessage("I throwed my result, so I can die. RIP ...");
-       }
-       
-       /**
-        * Callback on gadget stop.
-        */
-       public void onGadgetStop()
-       {
-               /* Stop the fake daemon loop */
-               this.daemonRun = false;
-       }
-}

Copied: 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonPlugin.java
 (from rev 4620, 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonGadget.java)
===================================================================
--- 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonPlugin.java
                               (rev 0)
+++ 
software_suite_v3/smart-core/smart-dev/plugin-toolkit/java/skeleton/trunk/sources/SkeletonPlugin.java
       2009-06-03 10:21:07 UTC (rev 4733)
@@ -0,0 +1,220 @@
+/* This file is part of "Skeleton java plugin".
+ *    Copyright 2009, kysoh
+ *    Author : Remi Jocaille
+ *    eMail  : [email protected]
+ *    Site   : http://www.kysoh.com/
+ *
+ * "Skeleton java plugin" 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.
+ *
+ * "Skeleton java plugin" 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 "Skeleton java plugin"; 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.
+ */
+
+import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePlugin;
+import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePluginConfiguration;
+import com.kysoh.tuxdroid.plugin.framework.plugin.SimplePluginException;
+
+/**
+ * This class override the SimpleGadget class to make easy
+ * the gadget coding.
+ */
+public class SkeletonPlugin extends SimplePlugin<SkeletonPlugin.Configuration>
+{
+       /**
+        * Enumerator of the parameter "enumeratedParam"
+        */
+       public static enum EnumParameter
+       {
+               value1, value2, value3, value4, valueN;
+       }
+       
+       /**
+        * This class make an access to the gadget parameters.
+     * Parameters are automatically filled by the SimpleGadget class at gadget
+     * starting.
+        */
+       public static class Configuration extends SimplePluginConfiguration
+       {
+               private String stringParam = "";
+               private int integerParam = 0;
+               private boolean booleanParam = false;
+               private EnumParameter enumeratedParam = EnumParameter.value1;
+               private String linuxParam = "";
+               private String windowsParam = "";
+
+               public String getStringParam()
+               {
+                       return stringParam;
+               }
+               
+               public void setStringParam(String stringParam)
+               {
+                       this.stringParam = stringParam;
+               }
+               
+               public int getIntegerParam()
+               {
+                       return integerParam;
+               }
+               
+               public void setIntegerParam(int integerParam)
+               {
+                       this.integerParam = integerParam;
+               }
+               
+               public boolean getBooleanParam()
+               {
+                       return booleanParam;
+               }
+               
+               public void setBooleanParam(boolean booleanParam)
+               {
+                       this.booleanParam = booleanParam;
+               }
+               
+               public EnumParameter getEnumeratedParam()
+               {
+                       return enumeratedParam;
+               }
+               
+               public void setEnumeratedParam(EnumParameter enumeratedParam)
+               {
+                       this.enumeratedParam = enumeratedParam;
+               }
+               
+               public String getLinuxParam()
+               {
+                       return linuxParam;
+               }
+               
+               public void setLinuxParam(String linuxParam)
+               {
+                       this.linuxParam = linuxParam;
+               }
+               
+               public String getWindowsParam()
+               {
+                       return windowsParam;
+               }
+               
+               public void setWindowsParam(String windowsParam)
+               {
+                       this.windowsParam = windowsParam;
+               }
+       }
+       
+       private boolean daemonRun = false;
+       
+       /**
+        * Program entry point.
+        */
+       public static void main(String[] args) throws Exception {
+               new SkeletonPlugin().boot(args, new Configuration());
+       }
+       
+       /**
+        * Plugin entry point.
+        * This method should be used to dispatch commands.
+        */
+       public void start() throws SimplePluginException
+       {
+               if (this.getCommand().equals("run"))
+               {
+                       this.run();
+               }
+               else if (this.getCommand().equals("run_daemon"))
+               {
+                       this.runDaemon();
+               }
+               else if (this.getCommand().equals("check"))
+               {
+                       this.check();
+               }
+               else
+               {
+                       this.run();
+               }
+       }
+       
+       /**
+        * Plugin entry point for the "run" command.
+        */
+       private void run()
+       {
+               if (this.isWindows())
+               {
+                       
this.throwMessage(this.configuration().getWindowsParam());
+               }
+               else
+               {
+                       this.throwMessage(this.configuration().getLinuxParam());
+               }
+               this.throwActuation("mouthOn", 2, "NDEF");
+               this.throwMessage("I finished my work ...");
+       }
+       
+       /**
+        * Plugin entry point for the "run_daemon" command.
+        */
+       private void runDaemon()
+       {
+               /* Start a fake daemon loop ...
+         * Warning the daemonRun flag is not safe-thread (in order to have a
+         * clean code in this plugin example) */
+               this.daemonRun = true;
+               while (this.daemonRun)
+               {
+                       try
+                       {
+                               Thread.sleep(500);
+                       }
+                       catch (InterruptedException e) {}
+               }
+       }
+       
+       /**
+        * Plugin entry point for the "check" command.
+        */
+       private void check()
+       {
+               /* Check a condition ...
+         * For example get the value of the parameter "booleanParam" */
+               boolean checkResult = this.configuration().getBooleanParam();
+               /* Return the check result */
+               this.throwResult(checkResult);
+               this.throwMessage("I throwed my result, so I can die. RIP ...");
+       }
+       
+       /**
+        * Callback on plugin stop.
+        */
+       public void onPluginStop()
+       {
+               /* Stop the fake daemon loop */
+               this.daemonRun = false;
+       }
+       
+       /**
+        * Callback on plugin event.
+        */
+       public void onPluginEvent(String eventName, String[] eventValues)
+       {
+               this.throwMessage("I received event");
+               this.throwTrace(eventName);
+               this.throwTrace(Integer.toString(eventValues.length));
+               for (int i = 0; i < eventValues.length; i++)
+               {
+                       this.throwTrace(eventValues[i]);
+               }
+       }
+}


------------------------------------------------------------------------------
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