summaryrefslogtreecommitdiff
authorMichael Krelin <hacker@klever.net>2007-07-07 16:49:19 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-16 11:43:49 (UTC)
commit2b97142421c04098b72021b0526873a54ba951d7 (patch) (side-by-side diff)
treefecb325510f285ed7e08bb4a917afc15f6fd2576
parent6e556a6cd6b4edf2abcf08a657c9f0b19a0fca76 (diff)
downloadopie-2b97142421c04098b72021b0526873a54ba951d7.zip
opie-2b97142421c04098b72021b0526873a54ba951d7.tar.gz
opie-2b97142421c04098b72021b0526873a54ba951d7.tar.bz2
opiealarm: substitute hardcoded paths with defines
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/opiealarm/opiealarm.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c
index 422865c..b948ef2 100644
--- a/core/opiealarm/opiealarm.c
+++ b/core/opiealarm/opiealarm.c
@@ -274,111 +274,111 @@ int suspend ( int fix_rtc )
if ( ioctl ( fd, RTC_AIE_ON, 0 ) < 0 )
break; // ( 1, "ioctl RTC_AIE_ON" ); // enable RTC alarm irq
// tell the parent it is safe to exit now .. we have set the RTC alarm
kill ( parent_pid, SIGUSR1 );
if ( read ( fd, buf, sizeof( unsigned long )) < 0 ) // wait for the RTC alarm irq
break; // ( 1, "read rtc alarm" );
// iPAQ woke up via RTC irq -- otherwise we would have received a SIGUSR2
// from the "resume instance" of opiealarm.
if ( ioctl ( fd, RTC_AIE_OFF, 0 ) < 0 ) // disable RTC alarm irq
break; // ( 1, "ioctl RTC_AIE_OFF" );
close ( fd );
fd = -1;
remove_pidfile ( );
return 0;
} while ( 0 );
if ( fp != NULL )
fclose ( fp );
if ( fd != -1 )
close ( fd );
kill ( parent_pid, SIGUSR1 );
while ( 1 ) // pretend that we are waiting on RTC, so opiealarm -r can kill us
sleep ( 1000 ); // if we don't do this, the "resuspend on AC" would be triggerd
return 0;
}
int onac ( void )
{
FILE *fp;
int on = 0;
// check the apm proc interface for AC status
if (( fp = fopen ( APMFILE, "r" ))) {
int ac = 0;
if ( fscanf ( fp, "%*[^ ] %*d.%*d 0x%*x 0x%x 0x%*x 0x%*x %*d%% %*i %*c", &ac ) == 1 )
on = ( ac == 0x01 ) ? 1 : 0;
fclose ( fp );
}
return on;
}
int resume ( int resuspend )
{
FILE *fp;
// re-suspend when on AC (optional) when woken up via RTC
if ( !opiealarm_was_running ) {
// if opiealarm -s didn't wake up via RTC, the old process gets killed
// by kill_by_pidfile(), which is recorded in opiealarm_was_running
if ( resuspend && onac ( )) {
time_t start, now;
char *argv [4];
if ( !fork_with_pidfile ( ))
return 4;
// we can't wait for the resuspend timeout in the parent process.
// so we fork and tell the parent it can exit immediatly
kill ( parent_pid, SIGUSR1 );
// sleep <resuspend> seconds - this method is much more precise than sleep() !
time ( &start );
do {
sleep ( 1 );
time ( &now );
} while (( now - start ) < resuspend );
if ( onac ( )) { // still on ac ?
argv[0] = "qcop";
argv[1] = "QPE/Desktop";
argv[2] = "suspend()";
argv[3] = 0;
// hard coded for now ...but needed
// another way would be to simulate a power-button press
setenv ( "LOGNAME", "root", 1 );
setenv ( "HOME", "/root", 1 );
- setenv ( "LD_LIBRARY_PATH", "/opt/QtPalmtop/lib", 1 );
- setenv ( "QTDIR", "/opt/QtPalmtop", 1 );
+ setenv ( "LD_LIBRARY_PATH", OPIE_LIBDIR, 1 );
+ setenv ( "QTDIR", OPIE_QTDIR, 1 );
remove_pidfile ( );
// no need for system() since this process is no longer useful anyway
- execv ( "/opt/QtPalmtop/bin/qcop", argv );
+ execv ( OPIE_BINDIR "/qcop", argv );
perror ( "exec for qcop failed" );
return 5;
}
}
}
return 0;
}