#!/bin/sh CONNECTED=false DROPCONN=false call_check () { # Check no call in progress oncall=`run-standalone.sh dbus-send --system --type=method_call --print-reply=literal --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus` if [ $oncall != "uint32 0" ]; then dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Sync dropped due to active call!" uint32:0 string:"OK" exit 1 fi } # check for existing wifi connectivity if [ "$(/sbin/route | awk '/au/ {print $1}')" == "default" ]; then CONNECTED=true else #Bring up WLAN sudo ifconfig wlan0 up for i in WLAN1 WLAN2 WLAN3 do # scan for SSIDs, if not found continue if [ -z `sudo iwlist wlan0 scan | grep -m 1 -o \"$i\"` ]; then continue; fi # find IAP_ID from SSID IAP_ID=`gconftool-2 -R /system/osso/connectivity/IAP | tac | awk "/name = $i/,/connectivity\/IAP/" | awk -F '/|:' '/connectivity\/IAP/{ print $6}'` # try to connect to known wifi dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"$IAP_ID" uint32:0 sleep 20 if [ "$(/sbin/route | awk '/au/ {print $1}')" == "default" ]; then CONNECTED=true DROPCONN=true break fi done # if no WLAN was found (i.e. outdoor), then put WLAN down if [ "$DROPCONN" == "false" ]; then sudo ifconfig wlan0 down fi fi # If no wifi try with GPRS if [ "$CONNECTED" == "false" ]; then opcode=`dbus-send --system --print-reply=literal --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_registration_status | tr '\n' ' ' | awk '{print $8,$10}' | cut -f1 -d' '` # Temporary disable SIM switch #opcode=10 # Check lock state of the phone and unlock lock=`dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_tklock_mode|awk -F "\"" '/g/ {print $2}'` call_check dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"unlocked" # if operator code is (1) switch to SIM2 if [ $opcode == 1 ]; then sim-switcher SIM2 if [ $? -ne 0 ]; then exit 1 fi fi # Connect Internet dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"Internet" uint32:0 if [ $? -ne 0 ]; then exit 1 fi CONNECTED=true DROPCONN=true sleep 10 fi if [ "$CONNECTED" == "true" ]; then # sync erminig if having connectivity #/usr/bin/erminig -a # sync MfE dbus-send --print-reply --type=method_call --session --dest=com.nokia.asdbus /com/nokia/asdbus com.nokia.asdbus.sync sleep 90 # drop the wifi connection if it was initiated by this script (saves battery) if [ "$DROPCONN" == "true" ]; then call_check dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true fi fi # Switch back to SIM1 if [ $opcode == 1 ]; then sim-switcher SIM1 fi # Lock back if needed if [ "$lock" == "locked" ]; then call_check dbus-send --system --type=method_call --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_tklock_mode_change string:"locked" fi