Tuesday, 24 April 2012

GSoC 2012 - Networking Dashboard

My proposal for 'Networking Dashboard' for 'Mozilla' got selected for GSoC 2012 today :).
I have been a contributor to Mozilla for a long time now. Till now mostly it was bug fixes.
But now I will be working on something real for Mozilla. My project is to make a tool for developers which allows them to have an insight of Mozilla networking. Google chrome already has something similar - "chrome://net-internals". This tool will be implemented as an add-on. The link to my proposal is here. It has a description about what functionality will be implemented. I wish I have a link to the add-on soon. I might blog about my experience with necko and about my progress in future. Stay tuned.

Fun with Flotype

I came across this new start up Flotype through a blog at hacker news.
It provides cross-language services to expose data and realtime updates to client devices and browsers.
They have simple APIs which can be used right away.  So I created a new account and started playing with the beta version. My first idea is to setup the server on my laptop and client on my android phone. So whenever server receives the message, it makes a system call for the message. That way I could use my laptops terminal remotely. Since it's available only in Javascript,Java,Ruby and Python, I chose Java.
First of all I created a server on my laptop:
 import com.flotype.bridge.*;  
 class ChatObj implements BridgeObject {  
   public void message(String sender, String message) {  
     System.out.println(sender + ":" + message);  
     Process execAcrobatPrs=null;  
       execAcrobatPrs = Runtime.getRuntime().exec(new String[]{"sh", "-c",message});  
    catch(Exception ex)  
 public class AuthServer {  
   public static void main(String[] args) throws Exception {  
     Bridge bridge = new Bridge()  
     bridge.joinChannel("channel-name", new ChatObj());  
and the client for android:
 package com.jiten;  
 import java.io.IOException;  
 import com.flotype.bridge.*;  
 import android.app.Activity;  
 import android.os.Bundle;  
 import android.util.Log;  
 import android.view.View;  
 import android.view.View.OnClickListener;  
 import android.widget.Button;  
 import android.widget.EditText;  
 interface RemoteChat extends BridgeRemoteObject {  
   public void message(String sender, String message);  
 public class MessageSenderActivity extends Activity implements OnClickListener{  
   /** Called when the activity is first created. */  
   public void onCreate(Bundle savedInstanceState) {  
     Button b = (Button) findViewById(R.id.button1);  
     b.setOnClickListener((android.view.View.OnClickListener) this);  
      public void onClick(View arg0) {  
           if(arg0.getId() == R.id.button1) {  
                EditText t = (EditText) findViewById(R.id.editText1);  
                Bridge bridge = new Bridge().setApiKey("myprivatekey");  
          RemoteChat channel = bridge.getChannel("channel-name", RemoteChat.class);  
          channel.message("Jiten", t.getText().toString());  
          try {  
                } catch (IOException e) {  
                     // TODO Auto-generated catch block  

That's it. Now I can run any terminal command from my laptop through my android phone.
This still is not interactive so it's of no use for commands like 'ls' but you can run applications in which you don't need interaction.
Well, I can't think of any important use for this but it was fun starting 'Catalyst' in my laptop through a command in my mobile phone. In future I might improve it for interactivity.