Re: How to deal with unplug from the LAN

2010-05-26 Thread Web Admin Himalayan Academy
With a tip from Andre, we solved this problem... it's really pretty 
neat. Perhaps someone else may need this.


Mac Only

This queries the hardware-network interface and give you and instant 
response... if the users just unplugs from the network or turns of her 
airport, with a remote volume mounted... you want to be sure you don't 
try to interact with the server...otherwise you will get a 2 minute time 
out waiting before the system gives back the CPU to RunRev


Do this first: (disclaimer, any code I offer probably could be highly 
optimized)


function connectionStatus

   put shell(ifconfig) into tStatus

   # Parse for ethernet status
   put lineOffset (en0:,tStatus) into tTarget
   put line ((lineOffset (Status:,tStatus,tTarget))+tTarget) of 
tStatus into tEN0status

   set the itemdel to :
   if (item -1 of tEN0status) =  active then
  return true
   else
  return false
   end if

   # Check Airport-Wireless status
   put lineOffset (en1:,tStatus) into tTarget
   put line ((lineOffset (Status,tStatus,tTarget))+tTarget) of 
tStatus into tEN1status

   set the itemdel to :
   if item -1of tEN1status =  active then
  return true
   end if
end connectionstatus

Then all other places you need to interact with the server:

command CheckVarunaIsMounted
   if connectionStatus()  True then
  answer You appear to be offline line. Connect to the network by 
ethernet or airport. Then try again. with OK

  exit to top
   else
  put URL 
