summaryrefslogtreecommitdiffstats
path: root/kmilo/powerbook2
diff options
context:
space:
mode:
Diffstat (limited to 'kmilo/powerbook2')
-rw-r--r--kmilo/powerbook2/Makefile.am34
-rw-r--r--kmilo/powerbook2/kmilo_powerbook.desktop106
-rw-r--r--kmilo/powerbook2/pb_monitor.cpp165
-rw-r--r--kmilo/powerbook2/pb_monitor.h55
4 files changed, 360 insertions, 0 deletions
diff --git a/kmilo/powerbook2/Makefile.am b/kmilo/powerbook2/Makefile.am
new file mode 100644
index 0000000..5c3f467
--- /dev/null
+++ b/kmilo/powerbook2/Makefile.am
@@ -0,0 +1,34 @@
+# This file is part of the KDE project
+# Copyright (C) 2003 George Staikos <staikos@kde.org>
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+INCLUDES=-I$(srcdir)/../kmilod $(all_includes)
+
+kde_module_LTLIBRARIES = kmilo_powerbook.la
+
+kmilo_powerbook_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+kmilo_powerbook_la_LIBADD = ../kmilod/libkmilo.la $(LIB_KIO) $(KEYBOARD_LIBS)
+kmilo_powerbook_la_SOURCES = pb_monitor.cpp
+METASOURCES = AUTO
+
+noinst_HEADERS = pb_monitor.h
+
+services_DATA = kmilo_powerbook.desktop
+servicesdir = $(kde_servicesdir)/kmilo
+
+messages:
+ $(XGETTEXT) $(kmilo_powerbook_la_SOURCES) -o $(podir)/kmilo_powerbook.pot
diff --git a/kmilo/powerbook2/kmilo_powerbook.desktop b/kmilo/powerbook2/kmilo_powerbook.desktop
new file mode 100644
index 0000000..9aff481
--- /dev/null
+++ b/kmilo/powerbook2/kmilo_powerbook.desktop
@@ -0,0 +1,106 @@
+[Desktop Entry]
+Type=Service
+ServiceTypes=KMilo Plugin
+X-KDE-ModuleType=Plugin
+Name=Apple PowerBook Plugin
+Name[ar]=ملحق Apple PowerBook
+Name[br]=Lugent Apple PowerBook
+Name[bs]=Apple PowerBook dodatak
+Name[ca]=Connector Apple PowerBook
+Name[cs]=Apple PowerBook modul
+Name[cy]=Ategyn Apple PowerBook
+Name[el]=Πρόσθετο Apple PowerBook
+Name[es]=Extensión del PowerBook de Apple
+Name[et]=Apple PowerBooki plugin
+Name[eu]=Apple PowerBook Plugina
+Name[fa]=Apple PowerBook وصلۀ
+Name[fi]=Apple PowerBook -liitännäinen
+Name[fr]=Module externe Apple PowerBook
+Name[ga]=Breiseán Apple® PowerBook®
+Name[he]=תוסף ל-Apple PowerBook
+Name[hi]=एपल पावर-बुक प्लगइन
+Name[hu]=Apple PowerBook bővítőmodul
+Name[is]=Apple PowerBook íforrit
+Name[it]=Plugin per Apple PowerBook
+Name[ja]=Apple PowerBook プラグイン
+Name[ka]=Apple PowerBook მოდული
+Name[kk]=Apple PowerBook модулі
+Name[km]=កម្មវិធីជំនួយ Apple PowerBook
+Name[lt]=Apple PowerBook priedas
+Name[mk]=Приклучок за Apple PowerBook
+Name[ms]= Plug masuk Apple PowerBook
+Name[nb]=Programtillegg for Apple PowerBook
+Name[nds]=Apple PowerBook-Moduul
+Name[ne]=एप्पल पावरबुक प्लगइन
+Name[nl]=Apple PowerBook-plugin
+Name[nn]=Programtillegg for Apple PowerBook
+Name[pa]=Apple PowerBook ਪਲੱਗਿੰਨ
+Name[pl]=Wtyczka Apple PowerBook
+Name[pt]='Plugin' para Apple PowerBook
+Name[pt_BR]=Plug-in para Apple PowerBook
+Name[ro]=Modul Apple PowerBook
+Name[ru]=Модуль Apple PowerBook
+Name[sk]=Module pre Applet PowerBook
+Name[sl]=Vstavek za Apple PowerBook
+Name[sr]=Прикључак за Apple-ов PowerBook
+Name[sr@Latn]=Priključak za Apple-ov PowerBook
+Name[sv]=Apple PowerBook-insticksprogram
+Name[ta]=ஆப்பிள் பவர்புக் சொருகுப்பொருள்
+Name[tg]=Модули Apple PowerBook
+Name[tr]=Apple PowerBook Eklentisi
+Name[uk]=Втулок Apple PowerBook
+Name[uz]=Apple PowerBook plagini
+Name[uz@cyrillic]=Apple PowerBook плагини
+Name[zh_CN]=Apple PowerBook 插件
+Name[zh_TW]=Apple Powerbook 外掛程式
+Comment=This plugin enabled support for special keys on Apple PowerBooks via pbbuttonsd.
+Comment[ar]=تمكّن الدعم لمفاتيح حاسوب Apple PowerBook المحمول الخاصة عن طريق pbbuttonsd.
+Comment[bg]=Тази приставка позволява поддръжката на специалните клавиши на Apple PowerBooks.
+Comment[bs]=Ovaj dodatak (plugin) omogućuje podršku za posebne tipke na Apple PowerBooks laptopima koristeći pbbuttonsd.
+Comment[ca]=Aquest connector activa el funcionament per a tecles especials dels Apple PowerBooks via pbbuttonsd.
+Comment[cs]=Tento modul umožňuje používat zvláštní klávesy notebooků Apple PowerBook přes pbbuttonsd.
+Comment[cy]=Galluoga'r ategyn yma gynhaliaeth ar gyfer bysyll arbennig ar yr Apple PowerBook drwy pbbuttonsd.
+Comment[da]=Dette plugin aktivere støtte for specielle taster på Apple PowerBooks via pbbuttonsd.
+Comment[de]=Dieses Plugin schaltet die Unterstützung für Sondertasten des Apple Powerbooks via pbbuttonsd ein.
+Comment[el]=Αυτό το πρόσθετο ενεργοποιεί την υποστήριξη για ειδικά πλήκτρα στα Apple PowerBooks μέσω του pbbuttonsd.
+Comment[es]=Esta extensión activa el soporte de las teclas especiales en los PowerBooks de Apple mediante «pbbuttonsd».
+Comment[et]=See plugin võimaldab pbbuttonsd vahendusel kasutada eriklahve Apple PowerBooksil
+Comment[eu]=Plugin honek tekla berezientzako euskarria gaitu du Apple PowerBook magalekoetan pbbuttonsd bitartez.
+Comment[fa]=این وصله، برای کلیدهای ویژۀ Apple PowerBooks via pbbuttonsd، پشتیبانی را فعال می‌کند.
+Comment[fi]=Tämä sovelma mahdollisti tuen Apple Powerbook kannettavien erikoisnäppäimille pbbuttonsd-ohjelman kautta.
+Comment[fr]=Ce module active la gestion des touches spéciales des Apple PowerBook via pbbuttonsd.
+Comment[ga]=Tacaíonn an breiseán seo le cnaipí speisialta ar ríomhairí glúine Apple® PowerBook® trí pbbuttonsd.
+Comment[he]=התוסף הזה מאפשר תמיכה במקשים מיוחדים על מחשבים הברכיים של Apple PowerBook
+Comment[hi]=यह प्लगइन एपल पावर-बुक पर pbbuttonsd के द्वारा विशिष्ट कुंजी समर्थन सक्षम करता है
+Comment[hu]=Az Apple PowerBook noteszgépek speciális kezelőelemeinek beállítása (a pbbuttonsd szolgáltatáson keresztül)
+Comment[is]=Þetta íforrit gerir þér kleyft að nota sérhnappana á Apple PowerBook með pbbuttonsd þjóninum.
+Comment[it]=Questo plugin abilita il supporto per i tasti speciali sui portatili Apple PowerBook tramite pbbuttonsd.
+Comment[ja]=このプラグインは pbbuttonsd を通して Apple PowerBook の特殊キーをサポートします
+Comment[ka]= ეს მოდული რთავს Apple PowerBooks-ის სპეციალური კლავიშების მხარდაჭერას pbbuttonsd-ის მეშვეობით.
+Comment[kk]=Бұл модуль Apple PowerBook ноутбуктерінде pbbuttonsd арқылы арнаулы пернелерді қолдау үшін.
+Comment[km]=កម្មវិធី​ជំនួយ​នេះបើក​ការគាំទ្រ​សម្រាប់​គ្រាប់ចុច​ពិសេសនៅលើ Apple PowerBooks តាមរយៈ pbbuttonsd ។
+Comment[lt]=Šis priedas įgalina specialiųjų raktų Apple PowerBook nešiojamuose kompiuteriuose palaikymą per pbbuttonsd.
+Comment[mk]=Овој приклучок дава поддршка за специјалните копчиња на Apple PowerBooks преку pbbuttonsd.
+Comment[ms]=Plug masuk membolehkan sokongan untuk kekunci khas Apple PowerBooks menerusi pbbuttonsd.
+Comment[nb]=Dette programtillegget muliggjør støtte for spesille taster på Apple PowerBooks via pbbuttonsd.
+Comment[nds]=Dit Moduul maakt de Sünnertasten-Ünnerstütten för Apple-PowerBooks via pbbuttonsd an.
+Comment[ne]=यो प्लगइनले pbbuttonsd द्वारा एप्पल पावरबुक विशेष कुञ्जीका लागि समर्थन सक्षम पार्दछ ।
+Comment[nl]=Maakt het mogelijk speciale toetsen op Apple (R) PowerBook (R) laptops te gebruiken via pbbuttonsd.
+Comment[nn]=Dette programtillegget gjer at du kan bruka spesialtastane på Apple PowerBook gjennom pbbuttonsd.
+Comment[pl]=Ta wtyczka umożliwia obsługę klawiszy specjalnych na laptopach Apple PowerBook za pomocą pbbuttonsd.
+Comment[pt]=Este 'plugin' activa o suporte para as teclas especiais nos portáteis Apple PowerBook através do 'pbbuttonsd'.
+Comment[pt_BR]=Este plug-in habilita suporte para teclas especiais nos Apple PowerBooks via pbbuttonsd.
+Comment[ro]=Acest modul activează suportul pentru tastele speciale din laptop-urile Apple PowerBook, utilizînd "pbbuttonsd".
+Comment[ru]=Этот модуль поддерживает специальные клавиши на Apple PowerBooks через pbbuttonsd.
+Comment[sk]=Tento modul obsahuje podporu špeciálnych kláves pre Apple (R) PowerBook (R) pomocou pbbuttonsd.
+Comment[sl]=Ta vstavek vam omogoča podboro posebnim ključem na prenosnikih Apple PowerBook preko pbbuttonsd.
+Comment[sr]=Овај прикључак омогућава подршку за специјалне тастере на Apple-овим PowerBook-овима преко pbbuttonsd.
+Comment[sr@Latn]=Ovaj priključak omogućava podršku za specijalne tastere na Apple-ovim PowerBook-ovima preko pbbuttonsd.
+Comment[sv]=Det här insticksprogrammet aktiverar stöd för speciella tangenter för Apple PowerBook via pbbuttonsd.
+Comment[ta]=ஆப்பிள் பவர்புக்ஸ் மூலமாக பிபிபட்டன்எஸ்டிக்கு இந்த சொருகுப் பொருள் ஆதரவளிக்கிறது
+Comment[tg]=Ин модул пуштибонии калидҳои махсусро дар компютери дастии Apple PowerBooks ба воситаи pbbuttonsd дармегиронад.
+Comment[tr]=Bu plugin pbbuttonsd aracılığı ile Apple PowerBook dizüstüler için özel tuş desteğini açar.
+Comment[uk]=Цей втулок дозволив користуватися спеціальними клавішами на лептопах Apple PowerBook за допомогою pbbuttonsd.
+Comment[zh_CN]=此插件启用 Apple PowerBook 电源按钮的特殊按键支持。
+Comment[zh_TW]=這個外掛程式透過 pbbuttonsd 開啟 Apple Powerbooks 特殊鍵支援。
+X-KDE-Library=kmilo_powerbook
diff --git a/kmilo/powerbook2/pb_monitor.cpp b/kmilo/powerbook2/pb_monitor.cpp
new file mode 100644
index 0000000..84c72d5
--- /dev/null
+++ b/kmilo/powerbook2/pb_monitor.cpp
@@ -0,0 +1,165 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*-
+/*
+ This file is part of the KDE project
+
+ Copyright (c) 2003 Zack Rusin <staikos@kde.org>
+ Pretty much ripped of from :
+ George Staikos <staikos@kde.org> :)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#include "pb_monitor.h"
+
+#include <kgenericfactory.h>
+#include <kdebug.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+
+extern "C" {
+//Hack because of the fact that pbb author is using C++ keywords in the code
+//among which is "template"...
+#undef template
+#include <pbb.h>
+
+// TAG_BRIGHTNESS was renamed to TAG_LCDBRIGHTNESS in pbbuttons
+// 0.6.1-2
+#ifndef TAG_LCDBRIGHTNESS
+#define TAG_LCDBRIGHTNESS TAG_BRIGHTNESS
+#endif
+}
+
+#define BUFFERLEN 200
+const QString tpmodes[] = { I18N_NOOP("No Tap"), I18N_NOOP("Tap"), I18N_NOOP("Drag"), I18N_NOOP("Lock") };
+
+namespace KMilo {
+
+PowerBookMonitor::PowerBookMonitor(QObject *parent, const char *name,
+ const QStringList& args)
+ : Monitor(parent, name, args),
+ m_progress( 0 )
+{
+ init_libpbb();
+}
+
+PowerBookMonitor::~PowerBookMonitor()
+{
+ ipc_exit();
+}
+
+
+bool PowerBookMonitor::init()
+{
+// pbbuttons 0.6.7 or newer
+#ifdef CLIENT_REGISTER
+ return ( ipc_init( "kmilo", LIBMODE_CLIENT, CLIENT_REGISTER ) == 0 );
+#else
+ return ( ipc_init( LIBMODE_CLIENT, 1 ) == 0 );
+#endif
+}
+
+
+Monitor::DisplayType PowerBookMonitor::poll()
+{
+ Monitor::DisplayType rc = None;
+ // Drain the queue, send the last message
+ struct tagitem* tag = readMessage();
+ m_message = QString::null;
+ while ( tag && tag->tag != TAG_END ) {
+ switch ( tag->tag ) {
+ case TAG_VOLUME:
+ rc = Monitor::Volume;
+ m_progress = (int)tag->data;
+ break;
+ case TAG_MUTE:
+ rc = Monitor::Mute;
+ m_progress = (int)tag->data;
+ break;
+ case TAG_LCDBRIGHTNESS:
+ rc = Monitor::Brightness;
+ m_progress = ((int)tag->data)*100/15;
+ break;
+ case TAG_TPMODE:
+ {
+ rc = Monitor::Tap;
+ QString marg = tpmodes[ tag->data & 3 ];
+ m_message = i18n( "Operating mode set to: %1." ).arg( marg );
+ }
+ break;
+ default:
+ break;
+ }
+ ++tag;
+ }
+
+ if ( m_sleep ) {
+ rc = Monitor::Sleep;
+ }
+
+ return rc;
+}
+
+
+int PowerBookMonitor::progress() const
+{
+ return m_progress;
+}
+
+QString PowerBookMonitor::message() const
+{
+ return m_message;
+}
+
+struct tagitem* PowerBookMonitor::readMessage()
+{
+ char buffer[BUFFERLEN];
+ m_sleep = false;
+ if ( (ipc_receive(buffer, BUFFERLEN)) >=0 ) {
+ if ( buffer ) {
+ struct pbbmessage *msg = reinterpret_cast<struct pbbmessage*>( buffer );
+ switch ( msg->action ) {
+ case REGFAILED:
+ kdDebug()<<"PBB registration failed"<<endl;
+ break;
+ case CLIENTEXIT:
+ kdDebug()<<"PBB client exited"<<endl;
+ break;
+ case CHANGEVALUE:
+ return msg->taglist;
+ break;
+ case WARNING:
+ if ( msg->taglist->data == 0 ) {
+ m_message = i18n( "The computer will sleep now." );
+ } else {
+ m_message = i18n( "The computer will sleep in %n second.",
+ "The computer will sleep in %n seconds.",
+ msg->taglist->data );
+ }
+ m_sleep = true;
+ kdDebug()<<"PBB Warning"<<endl;
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+}
+
+K_EXPORT_COMPONENT_FACTORY(kmilo_powerbook, KGenericFactory<KMilo::PowerBookMonitor>("kmilo_powerbook"))
+
diff --git a/kmilo/powerbook2/pb_monitor.h b/kmilo/powerbook2/pb_monitor.h
new file mode 100644
index 0000000..a6bf651
--- /dev/null
+++ b/kmilo/powerbook2/pb_monitor.h
@@ -0,0 +1,55 @@
+// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 2; -*-
+/*
+ This file is part of the KDE project
+
+ Copyright (c) 2003 Zack Rusin <staikos@kde.org>
+ Pretty much ripped of from :
+ George Staikos <staikos@kde.org> :)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+#ifndef _PBMONITOR_H_
+#define _PBMONITOR_H_
+
+#include "monitor.h"
+
+struct tagitem;
+
+namespace KMilo {
+
+class PowerBookMonitor : public KMilo::Monitor
+{
+public:
+ PowerBookMonitor(QObject *parent, const char *name, const QStringList&);
+ virtual ~PowerBookMonitor();
+
+ virtual bool init();
+ virtual DisplayType poll();
+ virtual int progress() const;
+ virtual QString message() const;
+
+private:
+ struct tagitem* readMessage();
+private:
+ int m_progress;
+ QString m_message;
+ bool m_sleep;
+};
+
+}
+
+#endif