Skip to content

Commit be02bde

Browse files
Sync with PythonLircClient: resolves bengtmartensson#3. Misc. improvements.
1 parent 125288d commit be02bde

10 files changed

Lines changed: 351 additions & 75 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
hs_err_pid*
1313
target
1414
nb*
15+
*~

‎pom.xml‎

Lines changed: 140 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
http://maven.apache.org/maven-v4_0_0.xsd">
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>org.harctoolbox</groupId>
8-
<artifactId>JavaLircClient</artifactId>
8+
<artifactId>LircClient</artifactId>
99
<packaging>jar</packaging>
1010
<version>0.1.1dev</version>
11-
<name>JavaLircClient</name>
11+
<name>LircClient</name>
1212
<licenses>
1313
<license>
1414
<name>GPL 3+</name>
@@ -18,6 +18,7 @@
1818
<description>An independent implementation of a Lirc Client, like irsend.</description>
1919
<url>http://www.harctoolbox.org</url>
2020
<properties>
21+
<project.nameLowercase>lircclient</project.nameLowercase>
2122
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2223
<maven.compiler.source>1.8</maven.compiler.source>
2324
<maven.compiler.target>1.8</maven.compiler.target>
@@ -33,7 +34,7 @@
3334
<configuration>
3435
<archive>
3536
<manifest>
36-
<mainClass>org.lirc.LircClient</mainClass>
37+
<mainClass>org.harctoolbox.lircclient.LircClient</mainClass>
3738
</manifest>
3839
</archive>
3940
<descriptorRefs>
@@ -63,9 +64,145 @@
6364
</configuration>
6465
</plugin>
6566

67+
<plugin>
68+
<groupId>org.codehaus.mojo</groupId>
69+
<artifactId>xml-maven-plugin</artifactId>
70+
<version>1.0</version>
71+
<executions>
72+
<execution>
73+
<phase>generate-sources</phase>
74+
<goals>
75+
<goal>transform</goal>
76+
</goals>
77+
</execution>
78+
</executions>
79+
<configuration>
80+
<transformationSets>
81+
<transformationSet>
82+
<dir>src/main/xml</dir>
83+
<outputDir>${project.build.directory}/generated-sources/xml/org/harctoolbox/lircclient</outputDir>
84+
<includes>
85+
<include>Version.xml</include>
86+
</includes>
87+
<stylesheet>${basedir}/tools/mkVersion.xsl</stylesheet>
88+
<parameters>
89+
<parameter>
90+
<name>version</name>
91+
<value>${project.version}</value>
92+
</parameter>
93+
<parameter>
94+
<name>url</name>
95+
<value>${project.url}</value>
96+
</parameter>
97+
<parameter>
98+
<name>appName</name>
99+
<value>${project.artifactId}</value>
100+
</parameter>
101+
</parameters>
102+
<fileMappers>
103+
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
104+
<targetExtension>.java</targetExtension>
105+
</fileMapper>
106+
</fileMappers>
107+
</transformationSet>
108+
</transformationSets>
109+
</configuration>
110+
111+
<dependencies>
112+
<dependency>
113+
<groupId>xalan</groupId>
114+
<artifactId>xalan</artifactId>
115+
<version>2.7.2</version>
116+
</dependency>
117+
</dependencies>
118+
</plugin>
119+
120+
<plugin>
121+
<groupId>org.codehaus.mojo</groupId>
122+
<artifactId>build-helper-maven-plugin</artifactId>
123+
<version>1.9.1</version>
124+
<executions>
125+
<execution>
126+
<phase>generate-sources</phase>
127+
<goals>
128+
<goal>add-source</goal>
129+
</goals>
130+
<configuration>
131+
<sources>
132+
<source>${project.build.directory}/generated-sources/xml</source>
133+
</sources>
134+
</configuration>
135+
</execution>
136+
</executions>
137+
</plugin>
138+
139+
<plugin>
140+
<!-- Copy resources in src/main/config to target dir. -->
141+
<artifactId>maven-resources-plugin</artifactId>
142+
<version>3.0.1</version>
143+
<executions>
144+
<execution>
145+
<id>copy-resources</id>
146+
<phase>validate</phase>
147+
<goals>
148+
<goal>copy-resources</goal>
149+
</goals>
150+
<configuration>
151+
<outputDirectory>${basedir}/target</outputDirectory>
152+
<resources>
153+
<resource>
154+
<directory>src/main/config</directory>
155+
<filtering>true</filtering>
156+
</resource>
157+
<!--resource>
158+
<directory>src/main/resources</directory>
159+
<filtering>false</filtering>
160+
</resource-->
161+
</resources>
162+
</configuration>
163+
</execution>
164+
</executions>
165+
</plugin>
66166
</plugins>
67167
</build>
68168

