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 --- kdelirc/irkick/Makefile.am | 42 +++ kdelirc/irkick/hi16-app-irkick.png | Bin 0 -> 954 bytes kdelirc/irkick/hi22-app-irkick.png | Bin 0 -> 1457 bytes kdelirc/irkick/hi32-app-irkick.png | Bin 0 -> 2421 bytes kdelirc/irkick/icons/Makefile.am | 3 + kdelirc/irkick/icons/hi16-action-irkick.png | Bin 0 -> 954 bytes kdelirc/irkick/icons/hi16-action-irkickflash.png | Bin 0 -> 892 bytes kdelirc/irkick/icons/hi16-action-irkickoff.png | Bin 0 -> 1016 bytes kdelirc/irkick/irkick.cpp | 336 +++++++++++++++++++++++ kdelirc/irkick/irkick.desktop | 116 ++++++++ kdelirc/irkick/irkick.h | 132 +++++++++ kdelirc/irkick/irkick.project | 12 + kdelirc/irkick/kdedmodule_stub.h | 34 +++ kdelirc/irkick/klircclient.cpp | 241 ++++++++++++++++ kdelirc/irkick/klircclient.h | 114 ++++++++ kdelirc/irkick/lo16-app-irkick.png | Bin 0 -> 381 bytes kdelirc/irkick/lo32-app-irkick.png | Bin 0 -> 603 bytes kdelirc/irkick/main.cpp | 39 +++ 18 files changed, 1069 insertions(+) create mode 100644 kdelirc/irkick/Makefile.am create mode 100644 kdelirc/irkick/hi16-app-irkick.png create mode 100644 kdelirc/irkick/hi22-app-irkick.png create mode 100644 kdelirc/irkick/hi32-app-irkick.png create mode 100644 kdelirc/irkick/icons/Makefile.am create mode 100644 kdelirc/irkick/icons/hi16-action-irkick.png create mode 100644 kdelirc/irkick/icons/hi16-action-irkickflash.png create mode 100644 kdelirc/irkick/icons/hi16-action-irkickoff.png create mode 100644 kdelirc/irkick/irkick.cpp create mode 100644 kdelirc/irkick/irkick.desktop create mode 100644 kdelirc/irkick/irkick.h create mode 100644 kdelirc/irkick/irkick.project create mode 100644 kdelirc/irkick/kdedmodule_stub.h create mode 100644 kdelirc/irkick/klircclient.cpp create mode 100644 kdelirc/irkick/klircclient.h create mode 100644 kdelirc/irkick/lo16-app-irkick.png create mode 100644 kdelirc/irkick/lo32-app-irkick.png create mode 100644 kdelirc/irkick/main.cpp (limited to 'kdelirc/irkick') diff --git a/kdelirc/irkick/Makefile.am b/kdelirc/irkick/Makefile.am new file mode 100644 index 0000000..5479ac1 --- /dev/null +++ b/kdelirc/irkick/Makefile.am @@ -0,0 +1,42 @@ +SUBDIRS = icons + +bin_PROGRAMS = +lib_LTLIBRARIES = +noinst_LTLIBRARIES = libirkick_common.la +kdeinit_LTLIBRARIES = irkick.la + +CLEANFILES = dummy.cpp + +libirkick_common_la_LIBADD = $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KSYCOCA) ../kdelirc/libkdelirc.la +libirkick_common_la_SOURCES = main.cpp irkick.cpp irkick.skel irkick.stub klircclient.cpp + +libirkick_common_la_LDFLAGS = $(all_libraries) + +irkick_la_LIBADD = libirkick_common.la +irkick_la_SOURCES = dummy.cpp +irkick_la_LDFLAGS = $(all_libraries) -module -avoid-version + +xdg_apps_DATA = irkick.desktop + +autostartdir = $(datadir)/autostart +autostart_DATA = irkick.desktop + +messages: + $(XGETTEXT) *.cpp -o $(podir)/irkick.pot + +dummy.cpp: + echo > dummy.cpp + +#kdedservicesdir = $(kde_servicesdir)/kded +#kdedservices_DATA = irkick.desktop +#lib_LTLIBRARIES = libkded_irkick.la +#libkded_irkick_la_SOURCES = irkick.cpp irkick.skel irkick.stub klircclient.cpp +#libkded_irkick_la_LDFLAGS = $(all_libraries) -module -avoid-version +#libkded_irkick_la_LIBADD = $(LIB_KDECORE) ../kdelirc/libkdelirc.la + +noinst_HEADERS = irkick.h klircclient.h irkick_stub.h + +INCLUDES = -I$(srcdir)/../kdelirc $(all_includes) + +KDE_ICON = AUTO +METASOURCES = AUTO diff --git a/kdelirc/irkick/hi16-app-irkick.png b/kdelirc/irkick/hi16-app-irkick.png new file mode 100644 index 0000000..65d7504 Binary files /dev/null and b/kdelirc/irkick/hi16-app-irkick.png differ diff --git a/kdelirc/irkick/hi22-app-irkick.png b/kdelirc/irkick/hi22-app-irkick.png new file mode 100644 index 0000000..fd09e86 Binary files /dev/null and b/kdelirc/irkick/hi22-app-irkick.png differ diff --git a/kdelirc/irkick/hi32-app-irkick.png b/kdelirc/irkick/hi32-app-irkick.png new file mode 100644 index 0000000..f283148 Binary files /dev/null and b/kdelirc/irkick/hi32-app-irkick.png differ diff --git a/kdelirc/irkick/icons/Makefile.am b/kdelirc/irkick/icons/Makefile.am new file mode 100644 index 0000000..307658e --- /dev/null +++ b/kdelirc/irkick/icons/Makefile.am @@ -0,0 +1,3 @@ +irkickiconsdir = $(kde_datadir)/irkick/icons +irkickicons_ICON = AUTO + diff --git a/kdelirc/irkick/icons/hi16-action-irkick.png b/kdelirc/irkick/icons/hi16-action-irkick.png new file mode 100644 index 0000000..65d7504 Binary files /dev/null and b/kdelirc/irkick/icons/hi16-action-irkick.png differ diff --git a/kdelirc/irkick/icons/hi16-action-irkickflash.png b/kdelirc/irkick/icons/hi16-action-irkickflash.png new file mode 100644 index 0000000..8c4e5d3 Binary files /dev/null and b/kdelirc/irkick/icons/hi16-action-irkickflash.png differ diff --git a/kdelirc/irkick/icons/hi16-action-irkickoff.png b/kdelirc/irkick/icons/hi16-action-irkickoff.png new file mode 100644 index 0000000..5498652 Binary files /dev/null and b/kdelirc/irkick/icons/hi16-action-irkickoff.png differ diff --git a/kdelirc/irkick/irkick.cpp b/kdelirc/irkick/irkick.cpp new file mode 100644 index 0000000..31ec93c --- /dev/null +++ b/kdelirc/irkick/irkick.cpp @@ -0,0 +1,336 @@ +/*************************************************************************** + irkick.cpp - Implementation of the main window + ------------------- + copyright : (C) 2002 by Gav Wood + email : gav@kde.org +***************************************************************************/ + +// This program is free software. + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#if !(KDE_VERSION_MINOR<=1 && KDE_VERSION_RELEASE<=5) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "profileserver.h" +#include "irkick.h" + +void IRKTrayIcon::mousePressEvent(QMouseEvent *e) +{ + KSystemTray::mousePressEvent(new QMouseEvent(QEvent::MouseButtonPress, e->pos(), e->globalPos(), e->button() == LeftButton ? RightButton : e->button(), e->state())); +} + +IRKick::IRKick(const QCString &obj) : QObject(), DCOPObject(obj), npApp(QString::null) +{ + kapp->dcopClient()->setDefaultObject(obj); + theClient = new KLircClient(); + + theTrayIcon = new IRKTrayIcon(); + if(theClient->isConnected()) + { theTrayIcon->setPixmap(SmallIcon("irkick")); + QToolTip::add(theTrayIcon, i18n("KDE Lirc Server: Ready.")); + } + else + { theTrayIcon->setPixmap(SmallIcon("irkickoff")); + QToolTip::add(theTrayIcon, i18n("KDE Lirc Server: No infra-red remote controls found.")); + QTimer::singleShot(10000, this, SLOT(checkLirc())); + } + theFlashOff = new QTimer(theTrayIcon); + connect(theFlashOff, SIGNAL(timeout()), SLOT(flashOff())); + + theResetCount = 0; + slotReloadConfiguration(); + connect(theClient, SIGNAL(connectionClosed()), this, SLOT(slotClosed())); + connect(theClient, SIGNAL(remotesRead()), this, SLOT(resetModes())); + connect(theClient, SIGNAL(commandReceived(const QString &, const QString &, int)), this, SLOT(gotMessage(const QString &, const QString &, int))); + + theTrayIcon->contextMenu()->changeTitle(0, "IRKick"); + theTrayIcon->contextMenu()->insertItem(SmallIcon( "configure" ), i18n("&Configure..."), this, SLOT(slotConfigure())); + theTrayIcon->contextMenu()->insertSeparator(); + theTrayIcon->contextMenu()->insertItem(SmallIcon( "help" ), KStdGuiItem::help().text(), (new KHelpMenu(theTrayIcon, KGlobal::instance()->aboutData()))->menu()); + theTrayIcon->actionCollection()->action("file_quit")->disconnect(SIGNAL(activated())); + connect(theTrayIcon->actionCollection()->action("file_quit"), SIGNAL(activated()), SLOT(doQuit())); + + theTrayIcon->show(); +} + +IRKick::~IRKick() +{ + delete theTrayIcon; + for(QMap::iterator i = currentModeIcons.begin(); i != currentModeIcons.end(); ++i) + if(*i) delete *i; +} + +void IRKick::slotClosed() +{ + theTrayIcon->setPixmap(SmallIcon("irkickoff")); + KPassivePopup::message("IRKick", i18n("The infrared system has severed its connection. Remote controls are no longer available."), SmallIcon("irkick"), theTrayIcon); + QTimer::singleShot(1000, this, SLOT(checkLirc())); +} + +void IRKick::checkLirc() +{ + if(!theClient->isConnected()) + if(theClient->connectToLirc()) + { KPassivePopup::message("IRKick", i18n("A connection to the infrared system has been made. Remote controls may now be available."), SmallIcon("irkick"), theTrayIcon); + theTrayIcon->setPixmap(SmallIcon("irkick")); + } + else + QTimer::singleShot(10000, this, SLOT(checkLirc())); +} + +void IRKick::flashOff() +{ + theTrayIcon->setPixmap(SmallIcon("irkick")); +} + +void IRKick::doQuit() +{ + KSimpleConfig theConfig("irkickrc"); + theConfig.setGroup("General"); + switch(KMessageBox::questionYesNoCancel(0, i18n("Should the Infrared Remote Control server start automatically when you begin KDE?"), i18n("Automatically Start?"), i18n("Start Automatically"), i18n("Do Not Start"))) + { case KMessageBox::No: theConfig.writeEntry("AutoStart", false); break; + case KMessageBox::Yes: theConfig.writeEntry("AutoStart", true); break; + case KMessageBox::Cancel: return; + } + KApplication::kApplication()->quit(); +} + +void IRKick::resetModes() +{ + if(theResetCount > 1) + KPassivePopup::message("IRKick", i18n("Resetting all modes."), SmallIcon("irkick"), theTrayIcon); + if(!theResetCount) + allModes.generateNulls(theClient->remotes()); + + QStringList remotes = theClient->remotes(); + for(QStringList::iterator i = remotes.begin(); i != remotes.end(); ++i) + { currentModes[*i] = allModes.getDefault(*i).name(); + if(theResetCount && currentModeIcons[*i]) delete currentModeIcons[*i]; + currentModeIcons[*i] = 0; + } + updateModeIcons(); + theResetCount++; +} + +void IRKick::slotReloadConfiguration() +{ + // load configuration from config file + KSimpleConfig theConfig("irkickrc"); + allActions.loadFromConfig(theConfig); + allModes.loadFromConfig(theConfig); + if(currentModes.count() && theResetCount) + resetModes(); +} + +void IRKick::slotConfigure() +{ + KApplication::startServiceByDesktopName("kcmlirc"); +} + +void IRKick::updateModeIcons() +{ + for(QMap::iterator i = currentModes.begin(); i != currentModes.end(); ++i) + { Mode mode = allModes.getMode(i.key(), i.data()); + if(mode.iconFile().isNull() || mode.iconFile().isEmpty()) + { if(currentModeIcons[i.key()]) + { delete currentModeIcons[i.key()]; + currentModeIcons[i.key()] = 0; + } + } + else + { if(!currentModeIcons[i.key()]) + { currentModeIcons[i.key()] = new IRKTrayIcon(); + currentModeIcons[i.key()]->show(); + currentModeIcons[i.key()]->contextMenu()->changeTitle(0, mode.remoteName()); + currentModeIcons[i.key()]->actionCollection()->action("file_quit")->setEnabled(false); + } + currentModeIcons[i.key()]->setPixmap(KIconLoader().loadIcon(mode.iconFile(), KIcon::Panel)); + QToolTip::add(currentModeIcons[i.key()], mode.remoteName() + ": " + mode.name() + ""); + } + } +} + +bool IRKick::getPrograms(const IRAction &action, QStringList &programs) +{ + DCOPClient *theDC = KApplication::dcopClient(); + programs.clear(); + + if(action.unique()) + { if(theDC->isApplicationRegistered(action.program().utf8())) + programs += action.program(); + } + else + { + QRegExp r = QRegExp("^" + action.program() + "-(\\d+)$"); + // find all instances... + QCStringList buf = theDC->registeredApplications(); + for(QCStringList::iterator i = buf.begin(); i != buf.end(); ++i) + { + QString program = QString::fromUtf8(*i); + if(program.contains(r)) + programs += program; + } + if(programs.size() > 1 && action.ifMulti() == IM_DONTSEND) + return false; + else if(programs.size() > 1 && action.ifMulti() == IM_SENDTOTOP) + { QValueList s = KWinModule().stackingOrder(); + // go through all the (ordered) window pids + for(QValueList::iterator i = s.fromLast(); i != s.end(); i--) + { int p = KWin::info(*i).pid; + QString id = action.program() + "-" + QString().setNum(p); + if(programs.contains(id)) + { programs.clear(); + programs += id; + break; + } + } + while(programs.size() > 1) programs.remove(programs.begin()); + } + else if(programs.size() > 1 && action.ifMulti() == IM_SENDTOBOTTOM) + { QValueList s = KWinModule().stackingOrder(); + // go through all the (ordered) window pids + for(QValueList::iterator i = s.begin(); i != s.end(); ++i) + { int p = KWin::info(*i).pid; + QString id = action.program() + "-" + QString().setNum(p); + if(programs.contains(id)) + { programs.clear(); + programs += id; + break; + } + } + while(programs.size() > 1) programs.remove(programs.begin()); + } + } + return true; +} + +void IRKick::executeAction(const IRAction &action) +{ + DCOPClient *theDC = KApplication::dcopClient(); + QStringList programs; + + if(!getPrograms(action, programs)) return; + + // if programs.size()==0 here, then the app is definately not running. + if(action.autoStart() && !programs.size()) + { QString sname = ProfileServer::profileServer()->getServiceName(action.program()); + if(!sname.isNull()) + { + KPassivePopup::message("IRKick", i18n("Starting %1...").arg(action.application()), SmallIcon("irkick"), theTrayIcon); + KApplication::startServiceByDesktopName(sname); + } + } + if(action.isJustStart()) return; + + if(!getPrograms(action, programs)) return; + + for(QStringList::iterator i = programs.begin(); i != programs.end(); ++i) + { const QString &program = *i; + if(theDC->isApplicationRegistered(program.utf8())) + { QByteArray data; QDataStream arg(data, IO_WriteOnly); + kdDebug() << "Sending data (" << program << ", " << action.object() << ", " << action.method().prototypeNR() << endl; + for(Arguments::const_iterator j = action.arguments().begin(); j != action.arguments().end(); ++j) + { kdDebug() << "Got argument..." << endl; + switch((*j).type()) + { case QVariant::Int: arg << (*j).toInt(); break; + case QVariant::CString: arg << (*j).toCString(); break; + case QVariant::StringList: arg << (*j).toStringList(); break; + case QVariant::UInt: arg << (*j).toUInt(); break; + case QVariant::Bool: arg << (*j).toBool(); break; + case QVariant::Double: arg << (*j).toDouble(); break; + default: arg << (*j).toString(); break; + } + } + theDC->send(program.utf8(), action.object().utf8(), action.method().prototypeNR().utf8(), data); + } + } +} + +void IRKick::gotMessage(const QString &theRemote, const QString &theButton, int theRepeatCounter) +{ + kdDebug() << "Got message: " << theRemote << ": " << theButton << " (" << theRepeatCounter << ")" << endl; + theTrayIcon->setPixmap(SmallIcon("irkickflash")); + theFlashOff->start(200, true); + if(!npApp.isNull()) + { + QString theApp = npApp; + npApp = QString::null; + // send notifier by DCOP to npApp/npModule/npMethod(theRemote, theButton); + QByteArray data; QDataStream arg(data, IO_WriteOnly); + arg << theRemote << theButton; + KApplication::dcopClient()->send(theApp.utf8(), npModule.utf8(), npMethod.utf8(), data); + } + else + { + if(currentModes[theRemote].isNull()) currentModes[theRemote] = ""; + IRAItList l = allActions.findByModeButton(Mode(theRemote, currentModes[theRemote]), theButton); + if(!currentModes[theRemote].isEmpty()) + l += allActions.findByModeButton(Mode(theRemote, ""), theButton); + bool doBefore = true, doAfter = false; + for(IRAItList::const_iterator i = l.begin(); i != l.end(); ++i) + if((**i).isModeChange() && !theRepeatCounter) + { // mode switch + currentModes[theRemote] = (**i).modeChange(); + Mode mode = allModes.getMode(theRemote, (**i).modeChange()); + updateModeIcons(); + doBefore = (**i).doBefore(); + doAfter = (**i).doAfter(); + break; + } + + for(int after = 0; after < 2; after++) + { if(doBefore && !after || doAfter && after) + for(IRAItList::const_iterator i = l.begin(); i != l.end(); ++i) + if(!(**i).isModeChange() && ((**i).repeat() || !theRepeatCounter)) + { executeAction(**i); + } + if(!after && doAfter) + { l = allActions.findByModeButton(Mode(theRemote, currentModes[theRemote]), theButton); + if(!currentModes[theRemote].isEmpty()) + l += allActions.findByModeButton(Mode(theRemote, ""), theButton); + } + } + } +} + +void IRKick::stealNextPress(QString app, QString module, QString method) +{ + npApp = app; + npModule = module; + npMethod = method; +} + +void IRKick::dontStealNextPress() +{ + npApp = QString::null; +} + +#include "irkick.moc" diff --git a/kdelirc/irkick/irkick.desktop b/kdelirc/irkick/irkick.desktop new file mode 100644 index 0000000..406c214 --- /dev/null +++ b/kdelirc/irkick/irkick.desktop @@ -0,0 +1,116 @@ +[Desktop Entry] +Type=Service +Name=IRKick +Name[sv]=IRkick +GenericName=KDE LIRC Server +GenericName[ar]=خادم LIRC لكدى +GenericName[bg]=Сървър LIRC +GenericName[br]=Servijer LIRC KDE +GenericName[bs]=KDE LIRC server +GenericName[ca]=Servidor LIRC de KDE +GenericName[cs]=LIRC server pro KDE +GenericName[cy]=Gweinydd LIRC KDE +GenericName[da]=KDE LIRC-server +GenericName[de]=KDE LIRC-Server +GenericName[el]=Εξυπηρετητής LIRC του KDE +GenericName[eo]=KDE LIRC-servilo +GenericName[es]=Servidor LIRC de KDE +GenericName[et]=KDE LIRC server +GenericName[eu]=KDE LIRC Zerbitzaria +GenericName[fa]=KDE LIRC کارساز +GenericName[fi]=KDE:n LIRC-palvelin +GenericName[fr]=Serveur KDE LIRC +GenericName[ga]=Freastalaí LIRC KDE +GenericName[he]=שרת ה-LIRC של KDE +GenericName[hu]=KDE LIRC szolgáltatás +GenericName[is]=KDE LIRC þjónn +GenericName[it]=Server LIRC di KDE +GenericName[ja]=KDE LIRC サーバ +GenericName[ka]=KDE LIRC სერვერი +GenericName[kk]=KDE LIRC сервері +GenericName[km]=ម៉ាស៊ីន​បម្រើ KDE LIRC +GenericName[lt]=KDE LIRC serveris +GenericName[nb]=KDE LIRC-tjener +GenericName[nds]=KDE LIRC-Server +GenericName[ne]=KDE LIRC सर्भर +GenericName[nl]=KDE LIRC-server +GenericName[nn]=KDE LIRC-tenar +GenericName[pa]=KDE LIRC ਸਰਵਰ +GenericName[pl]=Serwer LIRC dla KDE +GenericName[pt]=Servidor de LIRC do KDE +GenericName[pt_BR]=Servidor LIRC do KDE +GenericName[ru]=Сервер LIRC для KDE +GenericName[sk]=KDE LIRC server +GenericName[sl]=Strežnik KDE LIRC +GenericName[sr]=KDE-ов LIRC сервер +GenericName[sr@Latn]=KDE-ov LIRC server +GenericName[sv]=KDE:s LIRC-server +GenericName[ta]=KDE LIRC சேவகன் +GenericName[tr]=KDE LIRC Sunucusu +GenericName[uk]=Сервер LIRC для KDE +GenericName[uz]=KDE LIRC serveri +GenericName[uz@cyrillic]=KDE LIRC сервери +GenericName[zh_CN]=KDE LIRC 服务器 +GenericName[zh_TW]=KDE LIRC 伺服器 + +X-KDE-Library=irkick +X-KDE-autostart-after=panel +X-KDE-StartupNotify=false +X-DCOP-ServiceType=Unique +X-KDE-autostart-condition=irkickrc:General:AutoStart:false +Categories=Qt;KDE;Utility;X-KDE-Utilities-Peripherals; + +Exec=irkick +Icon=irkick +DocPath=irkick/index.html +Comment=KDE Linux infrared remote control server. +Comment[ar]=خادم كدى للتحكّم عن بعد بالأشعة تحت الحمراء في لينكس. +Comment[bg]=Сървър за управление на дистанционно устройство с инфрачервени лъчи +Comment[bs]=KDEov server za Linux infracrveno daljinsko upravljanje (Linux Infrared Remote Control). +Comment[ca]=Servidor de control remot per infrarojos de Linux KDE. +Comment[cs]=Server dálkového ovládání pro KDE. +Comment[cy]=Gweinydd rheolydd pell isgoch Linux KDE +Comment[da]=KDE Linux infrarød fjernbetjeningsserver. +Comment[de]=KDE Linux Infrarot Fernsteuerungsserver. +Comment[el]=Εξυπηρετητής τηλεχειριστηρίου υπερύθρων του Linux για το KDE. +Comment[es]=Servidor de control remoto por infrarrojos de KDE +Comment[et]=KDE Linuxi infrapuna kaugjuhtimise server. +Comment[eu]=KDE Linux infrasare urruneko aginte zerbitzaria. +Comment[fa]=KDE Linuxکارساز کنترل از راه دور مادون قرمز +Comment[fi]=KDE:n Linux infrapunalla toimivien kauko-ohjainten ohjauspalvelin. +Comment[fr]=Serveur de contrôle distant infrarouge sous Linux pour KDE. +Comment[ga]=Freastalaí KDE cianrialaithe infridhearg Linux +Comment[he]=שרת לשלט רחוק עבור KDE. +Comment[hi]=केडीई लिनक्स इन्फ्रारेड रिमोट नियंत्रण सर्वर. +Comment[hu]=KDE Linux szolgáltatás infravörös távirányítók kezeléséhez +Comment[is]=KDE Linux innrauða fjarstýringarstjórnborðið +Comment[it]=Server KDE per i telecomandi ad infrarossi +Comment[ja]=KDE Linux 赤外線リモートコントロールサーバ +Comment[ka]= KDE ლინუქსის ინფრაწითელი დაშორებული მართვის სერვერი +Comment[kk]=KDE Linux инфрақызыл порт арқылы басқару сервері. +Comment[km]=ម៉ាស៊ីន​បម្រើ​បញ្ជា KDE Linux infrared ពី​ចម្ងាយ ។ +Comment[lt]=KDE Linux infraraudonųjų spindulių sąsajos nuotolinio valdymo serveris +Comment[nb]=KDE Linux-tjener for infrarød fjernkontroll +Comment[nds]=KDE-Linux Infraroot-Feernbedeenkuntrullserver +Comment[ne]=KDE लिनक्स अवरक्त टाढाको नियन्त्रण सर्भर । +Comment[nl]=KDE-server voor infrarood-afstandsbediening. +Comment[nn]=KDE-tenar for infraraud fjernkontroll. +Comment[pa]=KDE ਲੀਨਕਸ ਇੰਫਰਾਰੈੱਡ ਰਿਮੋਟ ਕੰਟਰੋਲ ਸਰਵਰ ਹੈ। +Comment[pl]=Serwer obsługi pilotów dla KDE. +Comment[pt]=Servidor de comandos à distância por infravermelhos do KDE. +Comment[pt_BR]=servidor de controle infra-vermelho do Linux no KDE +Comment[ro]=Server de control al telecomenziilor în infraroşu +Comment[ru]=Сервер управления KDE через инфракрасный порт. +Comment[sk]=KDE server pre infračervené vzdialené ovládanie pre Linux. +Comment[sl]=Strežnik KDE Linux za infrardeči daljninski upravljalnik +Comment[sr]=KDE-ов сервер за контролу инфрацрвених даљинских управљача у Linux-у. +Comment[sr@Latn]=KDE-ov server za kontrolu infracrvenih daljinskih upravljača u Linux-u. +Comment[sv]=Infraröd fjärrkontrollserver +Comment[ta]=கேடிஇ லினக்ஸ் அகச்சிவப்பு கதிர் தொலைதூர கட்டுப்பாட்டு சேவகன் +Comment[tg]=Хидматрасони идоракунии дурдасти инфрасурхи KDE Linux. +Comment[tr]=KDE Linux kızılötesi uzaktan kontrol sunucusu. +Comment[uk]=Сервер дистанційного керування інфрачервоними пристроями для Linux та KDE. +Comment[uz]=Infraqizil nur bilan masofadan boshqarish serveri +Comment[uz@cyrillic]=Инфрақизил нур билан масофадан бошқариш сервери +Comment[zh_CN]=KDE Linux 红外远程控制服务器。 +Comment[zh_TW]=KDE Linux 紅外線遙控伺服器。 diff --git a/kdelirc/irkick/irkick.h b/kdelirc/irkick/irkick.h new file mode 100644 index 0000000..875d039 --- /dev/null +++ b/kdelirc/irkick/irkick.h @@ -0,0 +1,132 @@ +/*************************************************************************** + irkick.h - Interface of the main window + copyright : (C) 2002 by Gav Wood + email : gav@kde.org + +***************************************************************************/ + +// This program is free software. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef __IRKICK_H +#define __IRKICK_H + +#include + +#include +#include +#include + +#include + +#include "modes.h" +#include "iractions.h" +#include "klircclient.h" + +class QMouseEvent; + +class IRKTrayIcon: public KSystemTray +{ + void mousePressEvent(QMouseEvent *e); + +public: + KPopupMenu* contextMenu() const { return KSystemTray::contextMenu(); } + KActionCollection* actionCollection() { return KSystemTray::actionCollection(); } + + IRKTrayIcon(QWidget *parent = 0, const char *name = 0): KSystemTray(parent, name) {} +}; + +class IRKick: public QObject, public DCOPObject +{ + Q_OBJECT + K_DCOP + + QString npApp, npModule, npMethod; + QMap currentModes; + QMap currentModeIcons; + IRActions allActions; + int theResetCount; + Modes allModes; + + IRKTrayIcon *theTrayIcon; + KAboutData *aboutData; + QTimer *theFlashOff; + + void updateModeIcons(); + +protected: + KLircClient *theClient; + +k_dcop: + /** + * Query status of connection. + * + * @returns true if connected to lircd. + */ + virtual bool isConnected() { return theClient->isConnected(); } + + /** + * Query status of remote list. + * + * Make sure this is true before calling remotes()/buttons(...). + * + * @returns true if up to date. + */ + virtual bool haveFullList() { return theClient->haveFullList(); } + + /** + * Retrieve list of remote controls. + * + * @returns said list. + */ + virtual const QStringList remotes() { return theClient->remotes(); } + + /** + * Retrieve list of buttons of a praticular remote control. + * + * @returns said list. + */ + virtual const QStringList buttons(QString theRemote) { return theClient->buttons(theRemote); } + + /** + * Sends next keypress to given application by DCOP. + * + * @param The receiving application. + * @param The receiving application module. + * @param The method name. Must have two QString parameters. + */ + virtual void stealNextPress(QString app, QString module, QString method); + + /** + * Cancels the proceedings of the previous stealNextPress call, if any. + */ + virtual void dontStealNextPress(); + + /** + * Reloads configuration from file(s) + */ + virtual void reloadConfiguration() { slotReloadConfiguration(); } + +private slots: + void gotMessage(const QString &theRemote, const QString &theButton, int theRepeatCounter); + void resetModes(); + void doQuit(); + void flashOff(); + void checkLirc(); + + void slotConfigure(); + void slotReloadConfiguration(); + void slotClosed(); +private: + void executeAction(const IRAction &action); + bool getPrograms(const IRAction &action, QStringList &populous); + +public: + IRKick(const QCString &obj); + virtual ~IRKick(); +}; + +#endif diff --git a/kdelirc/irkick/irkick.project b/kdelirc/irkick/irkick.project new file mode 100644 index 0000000..b486441 --- /dev/null +++ b/kdelirc/irkick/irkick.project @@ -0,0 +1,12 @@ +# KDE Config File +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Exec=irkick -caption "%c" %i %m +Icon=irkick.png +DocPath=irkick/index.html +Comment= +Comment[de]= +Terminal=0 +Name=IRKick +Name[de]=IRKick diff --git a/kdelirc/irkick/kdedmodule_stub.h b/kdelirc/irkick/kdedmodule_stub.h new file mode 100644 index 0000000..5f248f8 --- /dev/null +++ b/kdelirc/irkick/kdedmodule_stub.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** DCOP Stub Definition created by dcopidl2cpp from kdedmodule.kidl +** +** WARNING! All changes made in this file will be lost! +** +*****************************************************************************/ + +/* This is a machine-generated file, and may be distributed under the GPL + licence, as described in kdelibs/COPYING. +*/ + +#ifndef __KDEDMODULE_STUB__ +#define __KDEDMODULE_STUB__ + +#include +#include +#include +#include +#include + + +class KDEDModule_stub : virtual public DCOPStub +{ +public: + KDEDModule_stub( const QCString& app, const QCString& id ); + KDEDModule_stub( DCOPClient* client, const QCString& app, const QCString& id ); + explicit KDEDModule_stub( const DCOPRef& ref ); +protected: + KDEDModule_stub() : DCOPStub( never_use ) {}; +}; + + +#endif diff --git a/kdelirc/irkick/klircclient.cpp b/kdelirc/irkick/klircclient.cpp new file mode 100644 index 0000000..2876079 --- /dev/null +++ b/kdelirc/irkick/klircclient.cpp @@ -0,0 +1,241 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: (C) 2002 by Malte Starostik +// Adaption : Gav Wood , (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "klircclient.h" + + +KLircClient::KLircClient(QWidget *parent, const char *name) : QObject(parent, name), theSocket(0), listIsUpToDate(false) +{ + connectToLirc(); +} + +bool KLircClient::connectToLirc() +{ + int sock = ::socket(PF_UNIX, SOCK_STREAM, 0); + if(sock == -1) return false; + + sockaddr_un addr; + addr.sun_family = AF_UNIX; + strcpy(addr.sun_path, "/dev/lircd"); + if(::connect(sock, (struct sockaddr *)(&addr), sizeof(addr)) == -1) + { ::close(sock); + // in case of mandrake... + strcpy(addr.sun_path, "/tmp/.lircd"); + if(::connect(sock, (struct sockaddr *)(&addr), sizeof(addr)) == -1) + { ::close(sock); + return false; + } + } + + theSocket = new QSocket; + theSocket->setSocket(sock); + connect(theSocket, SIGNAL(readyRead()), SLOT(slotRead())); + connect(theSocket, SIGNAL(connectionClosed()), SLOT(slotClosed())); + updateRemotes(); + return true; +} + +KLircClient::~KLircClient() +{ +// if(theSocket) + delete theSocket; +} + +void KLircClient::slotClosed() +{ + delete theSocket; + theSocket = 0; + emit connectionClosed(); +} + +const QStringList KLircClient::remotes() const +{ + QStringList remotes; + for(QMap::ConstIterator i = theRemotes.begin(); i != theRemotes.end(); ++i) + remotes.append(i.key()); + remotes.sort(); + return remotes; +} + +const QStringList KLircClient::buttons(const QString &theRemote) const +{ + return theRemotes[theRemote]; +} + +void KLircClient::slotRead() +{ + while (theSocket->bytesAvailable()) + { + QString line = readLine(); + if (line == "BEGIN") + { + // BEGIN + // + // [SUCCESS|ERROR] + // [DATA + // n + // n lines of data] + // END + line = readLine(); + if (line == "SIGHUP") + { + // Configuration changed + do line = readLine(); + while (!line.isEmpty() && line != "END"); + updateRemotes(); + return; + } + else if (line == "LIST") + { + // remote control list + if (readLine() != "SUCCESS" || readLine() != "DATA") + { + do line = readLine(); + while (!line.isEmpty() && line != "END"); + return; + } + QStringList remotes; + int count = readLine().toInt(); + for (int i = 0; i < count; ++i) + remotes.append(readLine()); + do line = readLine(); + while (!line.isEmpty() && line != "END"); + if (line.isEmpty()) + return; // abort on corrupt data + for (QStringList::ConstIterator it = remotes.begin(); it != remotes.end(); ++it) + sendCommand("LIST " + *it); + return; + } + else if (line.left(4) == "LIST") + { + // button list + if (readLine() != "SUCCESS" || readLine() != "DATA") + { + do line = readLine(); + while (!line.isEmpty() && line != "END"); + return; + } + QString remote = line.mid(5); + QStringList buttons; + int count = readLine().toInt(); + for (int i = 0; i < count; ++i) + { + // + QString btn = readLine().mid(17); + if(btn.isNull()) break; + if(btn.startsWith("'") && btn.endsWith("'")) + btn = btn.mid(1, btn.length() - 2); + buttons.append(btn); + } + theRemotes.insert(remote, buttons); + } + do line = readLine(); + while (!line.isEmpty() && line != "END"); + listIsUpToDate = true; + emit remotesRead(); + } + else + { + //