diff options
author | spiff <spiff@xbmc.org> | 2011-05-15 22:22:08 +0200 |
---|---|---|
committer | spiff <spiff@xbmc.org> | 2011-05-15 22:22:08 +0200 |
commit | 1c07455e94cd08a3565a5875cfc16be82337be01 (patch) | |
tree | 5e8ff80554b2a30d6388d0b09784557b54444b20 | |
parent | 5f8cd6f0798b60e5b31e4f57a1a147f2a51578bd (diff) |
changed: remove unused hardwareconfigure tool
-rw-r--r-- | tools/HardwareConfigure/AvailableRemotes | 1 | ||||
-rw-r--r-- | tools/HardwareConfigure/HardwareConfigure.cpp | 424 | ||||
-rw-r--r-- | tools/HardwareConfigure/HardwareConfigure.h | 81 | ||||
-rw-r--r-- | tools/HardwareConfigure/README | 12 | ||||
-rwxr-xr-x | tools/HardwareConfigure/build.sh | 1 | ||||
-rw-r--r-- | tools/HardwareConfigure/mceusb2.hardware.conf | 39 | ||||
-rw-r--r-- | tools/HardwareConfigure/mceusb2.lircd.conf | 104 |
7 files changed, 0 insertions, 662 deletions
diff --git a/tools/HardwareConfigure/AvailableRemotes b/tools/HardwareConfigure/AvailableRemotes deleted file mode 100644 index 18ff89c6ae..0000000000 --- a/tools/HardwareConfigure/AvailableRemotes +++ /dev/null @@ -1 +0,0 @@ -mceusb2 1137 2069 diff --git a/tools/HardwareConfigure/HardwareConfigure.cpp b/tools/HardwareConfigure/HardwareConfigure.cpp deleted file mode 100644 index 85b127abda..0000000000 --- a/tools/HardwareConfigure/HardwareConfigure.cpp +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include "HardwareConfigure.h" -#include <libhal-storage.h> -#include <iostream> -#include <fstream> -#include <string.h> -#include <sys/stat.h> -#include <stdio.h> -#include <stdlib.h> - -//#define HAL_HANDLEMOUNT - -bool CHalManager::NewMessage; -DBusError CHalManager::m_Error; - -/* A Removed device, It isn't possible to make a LibHalVolume from a removed device therefor - we catch the UUID from the udi on the removal */ -void CHalManager::DeviceRemoved(LibHalContext *ctx, const char *udi) -{ - NewMessage = true; - printf("HAL: Device (%s) Removed\n", udi); -// g_HalManager.RemoveDevice(udi); -} - -void CHalManager::DeviceNewCapability(LibHalContext *ctx, const char *udi, const char *capability) -{ - NewMessage = true; - printf("HAL: Device (%s) gained capability %s\n", udi, capability); - g_HalManager.ParseDevice(udi); -} - -void CHalManager::DeviceLostCapability(LibHalContext *ctx, const char *udi, const char *capability) -{ - NewMessage = true; - printf("HAL: Device (%s) lost capability %s\n", udi, capability); - g_HalManager.ParseDevice(udi); -} - -/* HAL Property modified callback. If a device is mounted. This is called. */ -void CHalManager::DevicePropertyModified(LibHalContext *ctx, const char *udi, const char *key, dbus_bool_t is_removed, dbus_bool_t is_added) -{ - NewMessage = true; - printf("HAL: Device (%s) Property %s modified\n", udi, key); - g_HalManager.ParseDevice(udi); -} - -void CHalManager::DeviceCondition(LibHalContext *ctx, const char *udi, const char *condition_name, const char *condition_details) -{ - printf("HAL: Device (%s) Condition %s | %s\n", udi, condition_name, condition_details); - NewMessage = true; - g_HalManager.ParseDevice(udi); -} - -/* HAL Device added. This is before mount. And here is the place to mount the volume in the future */ -void CHalManager::DeviceAdded(LibHalContext *ctx, const char *udi) -{ - NewMessage = true; - printf("HAL: Device (%s) Added\n", udi); - g_HalManager.ParseDevice(udi); -} - -CHalManager g_HalManager; - -/* Iterate through all devices currently on the computer. Needed mostly at startup */ -void CHalManager::GenerateGDL() -{ - if (m_Context == NULL) - return; - - char **GDL; - int i = 0; - printf("HAL: Generating global device list\n"); - GDL = libhal_get_all_devices(g_HalManager.m_Context, &i, &m_Error); - - if (!ReadAvailableRemotes()) - return; - - for (i = 0; GDL[i]; i++) - { - if (ParseDevice(GDL[i])) - break; - } - - printf("HAL: Generated global device list, found %i\n", i); -} - -CHalManager::CHalManager() -{ -} - -// Shutdown the connection and free the context -CHalManager::~CHalManager() -{ - if (m_Context != NULL) - libhal_ctx_shutdown(m_Context, NULL); - if (m_Context != NULL) - libhal_ctx_free(m_Context); - - if (m_DBusSystemConnection != NULL) - { - dbus_connection_unref(m_DBusSystemConnection); - m_DBusSystemConnection = NULL; - } - dbus_error_free(&m_Error); // Needed? -} - -// Initialize -void CHalManager::Initialize(const char *LircConfPath) -{ - printf("HAL: Starting initializing\n"); - strcpy(m_LircConfPath, LircConfPath); - - g_HalManager.m_Context = g_HalManager.InitializeHal(); - if (g_HalManager.m_Context == NULL) - { - printf("HAL: no Hal context\n"); - return; - } - - GenerateGDL(); - - printf("HAL: Sucessfully initialized\n"); -} - -// Initialize basic DBus connection -bool CHalManager::InitializeDBus() -{ - if (m_DBusSystemConnection != NULL) - return true; - - dbus_error_init (&m_Error); - if (m_DBusSystemConnection == NULL && !(m_DBusSystemConnection = dbus_bus_get (DBUS_BUS_SYSTEM, &m_Error))) - { - printf("DBus: Could not get system bus: %s\n", m_Error.message); - dbus_error_free (&m_Error); - } - - if (m_DBusSystemConnection != NULL) - return true; - else - return false; -} - -// Initialize basic HAL connection -LibHalContext *CHalManager::InitializeHal() -{ - LibHalContext *ctx; - char **devices; - int nr; - - if (!InitializeDBus()) - return NULL; - - if (!(ctx = libhal_ctx_new())) - { - printf("HAL: failed to create a HAL context!\n"); - return NULL; - } - - if (!libhal_ctx_set_dbus_connection(ctx, m_DBusSystemConnection)) - printf("HAL: Failed to connect with dbus\n"); - - libhal_ctx_set_device_added(ctx, DeviceAdded); - libhal_ctx_set_device_removed(ctx, DeviceRemoved); - libhal_ctx_set_device_new_capability(ctx, DeviceNewCapability); - libhal_ctx_set_device_lost_capability(ctx, DeviceLostCapability); - libhal_ctx_set_device_property_modified(ctx, DevicePropertyModified); - libhal_ctx_set_device_condition(ctx, DeviceCondition); - - if (!libhal_device_property_watch_all(ctx, &m_Error)) - { - printf("HAL: Failed to set property watch %s\n", m_Error.message); - dbus_error_free(&m_Error); - libhal_ctx_free(ctx); - return NULL; - } - - if (!libhal_ctx_init(ctx, &m_Error)) - { - printf("HAL: Failed to initialize hal context: %s\n", m_Error.message); - dbus_error_free(&m_Error); - libhal_ctx_free(ctx); - return NULL; - } - - /* - * Do something to ping the HAL daemon - the above functions will - * succeed even if hald is not running, so long as DBUS is. But we - * want to exit silently if hald is not running, to behave on - * pre-2.6 systems. - */ - if (!(devices = libhal_get_all_devices(ctx, &nr, &m_Error))) - { - printf("HAL: seems that Hal daemon is not running: %s\n", m_Error.message); - dbus_error_free(&m_Error); - - libhal_ctx_shutdown(ctx, NULL); - libhal_ctx_free(ctx); - return NULL; - } - - libhal_free_string_array(devices); - - return ctx; -} - -// Called from ProcessSlow to trigger the callbacks from DBus -bool CHalManager::Update() -{ - if (m_Context == NULL) - return false; - - if (!dbus_connection_read_write_dispatch(m_DBusSystemConnection, 0)) // We choose 0 that means we won't wait for a message - { - printf("DBus: System - read/write dispatch\n"); - return false; - } - if (NewMessage) - { - NewMessage = false; - return true; - } - else - return false; -} - -/* Parse newly found device and add it to our remembered devices */ -bool CHalManager::ParseDevice(const char *udi) -{ - int VendorID, ProductID; - - VendorID = libhal_device_get_property_int(m_Context, udi, "usb.vendor_id", NULL); - ProductID = libhal_device_get_property_int(m_Context, udi, "usb.product_id", NULL); - - const char *name = IsAllowedRemote(VendorID, ProductID); - - if (name != NULL) - { - printf("HAL: Found %s - %s\n", name, udi); - if (MoveConfigs(name)) - { - printf("HAL: Sucessfully created config for %s\n", name); - return true; - - RunCommand(name); - } - else - printf("HAL: Failed to create config for %s\n", name); - } - - return false; -} - -void Tokenize(const string& path, vector<string>& tokens, const string& delimiters) -{ - // Tokenize ripped from http://www.linuxselfhelp.com/HOWTO/C++Programming-HOWTO-7.html - // Skip delimiters at beginning. - string::size_type lastPos = path.find_first_not_of(delimiters, 0); - // Find first "non-delimiter". - string::size_type pos = path.find_first_of(delimiters, lastPos); - - while (string::npos != pos || string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(path.substr(lastPos, pos - lastPos)); - // Skip delimiters. Note the "not_of" - lastPos = path.find_first_not_of(delimiters, pos); - // Find next "non-delimiter" - pos = path.find_first_of(delimiters, lastPos); - } -} - -bool CHalManager::ReadAvailableRemotes() -{ - ifstream inputfile("AvailableRemotes"); - string line; - - m_AllowedRemotes.clear(); - - if (inputfile.is_open()) - { - while (!inputfile.eof()) - { - getline(inputfile, line); - if (line.size() > 0) - { - vector<string> tokens; - Tokenize(line, tokens, " "); - - if (tokens[1].size() > 0 && tokens[0].size() > 0) - { - CHalDevice dev(atoi(tokens[1].c_str()), atoi(tokens[2].c_str()), tokens[0].c_str()); - printf("AvailableRemote: (%s) (%i) (%i)\n", dev.FriendlyName, dev.VendorID, dev.ProductID); - m_AllowedRemotes.push_back(dev); - } - } - } - inputfile.close(); - - return true; - } - return false; -} - -const char *CHalManager::IsAllowedRemote(int VendorID, int ProductID) -{ - for (unsigned int i = 0; i < m_AllowedRemotes.size(); i++) - { - if (VendorID == m_AllowedRemotes[i].VendorID && ProductID == m_AllowedRemotes[i].ProductID) - return m_AllowedRemotes[i].FriendlyName; - } - return NULL; -} - -void CHalManager::RunCommand(const char *name) -{ - char script[1024]; - sprintf(script, "%s.sh", name); - if (Exists(script)) - { - popen(script, "r"); - } -} - -bool CHalManager::MoveConfigs(const char *name) -{ - char lircd[1024], hardware[1024], lircdout[1024], hardwareout[1024]; - - sprintf(lircd, "%s.lircd.conf", name); - sprintf(lircdout, "%s/lircd.conf", m_LircConfPath); - sprintf(hardware, "%s.hardware.conf", name); - sprintf(hardwareout, "%s/hardware.conf", m_LircConfPath); - - bool temp = true; - if (!Exists(lircd)) - { - temp = false; - printf("%s didn't exist\n", lircd); - } - if (!Exists(hardware)) - { - temp = false; - printf("%s didn't exist\n", hardware); - } - if (temp) - { - bool temp2 = true; - printf("Copying %s -> %s\n", lircd, lircdout); - if (!MoveConfig(lircd, lircdout)) - { - printf("Failed to move %s -> %s\n", lircd, lircdout); - temp2 = false; - } - printf("Copying %s -> %s\n", hardware, hardwareout); - if (!MoveConfig(hardware, hardwareout)) - { - printf("Failed to move %s -> %s\n", hardware, hardwareout); - temp2 = false; - } - return temp2; - } - else - return false; -} - -bool CHalManager::Exists(const char *path) -{ - struct stat stFileInfo; - - if (stat(path, &stFileInfo) == 0) - return true; - else - return false; -} - -bool CHalManager::MoveConfig(const char *InputConfig, const char *OutputConfig) -{ - string line; - - ifstream inputfile(InputConfig); - ofstream outputfile(OutputConfig, ios_base::out); - - if (inputfile.is_open() && outputfile.is_open()) - { - while (!inputfile.eof()) - { - getline(inputfile, line); - outputfile << line <<"\n"; - } - inputfile.close(); - outputfile.close(); - return true; - } - else - return false; -} - -int main(int argc, char* argv[]) -{ - if (argc == 2) - g_HalManager.Initialize(argv[1]); - else - printf("Usage: %s PathToLircConf\n", argv[0]); -} diff --git a/tools/HardwareConfigure/HardwareConfigure.h b/tools/HardwareConfigure/HardwareConfigure.h deleted file mode 100644 index 6871bda893..0000000000 --- a/tools/HardwareConfigure/HardwareConfigure.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef HARDWARECONFIGURE_H -#define HARDWARECONFIGURE_H - -/* - * Copyright (C) 2005-2008 Team XBMC - * http://www.xbmc.org - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * http://www.gnu.org/copyleft/gpl.html - * - */ - -#include <string.h> -#include <stdio.h> -#include <dbus/dbus.h> -#include <libhal.h> -#include <vector> - -using namespace std; - -class CHalDevice -{ -public: - int ProductID; - int VendorID; - char FriendlyName[1024]; - CHalDevice(int vendorID, int productID, const char *friendlyName) { ProductID = productID; VendorID = vendorID; strcpy(FriendlyName, friendlyName); } -}; - -class CHalManager -{ -public: - bool Update(); - - void Initialize(const char *LircConfPath); - CHalManager(); - ~CHalManager(); -protected: - DBusConnection *m_DBusSystemConnection; - LibHalContext *m_Context; - static DBusError m_Error; - static bool NewMessage; - - bool ParseDevice(const char *udi); -private: - char m_LircConfPath[1024]; - vector<CHalDevice> m_AllowedRemotes; - - LibHalContext *InitializeHal(); - bool InitializeDBus(); - void GenerateGDL(); - bool MoveConfigs(const char *udi); - bool MoveConfig(const char *InputConfig, const char *OutputConfig); - bool Exists(const char *path); - const char *IsAllowedRemote(int VendorID, int ProductID); - bool ReadAvailableRemotes(); - void RunCommand(const char *name); - - //Callbacks HAL - static void DeviceRemoved(LibHalContext *ctx, const char *udi); - static void DeviceNewCapability(LibHalContext *ctx, const char *udi, const char *capability); - static void DeviceLostCapability(LibHalContext *ctx, const char *udi, const char *capability); - static void DevicePropertyModified(LibHalContext *ctx, const char *udi, const char *key, dbus_bool_t is_removed, dbus_bool_t is_added); - static void DeviceCondition(LibHalContext *ctx, const char *udi, const char *condition_name, const char *condition_details); - static void DeviceAdded(LibHalContext *ctx, const char *udi); -}; - -extern CHalManager g_HalManager; -#endif diff --git a/tools/HardwareConfigure/README b/tools/HardwareConfigure/README deleted file mode 100644 index e0fd4fb377..0000000000 --- a/tools/HardwareConfigure/README +++ /dev/null @@ -1,12 +0,0 @@ -The HardwareConfigure is meant to look up known LIRC devices and copy the needed configure files for it. It will need root privelieges and it is only meant to be run at startup, no hotplugging. - -to compile it: -./build.sh - -to run it: -./HardwareConfigure PathToLIRC -PathToLIRC in ubuntu is /etc/lirc/ - -How to expand it: -Add the usb.vendor_id and usb.product_id tag in AvailableRemotes along with a FriendlyName, FriendlyName udi (ie mceusb2 would be: mceusb2 mceusb2 1137 2069), these can be found in ie gnome-device-manager. -Add friendlyname.hardware.conf and friendlyname.lircd.conf in the folder of HardwareConfigure and it will copy it if it finds the Hardware. also it's optional to add a friendlyname.sh that will be run at the time of configuration. diff --git a/tools/HardwareConfigure/build.sh b/tools/HardwareConfigure/build.sh deleted file mode 100755 index 8ead12b857..0000000000 --- a/tools/HardwareConfigure/build.sh +++ /dev/null @@ -1 +0,0 @@ -g++ HardwareConfigure.cpp -lhal-storage -ldbus-1 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -DDBUS_API_SUBJECT_TO_CHANGE -I/usr/include/hal -o HardwareConfigure diff --git a/tools/HardwareConfigure/mceusb2.hardware.conf b/tools/HardwareConfigure/mceusb2.hardware.conf deleted file mode 100644 index ba85300572..0000000000 --- a/tools/HardwareConfigure/mceusb2.hardware.conf +++ /dev/null @@ -1,39 +0,0 @@ -# /etc/lirc/hardware.conf -# -#Chosen Remote Control -REMOTE="Windows Media Center Remotes (new version Philips et al.)" -REMOTE_MODULES="lirc_dev lirc_mceusb2" -REMOTE_DRIVER="" -REMOTE_DEVICE="/dev/lirc0" -REMOTE_LIRCD_CONF="mceusb/lircd.conf.mceusb" -REMOTE_LIRCD_ARGS="" - -#Chosen IR Transmitter -TRANSMITTER="None" -TRANSMITTER_MODULES="" -TRANSMITTER_DRIVER="" -TRANSMITTER_DEVICE="" -TRANSMITTER_LIRCD_CONF="" -TRANSMITTER_LIRCD_ARGS="" - -#Enable lircd -START_LIRCD="true" - -#Don't start lircmd even if there seems to be a good config file -#START_LIRCMD="false" - -#Try to load appropriate kernel modules -LOAD_MODULES="true" - -# Default configuration files for your hardware if any -LIRCMD_CONF="" - -#Forcing noninteractive reconfiguration -#If lirc is to be reconfigured by an external application -#that doesn't have a debconf frontend available, the noninteractive -#frontend can be invoked and set to parse REMOTE and TRANSMITTER -#It will then populate all other variables without any user input -#If you would like to configure lirc via standard methods, be sure -#to leave this set to "false" -FORCE_NONINTERACTIVE_RECONFIGURATION="false" -START_LIRCMD="" diff --git a/tools/HardwareConfigure/mceusb2.lircd.conf b/tools/HardwareConfigure/mceusb2.lircd.conf deleted file mode 100644 index 041c2cbaf1..0000000000 --- a/tools/HardwareConfigure/mceusb2.lircd.conf +++ /dev/null @@ -1,104 +0,0 @@ -# -# RC-6 config file -# -# source: http://home.hccnet.nl/m.majoor/projects__remote_control.htm -# http://home.hccnet.nl/m.majoor/pronto.pdf -# -# used by: Philips -# -######### -# -# Philips Media Center Edition remote control -# For use with the USB MCE ir receiver -# -# Dan Conti dconti|acm.wwu.edu -# -# Updated with codes for MCE 2005 Remote additional buttons -# *, #, Teletext, Red, Green, Yellow & Blue Buttons -# Note: TV power button transmits no code until programmed. -# Updated 12th September 2005 -# Graham Auld - mce|graham.auld.me.uk -# -# Radio, Print, RecTV are only available on the HP Media Center remote control -# - -begin remote - - name mceusb - bits 16 - flags RC6|CONST_LENGTH - eps 30 - aeps 100 - - header 2667 889 - one 444 444 - zero 444 444 - pre_data_bits 21 - pre_data 0x37FF0 - gap 105000 - toggle_bit 22 - rc6_mask 0x100000000 - - - begin codes - - Blue 0x00007ba1 - Yellow 0x00007ba2 - Green 0x00007ba3 - Red 0x00007ba4 - Teletext 0x00007ba5 - -# starts at af - Radio 0x00007baf - Print 0x00007bb1 - Videos 0x00007bb5 - Pictures 0x00007bb6 - RecTV 0x00007bb7 - Music 0x00007bb8 - TV 0x00007bb9 -# no ba - d8 - - Guide 0x00007bd9 - LiveTV 0x00007bda - DVD 0x00007bdb - Back 0x00007bdc - OK 0x00007bdd - Right 0x00007bde - Left 0x00007bdf - Down 0x00007be0 - Up 0x00007be1 - - Star 0x00007be2 - Hash 0x00007be3 - - Replay 0x00007be4 - Skip 0x00007be5 - Stop 0x00007be6 - Pause 0x00007be7 - Record 0x00007be8 - Play 0x00007be9 - Rewind 0x00007bea - Forward 0x00007beb - ChanDown 0x00007bec - ChanUp 0x00007bed - VolDown 0x00007bee - VolUp 0x00007bef - More 0x00007bf0 - Mute 0x00007bf1 - Home 0x00007bf2 - Power 0x00007bf3 - Enter 0x00007bf4 - Clear 0x00007bf5 - Nine 0x00007bf6 - Eight 0x00007bf7 - Seven 0x00007bf8 - Six 0x00007bf9 - Five 0x00007bfa - Four 0x00007bfb - Three 0x00007bfc - Two 0x00007bfd - One 0x00007bfe - Zero 0x00007bff - end codes - -end remote |