From 0721b14d667c971f729a68bb7e8d04f9f7a89d1b Mon Sep 17 00:00:00 2001 From: Bengt Martensson Date: Fri, 5 Jan 2024 11:47:43 +0100 Subject: [PATCH] Remove GlobalCache IR database (old) importer. Resolves #516 . --- .../harctoolbox/irscrutinizer/GuiMain.form | 201 --------------- .../harctoolbox/irscrutinizer/GuiMain.java | 234 ------------------ .../harctoolbox/irscrutinizer/HelpTexts.java | 7 - .../importer/GlobalCacheIrDatabase.java | 187 -------------- src/main/xdocs/IrScrutinizer.xml | 20 +- 5 files changed, 4 insertions(+), 645 deletions(-) delete mode 100644 src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java diff --git a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form index 4e17d97c..9c60c67c 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form +++ b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.form @@ -3421,207 +3421,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java index b1b747ee..7bb907a9 100755 --- a/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/GuiMain.java @@ -181,7 +181,6 @@ private static int csvNumberbaseIndex2numberbase(int index) { private Component currentPane; private AboutPopup aboutBox; - private GlobalCacheIrDatabase globalCacheIrDatabase; private ControlTowerIrDatabase controlTowerIrDatabase; private Map controlTowerCodesetTable; private RemoteLocatorImporter remoteLocatorImporter; @@ -2303,18 +2302,6 @@ private void initComponents() { openLastFileButton1 = new javax.swing.JButton(); importPanel = new javax.swing.JPanel(); importTabbedPane = new javax.swing.JTabbedPane(); - gcdbPanel = new javax.swing.JPanel(); - gcdbImportButton = new javax.swing.JButton(); - globalCacheDBBrowseButton = new javax.swing.JButton(); - apiKeyButton = new javax.swing.JButton(); - gcdbManufacturerComboBox = new javax.swing.JComboBox<>(); - gcdbDeviceTypeComboBox = new javax.swing.JComboBox<>(); - gcdbCodeSetComboBox = new javax.swing.JComboBox<>(); - jLabel44 = new javax.swing.JLabel(); - jLabel47 = new javax.swing.JLabel(); - jLabel48 = new javax.swing.JLabel(); - gcdbTreeImporter = new org.harctoolbox.irscrutinizer.importer.TreeImporter(this.guiUtils); - importGlobalCacheHelpButton = new javax.swing.JButton(); controlTowerPanel = new javax.swing.JPanel(); controlTowerImportButton = new javax.swing.JButton(); controlTowerBrowseButton = new javax.swing.JButton(); @@ -4057,131 +4044,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { topLevelTabbedPane.addTab("Render", new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/gear.png")), generatePanel); // NOI18N - gcdbImportButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/reload.png"))); // NOI18N - gcdbImportButton.setText("Load"); - gcdbImportButton.setEnabled(false); - gcdbImportButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - gcdbImportButtonActionPerformed(evt); - } - }); - - globalCacheDBBrowseButton.setText("Web site"); - globalCacheDBBrowseButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - globalCacheDBBrowseButtonActionPerformed(evt); - } - }); - - apiKeyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/apps/password.png"))); // NOI18N - apiKeyButton.setText("ApiKey..."); - apiKeyButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - apiKeyButtonActionPerformed(evt); - } - }); - - gcdbManufacturerComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Select me to load" })); - gcdbManufacturerComboBox.setToolTipText(properties.getGlobalCacheApiKey().isEmpty() ? "API-Key not entered" : null); - gcdbManufacturerComboBox.setEnabled(!properties.getGlobalCacheApiKey().isEmpty()); - gcdbManufacturerComboBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - gcdbManufacturerComboBoxActionPerformed(evt); - } - }); - - gcdbDeviceTypeComboBox.setEnabled(false); - gcdbDeviceTypeComboBox.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - gcdbDeviceTypeComboBoxActionPerformed(evt); - } - }); - - gcdbCodeSetComboBox.setEnabled(false); - - jLabel44.setText("Manufacturer"); - - jLabel47.setText("Device Type"); - - jLabel48.setText("Setup Code"); - - importGlobalCacheHelpButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/help.png"))); // NOI18N - importGlobalCacheHelpButton.setText("Help"); - importGlobalCacheHelpButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - importGlobalCacheHelpButtonActionPerformed(evt); - } - }); - - javax.swing.GroupLayout gcdbPanelLayout = new javax.swing.GroupLayout(gcdbPanel); - gcdbPanel.setLayout(gcdbPanelLayout); - gcdbPanelLayout.setHorizontalGroup( - gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jLabel44) - .addComponent(gcdbManufacturerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(gcdbDeviceTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(jLabel47)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addComponent(gcdbCodeSetComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(gcdbImportButton) - .addGap(169, 169, 169)) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addComponent(jLabel48) - .addGap(461, 461, 461)))) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addComponent(gcdbTreeImporter, javax.swing.GroupLayout.DEFAULT_SIZE, 723, Short.MAX_VALUE) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 130, Short.MAX_VALUE) - .addComponent(importGlobalCacheHelpButton) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, gcdbPanelLayout.createSequentialGroup() - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(apiKeyButton, javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(globalCacheDBBrowseButton, javax.swing.GroupLayout.Alignment.TRAILING)))) - .addContainerGap()) - ); - - gcdbPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {apiKeyButton, globalCacheDBBrowseButton, importGlobalCacheHelpButton}); - - gcdbPanelLayout.setVerticalGroup( - gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addContainerGap() - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel44) - .addComponent(jLabel47) - .addComponent(jLabel48)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(gcdbManufacturerComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(gcdbDeviceTypeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(gcdbCodeSetComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(gcdbImportButton)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(gcdbPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(gcdbTreeImporter, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE) - .addGroup(gcdbPanelLayout.createSequentialGroup() - .addGap(12, 12, 12) - .addComponent(apiKeyButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(globalCacheDBBrowseButton) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 153, Short.MAX_VALUE) - .addComponent(importGlobalCacheHelpButton) - .addContainerGap()))) - ); - - importTabbedPane.addTab("GlobalCache DB (old)", gcdbPanel); - controlTowerImportButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/Crystal-Clear/22x22/actions/reload.png"))); // NOI18N controlTowerImportButton.setText("Load"); controlTowerImportButton.setEnabled(false); @@ -7681,77 +7543,6 @@ private void importXcfMenuItemActionPerformed(java.awt.event.ActionEvent evt) {/ importRemoteByFileSelector(xcfImporter, true); }//GEN-LAST:event_importXcfMenuItemActionPerformed - private void globalCacheDBBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalCacheDBBrowseButtonActionPerformed - try { - guiUtils.browse(new URI("http", GlobalCacheIrDatabase.globalCacheIrDatabaseHost, null)); - } catch (URISyntaxException ex) { - guiUtils.error(ex); - } - }//GEN-LAST:event_globalCacheDBBrowseButtonActionPerformed - - private void gcdbManufacturerComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gcdbManufacturerComboBoxActionPerformed - BusyWindow busyWindow = BusyWindow.mkBusyWindow(this); - try { - if (globalCacheIrDatabase == null) { - globalCacheIrDatabase = new GlobalCacheIrDatabase(properties.getGlobalCacheApiKey(), properties.getVerbose()); - Collection manufacturers = globalCacheIrDatabase.getManufacturers(); - String[] arr = manufacturers.toArray(new String[manufacturers.size()]); - Arrays.sort(arr); - DefaultComboBoxModel dcbm = new DefaultComboBoxModel(arr); - gcdbManufacturerComboBox.setModel(dcbm); - gcdbManufacturerComboBoxActionPerformed(null); - } else { - String manufacturer = (String) gcdbManufacturerComboBox.getSelectedItem(); - Collection devTypes = globalCacheIrDatabase.getDeviceTypes(manufacturer); - String[] arr = devTypes.toArray(new String[devTypes.size()]); - Arrays.sort(arr); - DefaultComboBoxModel dcbm = new DefaultComboBoxModel(arr); - gcdbDeviceTypeComboBox.setModel(dcbm); - gcdbDeviceTypeComboBoxActionPerformed(null); - gcdbDeviceTypeComboBox.setEnabled(true); - } - gcdbTreeImporter.clear(); - } catch (IOException ex) { - guiUtils.error(ex); - } finally { - busyWindow.unBusy(); - } - }//GEN-LAST:event_gcdbManufacturerComboBoxActionPerformed - - private void gcdbDeviceTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gcdbDeviceTypeComboBoxActionPerformed - BusyWindow busyWindow = BusyWindow.mkBusyWindow(this); - try { - String manufacturer = (String) gcdbManufacturerComboBox.getSelectedItem(); - String deviceType = (String) gcdbDeviceTypeComboBox.getSelectedItem(); - Collection codeSets = globalCacheIrDatabase.getCodeset(manufacturer, deviceType); - String[] arr = codeSets.toArray(new String[codeSets.size()]); - Arrays.sort(arr); - DefaultComboBoxModel dcbm = new DefaultComboBoxModel(arr); - gcdbCodeSetComboBox.setModel(dcbm); - gcdbCodeSetComboBox.setEnabled(true); - gcdbImportButton.setEnabled(true); - } catch (IOException ex) { - guiUtils.error(ex); - } finally { - busyWindow.unBusy(); - } - }//GEN-LAST:event_gcdbDeviceTypeComboBoxActionPerformed - - private void gcdbImportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gcdbImportButtonActionPerformed - BusyWindow busyWindow = BusyWindow.mkBusyWindow(this); - try { - String manufacturer = (String) gcdbManufacturerComboBox.getSelectedItem(); - String deviceType = (String) gcdbDeviceTypeComboBox.getSelectedItem(); - String codeSet = (String) gcdbCodeSetComboBox.getSelectedItem(); - globalCacheIrDatabase.load(manufacturer, deviceType, codeSet); - gcdbTreeImporter.setRemoteSet(globalCacheIrDatabase.getRemoteSet(), "GCDB (old)"); - } catch (IOException | InvalidArgumentException ex) { - guiUtils.error(ex); - } finally { - busyWindow.unBusy(); - } - }//GEN-LAST:event_gcdbImportButtonActionPerformed - private void remoteLocatorBrowseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remoteLocatorBrowseButtonActionPerformed guiUtils.browse(RemoteLocatorImporter.getHomeUri()); }//GEN-LAST:event_remoteLocatorBrowseButtonActionPerformed @@ -8362,10 +8153,6 @@ private void generateHelpButtonActionPerformed(java.awt.event.ActionEvent evt) { HelpPopup.newHelpPopup(this, HelpTexts.generateHelp); }//GEN-LAST:event_generateHelpButtonActionPerformed - private void importGlobalCacheHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importGlobalCacheHelpButtonActionPerformed - HelpPopup.newHelpPopup(this, HelpTexts.importGlobalCacheHelp); - }//GEN-LAST:event_importGlobalCacheHelpButtonActionPerformed - private void remoteLocatorHelpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remoteLocatorHelpButtonActionPerformed HelpPopup.newHelpPopup(this, HelpTexts.remoteLocatorHelp); }//GEN-LAST:event_remoteLocatorHelpButtonActionPerformed @@ -8940,15 +8727,6 @@ private void importControlTowerHelpButtonActionPerformed(java.awt.event.ActionEv HelpPopup.newHelpPopup(this, HelpTexts.importControlTowerHelp); }//GEN-LAST:event_importControlTowerHelpButtonActionPerformed - private void apiKeyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_apiKeyButtonActionPerformed - String apiKey = guiUtils.getInput("Enter GlobalCache API key", "API key entry", properties.getGlobalCacheApiKey()); - if (apiKey != null && !apiKey.trim().isEmpty()) { - properties.setGlobalCacheApiKey(apiKey.trim()); - gcdbManufacturerComboBox.setEnabled(true); - gcdbManufacturerComboBox.setToolTipText(null); - } - }//GEN-LAST:event_apiKeyButtonActionPerformed - private void topLevelTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_topLevelTabbedPaneStateChanged // Must make sure this is not effective during early initComponents(). if (hardwareManager != null) { @@ -9528,7 +9306,6 @@ private void tableKeyReleased(JTable table, KeyEvent evt) { private javax.swing.ButtonGroup analyzerBaseButtonGroup; private javax.swing.JMenu analyzerBasisMenu; private javax.swing.JTextField analyzerTextField; - private javax.swing.JButton apiKeyButton; private javax.swing.JPanel audioPanel; private javax.swing.JCheckBox autoOpenExportsCheckBox; private javax.swing.JCheckBox automaticExportFilenamesCheckBox; @@ -9654,12 +9431,6 @@ private void tableKeyReleased(JTable table, KeyEvent evt) { private javax.swing.JMenu fileMenu; private javax.swing.JLabel frequencyLabel; private javax.swing.JMenuItem frequencyToleranceMenuItem; - private javax.swing.JComboBox gcdbCodeSetComboBox; - private javax.swing.JComboBox gcdbDeviceTypeComboBox; - private javax.swing.JButton gcdbImportButton; - private javax.swing.JComboBox gcdbManufacturerComboBox; - private javax.swing.JPanel gcdbPanel; - private org.harctoolbox.irscrutinizer.importer.TreeImporter gcdbTreeImporter; private javax.swing.JButton generateButton; private javax.swing.JCheckBoxMenuItem generateCcfCheckBoxMenuItem; private javax.swing.JButton generateExportButton; @@ -9678,7 +9449,6 @@ private void tableKeyReleased(JTable table, KeyEvent evt) { private javax.swing.JPanel girsClientPanel; private org.harctoolbox.guicomponents.GirsClientBean girsTcpSerialComboBean; private javax.swing.JMenuItem gitMenuItem; - private javax.swing.JButton globalCacheDBBrowseButton; private org.harctoolbox.guicomponents.GlobalCacheBean globalCacheIrSenderSelector; private javax.swing.JPanel globalCachePanel; private javax.swing.JMenuItem globalCacheTimeoutMenuItem; @@ -9709,7 +9479,6 @@ private void tableKeyReleased(JTable table, KeyEvent evt) { private javax.swing.JMenuItem importGirrMenuItem; private javax.swing.JMenuItem importGirrMenuItem1; private javax.swing.JButton importGirrSignalHelpButton; - private javax.swing.JButton importGlobalCacheHelpButton; private javax.swing.JButton importIctHelpButton; private javax.swing.JMenuItem importIctMenuItem; private javax.swing.JMenuItem importIctMenuItem1; @@ -9782,11 +9551,8 @@ private void tableKeyReleased(JTable table, KeyEvent evt) { private javax.swing.JLabel jLabel30; private javax.swing.JLabel jLabel31; private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel44; private javax.swing.JLabel jLabel45; private javax.swing.JLabel jLabel46; - private javax.swing.JLabel jLabel47; - private javax.swing.JLabel jLabel48; private javax.swing.JLabel jLabel49; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel50; diff --git a/src/main/java/org/harctoolbox/irscrutinizer/HelpTexts.java b/src/main/java/org/harctoolbox/irscrutinizer/HelpTexts.java index d2306e43..6dc6ad07 100644 --- a/src/main/java/org/harctoolbox/irscrutinizer/HelpTexts.java +++ b/src/main/java/org/harctoolbox/irscrutinizer/HelpTexts.java @@ -115,13 +115,6 @@ class HelpTexts { + "The Export button initiates an export to a file format selected by the Export pane. The three lower buttons transfer the signal(s) to the scrutinize signal panel, the raw remote table, or the parameterized panel.\n\n" + "For the export and the transfer to the \"scrutinize remote\" tables, not only a single parameter value can be selected, but whole sets. The complete syntax and semantics is given in the IrpMaster documentation. Here we just mention that e.g. 12:34 means all numbers between 12 and 34, and * denotes all possible values."; - @SuppressWarnings("PackageVisibleField") - public static String importGlobalCacheHelp - = "To use the Global Caché data base, an API key has be be entered. A such can be obtained by logging in to http://irdatabase.globalcache.com from a Facebook, Google, or Yahoo account.\n\n" - + "After pressing the \"APIKey\" button, the API key is entered in the pop-up window. It is subsequently saved to the program's properties.\n\n" - + "To use, select, in order, a manufacturer, a device type, and a setup code, the latter possibly by trial-and-error.\n\n" - + "When pressing the \"Load\" button, " + treeHelp; - @SuppressWarnings("PackageVisibleField") public static String importControlTowerHelp = "The support for the Control Tower Data base is limited. It can be used for browsing the data base " diff --git a/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java b/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java deleted file mode 100644 index 534c1c4e..00000000 --- a/src/main/java/org/harctoolbox/irscrutinizer/importer/GlobalCacheIrDatabase.java +++ /dev/null @@ -1,187 +0,0 @@ -/* -Copyright (C) 2013 Bengt Martensson. - -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 3 of the License, 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 -this program. If not, see http://www.gnu.org/licenses/. -*/ - -package org.harctoolbox.irscrutinizer.importer; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonValue; -import javax.json.stream.JsonParser; -import org.harctoolbox.girr.Command; -import org.harctoolbox.girr.Remote; -import org.harctoolbox.girr.RemoteSet; -import org.harctoolbox.harchardware.ir.GlobalCache; -import org.harctoolbox.ircore.InvalidArgumentException; -import org.harctoolbox.ircore.IrSignal; -import org.harctoolbox.irscrutinizer.Props; - -public class GlobalCacheIrDatabase extends DatabaseImporter implements IRemoteSetImporter { - - public final static String globalCacheIrDatabaseHost = "irdatabase.globalcache.com"; - private final static String path = "/api/v1/"; - private final static String globalCacheDbOrigin = globalCacheIrDatabaseHost; - - private static String httpEncode(String s) throws UnsupportedEncodingException { - return URLEncoder.encode(s, "utf-8").replaceAll("\\+", "%20"); - } - - @SuppressWarnings("UseOfSystemOutOrSystemErr") - public static void main(String[] args) { - Props props = new Props(null); - Importer.setProperties(props); - try { - GlobalCacheIrDatabase gcdb = new GlobalCacheIrDatabase(props.getGlobalCacheApiKey(), true); - System.out.println(gcdb.getManufacturers()); - System.out.println(gcdb.getDeviceTypes("philips")); - System.out.println(gcdb.getCodeset("sony", "laser disc")); - System.out.println(gcdb.getCommands("sony", "laser disc", "201")); - } catch (IOException | InvalidArgumentException ex) { - System.err.println(ex.getMessage()); - } - } - - private boolean verbose = false; - - private final String apiKey; - private Map manufacturerMap = null; - private String manufacturer; - private String deviceType; - private RemoteSet remoteSet; - public GlobalCacheIrDatabase(String apiKey, boolean verbose) { - super(globalCacheDbOrigin); - this.apiKey = apiKey; - this.verbose = verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - @SuppressWarnings("UseOfSystemOutOrSystemErr") - private InputStreamReader getReader(String str) throws IOException { - URL url = new URL("http", globalCacheIrDatabaseHost, path + apiKey + "/" + str); - if (verbose) - System.err.println("Opening " + url.toString()); - URLConnection urlConnection = url.openConnection(); - return new InputStreamReader(urlConnection.getInputStream(), Charset.forName("US-ASCII")); - } - - private JsonValue readFrom(String str) throws IOException { - return readFrom(getReader(str)); - } - - private JsonValue readFrom(Reader reader) throws IOException { - JsonParser parser = Json.createParser(reader); - JsonParser.Event x = parser.next(); - return parser.getValue(); - } - - private Map getMap(String urlFragment, String keyName, String valueName) throws IOException { - JsonArray array = readFrom(urlFragment).asJsonArray(); - Map map = new HashMap<>(64); - for (JsonValue val : array) { - JsonObject obj = val.asJsonObject(); - map.put(obj.getString(keyName), obj.getString(valueName)); - } - return map; - } - - private void loadManufacturers() throws IOException { - manufacturerMap = getMap("manufacturers", "Manufacturer", "Key"); - } - - public Collection getManufacturers() throws IOException { - if (manufacturerMap == null) - loadManufacturers(); - return manufacturerMap.values(); - } - - public Collection getDeviceTypes(String manufacturerKey) throws IOException { - return getMap("manufacturers/" + httpEncode(manufacturerKey) + "/devicetypes", "DeviceType", "Key").values(); - } - - public Collection getCodeset(String manufacturerKey, String deviceTypeKey) throws IOException { - return getMap("manufacturers/" + httpEncode(manufacturerKey) + "/devicetypes/" + httpEncode(deviceTypeKey) + "/codesets", - "Codeset", "Key").values(); - } - - public ArrayList getCommands(String manufacturerKey, String deviceTypeKey, String codeSet) throws IOException, InvalidArgumentException { - load(manufacturerKey, deviceTypeKey, codeSet); - return getCommands();//codesMap; - } - - public void load(String manufacturerKey, String deviceTypeKey, String codeSet) throws IOException, InvalidArgumentException { - clearCommands(); - manufacturer = manufacturerKey; - deviceType = deviceTypeKey; - JsonArray array = readFrom("manufacturers/" + httpEncode(manufacturerKey) + "/devicetypes/" + httpEncode(deviceTypeKey) + "/codesets/" + codeSet).asJsonArray(); - for (JsonValue val : array) { - JsonObject obj = val.asJsonObject(); - String str = obj.getString("IRCode"); - IrSignal irSignal = GlobalCache.parse(GlobalCache.sendIrPrefix + ",1,1," + str); - if (irSignal != null) { - String keyName = obj.getString("KeyName"); - Command cmd = new Command(keyName, - "GCDB: " + manufacturer + "/" + deviceType + "/" + codeSet, irSignal); - addCommand(cmd); - } - } - Remote.MetaData metaData = new Remote.MetaData(manufacturer + "_" + deviceType + "_" + codeSet, // name, - null, // displayName - manufacturer, - null, // model, - deviceType, // deviceClass, - null // remoteName, - ); - Remote remote = new Remote(metaData, - null, //java.lang.String comment, - null, - getCommandIndex(), - null //java.util.HashMap> applicationParameters) - ); - - remoteSet = new RemoteSet(getCreatingUser(), origin, remote); - } - - @Override - public RemoteSet getRemoteSet() { - return remoteSet; - } - - @Override - public String getFormatName() { - return "Global Caché IR Database"; - } - - @Override - public Remote.MetaData getMetaData() { - return remoteSet.iterator().next().getMetaData(); - } -} diff --git a/src/main/xdocs/IrScrutinizer.xml b/src/main/xdocs/IrScrutinizer.xml index 5061a34d..26d92664 100644 --- a/src/main/xdocs/IrScrutinizer.xml +++ b/src/main/xdocs/IrScrutinizer.xml @@ -98,6 +98,10 @@ 2023-12-26 Removed leftover references to the "minimal json" as well as Fedore dnf tonto. + + 2024-01-05 + Removed GlobalCache IR database. +
@@ -745,22 +749,6 @@
Data bases -
- Global Caché Database -

Global Caché maintains a data base - of IR signals, made available free of charge. "Contains over 100,000 - Infrared codes for over 2,000 different remotes from over 500 manufacturers". - To use from IrScrutinizer, an API Key has be be retrieved. This can be done from - a Facebook, Google, or Yahoo account. After pressing the APIKey button, the - API key is entered in the pop-up window. It is subsequently saved to the - program's properties. - To use, first select Select me to load to load the list of the manufacturers. - Then select, in order, a manufacturer, a device - type, and a setup code, the latter possibly by - trial-and-error.

-

This data base is no longer maintained; replaced by the "Control Tower data base", described next.

-
-
Global Caché's Control Tower data base

This is the new data base from Global Caché. Unfortunately,