-rw-r--r-- | core/opiealarm/Makefile | 26 | ||||
-rw-r--r-- | core/opiealarm/opie-opiealarm.control | 13 | ||||
-rwxr-xr-x | core/opiealarm/opie-opiealarm.postinst | 4 | ||||
-rwxr-xr-x | core/opiealarm/opie-opiealarm.prerm | 4 | ||||
-rw-r--r-- | core/opiealarm/opiealarm.c | 91 | ||||
-rwxr-xr-x | core/opiealarm/opieatd | 22 | ||||
-rwxr-xr-x | root/etc/init.d/opieatd | 15 | ||||
-rw-r--r-- | root/etc/rc2.d/cvsdummy | 0 | ||||
-rwxr-xr-x | root/etc/resume-scripts/R46opiealarm | 5 | ||||
-rwxr-xr-x | root/etc/suspend-scripts/S46opiealarm | 7 | ||||
-rw-r--r-- | root/opie-windows2000-ppp-scripts.control | 2 |
11 files changed, 188 insertions, 1 deletions
diff --git a/core/opiealarm/Makefile b/core/opiealarm/Makefile new file mode 100644 index 0000000..e988abf --- a/dev/null +++ b/core/opiealarm/Makefile | |||
@@ -0,0 +1,26 @@ | |||
1 | |||
2 | DESTDIR=../../bin | ||
3 | |||
4 | CROSS:=arm-linux- | ||
5 | CC :=$(CROSS)gcc | ||
6 | LD :=$(CROSS)gcc | ||
7 | STRIP:=$(CROSS)strip | ||
8 | |||
9 | CFLAGS:=-O2 | ||
10 | LDFLAGS:= | ||
11 | |||
12 | all: $(DESTDIR)/opiealarm $(DESTDIR)/opieatd | ||
13 | |||
14 | $(DESTDIR)/opiealarm: opiealarm.c | ||
15 | $(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS) | ||
16 | $(STRIP) -s $(DESTDIR)/opiealarm | ||
17 | chmod u+s $(DESTDIR)/opiealarm | ||
18 | chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n" | ||
19 | |||
20 | $(DESTDIR)/opieatd: opieatd | ||
21 | cp opieatd $(DESTDIR)/opieatd | ||
22 | chmod +x $(DESTDIR)/opieatd | ||
23 | |||
24 | clean: | ||
25 | -rm -f *~ core | ||
26 | |||
diff --git a/core/opiealarm/opie-opiealarm.control b/core/opiealarm/opie-opiealarm.control new file mode 100644 index 0000000..b63fa66 --- a/dev/null +++ b/core/opiealarm/opie-opiealarm.control | |||
@@ -0,0 +1,13 @@ | |||
1 | Files: bin/opiealarm bin/opieatd ipaq/etc/init.d/opieatd ipaq/etc/rc2.d/S96opieatd ipaq/etc/suspend-scripts/S46opiealarm ipaq/etc/resume-scripts/R46opiealarm | ||
2 | Priority: required | ||
3 | Provides: ipaqalarm | ||
4 | Conflicts: ipaqalarm | ||
5 | Section: opie/system | ||
6 | Maintainer: Robert Griebl <sandman@handhelds.org> | ||
7 | Architecture: arm | ||
8 | Version: $QPE_VERSION-$SUB_VERSION | ||
9 | Depends: hotplug | ||
10 | Description: A wakeup system for OPIE events. | ||
11 | Tiny, OPIE specific replacement for ipaqalarm, | ||
12 | uschedule and qpe2uschedule | ||
13 | |||
diff --git a/core/opiealarm/opie-opiealarm.postinst b/core/opiealarm/opie-opiealarm.postinst new file mode 100755 index 0000000..7fc8350 --- a/dev/null +++ b/core/opiealarm/opie-opiealarm.postinst | |||
@@ -0,0 +1,4 @@ | |||
1 | #/bin/sh | ||
2 | |||
3 | /etc/init.d/opieatd start | ||
4 | exit 0 \ No newline at end of file | ||
diff --git a/core/opiealarm/opie-opiealarm.prerm b/core/opiealarm/opie-opiealarm.prerm new file mode 100755 index 0000000..b37df5e --- a/dev/null +++ b/core/opiealarm/opie-opiealarm.prerm | |||
@@ -0,0 +1,4 @@ | |||
1 | #/bin/sh | ||
2 | |||
3 | /etc/init.d/opieatd stop | ||
4 | exit 0 | ||
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c new file mode 100644 index 0000000..071cb24 --- a/dev/null +++ b/core/opiealarm/opiealarm.c | |||
@@ -0,0 +1,91 @@ | |||
1 | /* opiealarm.c | ||
2 | * This program is for extracting the event time/date out | ||
3 | * of /etc/resumeat and setting the RTC alarm to that time/date. | ||
4 | * It is designed to run via a script just before the iPaq | ||
5 | * is suspended. | ||
6 | * | ||
7 | * Roughly based on ipaqalarm from Benjamin Long | ||
8 | * | ||
9 | * written by Robert Griebl <sandman@handhelds.org> | ||
10 | */ | ||
11 | |||
12 | #include <stdio.h> | ||
13 | #include <linux/rtc.h> | ||
14 | #include <sys/ioctl.h> | ||
15 | #include <sys/time.h> | ||
16 | #include <sys/types.h> | ||
17 | #include <fcntl.h> | ||
18 | #include <unistd.h> | ||
19 | #include <errno.h> | ||
20 | #include <time.h> | ||
21 | #include <stdlib.h> | ||
22 | |||
23 | |||
24 | void error_msg_and_die ( int perr, const char *msg ) | ||
25 | { | ||
26 | if ( perr ) | ||
27 | perror ( msg ); | ||
28 | else | ||
29 | fprintf ( stderr, "%s\n", msg ); | ||
30 | exit ( 1 ); | ||
31 | } | ||
32 | |||
33 | |||
34 | void extractevent ( ) | ||
35 | { | ||
36 | FILE *fp; | ||
37 | char buf [64]; | ||
38 | time_t t; | ||
39 | struct tm *tm; | ||
40 | int fd; | ||
41 | |||
42 | if (!( fp = fopen ( "/etc/resumeat", "r" ))) | ||
43 | error_msg_and_die ( 1, "/etc/resumeat" ); | ||
44 | |||
45 | if ( !fgets ( buf, sizeof( buf ) - 1, fp )) | ||
46 | error_msg_and_die ( 1, "/etc/resumeat" ); | ||
47 | |||
48 | fclose ( fp ); | ||
49 | |||
50 | t = atoi ( buf ); | ||
51 | |||
52 | if ( t == 0 ) | ||
53 | error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" ); | ||
54 | |||
55 | /* subtract 5 sec from event time... */ | ||
56 | t -= 5; | ||
57 | tm = gmtime ( &t ); | ||
58 | |||
59 | /* Write alarm time to RTC */ | ||
60 | fd = open ( "/dev/misc/rtc", O_RDWR ); | ||
61 | if ( fd < 0 ) | ||
62 | error_msg_and_die ( 1, "/dev/misc/rtc" ); | ||
63 | |||
64 | // set alarm time | ||
65 | if ( ioctl ( fd, RTC_ALM_SET, tm ) < 0 ) | ||
66 | error_msg_and_die ( 1, "ioctl RTC_ALM_SET" ); | ||
67 | |||
68 | // enable alarm irq | ||
69 | if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 ) | ||
70 | error_msg_and_die ( 1, "ioctl RTC_AIE_ON" ); | ||
71 | |||
72 | // wait for alarm irq | ||
73 | if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) | ||
74 | error_msg_and_die ( 1, "read rtc alarm" ); | ||
75 | |||
76 | // disable alarm irq | ||
77 | if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) | ||
78 | error_msg_and_die ( 1, "ioctl RTC_AIE_OFF" ); | ||
79 | |||
80 | close ( fd ); | ||
81 | } | ||
82 | |||
83 | |||
84 | int main ( ) | ||
85 | { | ||
86 | if ( geteuid ( ) != 0 ) | ||
87 | error_msg_and_die ( 0, "You need root priviledges to run opiealarm." ); | ||
88 | |||
89 | extractevent ( ); | ||
90 | return 0; | ||
91 | } | ||
diff --git a/core/opiealarm/opieatd b/core/opiealarm/opieatd new file mode 100755 index 0000000..3b9dc0e --- a/dev/null +++ b/core/opiealarm/opieatd | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | timefile=/etc/resumeat | ||
4 | |||
5 | mkdir -p /var/spool/at | ||
6 | [ -p /var/spool/at/trigger ] || mkfifo /var/spool/at/trigger | ||
7 | |||
8 | while true; do | ||
9 | cat /var/spool/at/trigger | while read line; do | ||
10 | FILE=`ls -1 /var/spool/at/[0-9]* | head -n1` | ||
11 | echo "File = $FILE" | ||
12 | if [ -z "$FILE" ]; then | ||
13 | echo "clear resume at" | ||
14 | echo "" >$timefile | ||
15 | else | ||
16 | unixtime=`basename $FILE | cut -c1-10` | ||
17 | echo "Datestring = $unixtime" | ||
18 | echo "$unixtime" >$timefile | ||
19 | fi | ||
20 | done | ||
21 | done | ||
22 | |||
diff --git a/root/etc/init.d/opieatd b/root/etc/init.d/opieatd new file mode 100755 index 0000000..83f6035 --- a/dev/null +++ b/root/etc/init.d/opieatd | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | PATH=/usr/bin:/bin | ||
4 | HOME=/root | ||
5 | |||
6 | case "$1" in | ||
7 | start) | ||
8 | /opt/QtPalmtop/bin/opieatd & | ||
9 | ;; | ||
10 | stop) | ||
11 | killall opieatd | ||
12 | ;; | ||
13 | esac | ||
14 | |||
15 | exit 0 | ||
diff --git a/root/etc/rc2.d/cvsdummy b/root/etc/rc2.d/cvsdummy new file mode 100644 index 0000000..e69de29 --- a/dev/null +++ b/root/etc/rc2.d/cvsdummy | |||
diff --git a/root/etc/resume-scripts/R46opiealarm b/root/etc/resume-scripts/R46opiealarm new file mode 100755 index 0000000..e56c5bf --- a/dev/null +++ b/root/etc/resume-scripts/R46opiealarm | |||
@@ -0,0 +1,5 @@ | |||
1 | #!/bin/sh | ||
2 | # Starts opiealarm, which only runs while the iPaq sleeps | ||
3 | # and wakes it up when the RTC alarm goes off. | ||
4 | |||
5 | start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/opiealarm.pid --exec /opt/QtPalmtop/bin/opiealarm | ||
diff --git a/root/etc/suspend-scripts/S46opiealarm b/root/etc/suspend-scripts/S46opiealarm new file mode 100755 index 0000000..504f9c4 --- a/dev/null +++ b/root/etc/suspend-scripts/S46opiealarm | |||
@@ -0,0 +1,7 @@ | |||
1 | #!/bin/sh | ||
2 | # Starts opiealarm, which only runs while the iPaq sleeps | ||
3 | # and wakes it up when the RTC alarm goes off. | ||
4 | |||
5 | export HOME=/root | ||
6 | start-stop-daemon --make-pidfile --start --quiet --pidfile /var/run/opiealarm.pid --exec /opt/QtPalmtop/bin/opiealarm & | ||
7 | |||
diff --git a/root/opie-windows2000-ppp-scripts.control b/root/opie-windows2000-ppp-scripts.control index 1a4f856..48249ed 100644 --- a/root/opie-windows2000-ppp-scripts.control +++ b/root/opie-windows2000-ppp-scripts.control | |||
@@ -1,4 +1,4 @@ | |||
1 | Files: ipaq/etc | 1 | Files: ipaq/etc/hosts ipaq/etc/inittab ipaq/etc/ppp |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/system | 3 | Section: opie/system |
4 | Maintainer: Trenton Schulz <twschulz@trolltech.com> | 4 | Maintainer: Trenton Schulz <twschulz@trolltech.com> |