summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/Makefile26
-rw-r--r--core/opiealarm/opie-opiealarm.control13
-rwxr-xr-xcore/opiealarm/opie-opiealarm.postinst4
-rwxr-xr-xcore/opiealarm/opie-opiealarm.prerm4
-rw-r--r--core/opiealarm/opiealarm.c91
-rwxr-xr-xcore/opiealarm/opieatd22
-rwxr-xr-xroot/etc/init.d/opieatd15
-rw-r--r--root/etc/rc2.d/cvsdummy0
-rwxr-xr-xroot/etc/resume-scripts/R46opiealarm5
-rwxr-xr-xroot/etc/suspend-scripts/S46opiealarm7
-rw-r--r--root/opie-windows2000-ppp-scripts.control2
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 @@
+
+DESTDIR=../../bin
+
+CROSS:=arm-linux-
+CC :=$(CROSS)gcc
+LD :=$(CROSS)gcc
+STRIP:=$(CROSS)strip
+
+CFLAGS:=-O2
+LDFLAGS:=
+
+all: $(DESTDIR)/opiealarm $(DESTDIR)/opieatd
+
+$(DESTDIR)/opiealarm: opiealarm.c
+ $(CC) $(CFLAGS) opiealarm.c -o $(DESTDIR)/opiealarm $(LDFLAGS)
+ $(STRIP) -s $(DESTDIR)/opiealarm
+ chmod u+s $(DESTDIR)/opiealarm
+ chown root $(DESTDIR)/opiealarm 2>/dev/null || echo -e "\nopiealarm must be owned by root to work correctly.\n"
+
+$(DESTDIR)/opieatd: opieatd
+ cp opieatd $(DESTDIR)/opieatd
+ chmod +x $(DESTDIR)/opieatd
+
+clean:
+ -rm -f *~ core
+
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 @@
+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
+Priority: required
+Provides: ipaqalarm
+Conflicts: ipaqalarm
+Section: opie/system
+Maintainer: Robert Griebl <sandman@handhelds.org>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION
+Depends: hotplug
+Description: A wakeup system for OPIE events.
+ Tiny, OPIE specific replacement for ipaqalarm,
+ uschedule and qpe2uschedule
+
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 @@
+#/bin/sh
+
+/etc/init.d/opieatd start
+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 @@
+#/bin/sh
+
+/etc/init.d/opieatd stop
+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 @@
+/* opiealarm.c
+* This program is for extracting the event time/date out
+* of /etc/resumeat and setting the RTC alarm to that time/date.
+* It is designed to run via a script just before the iPaq
+* is suspended.
+*
+* Roughly based on ipaqalarm from Benjamin Long
+*
+* written by Robert Griebl <sandman@handhelds.org>
+*/
+
+#include <stdio.h>
+#include <linux/rtc.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <time.h>
+#include <stdlib.h>
+
+
+void error_msg_and_die ( int perr, const char *msg )
+{
+ if ( perr )
+ perror ( msg );
+ else
+ fprintf ( stderr, "%s\n", msg );
+ exit ( 1 );
+}
+
+
+void extractevent ( )
+{
+ FILE *fp;
+ char buf [64];
+ time_t t;
+ struct tm *tm;
+ int fd;
+
+ if (!( fp = fopen ( "/etc/resumeat", "r" )))
+ error_msg_and_die ( 1, "/etc/resumeat" );
+
+ if ( !fgets ( buf, sizeof( buf ) - 1, fp ))
+ error_msg_and_die ( 1, "/etc/resumeat" );
+
+ fclose ( fp );
+
+ t = atoi ( buf );
+
+ if ( t == 0 )
+ error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" );
+
+ /* subtract 5 sec from event time... */
+ t -= 5;
+ tm = gmtime ( &t );
+
+ /* Write alarm time to RTC */
+ fd = open ( "/dev/misc/rtc", O_RDWR );
+ if ( fd < 0 )
+ error_msg_and_die ( 1, "/dev/misc/rtc" );
+
+ // set alarm time
+ if ( ioctl ( fd, RTC_ALM_SET, tm ) < 0 )
+ error_msg_and_die ( 1, "ioctl RTC_ALM_SET" );
+
+ // enable alarm irq
+ if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 )
+ error_msg_and_die ( 1, "ioctl RTC_AIE_ON" );
+
+ // wait for alarm irq
+ if ( read ( fd, buf, sizeof( unsigned long )) < 0 )
+ error_msg_and_die ( 1, "read rtc alarm" );
+
+ // disable alarm irq
+ if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 )
+ error_msg_and_die ( 1, "ioctl RTC_AIE_OFF" );
+
+ close ( fd );
+}
+
+
+int main ( )
+{
+ if ( geteuid ( ) != 0 )
+ error_msg_and_die ( 0, "You need root priviledges to run opiealarm." );
+
+ extractevent ( );
+ return 0;
+}
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 @@
+#!/bin/sh
+
+timefile=/etc/resumeat
+
+mkdir -p /var/spool/at
+[ -p /var/spool/at/trigger ] || mkfifo /var/spool/at/trigger
+
+while true; do
+ cat /var/spool/at/trigger | while read line; do
+ FILE=`ls -1 /var/spool/at/[0-9]* | head -n1`
+ echo "File = $FILE"
+ if [ -z "$FILE" ]; then
+ echo "clear resume at"
+ echo "" >$timefile
+ else
+ unixtime=`basename $FILE | cut -c1-10`
+ echo "Datestring = $unixtime"
+ echo "$unixtime" >$timefile
+ fi
+ done
+done
+
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 @@
+#!/bin/sh
+
+PATH=/usr/bin:/bin
+HOME=/root
+
+case "$1" in
+ start)
+ /opt/QtPalmtop/bin/opieatd &
+ ;;
+ stop)
+ killall opieatd
+ ;;
+esac
+
+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 @@
+#!/bin/sh
+# Starts opiealarm, which only runs while the iPaq sleeps
+# and wakes it up when the RTC alarm goes off.
+
+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 @@
+#!/bin/sh
+# Starts opiealarm, which only runs while the iPaq sleeps
+# and wakes it up when the RTC alarm goes off.
+
+export HOME=/root
+start-stop-daemon --make-pidfile --start --quiet --pidfile /var/run/opiealarm.pid --exec /opt/QtPalmtop/bin/opiealarm &
+
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 @@
-Files: ipaq/etc
+Files: ipaq/etc/hosts ipaq/etc/inittab ipaq/etc/ppp
Priority: optional
Section: opie/system
Maintainer: Trenton Schulz <twschulz@trolltech.com>