Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 20 Aug 2014, 12:41
All times are UTC - 4
 Forum index » Advanced Topics » Puppy Projects
Phoenix CE - Connection check at browser launch
Moderators: Flash, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Wed 23 Jan 2008, 22:24    Post subject:  Phoenix CE - Connection check at browser launch
Subject description: Offers easy link to internet setup wizard if not already established
 

Something I remember about internet explorer on windows (all those years ago) is that if an active internet connection was not found then a dialog box would come up and ask you if you wanted to configure your internet connection, or continue to work offline. When watching new users try puppy for the first timeI notice that as soon as puppy boots, they try going on the net using seamonkey, and the local launch page shows. They click on one of the links and the browser displays "page cannot be displayed" as they have not run the internet connection wizard as yet.

I believe it would make puppy a lot more friendly if a check for internet connectivity be made before starting the browser (and other applications that require an internet connection) and if one is not present, offer the user a choice to work offline or run the internet connection wizard. There are already several scripts called "defaultbrowser" and such which could be modified to run this?

How would this effect performance (perhaps with a test like "ping www.google.co.uk" ?).

_________________
Puppy Linux's Mission

Sorry, my server is down atm!

Last edited by ecomoney on Mon 11 Feb 2008, 10:40; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
cb88


Joined: 28 Jan 2007
Posts: 1169
Location: USA

PostPosted: Wed 23 Jan 2008, 23:00    Post subject:  

can't you start a program from a browser? how about editing the connection error page to have relevant intructions or have it start up the net wizard if possible
_________________
Taking Puppy Linux to the limit of perfection. meanwhile try "puppy pfix=duct_tape" kernel parem eater.
X86: Sager NP6110 3630QM 16GB ram, Tyan Thunder 2 2x 300Mhz
Sun: SS2 , LX , SS5 , SS10 , SS20 ,Ultra 1, Ultra 10 , T2000
Mac: Platinum Plus, SE/30
Back to top
View user's profile Send private message Visit poster's website 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 24 Jan 2008, 00:58    Post subject:  

I did some connection testing code for freshclam in pcPuppyOS, to make sure it waited until there was a connection to try updating (otherwise it would pop up an error message every two hours). This is what I did to make it wait:
Code:
#don't bother starting until there's a network connection (else it spouts errors)
NOCONNECTION=1
while [ ! $NOCONNECTION = 0 ]; do
   ping -c 2 clamav.net
   NOCONNECTION=$?
   [ ! $NOCONNECTION = 0 ] && sleep 300
done
#if we're over here, then there is a connection


Taking out the waiting stuff and modifying it a little gives me this:
Code:
ping -c 1 google.com
NOCONNECTION=$?
if [ ! $NOCONNECTION = 0 ]; then
   #no connection, do stuff here
   
else
   #there's a connection
   
fi


But don't forget that people might want to run the browser to read an HTML file on their drive, in which case they don't care if there's a network connection yet. I think cb88 has the right idea here.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
HairyWill


Joined: 26 May 2006
Posts: 2949
Location: Southampton, UK

PostPosted: Thu 24 Jan 2008, 05:20    Post subject:  

cb88 wrote:
can't you start a program from a browser? how about editing the connection error page to have relevant intructions or have it start up the net wizard if possible

Think about the security implications of that, javascript executing local code.
quirksmode wrote:
JavaScript cannot read files from or write them to the file system on the computer. This would be a clear security hazard
http://www.quirksmode.org/js/intro.html
The only way I can think of to do it that way would involve starting a web server to show the help page then you could use serverside scripting to do anything you like. This is a lot of overhead and opens an http port, so now you need a firewall. This reminds me that the local cups interface is automatically accessible over the network, users are currently not given any warning of this. I presume that the cups security model is reasonably well thought out.

You could include the check in the browser start script
show a dialogue box offering to start the net wizard and include a checkbox that says don't show this warning again.

_________________
Will
contribute: community website, screenshots, puplets, wiki, rss
Back to top
View user's profile Send private message 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Thu 24 Jan 2008, 07:16    Post subject: code  

so, if the "defaultbrowser" script read something like this:-

Code:
ping -c 1 google.com
NOCONNECTION=$?
if [ ! $NOCONNECTION = 0 ]; then
   msgbox "Currently this computer cannot connect to the internet, please check your cables, modem, and run the internet connection wizard under 'menu>setup>setup>connection wizard'. You may continue and work offline, or exit."
else
   exec seamonkey
fi

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Leachim

Joined: 27 May 2007
Posts: 229

PostPosted: Thu 24 Jan 2008, 11:17    Post subject: better network wizard  

I think the main problem is that one have to explicitly call the network wizard. The network setup could be done automatically in many cases - surely not in all cases.
Back to top
View user's profile Send private message 
Pizzasgood


Joined: 04 May 2005
Posts: 6270
Location: Knoxville, TN, USA

PostPosted: Thu 24 Jan 2008, 21:28    Post subject:  

I think this would be better:
Code:
ping -c 1 google.com
NOCONNECTION=$?
if [ ! $NOCONNECTION = 0 ]; then
   Xdialog --title "No Internet Connection" --msgbox "Currently this computer cannot connect to the internet, please check\nyour cables, modem, and run the internet connection wizard under\n'menu>setup>setup>connection wizard'\nYou may continue and work offline, or exit." 0 0
fi
exec seamonkey

The one you used wouldn't run Seamonkey at all unless there was a connection.

Quote:
You could include the check in the browser start script
show a dialogue box offering to start the net wizard and include a checkbox that says don't show this warning again.
That would be even better.


Quote:
I think the main problem is that one have to explicitly call the network wizard. The network setup could be done automatically in many cases - surely not in all cases.
For most people, just having the boot process run dhcpcd eth0 (but with the extra options I never use) would get most people online. It would need to be run in parallel though, or it could really slow down the boot.

An issue with doing that is whether the user wants the machine to auto connect without permission. It wouldn't bother me much, but I know several people who wouldn't like that at all.

_________________
Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib

Back to top
View user's profile Send private message Visit poster's website 
Everitt

Joined: 19 Dec 2006
Posts: 331
Location: Leeds,UK or Birmingham, UK

PostPosted: Fri 25 Jan 2008, 08:43    Post subject:  

First off, wouldn't it make more sense to export this code to a seperate script, so it could be called from any app startup script. That way it can easily be used for email and IM etc too.
Secondly, couldn't we be more verbose? Try and tell the user why their internet isn't up, not just that it's missing. We could check that there is an interface up, that it has an ip address, that there is a nameserver set, that the name server is accessable etc. That way we aren't dependent on google being up.
If no connection is found then offer to run the wizard, or display a list of results for the above tests, and offer generic solutions (check cables, run wizard, scream, the usual. Smile )
I'm using my phone in a lecture ATM, but I'll have a play and maybe suggest some code this afternoon., when I get home.
Back to top
View user's profile Send private message 
Everitt

Joined: 19 Dec 2006
Posts: 331
Location: Leeds,UK or Birmingham, UK

PostPosted: Fri 25 Jan 2008, 18:21    Post subject:  

Ah, here's a problem, Puppy comes with the busybox version of ping, which doesn't support setting the time out, so even with -c 1 it can cause a noticeable delay.
Back to top
View user's profile Send private message 
Everitt

Joined: 19 Dec 2006
Posts: 331
Location: Leeds,UK or Birmingham, UK

PostPosted: Fri 25 Jan 2008, 19:03    Post subject:  

This gets around the ping problem most of the time by using faster methods to determine if it is possible there is a connection first. It also checks that wireless devices are set up, so we have the option give a bit more advice on this slightly trickier area.
Code:

#!/bin/sh
#Script to check fr inet connectivity.
UP=""
for IF in `ifconfig -a | grep encap | grep -v "lo" | cut -d " " -f 1 | tr "\n" " "`; do #some diagnostics on each device
  printf "\n______________________________\n\n$IF\n" #DEBUG
  if [ `ifplugstatus -q $IF; echo $?` == 2 ]; then
    echo "  $IF is plugged in"
    iwconfig $IF &> /tmp/chknetwirelesstempfile
    if ! grep " no wireless extensions." /tmp/chknetwirelesstempfile &> /dev/null; then
      #it is wireless, so run some extra checks first
      echo "    $IF is wireless"
      #the iwconfig commands refuse to not output to the console for some reason :S
      if grep "radio off" /tmp/chknetwirelesstempfile&> /dev/null; then
        echo "      Wireless not configured. Interface not powered up. Run wizard"
      else
        echo "      Wireless powered on"
      fi
      if grep "ESSID:off/any" /tmp/chknetwirelesstempfile &> /dev/null; then
        echo "      Wireless not configured. No ESSID selected. Run wizard"
      else
        echo "      Wireless ESSID selected"
      fi
    else
      echo "    $IF is wired"
    fi
    if ifconfig $IF | grep "inet addr" > /dev/null; then
      echo "      $IF has an address"
      echo "      adding $IF to list"
      UP=$UP$IF" "
    else
      echo "      $IF has no address"
    fi
  else
    echo "  $IF is not plugged in"
  fi
  rm /tmp/chknetwirelesstempfile > /dev/null #remove tempfile, if it exists
done
if [ `echo "$UP" | wc -c` -gt 1 ]; then
  #it seems everything is in order, so try a ping
  if ping -c 1 www.google.com > /dev/null; then
    exit 0
  else
    if Xdialog --wrap --stdout --yesno "Puppy can't find the internet! Do you want to try and fix this using the network wizard?" 25% 50%; then
      echo "run wizard"
      . /usr/sbin/connectwizard
      exit $? #return the connectwizard's exit value
    else
      echo "exit"
      exit 1
    fi
  fi
else
   if Xdialog --wrap --stdout --yesno "Puppy can't find the internet! Do you want to try and fix this using the network wizard?" 25% 50%; then
     echo "run wizard"
     . /usr/sbin/connectwizard
     exit $? #return the connectwizard's exit value
   else
     echo "exit"
     exit 1
   fi
fi

Last edited by Everitt on Mon 28 Jan 2008, 17:11; edited 1 time in total
Back to top
View user's profile Send private message 
ecomoney


Joined: 25 Nov 2005
Posts: 2183
Location: Lincolnshire, England

PostPosted: Fri 25 Jan 2008, 21:01    Post subject: Logic  

Youve seen my bash coding, so I hope you understand why I need a written "pseudocode" explaination of what seems to be the start of a very promising internet connection wizard Smile

I have no idea of programming constructs in Bash, but I do know code needs to have "layers" and specific code for doing one thing kept in one place. This makes it easier for maintenence and legiability.

How would this routine be made into a subroutine/function/library (insert own preferred terminalogy here), say called ActivateConnection(), which returned a series of integer outcomes/return values/. That way the script for launching each application that requires the internet would read something like...

Code:


Const ConnectionNotRequired =2
Const ConnectionActivated = 1
Const ConnectionUnavailable = 0

Select Case ActivateConnection()
   Case ConnectionActivated
      exec Seamonkey # or any other app needing the web
   Case ConnectionNotRequired
      exec Seamonkey # but not apps that have no function if offline (like Transmission)
   Case ConnectionUnavailable
      exit
End Case



This way the code for manageing the connection only needs to be programmed once, you never know what new and innovative ways people would have of connecting to the web in the future, this would mean that only one piece of code would be needed to be changed and kept updated.

One "achillies heel" I notice about the intended 2.14 base is that the internet connection is very difficult to find. There is an icon on the dektop (connect) that launches the connection wizard, but this would be obscured by the open seamonkey window. The user would most probably then click on the start menu, go on "internet connection" and try to run one of the wizards in their for modem dialup or one of the other methids. The main (and recommended) method that people use to connect to the web if via an ethernet cable, secondly via usb and then thirdly via wireless. Perhaps pictures of these types of plugs (usb, ethernet and an arial) would be handy to make a very uninitiated user able to understand which type of connection they have.

_________________
Puppy Linux's Mission

Sorry, my server is down atm!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
Everitt

Joined: 19 Dec 2006
Posts: 331
Location: Leeds,UK or Birmingham, UK

PostPosted: Mon 28 Jan 2008, 17:28    Post subject: Re: Logic  

ecomoney wrote:
You've seen my bash coding, so I hope you understand why I need a written "pseudocode" explaination of what seems to be the start of a very promising internet connection wizard Smile

This isn't the nicest code to follow, and I'm not very good when it comes to commenting.

The for loop between lines 4 and 37 goes through all the interfaces listed by ifconfig, ie every network interface that has a driver loaded.
Within the loop are a series of tests. The tests are:
Code:

Connected (Wire plugged in) [Uses ifplugged]
        Wireless. [Using iwconfig] (If wired then the following tests are skipped, ie it jumps to 'has ip address'
                Powered on. [radio on]
                Configured [has ESSID set, ie it has been connected to a wireless network]
         Has ip address [using ifconfig]


Line 39 tests if anything has been added to the list UP (note: I left in a debugging fudge, it should be 1, not 91. Now fixed in previous post) If it has then it tries to ping google.If this works then the script returns 0 (all ok. If not it offers to run the wizard.
If nothing has been added to the list then the script once again offers to run the script.
In both cases, when the script is offered a 'No' will return 1 (fail), or, for a 'yes', it will return the value returned by the connection script.

The end result is that if the Internet is found then 0 is returned. If the script can't find the inet, and nothing is done, then it returns 1. If the wizard is run, and succeeds then, with some luck (I haven't found time to test) a 0 is returned. If setup fails / is canceled then, once again, with luck, something other than 0 is returned.
The practicle upshot of this is that the existing 'exec sea monkey' could simply be replaced by '<script name> && exec seamonkey'
To allow offline mode all is needed is to call the script before calling seamonkey. This will cause the checks, and the offer of the setup dialog, then run seamonkey anyway.

The problem with having one single entity to run anything is that we need some way to know whether to run it in offline mode or not. I personally think it would be easier to leave than up to the individual launcher.
A basic template would be something like this (pseudo code)
Code:

#Setup lines here as usual

#Followed by this:
if <script from this thread>; then
        #Returned 0, suggesting a connection
        exec <application>
else
        if [ ask if they want to run in offline mode ]; then
                #They said yes
                exec <application>
        else
                #They said no
                exit
         fi
fi
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Puppy Projects
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1082s ][ Queries: 12 (0.0043s) ][ GZIP on ]