file:/Volumes/Varuna/WWW/*Sites/varuna.hindu.org/ping.txt into 
gControlFile

  if gControlFile = true then
 set the icon of btn Connected to 1097
 put true into gVarunaMounted
 set the uVarunaMounted of this stack to true
  else
 put false into gVarunaMounted
 set the uVarunaMounted of this stack to False
 set the icon of btn Connected to 1098
 answer Varuna is not mounted. Shall I mount it for you? with 
OK

 mountVaruna
 exit to top
  end if
   end if

end CheckVarunaIsMounted

command Checkin pFileName

   CheckVarunaIsMounted

   if the uVarunaMounted of this stack  true then
  answer  Sorry, Varuna is not mounted, you cannot check in 
files. with OK

  exit to top
   end if

   # increment revision number; change co to CI; retain user initials; 
rename local file

   put pFileName into tNewFileName

etc...

end checkIn

Then I always run this every time I set the default folder to the 
server, when done getting the file listing:


command unTetherStackFromServer
   set the defaultFolder to ($Home/Documents/)
end unTetherStackFromServer

and then the user gets no msg saying he can't unmount the volume because 
it is in use by RunRev.


HTH somebody...


Sivakatirswami



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: How to deal with unplug from the LAN

2010-05-26 Thread Alex Tweedly
Hmmm ... looks like you may have a problem with copy/paste in creating 
this email. in connectionStatus the first if ...then...else cluae will 
*always* cause a return, so the check for Airport never gets used. I 
suspect the original code did the Airport check first, then the Ethernet 
one - that would have been OK.


In general, can there not be more than one ethernet interface installed 
- so why not check if *any* interface of the formenx ihas status active.


e.g. (typed direct into email - beware typos) ...

set the itemdel to :
repeat for each line L in tStatus
  if char 1 to 2 of L = en  char 3 to -1 of (item 1 of L) is a 
number then

  put lineOffset (L,tStatus) into tTarget
  put line ((lineOffset (Status:,tStatus,tTarget))+tTarget) of 
tStatus into tENstatus

   if (item -1 of tENstatus) =  active then
  return true
   end if
end repeat
return 'false'

-- Alex.

On 26/05/2010 18:16, Web Admin Himalayan Academy wrote:
With a tip from Andre, we solved this problem... it's really pretty 
neat. Perhaps someone else may need this.


Mac Only

This queries the hardware-network interface and give you and instant 
response... if the users just unplugs from the network or turns of her 
airport, with a remote volume mounted... you want to be sure you don't 
try to interact with the server...otherwise you will get a 2 minute 
time out waiting before the system gives back the CPU to RunRev


Do this first: (disclaimer, any code I offer probably could be highly 
optimized)


function connectionStatus

   put shell(ifconfig) into tStatus

   # Parse for ethernet status
   put lineOffset (en0:,tStatus) into tTarget
   put line ((lineOffset (Status:,tStatus,tTarget))+tTarget) of 
tStatus into tEN0status

   set the itemdel to :
   if (item -1 of tEN0status) =  active then
  return true
   else
  return false
   end if

   # Check Airport-Wireless status
   put lineOffset (en1:,tStatus) into tTarget
   put line ((lineOffset (Status,tStatus,tTarget))+tTarget) of 
tStatus into tEN1status

   set the itemdel to :
   if item -1of tEN1status =  active then
  return true
   end if
end connectionstatus

Then all other places you need to interact with the server:

command CheckVarunaIsMounted
   if connectionStatus()  True then
  answer You appear to be offline line. Connect to the network by 
ethernet or airport. Then try again. with OK

  exit to top
   else
  put URL 
file:/Volumes/Varuna/WWW/*Sites/varuna.hindu.org/ping.txt into 
gControlFile

  if gControlFile = true then
 set the icon of btn Connected to 1097
 put true into gVarunaMounted
 set the uVarunaMounted of this stack to true
  else
 put false into gVarunaMounted
 set the uVarunaMounted of this stack to False
 set the icon of btn Connected to 1098
 answer Varuna is not mounted. Shall I mount it for you? 
with OK

 mountVaruna
 exit to top
  end if
   end if

end CheckVarunaIsMounted

command Checkin pFileName

   CheckVarunaIsMounted

   if the uVarunaMounted of this stack  true then
  answer  Sorry, Varuna is not mounted, you cannot check in 
files. with OK

  exit to top
   end if

   # increment revision number; change co to CI; retain user initials; 
rename local file

   put pFileName into tNewFileName

etc...

end checkIn

Then I always run this every time I set the default folder to the 
server, when done getting the file listing:


command unTetherStackFromServer
   set the defaultFolder to ($Home/Documents/)
end unTetherStackFromServer

and then the user gets no msg saying he can't unmount the volume 
because it is in use by RunRev.


HTH somebody...


Sivakatirswami



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


How to deal with unplug from the LAN

2010-05-25 Thread Sivakatirswami
I'm working on an app that requires a remote volume to be mounted (Mac 
OS X 10.6)


I use several basic connectivity tests like

put hostAddressToName (11.11.11.11:) into the server

# If I get DNS from the XServe box I know the user is at least plugged 
in or has his Airport connection uup and running..


# next, get a ping file which is a little file containing the word true

command CheckForServerIs Mounted
   put url file:/volumes/XServer/Sites/public_html/ping.txt into 
tPingTest

 if tPingTest is True then
  set the enabled of button connected to true (small animated gif 
that show a live connection

  put true into gConnectedToLanServer # a global for later testing.
 else
  answer Sorry, the server is not mounted.. shall I mount it for 
you?  with No or Yes

 # run afp apple script here to mount the remote volume.

 end if

end CheckForServerIsMounted


OK the above works fine if the user is a Tidy Boy and is careful to 
dismount the volume, but if he just up and pulls the ethernet cable out 
with the remote volume mounted and runs off to the dentist with his lap 
top... if he has my app open and tries anything, it goes into a 3 minute 
wait...( this is actually a long standing nuisance with Apple's API to 
the network framework... and can happen with pretty much any other app 
and not just RunRev) *finally* after  3 minutes, the system seems to 
realize he's cut off, gives up, and gives the CPU back to RunRev...my 
dialog pop's up to offer the user the option to mount. But because he's 
unplugged, his is informed he is off line and he's gracefully left to 
work off line...


So, this all works well, but the part where I am unable to test for if 
the user just pulled out his ethernet cable with the volume still 
mounted, without this long hang up...


Any ideas?

Sivakatirswami
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution