Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

custom-sharp.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 
00021 #define QPE_NOCIBAUD
00022 
00023 #include <asm/sharp_apm.h>
00024 #ifndef APM_IOC_BATTERY_BACK_CHK
00025 #define APM_IOC_BATTERY_BACK_CHK       _IO(APM_IOC_MAGIC, 32)
00026 #endif
00027 #ifndef APM_IOC_BATTERY_MAIN_CHK
00028 #define APM_IOC_BATTERY_MAIN_CHK       _IO(APM_IOC_MAGIC, 33)
00029 #endif
00030 
00031 #include <unistd.h>
00032 #include <stdio.h>
00033 #include <signal.h>
00034 #include <fcntl.h>
00035 #include <sys/ioctl.h>
00036 
00037 
00038 #include <sys/ioctl.h>
00039 #include <asm/sharp_char.h>
00040 
00041 #define QPE_HAVE_MEMALERTER
00042 
00043 #define QPE_MEMALERTER_IMPL \
00044 static void sig_handler(int sig) \
00045 { \
00046     switch (sig) { \
00047     case SIGHUP: \
00048   memstate = VeryLow; \
00049   break; \
00050     case SIGUSR1: \
00051   memstate = Normal; \
00052   break; \
00053     case SIGUSR2: \
00054   memstate = Low; \
00055   break; \
00056     } \
00057 } \
00058 static void initMemalerter() \
00059 { \
00060     struct sigaction sa; \
00061     memset(&sa, '\0', sizeof sa); \
00062     sa.sa_handler = sig_handler; \
00063     sa.sa_flags = SA_RESTART; \
00064     if (sigaction(SIGHUP, &sa, NULL) < 0) { \
00065   return; \
00066     } \
00067     if (sigaction(SIGUSR1, &sa, NULL) < 0) { \
00068   return; \
00069     } \
00070     if (sigaction(SIGUSR2, &sa, NULL) < 0) { \
00071   return; \
00072     } \
00073     FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \
00074      \
00075     if (!fo) \
00076         return; \
00077     fprintf(fo, "qpe\n"); \
00078     fclose(fo); \
00079 }
00080 
00081 #define QPE_INITIAL_NUMLOCK_STATE \
00082 { \
00083     bool numLock = FALSE; \
00084     sharp_kbdctl_modifstat  st; \
00085     int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \
00086     if( dev >= 0 ) { \
00087   memset(&st, 0, sizeof(st)); \
00088   st.which = 3; \
00089                 int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \
00090   if( !ret ) \
00091       numLock = (bool)st.stat; \
00092   ::close(dev); \
00093     } \
00094     return numLock; \
00095 }

Generated on Sat Nov 5 16:16:35 2005 for OPIE by  doxygen 1.4.2