From 2bda8f7717adf28da4af0d34fb82f63d2868c31d Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kmilo/powerbook/Makefile.am | 34 +++++++++ kmilo/powerbook/kmilo_powerbook.desktop | 105 ++++++++++++++++++++++++++ kmilo/powerbook/pb_monitor.cpp | 127 ++++++++++++++++++++++++++++++++ kmilo/powerbook/pb_monitor.h | 42 +++++++++++ 4 files changed, 308 insertions(+) create mode 100644 kmilo/powerbook/Makefile.am create mode 100644 kmilo/powerbook/kmilo_powerbook.desktop create mode 100644 kmilo/powerbook/pb_monitor.cpp create mode 100644 kmilo/powerbook/pb_monitor.h (limited to 'kmilo/powerbook') diff --git a/kmilo/powerbook/Makefile.am b/kmilo/powerbook/Makefile.am new file mode 100644 index 0000000..5c3f467 --- /dev/null +++ b/kmilo/powerbook/Makefile.am @@ -0,0 +1,34 @@ +# This file is part of the KDE project +# Copyright (C) 2003 George Staikos + +# 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/powerbook/kmilo_powerbook.desktop b/kmilo/powerbook/kmilo_powerbook.desktop new file mode 100644 index 0000000..842d276 --- /dev/null +++ b/kmilo/powerbook/kmilo_powerbook.desktop @@ -0,0 +1,105 @@ +[Desktop Entry] +Type=Service +ServiceTypes=KMilo Plugin +X-KDE-ModuleType=Plugin +Name=Apple (R) PowerBook (R) Plugin +Name[ar]=ملحق Apple (R) PowerBook (R)ة +Name[br]=Lugent Apple (R) PowerBook (R) +Name[bs]=Apple (R) PowerBook (R) dodatak +Name[ca]=Connector Apple (R) PowerBook (R) +Name[cs]=Apple (R) PowerBook (R) modul +Name[cy]=Ategyn Apple (R) PowerBook (R) +Name[da]=Apple (R) PowerBook (R) plugin +Name[el]=Πρόσθετο Apple (R) PowerBook (R) +Name[es]=Extensión para Apple ® PowerBook ® +Name[et]=Apple (R) PowerBook (R) plugin +Name[eu]=Apple (R) PowerBook (R) Plugina +Name[fa]=Apple (R) PowerBook (R) وصلۀ +Name[fi]=Apple (R) PowerBook (R) -liitännäinen +Name[fr]=Module externe Apple (R) PowerBook (R) +Name[ga]=Breiseán Apple® PowerBook® +Name[he]=תוסף למחשבי Apple (R) PowerBook (R) +Name[hi]=एप्पल (R) पावरबुक (R) प्लगइन +Name[hu]=Apple (R) PowerBook (R) bővítőmodul +Name[is]=Apple (R) PowerBook (R) íforrit +Name[it]=Plugin per Apple (R) PowerBook (R) +Name[ja]=Apple (R) PowerBook (R) プラグイン +Name[ka]=Apple (R) PowerBook (R) მოდული +Name[kk]=Apple (R) PowerBook (R) модулі +Name[km]=កម្មវិធី​ជំនួយ Apple (R) PowerBook (R) +Name[lt]=Apple (R) PowerBook (R) priedas +Name[mk]=Приклучок за Apple (R) PowerBook (R) +Name[nb]=Programtillegg for Apple (R) PowerBook (R) +Name[nds]=Apple(R) PowerBook(R)-Moduul +Name[ne]=एप्पल (R) पावरबुक (R) प्लगइन +Name[nl]=Apple (R) PowerBook (R)-Plugin +Name[nn]=Tilleggsprogram for Apple ® PowerBook ® +Name[pa]=Apple (R) PowerBook (R) ਪਲੱਗਿੰਨ +Name[pl]=Wtyczka Apple (R) PowerBook (R) +Name[pt]='Plugin' para Apple (R) PowerBook (R) +Name[pt_BR]=Plug-in para Apple (R) PowerBook (R) +Name[ro]=Modul Apple (R) PowerBook (R) +Name[ru]=Модуль Apple® PowerBook® +Name[sk]=Modul pre Apple (R) PowerBook (R) +Name[sl]=Vstavek za Apple (R) PowerBook (R) +Name[sr]=Прикључак за Apple-ов PowerBook +Name[sr@Latn]=Priključak za Apple-ov PowerBook +Name[sv]=Apple ® PowerBook ®-insticksprogram +Name[ta]=ஆப்பிள் (R) பவர்புக் (R) சொருகுப்பொருள் +Name[tg]=Модули Apple (R) PowerBook (R) +Name[tr]=Apple (R) PowerBook (R) Eklentisi +Name[uk]=Втулок Apple (R) PowerBook (R) +Name[uz]=Apple (R) PowerBook (R) plagini +Name[uz@cyrillic]=Apple (R) PowerBook (R) плагини +Name[zh_CN]=Apple(R) PowerBook(R) 插件 +Name[zh_TW]=Apple (R) PowerBook (R) 外掛程式 +Comment=This plugin enables support for special keys on Apple (R) PowerBook (R) laptops via pbbuttonsd. +Comment[ar]=تمكّن الدعم لمفاتيح حاسوب Apple (R) PowerBook (R) المحمول الخاصة عن طريق pbbuttonsd. +Comment[bg]=Тази приставка позволява поддръжката на специалните клавиши на Apple (R) PowerBook (R) laptops. +Comment[bs]=Ovaj dodatak (plugin) omogućuje podršku za posebne tipke na Apple (R) PowerBook (R) laptopima koristeći pbbuttonsd. +Comment[ca]=Aquest connector activa el funcionament per a tecles especials dels Apple (R) PowerBooks (R) via pbbuttonsd. +Comment[cs]=Tento modul umožňuje používat zvláštní klávesy notebooků Apple (R) PowerBook (R) přes pbbuttonsd. +Comment[cy]=Galluoga'r ategyn yma gynhaliaeth ar gyfer bysyll arbennig ar luniaduron Apple (R) PowerBook (R) drwy pbbuttonsd. +Comment[da]=Dette plugin aktivere støtte for specielle taster på Apple (R) PowerBook (R) bærbare via pbbuttonsd. +Comment[de]=Dieses Plugin schaltet die Unterstützung für Sondertasten des Apple (R) Powerbooks (R) via pbbuttonsd ein. +Comment[el]=Αυτό το πρόσθετο ενεργοποιεί την υποστήριξη για ειδικά πλήκτρα στα φορητά Apple (R) PowerBook (R) μέσω του pbbuttonsd. +Comment[es]=Esta extensión activa el soporte de las teclas especiales en los portátiles Apple ® PowerBook ® mediante pbbuttonsd. +Comment[et]=See plugin võimaldab pbbuttonsd vahendusel kasutada eriklahve Apple (R) PowerBook (R) sülearvutil. +Comment[eu]=Plugin honek tekla berezientzako euskarria gaitzen du Apple (R) PowerBook (R) magalekoetan pbbuttonsd bitartez. +Comment[fa]=این وصله، برای کلیدهای ویژۀ روی رایانه‌های کیفی Apple (R) PowerBook (R) via pbbuttonsd پشتیبانی را فعال می‌کند. +Comment[fi]=Tänmä liitännäinen mahdollistaa tuen Apple (R) PowerBook (R) kannettavien erikoisnäppäimille pbbuttonsd-ohjelman kautta. +Comment[fr]=Ce module active la gestion des touches spéciales des Apple (R)PowerBook (R) 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 (R) PowerBook (R) +Comment[hi]=यह प्लगइन एपल (R) पावर-बुक (R) लैपटॉप पर pbbuttonsd के द्वारा विशिष्ट कुंजी समर्थन सक्षम करता है +Comment[hu]=Ez a bővítőmodul lehetővé teszi az extra billentyűk használatát Apple (R) PowerBook (R) noteszgépeken (a pbbuttonsd szolgáltatáson keresztül). +Comment[is]=Þetta íforrit gerir þér kleyft að nota sérhnappana á Apple (R) PowerBook (R) með pbbuttonsd þjóninum. +Comment[it]=Questo plugin abilita il supporto per i tasti speciali sui portatili Apple (R) PowerBook (R) tramite pbbuttonsd. +Comment[ja]=このプラグインは pbbuttonsd を通して Apple (R) PowerBook (R) ラップトップの特殊キーをサポートします +Comment[ka]=.ეს მოდული რთავს Apple (R) PowerBook (R) ლეპტოპის სპეციალური კლავიშების მხარდაჭერას pbbuttonsd-ის მეშვეობით. +Comment[kk]=Бұл модуль Apple (R) PowerBook (R) ноутбуктерінде pbbuttonsd арқылы арнаулы пернелерді қолдау үшін. +Comment[km]=កម្មវិធី​ជំនួយនេះបើក​ការគាំទ្រ​សម្រាប់​គ្រាប់ចុច​ពិសេសនៅ​លើកុំព្យូទ័រ​យួរដៃ Apple (R) PowerBook (R) តាម​រយៈ pbbuttonsd ។ +Comment[lt]=Šis priedas įgalina specialiųjų raktų Apple (R) PowerBook (R) nešiojamuose kompiuteriuose palaikymą per pbbuttonsd. +Comment[mk]=Овој приклучок дава поддршка за специјалните копчиња на лаптопите Apple (R) PowerBook (R) преку pbbuttonsd. +Comment[nb]=Dette programtilleggmet muliggjør støtte for spesielle taster på Apple (R) PowerBook (R) bærbare maskiner via pbbuttonsd. +Comment[nds]=Dit Moduul maakt de Sünnertasten-Ünnerstütten för PowerBook(R)-Klappreekners vun Apple(R) via pbbuttonsd an. +Comment[ne]=यो प्लगइनले pbbuttonsd द्वारा एप्पल (R) पावरबुक (R) ल्यापटपका विशेष कुञ्जीका लागि समर्थन सक्षम पार्दछ । +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 (R) PowerBook (R) za pomocą pbbuttonsd. +Comment[pt]=Este 'plugin' activa o suporte para as teclas especiais nos portáteis Apple (R) PowerBook (R) através do 'pbbuttonsd'. +Comment[pt_BR]=Este plug-in habilita suporte para teclas especiais nos Apple (R) PowerBooks (R) via pbbuttonsd. +Comment[ro]=Acest modul activează suportul pentru tastele speciale din laptop-urile Apple (R) PowerBook (R), utilizînd "pbbuttonsd". +Comment[ru]=Этот модуль поддерживает специальные клавиши на ноутбуках Apple® PowerBook® через 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 (R) PowerBook (R) preko pbbuttonsd. +Comment[sr]=Овај прикључак омогућава подршку за специјалне тастере на Apple-овим PowerBook лаптопима преко pbbuttonsd. +Comment[sr@Latn]=Ovaj priključak omogućava podršku za specijalne tastere na Apple-ovim PowerBook laptopima preko pbbuttonsd. +Comment[sv]=Det här insticksprogrammet aktiverar stöd för speciella tangenter för Apple ® PowerBook ® via pbbuttonsd. +Comment[ta]=ஆப்பிள் (R) பவர்புக் (R) மடிக் கணினி மூலமாக பிபிபட்டன்எஸ்டி போன்றவைக்கு இந்த சொருகு பொருள் ஆதரிக்கிறது. +Comment[tg]=Ин модул пуштибонии калидҳои махсусро дар компютери дастии Apple (R) PowerBook (R) ба воситаи pbbuttonsd дармегиронад. +Comment[tr]=Bu plugin pbbuttonsd aracılığı ile Apple(R) PowerBook(R) dizüstüler için özel tuş desteğini açar. +Comment[uk]=Цей втулок дозволяє користуватися спеціальними клавішами на лептопах Apple (R) PowerBook (R) за допомогою pbbuttonsd. +Comment[zh_CN]=此插件启用 Apple(R) PowerBook(R) 便携电脑上的特殊按键。 +Comment[zh_TW]=這個外掛程式透過 pbbuttonsd 開啟 Apple(R) PowerBook(R) 筆記型電腦的特殊鍵支援。 +X-KDE-Library=kmilo_powerbook diff --git a/kmilo/powerbook/pb_monitor.cpp b/kmilo/powerbook/pb_monitor.cpp new file mode 100644 index 0000000..6279854 --- /dev/null +++ b/kmilo/powerbook/pb_monitor.cpp @@ -0,0 +1,127 @@ +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos + + 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 +#include + +#include + +extern "C" { +#include +} + +namespace KMilo { + +PowerBookMonitor::PowerBookMonitor(QObject *parent, const char *name, const QStringList& args) +: Monitor(parent, name, args) { + _serverPort = -1; + _clientPort = -1; + _progress = 0; +} + + +PowerBookMonitor::~PowerBookMonitor() { +struct pbb_message msg; + if (_serverPort >= 0) { + msg.code = UNREGISTERCLIENT; + msg.value = _clientPort; + put_message(_serverPort, &msg); + } + + if (_clientPort >= 0) { + remove_msgport(_clientPort); + } +} + + +bool PowerBookMonitor::init() { + _serverPort = find_msgport(SERVERPORTKEY); + if (_serverPort < 0) { + return false; + } + + _clientPort = create_msgport(getpid()); + if (_clientPort < 0) { + _serverPort = -1; + return false; + } + + // Register + struct pbb_message msg; + msg.code = REGISTERCLIENT; + msg.value = _clientPort; + if (put_message(_serverPort, &msg) < 0) { + remove_msgport(_clientPort); + _clientPort = -1; + _serverPort = -1; + return false; + } + +return true; +} + + +Monitor::DisplayType PowerBookMonitor::poll() { +Monitor::DisplayType rc = None; +struct pbb_message msg; + + if (_serverPort < 0 || _clientPort < 0) + return Error; + + // Drain the queue, send the last message + while (0 == get_message(_clientPort, 0, &msg)) { + switch (msg.code) { + case DISPLAYVOLUME: + rc = Monitor::Volume; + _progress = msg.value; + break; + case DISPLAYMUTE: + rc = Monitor::Mute; + _progress = msg.value; + break; + case DISPLAYBRIGHTNESS: + rc = Monitor::Brightness; + _progress = msg.value*100/15; + break; + case REGFAILED: + case CLIENTEXIT: + rc = Monitor::Error; + break; + default: + break; + } + } + +return rc; +} + + +int PowerBookMonitor::progress() const { + return _progress; +} + +}; + +K_EXPORT_COMPONENT_FACTORY(kmilo_powerbook, KGenericFactory("kmilo_powerbook")) + diff --git a/kmilo/powerbook/pb_monitor.h b/kmilo/powerbook/pb_monitor.h new file mode 100644 index 0000000..6d2736d --- /dev/null +++ b/kmilo/powerbook/pb_monitor.h @@ -0,0 +1,42 @@ +/* + This file is part of the KDE project + + Copyright (c) 2003 George Staikos + + 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" + +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; + + private: + int _clientPort; + int _serverPort; + int _progress; +}; + +#endif -- cgit v1.2.1