maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   Smart mail checking alarmd script (https://talk.maemo.org/showthread.php?t=68111)

vi_ 2011-01-09 19:14

Smart mail checking alarmd script
 
Smart mail checking alarmd script

This is a fairly simple script that will sync your email. It can be set to run hourly etc. with crom/alarmd etc.

The thng that makes this script special is that it will put your wifi back to the way it is when it is run.

For example there are 3 possibilities. 1. wifi is already connected, 2 wifi kernel modules loaded, kernel modules not loaded. This script will detect one of the three possibilities, take appropriate action (load modules, connect etc) then return your wifi back to it's original setting (unloaded, not connect, connected).

It can be run with:

Code:

echo "/path/to/script.sh" | sudo gainroot | echo ""
and the script:

Code:

#!/bin/sh
#smart email check script
out=`ifconfig wlan0`
if [ $? -eq "0" ] ; then
        if [ `echo "$out" | grep -c RUNNING` -gt "0" ] ; then
                echo "wifi connected, checking mail"
                run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive

        else
                echo "wifi disconnected, connecting..."
                sleep 2
                run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0
                sleep 15
                run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive
                echo "checking mail"
                sleep 55
                dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true | echo ""
        fi       
        exit 2

        else
                echo "wifi modules unloaded, bringing up"
                modprobe wl12xx
                wl1251-cal
                stop wlancond
                start wlancond
                ifconfig wlan0 up

                sleep 1
                dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 | echo ""
                sleep 7
                run-standalone.sh dbus-send --type=method_call --dest=com.nokia.modest /com/nokia/modest com.nokia.modest.SendReceive
                echo "checking email"
                sleep 35
                ifconfig wlan0 down
                rmmod wl12xx

        exit 0
fi

unfortunatley you need to have modest 'autoupdate' enabled for it to respond to the syncemail dbus call (which totally sucks btw). I have simply editited the modest.conf autocheck time value to 999999.

Seems to work!

miskooldfield 2011-01-10 15:24

Re: Smart mail checking alarmd script
 
Hello,

can you please advice where can i locate the modest.conf file?
I was able to find one modest.conf file under

Quote:

etc/osso-backup/applications/modest.conf
the content of the file looks like this:
Quote:

<backup-configuration>
<locations>
<location type="file" category="comm_and_cal" auto="true">$HOME/.modest-backup.tar.gz</location>
<location type="dir" category="comm_and_cal" auto="true">/var/lib/gconf/apps/modest</location>
</locations>
</backup-configuration>
I'm not sure how i should define the "autoupdate" value. Please help me locate the correct modest.conf file. :)

Thank you
-Michal.

kureyon 2011-01-11 01:44

Re: Smart mail checking alarmd script
 
modest config is stored in that POS gconf:

Code:

gconftool-2 -R /apps/modest | less

miskooldfield 2011-01-11 08:36

Re: Smart mail checking alarmd script
 
thanks a lot kureyon,

just in case, here is what i did, with my comments; as i used gconftool-2 for the first time:
i've checked the update_interval value
Quote:

>gconftool-2 -g /apps/modest/update_interval
1440
i found what kind of type this one is (probably obvious to most of you guys):
Quote:

gconftool-2 -T /apps/modest/update_interval
int
so i've set it to 999999
Quote:

>gconftool-2 -s /apps/modest/update_interval --type int 999999
and ...double checked
Quote:

>gconftool-2 -g /apps/modest/update_interval
999999
again, thanks for giving me a heads up on this.

modest is now responsive to the dbus calls, as adviced

-M.

fleetwood 2011-01-11 08:57

Re: Smart mail checking alarmd script
 
Quote:

Originally Posted by vi_ (Post 916084)
unfortunatley you need to have modest 'autoupdate' enabled for it to respond to the syncemail dbus call (which totally sucks btw). I have simply editited the modest.conf autocheck time value to 999999.

Ah, now I know why my own scripts have never worked! Thanks! :)

jerryfreak 2011-01-11 09:45

Re: Smart mail checking alarmd script
 
is this anything close to imap idle? can you set it to check every minute or would it tax the n900 too much?

vi_ 2011-01-13 11:07

Re: Smart mail checking alarmd script
 
You could set it to check every minute however Modest is such ball smoking crap you would probably be issuing multiple email syncs at once.


All times are GMT. The time now is 22:47.

vBulletin® Version 3.8.8