Jump to content

Encore une appli belge: BBOX infos


Recommended Posts

Info destinée aux belges ayant une connexion internet Belgacom.

J'avais besoin de voir qui était connecté sur mon réseau Wifi, je me suis donc fait une appli minute.

Pour l'instant, elle satisfait mes besoins simples, mais j'avais envie de partager tout ca! Je ne sais pas si ca fonctionnera chez tout le monde, mais chez moi, ca fonctionne.

Recherchez Belgacom sur le market et mettez le mot de passe que vous mettez à pârtir de cette page: http://192.168.1.1/

Suis ouvert à toutes propositions d'amélioration. Comme toujours: l'interface, je m'en branle au début :D

Je peux retrouver toutes les infos disponibles sur la BBOX, mais comme j'y connais rien en réseau, je sais pas ce qui est important (IPoE, PPPoE, VLAN 10, DHCP server status, WAN MAC Address) car c'est du chinois pour moi! Donc faites votre demande et dites moi ce qui vous intéresse dans ce foutoir.

20091226-xdtbxs2j5ixy43peybapy7qypr.jpg

Petit travail sur l'apparence et plus besoin de mot de passe!!!

20091226-d14bd8456ymjw9976xbcapt9tw.jpg

Edited by Profete162
Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Ca y'est déjà des utilisateurs en Asie et en Amerique du nord... Faut croire qu'ils ne savent pas lire la description d'une application!

Je n'ai pas ce probleme avec l'application des trains.

Bon, bin nouvelle version sur le market, plus besoin de rentrer son mot de passe, l'appli fait tout toute seule! ( note: c'est un peu inquiétant car je peux me connecter sur n'importe quelle Box et changer les parametres,... Bravo Belgacom!

Link to comment
Share on other sites

