Commits

Anonymous committed 250f667

auto refresh

Comments (0)

Files changed (3)

nbproject/private/private.properties

-#Sat, 14 May 2011 21:41:34 +0800
+#Tue, 17 May 2011 15:39:15 +0800
 app-version.autoincrement=true
 config.active=release
-deployment.counter=72
-deployment.number=0.0.71
+deployment.counter=74
+deployment.number=0.0.73
 file.reference.cldc_classes.zip=/home/yaochunlin/NetBeansProjects/mobile-otp/lib/cldc_classes.zip
 file.reference.cldc_crypto.zip=/home/yaochunlin/NetBeansProjects/mobile-otp/lib/cldc_crypto.zip
 javadoc.preview=true

src/TokenGenerator/Main.java

 
 import TokenGenerator.Account.OtpType;
 import java.util.Date;
+import java.util.Timer;
+import java.util.TimerTask;
 import javax.microedition.midlet.*;
 import javax.microedition.lcdui.*;
-import javax.microedition.rms.RecordStoreException;
-import javax.microedition.rms.RecordStoreNotOpenException;
 
 /**
  * @author bruj0
     private StringItem stringItem;
     //</editor-fold>//GEN-END:|fields|0|
     private String selectedAccount;
-
+    private Timer timer;
     /**
      * The HelloMIDlet constructor.
      */
     public Main() {
     }
 
-    private void caculateToken() {
+    private synchronized void caculateToken() {
+        
         // write pre-action user code here
         OtpType type = AccountDB.getOtpType(selectedAccount);
         if (type == OtpType.HOTP) {
             long ts = (new Date()).getTime() / 1000L;
             getExtraInfo().setText(String.valueOf(interval.intValue() - (ts % interval.intValue())));
         }
-
+    
         // write post-action user code here
     }
 
-    private void updateAccount() {
+    private synchronized void updateAccount() {
         // write pre-action user code here
         try {
             String tokenKey = getSecretTextfield().getString();
         }
     }
 
-    private void editAccount() {
+    private synchronized void editAccount() {
         selectedAccount = getAccountList().getString(getAccountList().getSelectedIndex());
         getAccountNameTextField().setString(selectedAccount);
         getSecretTextfield().setString(AccountDB.getSecret(selectedAccount));
         switchDisplayable(null, getAddForm());
     }
 
-    private void deleteAccount() {
+    private synchronized void deleteAccount() {
         selectedAccount = getAccountList().getString(getAccountList().getSelectedIndex());
         getDeleteAccountName().setText(selectedAccount);
         switchDisplayable(null, getDeleteForm());
      */
     private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
         // write pre-initialize user code here
+        timer = new Timer();
+        timer.schedule(new TimerTask(){
 
+            public void run() {
+                if(selectedAccount != null){
+                    if(AccountDB.getOtpType(selectedAccount) == OtpType.TOTP){
+                        caculateToken();
+                    }
+                }
+            }
+        }, 1000, 1000);
 
         stringItem = new StringItem("\u786E\u8BA4\u5220\u9664\u4EE5\u4E0B\u5E10\u53F7\u5417\uFF1F", null);//GEN-LINE:|0-initialize|1|0-postInitialize
         // write post-initialize user code here
                 // write pre-action user code here
                 selectedAccount = getAccountList().getString(getAccountList().getSelectedIndex());
                 caculateToken();
-                switchDisplayable(null, getPassForm());//GEN-LINE:|7-commandAction|12|83-postAction
+//GEN-LINE:|7-commandAction|12|83-postAction
+                switchDisplayable(null, getPassForm());  
                 // write post-action user code here
             }//GEN-BEGIN:|7-commandAction|13|69-preAction
         } else if (displayable == addForm) {
             accountList.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);
             accountList.setSelectedFlags(new boolean[] {  });//GEN-END:|74-getter|1|74-postInit
             // write post-init user code here
+            accountList.setSelectCommand(getOkCommand());
             refreshAccountList();
         }//GEN-BEGIN:|74-getter|2|
         return accountList;
     public Command getOkCommand() {
         if (okCommand == null) {//GEN-END:|82-getter|0|82-preInit
             // write pre-init user code here
-            okCommand = new Command("\u786E\u5B9A", Command.OK, 0);//GEN-LINE:|82-getter|1|82-postInit
+            okCommand = new Command("\u786E\u5B9A", Command.ITEM, 9);//GEN-LINE:|82-getter|1|82-postInit
             // write post-init user code here
         }//GEN-BEGIN:|82-getter|2|
         return okCommand;

src/TokenGenerator/Main.vmd

                     <Property name="instanceName" typeID="Pjava.lang.String" value="VokCommand"/>
                     <Property name="codeGenerated" typeID="Pboolean" value="Vtrue"/>
                     <Property name="label" typeID="Pjava.lang.String" value="V确定"/>
-                    <Property name="type" typeID="Pint" value="V4"/>
+                    <Property name="type" typeID="Pint" value="V8"/>
+                    <Property name="priority" typeID="Pint" value="V9"/>
                 </Component>
                 <Component componentID="91" typeID="Cjavax.microedition.lcdui.Command">
                     <Property name="instanceName" typeID="Pjava.lang.String" value="VokCommand1"/>
                         </Component>
                     </Component>
                     <Component componentID="83" typeID="C#CommandEventSource">
-                        <Property name="eventHandler" typeID="C#EventHandler" value="R84"/>
                         <Property name="displayable" typeID="Cjavax.microedition.lcdui.Displayable" value="R74"/>
                         <Property name="command" typeID="Cjavax.microedition.lcdui.Command" value="R82"/>
-                        <Component componentID="84" typeID="C#SwitchDisplayableEventHandler">
-                            <Property name="eventSource" typeID="C#EventSource" value="R83"/>
-                            <Property name="displayable" typeID="Cjavax.microedition.lcdui.Displayable" value="R14"/>
-                        </Component>
                     </Component>
                     <Component componentID="107" typeID="C#CommandEventSource">
                         <Property name="displayable" typeID="Cjavax.microedition.lcdui.Displayable" value="R74"/>
         </Component>
     </Document>
     <FlowScene version="1">
+        <Node componentID="61" descriptorID="componentNode61" x="594" y="251"/>
+        <Node componentID="74" descriptorID="componentNode74" x="259" y="411"/>
+        <Node componentID="90" descriptorID="componentNode90" x="664" y="117"/>
         <Node componentID="14" descriptorID="componentNode14" x="268" y="31"/>
+        <Node componentID="108" descriptorID="componentNode108" x="558" y="399"/>
         <Node componentID="2" descriptorID="componentNode2" x="34" y="181"/>
-        <Node componentID="74" descriptorID="componentNode74" x="259" y="411"/>
-        <Node componentID="61" descriptorID="componentNode61" x="594" y="251"/>
-        <Node componentID="90" descriptorID="componentNode90" x="664" y="117"/>
-        <Node componentID="108" descriptorID="componentNode108" x="558" y="399"/>
     </FlowScene>
 </VisualDesign>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.