head 1.6; access; symbols pkgsrc-2017Q3:1.5.0.48 pkgsrc-2017Q3-base:1.5 pkgsrc-2017Q2:1.5.0.44 pkgsrc-2017Q2-base:1.5 pkgsrc-2017Q1:1.5.0.42 pkgsrc-2017Q1-base:1.5 pkgsrc-2016Q4:1.5.0.40 pkgsrc-2016Q4-base:1.5 pkgsrc-2016Q3:1.5.0.38 pkgsrc-2016Q3-base:1.5 pkgsrc-2016Q2:1.5.0.36 pkgsrc-2016Q2-base:1.5 pkgsrc-2016Q1:1.5.0.34 pkgsrc-2016Q1-base:1.5 pkgsrc-2015Q4:1.5.0.32 pkgsrc-2015Q4-base:1.5 pkgsrc-2015Q3:1.5.0.30 pkgsrc-2015Q3-base:1.5 pkgsrc-2015Q2:1.5.0.28 pkgsrc-2015Q2-base:1.5 pkgsrc-2015Q1:1.5.0.26 pkgsrc-2015Q1-base:1.5 pkgsrc-2014Q4:1.5.0.24 pkgsrc-2014Q4-base:1.5 pkgsrc-2014Q3:1.5.0.22 pkgsrc-2014Q3-base:1.5 pkgsrc-2014Q2:1.5.0.20 pkgsrc-2014Q2-base:1.5 pkgsrc-2014Q1:1.5.0.18 pkgsrc-2014Q1-base:1.5 pkgsrc-2013Q4:1.5.0.16 pkgsrc-2013Q4-base:1.5 pkgsrc-2013Q3:1.5.0.14 pkgsrc-2013Q3-base:1.5 pkgsrc-2013Q2:1.5.0.12 pkgsrc-2013Q2-base:1.5 pkgsrc-2013Q1:1.5.0.10 pkgsrc-2013Q1-base:1.5 pkgsrc-2012Q4:1.5.0.8 pkgsrc-2012Q4-base:1.5 pkgsrc-2012Q3:1.5.0.6 pkgsrc-2012Q3-base:1.5 pkgsrc-2012Q2:1.5.0.4 pkgsrc-2012Q2-base:1.5 pkgsrc-2012Q1:1.5.0.2 pkgsrc-2012Q1-base:1.5 pkgsrc-2011Q4:1.4.0.68 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q3:1.4.0.66 pkgsrc-2011Q3-base:1.4 pkgsrc-2011Q2:1.4.0.64 pkgsrc-2011Q2-base:1.4 pkgsrc-2011Q1:1.4.0.62 pkgsrc-2011Q1-base:1.4 pkgsrc-2010Q4:1.4.0.60 pkgsrc-2010Q4-base:1.4 pkgsrc-2010Q3:1.4.0.58 pkgsrc-2010Q3-base:1.4 pkgsrc-2010Q2:1.4.0.56 pkgsrc-2010Q2-base:1.4 pkgsrc-2010Q1:1.4.0.54 pkgsrc-2010Q1-base:1.4 pkgsrc-2009Q4:1.4.0.52 pkgsrc-2009Q4-base:1.4 pkgsrc-2009Q3:1.4.0.50 pkgsrc-2009Q3-base:1.4 pkgsrc-2009Q2:1.4.0.48 pkgsrc-2009Q2-base:1.4 pkgsrc-2009Q1:1.4.0.46 pkgsrc-2009Q1-base:1.4 pkgsrc-2008Q4:1.4.0.44 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.42 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.40 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.38 pkgsrc-2008Q2-base:1.4 cwrapper:1.4.0.36 pkgsrc-2008Q1:1.4.0.34 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.32 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.30 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.28 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.26 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.24 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.22 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.20 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.18 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.16 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.14 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.12 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.4.0.10 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.8 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.6 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.4 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.4.0.2 pkgsrc-2004Q1-base:1.4 pkgsrc-2003Q4:1.3.0.2 pkgsrc-2003Q4-base:1.3 netbsd-1-6-1:1.2.0.2 netbsd-1-6-1-base:1.2 netbsd-1-6:1.1.1.1.0.4 netbsd-1-6-RELEASE-base:1.1 pkgviews:1.1.1.1.0.6 pkgviews-base:1.1 buildlink2-base:1.1.1.1 buildlink2:1.1.1.1.0.2 pkg-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.6 date 2017.09.26.10.27.08; author wiz; state dead; branches; next 1.5; commitid 9ARpkXTuh9Wg2H8A; 1.5 date 2012.03.08.09.07.28; author shattered; state Exp; branches; next 1.4; 1.4 date 2004.02.04.20.38.00; author markd; state Exp; branches; next 1.3; 1.3 date 2003.03.11.13.22.32; author markd; state Exp; branches; next 1.2; 1.2 date 2002.10.04.00.14.19; author chris; state Exp; branches; next 1.1; 1.1 date 2002.05.31.13.42.36; author skrll; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2002.05.31.13.42.36; author skrll; state Exp; branches 1.1.1.1.2.1; next ; 1.1.1.1.2.1 date 2002.05.31.13.42.36; author jlam; state dead; branches; next 1.1.1.1.2.2; 1.1.1.1.2.2 date 2002.06.23.18.53.47; author jlam; state Exp; branches; next ; desc @@ 1.6 log @*: remove qt3 and the packages using it, including KDE3 Announced in https://mail-index.netbsd.org/pkgsrc-users/2017/09/10/msg025556.html @ text @$NetBSD: patch-an,v 1.5 2012/03/08 09:07:28 shattered Exp $ --- klaptopdaemon/portable.cpp.orig 2008-02-13 09:38:14.000000000 +0000 +++ klaptopdaemon/portable.cpp @@@@ -2438,10 +2438,14 @@@@ laptop_portable::software_suspend_set_ma #include #include #include -#include +#include +#include +#include +#include +#include // -// klaptopdeamon interface to NetBSD 1.5 apm. +// Klaptopdeamon interface to NetBSD 1.5 apm. // Scott Presnell, srp@@zgi.com, srp@@tworoads.net // Fri Jun 29 17:21:25 PDT 2001 // Tested on Dell I4K running NetBSD 1.5R @@@@ -2463,6 +2467,7 @@@@ laptop_portable::has_power_management() } struct apm_power_info info; + memset(&info, 0, sizeof(info)); ret=ioctl(fd, APM_IOC_GETPOWER, &info); ::close(fd); @@@@ -2490,6 +2495,7 @@@@ int laptop_portable::has_battery_time() return 0; struct apm_power_info info; + memset(&info, 0, sizeof(info)); ret=ioctl(fd, APM_IOC_GETPOWER, &info); ::close(fd); @@@@ -2661,6 +2667,15 @@@@ laptop_portable::apm_set_mask(bool , boo // +// adds extra widgets to the battery panel +// +void +laptop_portable::extra_config(QWidget *parent, KConfig *config, QVBoxLayout *layout) +{ +} + + +// // return current battery state // struct power_result laptop_portable::poll_battery_state() @@@@ -2674,6 +2689,7 @@@@ struct power_result laptop_portable::pol goto bad; struct apm_power_info info; + memset(&info, 0, sizeof(info)); ret=ioctl(fd, APM_IOC_GETPOWER, &info); ::close(fd); @@@@ -2736,7 +2752,16 @@@@ laptop_portable::get_brightness() } bool -laptop_portable::get_system_throttling(bool, int ¤t, QStringList &s) // do something to help get system throttling data from places like ACPI +laptop_portable::get_system_performance(bool, int ¤t, QStringList &s, bool *&) // do something to help get system profiles from places like ACPI +{ + // INSERT HERE + current = 0; + s.clear(); + return(0); // if no profiles are available +} + +bool +laptop_portable::get_system_throttling(bool, int ¤t, QStringList &s, bool *&) // do something to help get system throttling data from places like ACPI { // INSERT HERE current = 0; @@@@ -2794,6 +2819,18 @@@@ laptop_portable::get_battery_status(int values.append(s); } +bool +laptop_portable::has_software_suspend(int /*type*/) +{ + return false; // (::has_software_suspend(type)); +} + +void +laptop_portable::software_suspend_set_mask(bool hibernate) +{ + // software_suspend_is_preferred = hibernate; +} + #else /* @ 1.5 log @PR/40020 -- provide laptop_portable::has_software_suspend(). This stops the crash in kcontrol and allows battery monitor to work. @ text @d1 1 a1 1 $NetBSD$ @ 1.4 log @Update to KDE 3.2 Changes: Utilities KRegExpEditor * Create an application on its own from KRegExpEditor (several users have requested this) Jesper K. Pedersen * Add a verifier window where user can try his regular expression Jesper K. Pedersen * Add some warnings on invalid regular expressions (like $^) Jesper K. Pedersen * Ensure predefined regular expressions are correct i18n'ed Jesper K. Pedersen * Add support for Emacs style Regular Expression syntaxes Jesper K. Pedersen KJots * XMLUI-ify and improve the interface. Using a treeview for books and bookmarks for quick nav. Aaron J. Seigo * Printing and viewing of entire books. Aaron J. Seigo * Autosave. Aaron J. Seigo KMilo * NEW IN KDE: A generic framework to support special keyboards and hardware features, such as those found on laptops. George Staikos * KMilo support for PowerBooks via pbbuttonsd. George Staikos KLaptop * Full Linux ACPI support (suspend etc, throttling, performance profiles) Paul Campbell * Back panel brightness support for some laptops (Sony, Toshiba) Paul Campbell * Recode to run as a KDED daemon Paul Campbell * Better Thinkpad support Paul Campbell * Triggers from lid closure (suspend, powerdown etc) - on laptops with ACPI support Paul Campbell * Sony laptop extensions support (/dev/sonypi - scroll wheel, panel brightness) Paul Campbell * Added the ability to auto-disable suspend etc when the load average is high Paul Campbell * Display the state of individual batteries in ACPI systems Paul Campbell * Support for Linux kernel software suspend Paul Campbell * Added battery charged notification dialog Paul Campbell * Option to use blank screensaver when in battery mode George Staikos * Support for the Linux CPUFreq interface. Volker Krause Kgpg * NEW IN KDE: frontend for gpg. Jean-Baptiste Mardelle * Key editing in GUI (changing passphrase, trust, expiration) * Support for key groups * Speed up key manager * Gpg-agent support * Auto import missing signatures * improved editor (print, spell check, ...) * Manage photo id's * Revocation certificates (print, save) * Change dialogs to KBaseDialog for ui consistency * Implement the missing key editing commands in the GUI (adduid, deluid,..) * When encrypting a folder, give a choice of compression scheme (zip, tar,...) KHexEdit2 * NEW IN KDE: A hex edit widget library Friedrich W. H. Kossebau * move the lib of the new KHexEdit2 widget from kdenonbeta over to kdeutils/khexedit/lib Friedrich W. H. Kossebau * implement interfaces for the KBytesEdit widget part Friedrich W. H. Kossebau @ text @d3 1 a3 1 --- klaptopdaemon/portable.cpp.orig 2003-11-30 22:50:47.000000000 +1300 d5 1 a5 1 @@@@ -2414,10 +2414,14 @@@@ laptop_portable::software_suspend_set_ma d22 1 a22 1 @@@@ -2439,6 +2443,7 @@@@ laptop_portable::has_power_management() d30 1 a30 1 @@@@ -2466,6 +2471,7 @@@@ int laptop_portable::has_battery_time() d38 1 a38 1 @@@@ -2639,6 +2645,15 @@@@ laptop_portable::apm_set_mask(bool , boo d54 1 a54 1 @@@@ -2652,6 +2667,7 @@@@ struct power_result laptop_portable::pol d62 1 a62 1 @@@@ -2714,7 +2730,16 @@@@ laptop_portable::get_brightness() d80 1 a80 1 @@@@ -2772,6 +2797,12 @@@@ laptop_portable::get_battery_status(int d84 6 @ 1.3 log @Update KDE to 3.1. Many bugfixes and functionality enhancements including: kdeaddons NEW IN KDE: Noatun plugin to search for lyrics of the current song. kdeadmin kcmlinuz: is now a standalone application kcmlinuz: Added capability to search for configuration options kdeedu NEW IN KDE: Kiten, a Japanese Reference Tool. NEW IN KDE: FlashKard, a vocabulary tool. Is able to read KVTML files which were written by KVocTrain. NEW IN KDE: started a libkdeedu, which allows interopability and code sharing between KDE Educational applications. kdepim libkabc Plugin interface for resources and formats. Control module for configuring multiple resources. Optional directory resource which stores each entry as own file. LDAP resource. Optional binary storage format for better performance with large addressbooks. Completed support for vCard entities: sound, geo, key and some more. vCard 2.1 import. LDAP aware mail address input field. KAddressbook New card and icon views. Multiple configurable views. "kab-style" details view for selected entry. Customizable view filters. Customizable categories for addressbook entries. Support for transparently accessing multiple addressbooks. Redesigned entry editor widget. Printing option supporting two different styles. Optional embedded entry and ditribution list editor. "Jump bar" for quick alphabetical access of entries. Fetch addresses from LDAP servers, including support for multiple servers. Importing of vCard 2.1 files. Improved CSV import (including template for import from Outlook 2000). vCard export. KAlarm Added option to execute commands in alarms. Implemented daily, weekly, monthly and annual recurrences. Optionally play audio notification when an alarm triggers. KPilot Added time conduit VCal conduits (TODO and Calendar) have been improved to function properly. Addressbook conduit has been ported to use libkabc. KOrganizer General User definable templates for events and TODOs. Alarms for TODOs. Added support for automatic HTML export on save of a calendar file. Time table print view. New "location" attribute for events. Experimental "Get Hot New Stuff" button for downloading and uploading calendar files of common interest. Views Added new "Next 3 days" view. Added selection of time span for a new event in day and week views. Direct manipulation of priority, completion status and categories of TODOs by context menus added. Deletion of individual instances of recurring events. Rewritten month view. Coloring of events in month view based on categories. Coloring of due and overdue todos. Improved "What's Next" view. Configurable cell height in week and day views Group scheduling iMIP group scheduling functions for TODOs. Publishing of Free/Busy information by iMIP conformant email. Improved automatisation of group scheduling. Interopability and integration Support for "webcal" URLs in Konqueror (known from Apple iCal). Support for iCalendar based drag&drop. KOrganizer now shares the dialogs for categories with KAddressBook. Improved iCalendar conformance. Improved right-to-left languages support. Bug fixes for non-latin1 encodings. Plugins New plugin for importing Birthdays of contacts in the KDE address book. New plugin for accessing calendar data stored on an Exchange 2000 server. kdeutils Partially ACPI support in KLaptop. @ text @d3 1 a3 1 --- klaptopdaemon/portable.cpp.orig Fri Jan 3 18:07:53 2003 d5 18 a22 1 @@@@ -1130,6 +1130,7 @@@@ laptop_portable::has_power_management() d30 1 a30 1 @@@@ -1151,6 +1152,7 @@@@ int laptop_portable::has_battery_time() d38 1 a38 1 @@@@ -1288,6 +1290,15 @@@@ void laptop_portable::invoke_hibernation d54 1 a54 1 @@@@ -1301,6 +1312,7 @@@@ struct power_result laptop_portable::pol d62 31 @ 1.2 log @Make klaptopdaemon build with __NetBSD_APM__ where appropriate. Also update patch-an so that 1.6 and -current systems work. Based on and should fix pkg/18447. @ text @d3 23 a25 183 --- klaptopdaemon/portable.cpp.orig Sat Jan 26 17:58:32 2002 +++ klaptopdaemon/portable.cpp Thu Oct 3 23:42:47 2002 @@@@ -857,6 +857,241 @@@@ { return(1); } + +#elif __NetBSD_APM__ + +#include +#include +#include +#include +#include +#include +#include +#include + +// +// klaptopdeamon interface to NetBSD 1.5 apm. +// Scott Presnell, srp@@zgi.com, srp@@tworoads.net +// Fri Jun 29 17:21:25 PDT 2001 +// Tested on Dell I4K running NetBSD 1.5R +// +#define APMDEV "/dev/apm" + +// +// Check for apm in kernel by talking to /dev/apm +// (opening read only is allowed by any process). +// returns 1 if we support power management +// +int +laptop_portable::has_power_management() +{ + int ret, fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) { + return 0; + } + + struct apm_power_info info; + memset(&info, 0, sizeof(info)); + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) { + return 0; + } + + return 1; +} + +// +// returns 1 if the BIOS returns the time left in the battery rather than a % of full +// +int laptop_portable::has_battery_time() +{ + int ret, fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) + return 0; + + struct apm_power_info info; + memset(&info, 0, sizeof(info)); + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) + return 0; + + return (info.minutes_left != 0xffff); +} + +// +// returns 1 if we can perform a change-to-suspend-mode operation for the user +// (ust check to see if we have the binary) +// (has_power_management() has already returned 1) +// +int laptop_portable::has_suspend() +{ + + struct stat s; + if (stat("/usr/sbin/apm", &s)) + return(0); + return(1); +} + +// +// returns 1 if we can perform a change-to-standby-mode operation for the user +// (just check to see if we have the binary) +// (has_power_management() has already returned 1) +// +int laptop_portable::has_standby() +{ + + struct stat s; + if (stat("/usr/sbin/apm", &s)) + return(0); + return(1); +} + +// +// returns 1 if we can perform a change-to-hibernate-mode for a user +// (has_power_management() has already returned 1) [hibernate is the save-to-disk mode +// not supported by linux - different laptops have their own - the first here is for +// a ThinkPad] +// No support in NetBSD at this time. +// +int laptop_portable::has_hibernation() +{ + return(0); +} + +// +// explain to the user what they need to do if has_power_management() returned 0 +// to get any software they lack +// +QLabel *laptop_portable::no_power_management_explanation(QWidget *parent) +{ + int fd; + QLabel *explain; + + fd = ::open(APMDEV, O_RDONLY); + if (fd == -1) { + switch (errno) { + case ENOENT: + explain = new QLabel("There is no /dev/apm file on this system. Pleae review the NetBSD documentation on how to create a device node for the apm device driver (man 4 apm)", parent); + break; + case EACCES: + explain = new QLabel("Your system has the proper device node for apm support, however you can't access it. If you have apm in the kernel this should not happen", parent); + break; + case ENXIO: + explain = new QLabel("Your kernel lacks support for Advanced Power Managment.", parent); + break; + break; + default: + explain = new QLabel("There was some generic error while opening /dev/apm.", parent); + break; + } + } else { + close(fd); + explain = new QLabel("APM has most likely been disabled. Oops", parent); + } + + explain->setMinimumSize(explain->sizeHint()); + return(explain); +} + +// +// explain to the user what they need to do to get suspend/resume to work from user mode +// +QLabel *laptop_portable::how_to_do_suspend_resume(QWidget *parent) +{ + QLabel* note = new QLabel(i18n(" "), parent); + note->setMinimumSize(note->sizeHint()); + return(note); +} + +// +// pcmcia support - this will be replaced by better - pcmcia support being worked on by +// others +// +QLabel *laptop_portable::pcmcia_info(int x, QWidget *parent) +{ + if (x == 0) + return(new QLabel(i18n("No PCMCIA controller detected"), parent)); + return(new QLabel(i18n(""), parent)); +} + +// +// puts us into standby mode +// Use apm rather than ioctls in case they are running apmd +// (as they should be). +// +void laptop_portable::invoke_standby() +{ + ::system("/usr/sbin/apm -S"); +} + +// +// puts us into suspend mode +// Use apm rather than ioctls in case they are running apmd +// (as they should be). d27 2 a28 1 +void laptop_portable::invoke_suspend() a29 2 + + ::system("/usr/sbin/apm -z"); a31 35 +// +// puts us into hibernate mode +// No hibernate mode for NetBSD. +// +void laptop_portable::invoke_hibernation() +{ + return; +} + + +// +// return current battery state +// +struct power_result laptop_portable::poll_battery_state() +{ + struct power_result p; + int ret; + + int fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) + goto bad; + + struct apm_power_info info; + memset(&info, 0, sizeof(info)); + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) + goto bad; + + p.powered = (info.ac_state == APM_AC_ON); + p.percentage = (info.battery_life==255 ? 100 : info.battery_life); + p.time = (info.minutes_left != 0xffff ? info.minutes_left : -1); + return(p); a32 8 +bad: + p.powered = 1; + p.percentage = 100; + p.time = 0; + return(p); +} + +// d34 5 a38 7 +// returns true if any mouse or kdb activity has been detected +// +int laptop_portable::poll_activity() +{ + return(1); +} #else d40 5 a44 1 // INSERT HERE @ 1.1 log @Initial revision @ text @d3 3 a5 3 --- klaptopdaemon/portable.cpp.orig Wed Jan 9 12:11:32 2002 +++ klaptopdaemon/portable.cpp @@@@ -857,6 +857,238 @@@@ d44 1 d66 1 d217 1 @ 1.1.1.1 log @Initial import of the kdeutils pkg (in the right place this time.) @ text @@ 1.1.1.1.2.1 log @file patch-an was added on branch buildlink2 on 2002-06-23 18:53:47 +0000 @ text @d1 243 @ 1.1.1.1.2.2 log @Merge from pkgsrc-current to buildlink2 branch. @ text @a0 243 $NetBSD: patch-an,v 1.1.1.1.2.1 2002/06/23 18:53:47 jlam Exp $ --- klaptopdaemon/portable.cpp.orig Wed Jan 9 12:11:32 2002 +++ klaptopdaemon/portable.cpp @@@@ -857,6 +857,238 @@@@ { return(1); } + +#elif __NetBSD_APM__ + +#include +#include +#include +#include +#include +#include +#include +#include + +// +// klaptopdeamon interface to NetBSD 1.5 apm. +// Scott Presnell, srp@@zgi.com, srp@@tworoads.net +// Fri Jun 29 17:21:25 PDT 2001 +// Tested on Dell I4K running NetBSD 1.5R +// +#define APMDEV "/dev/apm" + +// +// Check for apm in kernel by talking to /dev/apm +// (opening read only is allowed by any process). +// returns 1 if we support power management +// +int +laptop_portable::has_power_management() +{ + int ret, fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) { + return 0; + } + + struct apm_power_info info; + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) { + return 0; + } + + return 1; +} + +// +// returns 1 if the BIOS returns the time left in the battery rather than a % of full +// +int laptop_portable::has_battery_time() +{ + int ret, fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) + return 0; + + struct apm_power_info info; + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) + return 0; + + return (info.minutes_left != 0xffff); +} + +// +// returns 1 if we can perform a change-to-suspend-mode operation for the user +// (ust check to see if we have the binary) +// (has_power_management() has already returned 1) +// +int laptop_portable::has_suspend() +{ + + struct stat s; + if (stat("/usr/sbin/apm", &s)) + return(0); + return(1); +} + +// +// returns 1 if we can perform a change-to-standby-mode operation for the user +// (just check to see if we have the binary) +// (has_power_management() has already returned 1) +// +int laptop_portable::has_standby() +{ + + struct stat s; + if (stat("/usr/sbin/apm", &s)) + return(0); + return(1); +} + +// +// returns 1 if we can perform a change-to-hibernate-mode for a user +// (has_power_management() has already returned 1) [hibernate is the save-to-disk mode +// not supported by linux - different laptops have their own - the first here is for +// a ThinkPad] +// No support in NetBSD at this time. +// +int laptop_portable::has_hibernation() +{ + return(0); +} + +// +// explain to the user what they need to do if has_power_management() returned 0 +// to get any software they lack +// +QLabel *laptop_portable::no_power_management_explanation(QWidget *parent) +{ + int fd; + QLabel *explain; + + fd = ::open(APMDEV, O_RDONLY); + if (fd == -1) { + switch (errno) { + case ENOENT: + explain = new QLabel("There is no /dev/apm file on this system. Pleae review the NetBSD documentation on how to create a device node for the apm device driver (man 4 apm)", parent); + break; + case EACCES: + explain = new QLabel("Your system has the proper device node for apm support, however you can't access it. If you have apm in the kernel this should not happen", parent); + break; + case ENXIO: + explain = new QLabel("Your kernel lacks support for Advanced Power Managment.", parent); + break; + break; + default: + explain = new QLabel("There was some generic error while opening /dev/apm.", parent); + break; + } + } else { + close(fd); + explain = new QLabel("APM has most likely been disabled. Oops", parent); + } + + explain->setMinimumSize(explain->sizeHint()); + return(explain); +} + +// +// explain to the user what they need to do to get suspend/resume to work from user mode +// +QLabel *laptop_portable::how_to_do_suspend_resume(QWidget *parent) +{ + QLabel* note = new QLabel(i18n(" "), parent); + note->setMinimumSize(note->sizeHint()); + return(note); +} + +// +// pcmcia support - this will be replaced by better - pcmcia support being worked on by +// others +// +QLabel *laptop_portable::pcmcia_info(int x, QWidget *parent) +{ + if (x == 0) + return(new QLabel(i18n("No PCMCIA controller detected"), parent)); + return(new QLabel(i18n(""), parent)); +} + +// +// puts us into standby mode +// Use apm rather than ioctls in case they are running apmd +// (as they should be). +// +void laptop_portable::invoke_standby() +{ + ::system("/usr/sbin/apm -S"); +} + +// +// puts us into suspend mode +// Use apm rather than ioctls in case they are running apmd +// (as they should be). +// +void laptop_portable::invoke_suspend() +{ + + ::system("/usr/sbin/apm -z"); +} + +// +// puts us into hibernate mode +// No hibernate mode for NetBSD. +// +void laptop_portable::invoke_hibernation() +{ + return; +} + + +// +// return current battery state +// +struct power_result laptop_portable::poll_battery_state() +{ + struct power_result p; + int ret; + + int fd = ::open(APMDEV, O_RDONLY); + + if (fd == -1) + goto bad; + + struct apm_power_info info; + ret=ioctl(fd, APM_IOC_GETPOWER, &info); + ::close(fd); + + if (ret == -1) + goto bad; + + p.powered = (info.ac_state == APM_AC_ON); + p.percentage = (info.battery_life==255 ? 100 : info.battery_life); + p.time = (info.minutes_left != 0xffff ? info.minutes_left : -1); + return(p); + +bad: + p.powered = 1; + p.percentage = 100; + p.time = 0; + return(p); +} + +// +// +// returns true if any mouse or kdb activity has been detected +// +int laptop_portable::poll_activity() +{ + return(1); +} #else // INSERT HERE @