essaye avec ton navigateur (http://192.168.1.1/) , tu auras le même probleme.

Je ne sais pas trop ce que ca veut dire... Mais il suffit de redémarrer la Box.

Si tu as MSN/Google Talk et que tu as quelques minutes, contacte moi par MP, cela me permettra d'avoir mes premiers retours sur une Box qui n'est pas la mienne!

Edited by Profete162
Link to comment
Share on other sites

Voilà, envoyé, désolé, dans ma hâte d'aller manger j'ai oublié d'envoyé mon message privé :rolleyes:.

Mon ordinateur est effectivement connecté par câble.

J'ai la box, en bas avec un câble Ethernet qui monte dans ma chambre et se connecte au routeur puis mon ordinateur est connecté à ce routeur.

Edited by dona-3000
Link to comment
Share on other sites

  • 3 months later...

Bon,je vous balance tout le code:

à savoir:

J'ai écrit ce code une semaine apres mon premier tutorial Java, c'est donc horrible!

Ne me jugez pas là dessus par pitié!

package tof.cv.BBoxInfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class BBoxInfo extends ListActivity {

   String mon_url;
   public static final String PREFS_NAME = "MyBBOXPrefsFile";
   SharedPreferences settings;
   private Cursor mNotesCursor;
   private int mNoteNumber = 1;
   private static NotesDbAdapter mDbHelper;



   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);

       mDbHelper = new NotesDbAdapter(this);
       mDbHelper.open();

       final TextView etHt= (TextView) findViewById(R.id.etHowTo);       
       final EditText etPw= (EditText) findViewById(R.id.etPw);
       final LinearLayout llChamps= (LinearLayout) findViewById(R.id.llchamps);
       final Button bnSearch= (Button) findViewById(R.id.bnSearch);
       final ImageView ivBox= (ImageView) findViewById(R.id.ivBox);

       settings = getSharedPreferences(PREFS_NAME, 0);
       //SharedPreferences.Editor editor = settings.edit();
       String defaultSearch = settings.getString("pSearch","");
       etPw.setText(defaultSearch);

       String html=Codes.getHTML("http://192.168.1.1/index.cgi?user_name=admin&password=BGCVDSL2");

       llChamps.setVisibility(1);
       etHt.setVisibility(1);
       bnSearch.setVisibility(1);

       if(!html.contentEquals(""))
       { 
           Codes.mondebug("AutoLogin...");
           mDbHelper.deleteAllNote();
           getProp(html);
           llChamps.setVisibility(8);
           etHt.setVisibility(8);
           bnSearch.setVisibility(8);
           ivBox.setVisibility(8);
       }


       Button my_ok_button = (Button)findViewById(R.id.bnSearch);
       my_ok_button.setOnClickListener(new Button.OnClickListener() {        
           public void onClick(View v) { 



               String mdp=etPw.getText().toString();
               mon_url="http://192.168.1.1/index.cgi?user_name=user&password="+mdp;



               String html=Codes.getHTML(mon_url);
               if(html.contentEquals(""))
               { 
                   html=Codes.getHTML("http://192.168.1.1/index.cgi?user_name=admin&password=BGCVDSL2");
                   if(html.contentEquals(""))
                   { 
                       Codes.mondebug("Password Not OK...");
                       mDbHelper.deleteAllNote();
                       createNote("Verifiez votre mot de passe (admin par d�faut)\nEtes vous connect� en Wifi sur votre BBOX?","","");
                       fillData();
                       llChamps.setVisibility(1);
                       etHt.setVisibility(1);
                       bnSearch.setVisibility(1);
                       ivBox.setVisibility(1);
                   }
                   else
                   { 
                       Codes.mondebug("Password Not OK... Testing with default Password");
                       mDbHelper.deleteAllNote();
                       getProp(html);
                       llChamps.setVisibility(8);
                       etHt.setVisibility(8);
                       bnSearch.setVisibility(8);
                       ivBox.setVisibility(8);

                   }
               }
               else
               { 
                   Codes.mondebug("Password OK");
                   mDbHelper.deleteAllNote();
                   getProp(html);
                   llChamps.setVisibility(8);
                   etHt.setVisibility(8);
                   bnSearch.setVisibility(8);
                   ivBox.setVisibility(8);

               }

           }
       });


   }


   private void getProp(String html){

       Codes.mondebug(html);
       try{

           html=html.substring(html.indexOf("Clients MAC Address"));
           html=html.substring(html.indexOf("\"status\">")+9);
           String title=html.substring(0,html.indexOf("<"));
           html=html.substring(html.indexOf("connected")+9);
           createNote(CorrectHTML(title),CorrectHTML(html.substring(0,html.indexOf(" "))),"");

         } catch (Exception e) {
           Log.e("BACKGROUND_PROC", e.getMessage());
           createNote("Erreur","La version de ta Box n'est pas supportée.\nContacte moi par mail pour que je mette le programme � jour.","");

         }
         fillData();
     }




   public static String CorrectHTML (String bla)
   {

   String txt=bla.replace("
","\n");
   //txt=txt.replace(" ", " ");



   return txt;
   }



   public void createNote(String noteName, String noteBody, String noteNumber) 
   {
       mNoteNumber++;
       if(mDbHelper.createNote(noteName,noteBody,noteNumber)==-1)
          {
           Toast.makeText(this, "*ERROR*", 1).show();
          };   
          Codes.mondebug("add note"+noteName);
   }

   private void fillData() {
       // Get all of the rows from the database and create the item list

       //TODO : remove this line
       createNote("More info","Si vous voulez voir plus d'infos ((IPoE, PPPoE, VLAN 10, DHCP server status, WAN MAC Address) contactez moi par email car c'est du chinois pour moi!\n\nchristophe.versieux@gmail.com ","");

       mNotesCursor = mDbHelper.fetchAllNotes();
       startManagingCursor(mNotesCursor);

       // Create an array to specify the fields we want to display in the list (only TITLE)
       String[] from = new String[]{NotesDbAdapter.KEY_TITLE,NotesDbAdapter.KEY_BODY};

       // and an array of the fields we want to bind those fields to (in this case just text1)
       int[] to = new int[]{android.R.id.text1,android.R.id.text2};

       // Now create a simple cursor adapter and set it to display
       SimpleCursorAdapter notes = 
               new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, mNotesCursor, from, to);
       setListAdapter(notes);
   }




   protected void onPause() {
       super.onPause();
       SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
       SharedPreferences.Editor editor = settings.edit();
       EditText etName = (EditText) findViewById(R.id.etPw);
       editor.putString("pSearch",etName.getText().toString());
       // Don't forget to commit your edits!!!
       editor.commit();

   }


}

package tof.cv.BBoxInfo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;



   public class Codes 
   { 


       public static void mondebug(String mon_string) 
       {
           System.out.println(" ");
           System.out.println("_");
           System.out.println("_");           
           System.out.println(mon_string);
           System.out.println("_");
           System.out.println("_");
           System.out.println(" ");
       }


       public static String getHTML(String mon_url) 
       { 

           System.out.println("Affiche les infos HTML depuis la page: "+mon_url);     


                 String txt="";


               DefaultHttpClient httpclient = new DefaultHttpClient();

                  HttpGet get = new HttpGet(mon_url);
               HttpResponse response;



               try {
                   response = httpclient.execute(get);

                   HttpEntity entity = response.getEntity();        
                   BufferedReader buf = new BufferedReader(new InputStreamReader(entity.getContent()));


                   boolean follow=true;
                   while(follow)
                   {
                       String line=buf.readLine();
                       if(line!=null)
                       {    
                           System.out.println("line"+line); 
                            if(line.contains("Digest Algorithm, as defined in RFC 1321"))
                               return "";
                           txt+=line+buf.readLine();

                       }

                       else
                           follow=false;
                   }
                  if (entity != null) 
                  {

                      entity.consumeContent();
                  }
               } 

               catch (ClientProtocolException e) 
               {
                   e.printStackTrace();
               } 

               catch (IOException e) 
               {
                   e.printStackTrace();
               }


               return txt;
       } 




       public static String CorrectHTML (String bla)
       {

       String txt=bla.replace("", "");
       txt=txt.replace("","");
       txt=txt.replace("
","");
       txt=txt.replace("","");
       txt=txt.replace(" ", " ");
       txt=txt.replace("", "");
       return txt;
       }





   }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...