Monday, June 13, 2011

Developing first example application: Remotetime App in eyeOS

In this post you'll find the code to write an example of Remote Time App, explained previously in the eyeOS developer manual. Be aware that the post will also be rewrote ... because the perfection is only achieved by revision.

First need to download and install eyeOS on your system (mind note: create a post with a small guide on how to prepare your development environment), and then you can continue.

Create a folder with the application name in eyeOS/apps in our case remotetime.
Now access to your eyeOS/apps/remotetime/ folder and create three files as follows:
for info.xml
<?xml version="1.0"?>
<meta>
  <entry key="eyeos.application.name">Remote Time</entry>
  <entry key="eyeos.application.author">Julio Molina Soler</entry>
  <entry key="eyeos.application.version">1.0</entry>
  <entry key="eyeos.application.description">Simple application example</entry>
  <entry key="eyeos.application.license">AGPL</entry>
  <entry key="eyeos.application.category">Utils</entry>
  <entry key="eyeos.application.iconUrl">sys:///extern/images/48x48/apps/accessories-calculator.png</entry>
  <entry key="eyeos.application.taskBarIconUrl">sys:///extern/images/16x16/apps/accessories-calculator.png</entry>
  <entry key="eyeos.application.systemParameters" type="array">
   <entry key="listable">true</entry>
   <entry key="owner">root</entry>
   <entry key="group">users</entry>
   <entry key="permissions">---x--x--x</entry>
   <entry key="anonymous">false</entry>
   <entry key="suid">false</entry>
  </entry>
</meta>

Then create the file remotetime.js that holds the interaction with eyeOS, in this case would be a javascript file:
function remotetime_application(checknum,pid,args){
 var app = new eyeos.application.Remotetime(checknum,pid);
 app.drawGUI();
}

qx.Class.define("eyeos.application.Remotetime", 
  {extend: eyeos.system.EyeApplication,
   construct: function(checknum,pid){
    arguments.callee.base.call(this,"Remotetime",checknum,pid);
   },
   members: {
    drawGUI: function(){
     var mainWindow = new eyeos.ui.Window(this, tr("Remote Time"), 'index.php?extern=/images/16x16/apps/accessories-calculator.png');
     mainWindow.setLayout(new qx.ui.layout.VBox(3));
     mainWindow.setAllowMaximize(false);
     mainWindow.open();
     // Display setup
     var display = new qx.ui.basic.Label("").set({
      allowGrowX: true,
      allowGrowY: true,
      textAlign : "right",
      font: "bold",
      decorator: "main"
     });
     mainWindow.add(display);
     // Button setup
     var b2 = new qx.ui.form.Button("Get the time");
     b2.addListener('click',function(){
      eyeos.callMessage(this.getChecknum(),'getTime',null,function(hora){
       display.setValue(hora);
      },this);
      },this);
     mainWindow.add(b2);
    }
   }
});

We will also create the file remotetime.php, it will return the correct date/time every time we press the button:
<?php
abstract class RemotetimeApplication extends EyeosApplicationExecutable {
 public static function getTime(){
  return date('l jS \of F Y h:i:s A');
 }
}
?>

1 comment:

  1. can you please provide me details ...of uploadin data to eyeos cloud from a mobile app....If so wat's the uri i can give in the mobile app for the particular storage place of the eyeos cloud....my mobile app is an android based app, codings for the android app is done in java...waiting for ur skilful reply ASAP... :)

    ReplyDelete