169+
<profiles>
170+
<profile>
171+
<id>chmod</id>
172+
<activation>
173+
<file>
174+
<exists>/usr/bin/chmod</exists> <!-- good enough for now :-) -->
175+
</file>
176+
</activation>
177+
<build>
178+
<plugins>
179+
<plugin>
180+
<groupId>org.codehaus.mojo</groupId>
181+
<artifactId>exec-maven-plugin</artifactId>
182+
<version>1.5.0</version>
183+
<executions>
184+
<execution>
185+
<id>make-wrapper-executable</id>
186+
<phase>prepare-package</phase>
187+
<goals>
188+
<goal>exec</goal>
189+
</goals>
190+
<configuration>
191+
<executable>chmod</executable>
192+
<workingDirectory>${project.build.directory}</workingDirectory>
193+
<arguments>
194+
<argument>0755</argument>
195+
<argument>${project.nameLowercase}.sh</argument>
196+
</arguments>
197+
</configuration>
198+
</execution>
199+
</executions>
200+
</plugin>
201+
</plugins>
202+
</build>
203+
</profile>
204+
</profiles>
205+
69206
<dependencies>
70207
<dependency>
71208
<groupId>com.beust</groupId>

‎src/main/config/lircclient.bat‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@echo off
2+
3+
REM Wrapper for LircClient as a command line program for Windows/MSDOS.
4+
5+
REM Command to call the desired Java VM
6+
set JAVA=java
7+
8+
REM Where the files are located, change of desired
9+
set APPLICATIONHOME=%~dp0
10+
11+
REM Normally no need to change the rest of the file
12+
set JAR=%APPLICATIONHOME%\${project.name}-${project.version}-jar-with-dependencies.jar
13+
14+
"%JAVA%" -jar "%JAR%" %*

‎src/main/config/lircclient.sh‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# Wrapper for LircClient
3+
4+
# Command to call the desired Java VM
5+
JAVA=java
6+
7+
LIRCCLIENTHOME="$(dirname -- "$(readlink -f -- "${0}")" )"
8+
JAR=${LIRCCLIENTHOME}/${project.name}-${project.version}-jar-with-dependencies.jar
9+
10+
${JAVA} -jar "$JAR" "$@"

‎src/main/java/org/harctoolbox/lircclient/Example.java‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (C) 2016 Bengt Martensson.
2+
Copyright (C) 2016, 2017 Bengt Martensson.
33
44
This program is free software: you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -28,13 +28,12 @@ public class Example {
2828

2929
public static void main(String[] args) {
3030
try {
31-
LircClient lirc = new TcpLircClient("localhost", 8765);
31+
LircClient lirc = new TcpLircClient("localhost", 8765, true, 5000);
3232
String version = lirc.getVersion();
3333
System.out.println(version);
3434
List<String> remotes = lirc.getRemotes();
35-
int i = 0;
36-
for (String remote : remotes)
37-
System.out.println(i++ + ":\t" + remote);
35+
for (int i = 0; i < remotes.size(); i++)
36+
System.out.println(i + ":\t" + remotes.get(i));
3837

3938
System.out.println("Select a remote by entering its number");
4039
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in, LircClient.encodingName));
@@ -44,9 +43,8 @@ public static void main(String[] args) {
4443
int remoteNo = Integer.parseInt(line);
4544
String remote = remotes.get(remoteNo);
4645
List<String> commands = lirc.getCommands(remote);
47-
i = 0;
48-
for (String command : commands)
49-
System.out.println(i++ + ":\t" + command);
46+
for (int i = 0; i < commands.size(); i++)
47+
System.out.println(i + ":\t" + commands.get(i));
5048
System.out.println("Select a command by entering its number");
5149
line = reader.readLine();
5250
if (line == null)

0 commit comments

Comments
 (0)