summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-08-04 11:10:44 +0200
committergeronimo <geronimo013@gmx.de>2012-08-04 11:10:44 +0200
commite8175c7b23047fefd52f85afe05e2864b2a9bba8 (patch)
tree8dab4e287545805d173a6c8e297c1798a1a01599
parentc7d67f443bdfe842c2e356d4edbe345338e3e08d (diff)
downloadcmp-e8175c7b23047fefd52f85afe05e2864b2a9bba8.tar.gz
cmp-e8175c7b23047fefd52f85afe05e2864b2a9bba8.tar.bz2
created new icons to enable visual feedback on mediatype selection, changed json-parser and enabled virtual mediatype usage
-rw-r--r--cmpcj/.classpath3
-rw-r--r--cmpcj/lib/gson-2.2.2.jarbin0 -> 189285 bytes
-rw-r--r--cmpcj/lib/jackson-all-1.9.2.jarbin1107436 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black.pngbin117733 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_dvd.pngbin116838 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_dvd.pngbin128700 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_movies.pngbin133715 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_vdr.pngbin140435 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_i_vdr_old.pngbin181800 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_library.pngbin121207 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_movies.pngbin125320 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_music.pngbin121853 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_photos.pngbin129249 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_playlist.pngbin121207 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_vdr.pngbin128692 -> 0 bytes
-rw-r--r--cmpcj/res/images/folder_black_vdr_old.pngbin172383 -> 0 bytes
-rw-r--r--cmpcj/res/images/sr_default.pngbin0 -> 114212 bytes
-rw-r--r--cmpcj/res/images/sr_dvd.pngbin0 -> 119043 bytes
-rw-r--r--cmpcj/res/images/sr_dvd_i.pngbin0 -> 134812 bytes
-rw-r--r--cmpcj/res/images/sr_lvdr.pngbin0 -> 174142 bytes
-rw-r--r--cmpcj/res/images/sr_lvdr_i.pngbin0 -> 185903 bytes
-rw-r--r--cmpcj/res/images/sr_movies.pngbin0 -> 122199 bytes
-rw-r--r--cmpcj/res/images/sr_movies_i.pngbin0 -> 138608 bytes
-rw-r--r--cmpcj/res/images/sr_music.pngbin0 -> 117609 bytes
-rw-r--r--cmpcj/res/images/sr_photos.pngbin0 -> 124129 bytes
-rw-r--r--cmpcj/res/images/sr_playlist.pngbin0 -> 116457 bytes
-rw-r--r--cmpcj/res/images/sr_vdr.pngbin0 -> 130356 bytes
-rw-r--r--cmpcj/res/images/sr_vdr_i.pngbin0 -> 145850 bytes
-rw-r--r--cmpcj/res/images/sradefault.pngbin0 -> 131251 bytes
-rw-r--r--cmpcj/res/images/sradvd.pngbin0 -> 136534 bytes
-rw-r--r--cmpcj/res/images/sradvd_i.pngbin0 -> 152638 bytes
-rw-r--r--cmpcj/res/images/sralvdr.pngbin0 -> 190151 bytes
-rw-r--r--cmpcj/res/images/sralvdr_i.pngbin0 -> 201594 bytes
-rw-r--r--cmpcj/res/images/sramovies.pngbin0 -> 138966 bytes
-rw-r--r--cmpcj/res/images/sramovies_i.pngbin0 -> 156017 bytes
-rw-r--r--cmpcj/res/images/sramusic.pngbin0 -> 134757 bytes
-rw-r--r--cmpcj/res/images/sraphotos.pngbin0 -> 140488 bytes
-rw-r--r--cmpcj/res/images/sraplaylist.pngbin0 -> 132791 bytes
-rw-r--r--cmpcj/res/images/sravdr.pngbin0 -> 146699 bytes
-rw-r--r--cmpcj/res/images/sravdr_i.pngbin0 -> 162536 bytes
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java37
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java34
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java36
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java39
-rw-r--r--cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java173
-rw-r--r--cmps/main.cc23
-rw-r--r--cmps/nbproject/Makefile-Debug.mk30
-rw-r--r--cmps/nbproject/Makefile-Release.mk12
-rw-r--r--cmps/nbproject/configurations.xml12
-rw-r--r--cmps/tests/StringBuilderTest.cc17
-rw-r--r--libs/IO/src/CommandReader.cc12
-rw-r--r--libs/mediaScan/src/Audio.cc2
-rw-r--r--libs/mediaScan/src/DVDImage.cc2
-rw-r--r--libs/mediaScan/src/LegacyVdrRecording.cc2
-rw-r--r--libs/mediaScan/src/Movie.cc2
-rw-r--r--libs/mediaScan/src/Picture.cc2
-rw-r--r--libs/mediaScan/src/VdrRecording.cc2
-rw-r--r--libs/networking/src/HTTPServer.cc2
-rw-r--r--libs/util/include/StringBuilder.h7
-rw-r--r--libs/util/src/JSonWriter.cc5
-rw-r--r--libs/util/src/StringBuilder.cc50
61 files changed, 416 insertions, 88 deletions
diff --git a/cmpcj/.classpath b/cmpcj/.classpath
index ae6697e..b28f98d 100644
--- a/cmpcj/.classpath
+++ b/cmpcj/.classpath
@@ -4,6 +4,7 @@
<classpathentry kind="src" path="res"/>
<classpathentry kind="lib" path="lib/glazedlists_java15.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/jackson-all-1.9.2.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="lib" path="lib/gson-2.2.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/cmpcj/lib/gson-2.2.2.jar b/cmpcj/lib/gson-2.2.2.jar
new file mode 100644
index 0000000..f2108e0
--- /dev/null
+++ b/cmpcj/lib/gson-2.2.2.jar
Binary files differ
diff --git a/cmpcj/lib/jackson-all-1.9.2.jar b/cmpcj/lib/jackson-all-1.9.2.jar
deleted file mode 100644
index f1d8c3d..0000000
--- a/cmpcj/lib/jackson-all-1.9.2.jar
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black.png b/cmpcj/res/images/folder_black.png
deleted file mode 100644
index 01b5b20..0000000
--- a/cmpcj/res/images/folder_black.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_dvd.png b/cmpcj/res/images/folder_black_dvd.png
deleted file mode 100644
index 26c72c2..0000000
--- a/cmpcj/res/images/folder_black_dvd.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_dvd.png b/cmpcj/res/images/folder_black_i_dvd.png
deleted file mode 100644
index 2b4294c..0000000
--- a/cmpcj/res/images/folder_black_i_dvd.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_movies.png b/cmpcj/res/images/folder_black_i_movies.png
deleted file mode 100644
index e5ed555..0000000
--- a/cmpcj/res/images/folder_black_i_movies.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_vdr.png b/cmpcj/res/images/folder_black_i_vdr.png
deleted file mode 100644
index 129b733..0000000
--- a/cmpcj/res/images/folder_black_i_vdr.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_i_vdr_old.png b/cmpcj/res/images/folder_black_i_vdr_old.png
deleted file mode 100644
index 4cb2584..0000000
--- a/cmpcj/res/images/folder_black_i_vdr_old.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_library.png b/cmpcj/res/images/folder_black_library.png
deleted file mode 100644
index 6e1cc81..0000000
--- a/cmpcj/res/images/folder_black_library.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_movies.png b/cmpcj/res/images/folder_black_movies.png
deleted file mode 100644
index 34c46f3..0000000
--- a/cmpcj/res/images/folder_black_movies.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_music.png b/cmpcj/res/images/folder_black_music.png
deleted file mode 100644
index e534703..0000000
--- a/cmpcj/res/images/folder_black_music.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_photos.png b/cmpcj/res/images/folder_black_photos.png
deleted file mode 100644
index 59f80a4..0000000
--- a/cmpcj/res/images/folder_black_photos.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_playlist.png b/cmpcj/res/images/folder_black_playlist.png
deleted file mode 100644
index 6e1cc81..0000000
--- a/cmpcj/res/images/folder_black_playlist.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_vdr.png b/cmpcj/res/images/folder_black_vdr.png
deleted file mode 100644
index 17fcbb9..0000000
--- a/cmpcj/res/images/folder_black_vdr.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/folder_black_vdr_old.png b/cmpcj/res/images/folder_black_vdr_old.png
deleted file mode 100644
index b56f5f7..0000000
--- a/cmpcj/res/images/folder_black_vdr_old.png
+++ /dev/null
Binary files differ
diff --git a/cmpcj/res/images/sr_default.png b/cmpcj/res/images/sr_default.png
new file mode 100644
index 0000000..8628dfe
--- /dev/null
+++ b/cmpcj/res/images/sr_default.png
Binary files differ
diff --git a/cmpcj/res/images/sr_dvd.png b/cmpcj/res/images/sr_dvd.png
new file mode 100644
index 0000000..899b0e3
--- /dev/null
+++ b/cmpcj/res/images/sr_dvd.png
Binary files differ
diff --git a/cmpcj/res/images/sr_dvd_i.png b/cmpcj/res/images/sr_dvd_i.png
new file mode 100644
index 0000000..18a7571
--- /dev/null
+++ b/cmpcj/res/images/sr_dvd_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_lvdr.png b/cmpcj/res/images/sr_lvdr.png
new file mode 100644
index 0000000..1b90956
--- /dev/null
+++ b/cmpcj/res/images/sr_lvdr.png
Binary files differ
diff --git a/cmpcj/res/images/sr_lvdr_i.png b/cmpcj/res/images/sr_lvdr_i.png
new file mode 100644
index 0000000..31a475e
--- /dev/null
+++ b/cmpcj/res/images/sr_lvdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_movies.png b/cmpcj/res/images/sr_movies.png
new file mode 100644
index 0000000..794a5fa
--- /dev/null
+++ b/cmpcj/res/images/sr_movies.png
Binary files differ
diff --git a/cmpcj/res/images/sr_movies_i.png b/cmpcj/res/images/sr_movies_i.png
new file mode 100644
index 0000000..efe3e3a
--- /dev/null
+++ b/cmpcj/res/images/sr_movies_i.png
Binary files differ
diff --git a/cmpcj/res/images/sr_music.png b/cmpcj/res/images/sr_music.png
new file mode 100644
index 0000000..cacaa0c
--- /dev/null
+++ b/cmpcj/res/images/sr_music.png
Binary files differ
diff --git a/cmpcj/res/images/sr_photos.png b/cmpcj/res/images/sr_photos.png
new file mode 100644
index 0000000..8493512
--- /dev/null
+++ b/cmpcj/res/images/sr_photos.png
Binary files differ
diff --git a/cmpcj/res/images/sr_playlist.png b/cmpcj/res/images/sr_playlist.png
new file mode 100644
index 0000000..41ca388
--- /dev/null
+++ b/cmpcj/res/images/sr_playlist.png
Binary files differ
diff --git a/cmpcj/res/images/sr_vdr.png b/cmpcj/res/images/sr_vdr.png
new file mode 100644
index 0000000..d750edf
--- /dev/null
+++ b/cmpcj/res/images/sr_vdr.png
Binary files differ
diff --git a/cmpcj/res/images/sr_vdr_i.png b/cmpcj/res/images/sr_vdr_i.png
new file mode 100644
index 0000000..a02a741
--- /dev/null
+++ b/cmpcj/res/images/sr_vdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sradefault.png b/cmpcj/res/images/sradefault.png
new file mode 100644
index 0000000..fa5ae3d
--- /dev/null
+++ b/cmpcj/res/images/sradefault.png
Binary files differ
diff --git a/cmpcj/res/images/sradvd.png b/cmpcj/res/images/sradvd.png
new file mode 100644
index 0000000..fd66ad5
--- /dev/null
+++ b/cmpcj/res/images/sradvd.png
Binary files differ
diff --git a/cmpcj/res/images/sradvd_i.png b/cmpcj/res/images/sradvd_i.png
new file mode 100644
index 0000000..b7fc014
--- /dev/null
+++ b/cmpcj/res/images/sradvd_i.png
Binary files differ
diff --git a/cmpcj/res/images/sralvdr.png b/cmpcj/res/images/sralvdr.png
new file mode 100644
index 0000000..5677308
--- /dev/null
+++ b/cmpcj/res/images/sralvdr.png
Binary files differ
diff --git a/cmpcj/res/images/sralvdr_i.png b/cmpcj/res/images/sralvdr_i.png
new file mode 100644
index 0000000..c6f1725
--- /dev/null
+++ b/cmpcj/res/images/sralvdr_i.png
Binary files differ
diff --git a/cmpcj/res/images/sramovies.png b/cmpcj/res/images/sramovies.png
new file mode 100644
index 0000000..b74967a
--- /dev/null
+++ b/cmpcj/res/images/sramovies.png
Binary files differ
diff --git a/cmpcj/res/images/sramovies_i.png b/cmpcj/res/images/sramovies_i.png
new file mode 100644
index 0000000..85c08e7
--- /dev/null
+++ b/cmpcj/res/images/sramovies_i.png
Binary files differ
diff --git a/cmpcj/res/images/sramusic.png b/cmpcj/res/images/sramusic.png
new file mode 100644
index 0000000..9a0ceb9
--- /dev/null
+++ b/cmpcj/res/images/sramusic.png
Binary files differ
diff --git a/cmpcj/res/images/sraphotos.png b/cmpcj/res/images/sraphotos.png
new file mode 100644
index 0000000..47192f0
--- /dev/null
+++ b/cmpcj/res/images/sraphotos.png
Binary files differ
diff --git a/cmpcj/res/images/sraplaylist.png b/cmpcj/res/images/sraplaylist.png
new file mode 100644
index 0000000..f1dc30b
--- /dev/null
+++ b/cmpcj/res/images/sraplaylist.png
Binary files differ
diff --git a/cmpcj/res/images/sravdr.png b/cmpcj/res/images/sravdr.png
new file mode 100644
index 0000000..2f75626
--- /dev/null
+++ b/cmpcj/res/images/sravdr.png
Binary files differ
diff --git a/cmpcj/res/images/sravdr_i.png b/cmpcj/res/images/sravdr_i.png
new file mode 100644
index 0000000..24c0e18
--- /dev/null
+++ b/cmpcj/res/images/sravdr_i.png
Binary files differ
diff --git a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java b/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
index 73f6204..0448549 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/app/SRMediaPlayer.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: SRMediaPlayer.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: SRMediaPlayer.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -159,6 +159,7 @@ public class SRMediaPlayer implements IMediaPlayer {
public static void main(final String[] args) {
+ appInfo();
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
@@ -169,6 +170,14 @@ public class SRMediaPlayer implements IMediaPlayer {
});
}
+
+ protected static void appInfo() {
+ System.err.println("cmpcj - the java frontend of CMP (compound media player)");
+ System.err.println(" serves to browse a medialist from remote systems and to start a player");
+ System.err.println(" for selected media.");
+ System.err.println(" (c) 2012 - Reinhard Mantey - some rights reserved.");
+ System.err.println(" CMP is published as open source under Creative Commons by-sa");
+ }
private boolean debug = false;
private JFrame mainFrame;
private Config config;
diff --git a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
index c336329..57f320f 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/domain/MediaType.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: MediaType.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: MediaType.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -32,7 +32,7 @@ public class MediaType {
}
- public int getStart() {
+ public long getStart() {
return start;
}
@@ -42,10 +42,10 @@ public class MediaType {
}
- public void setStart(int start) {
+ public void setStart(long start) {
this.start = start;
}
private String name;
- private int start;
+ private long start;
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
index b37834c..983fdd3 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaListLoader.java
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
*
- * File: MediaListLoader.java
- * Created:
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * Project: cmpc - a java frontend (client) part of compound media player
- * uses external players to play the media
+ * File: MediaListLoader.java Created: Author: <a
+ * href="mailto:geronimo013@gmx.de">Geronimo</a> Project: cmpc - a java frontend
+ * (client) part of compound media player uses external players to play the
+ * media
*
* CMP - compound media player
*
- * is a client/server mediaplayer intended to play any media from any workstation
- * without the need to export or mount shares. cmps is an easy to use backend
- * with a (ready to use) HTML-interface. Additionally the backend supports
- * authentication via HTTP-digest authorization.
- * cmpc is a client with vdr-like osd-menues.
+ * is a client/server mediaplayer intended to play any media from any
+ * workstation without the need to export or mount shares. cmps is an easy to
+ * use backend with a (ready to use) HTML-interface. Additionally the backend
+ * supports authentication via HTTP-digest authorization. cmpc is a client with
+ * vdr-like osd-menues.
*
- * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
- * published under Creative Commons by-sa
- * For details see http://creativecommons.org/licenses/by-sa/3.0/
+ * Copyright (c) 2012 Reinhard Mantey, some rights reserved! published under
+ * Creative Commons by-sa For details see
+ * http://creativecommons.org/licenses/by-sa/3.0/
*
- * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
+ * The cmp project's homepage is at
+ * http://projects.vdr-developer.org/projects/cmp
*
* --------------------------------------------------------------
*/
@@ -30,7 +30,6 @@ import java.net.ConnectException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
-import org.codehaus.jackson.map.ObjectMapper;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import de.schwarzrot.cmpc.domain.Media;
@@ -64,7 +63,7 @@ public class MediaListLoader implements Runnable {
start = new Date();
request = new URL("http", hostName, port, "/?format=json");
URLConnection conn = request.openConnection();
- final PlayList firstPlaylist = jsonOM.readValue(conn.getInputStream(), PlayList.class);
+ final PlayList firstPlaylist = jsonParser.parseListChunk(conn.getInputStream());
mediaPool.getReadWriteLock().writeLock().lock();
for (Media m : firstPlaylist.getResults()) {
@@ -85,7 +84,7 @@ public class MediaListLoader implements Runnable {
uri = String.format("/?start=%d&limit=%d&format=json", n, 100);
request = new URL("http", hostName, port, uri);
conn = request.openConnection();
- next = jsonOM.readValue(conn.getInputStream(), PlayList.class);
+ next = jsonParser.parseListChunk(conn.getInputStream());
mediaPool.getReadWriteLock().writeLock().lock();
for (Media m : next.getResults()) {
mediaPool.add(m);
@@ -96,6 +95,7 @@ public class MediaListLoader implements Runnable {
}
} catch (Throwable t) {
System.out.println("Oups, media list contains now #" + mediaPool.size() + " entries.");
+ System.err.println("Error on chunk #" + n);
t.printStackTrace();
} finally {
try {
@@ -119,6 +119,6 @@ public class MediaListLoader implements Runnable {
private String hostName;
private int port;
- private ObjectMapper jsonOM = new ObjectMapper();
+ private MedialistParser jsonParser = new MedialistParser();
private EventList<Media> mediaPool = new BasicEventList<Media>();
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
index 24cd506..bde865a 100644
--- a/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MediaTypeSelect.java
@@ -60,14 +60,17 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
+ ImageIcon icon = null;
+
if (isSelected) {
setBackground(list.getSelectionBackground());
setForeground(list.getSelectionForeground());
+ icon = selImages[((Media.SupportedMediaType) value).ordinal()];
} else {
setBackground(list.getBackground());
setForeground(list.getForeground());
+ icon = stdImages[((Media.SupportedMediaType) value).ordinal()];
}
- ImageIcon icon = images[((Media.SupportedMediaType) value).ordinal()];
setSize(110, 110);
setHorizontalAlignment(JLabel.CENTER);
@@ -86,21 +89,35 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
ClassLoader cl = getClass().getClassLoader();
URL url;
- images = new ImageIcon[iconFiles.length];
+ stdImages = new ImageIcon[iconFiles.length];
for (int i = 0; i < iconFiles.length; ++i) {
try {
url = cl.getResource(iconFiles[i]);
img = ImageIO.read(url);
- images[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
+ stdImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
} catch (Throwable t) {
System.err.println("failed to read image from " + iconFiles[i]);
t.printStackTrace();
}
}
+
+ selImages = new ImageIcon[activeIconFiles.length];
+ for (int i = 0; i < activeIconFiles.length; ++i) {
+ try {
+ url = cl.getResource(activeIconFiles[i]);
+
+ img = ImageIO.read(url);
+ selImages[i] = new ImageIcon(img.getScaledInstance(110, 110, Image.SCALE_SMOOTH));
+ } catch (Throwable t) {
+ System.err.println("failed to read image from " + activeIconFiles[i]);
+ t.printStackTrace();
+ }
+ }
}
- ImageIcon[] images;
+ ImageIcon[] stdImages;
+ ImageIcon[] selImages;
}
@@ -139,11 +156,15 @@ public class MediaTypeSelect extends AbstractMatcherEditor<Media> implements Lis
private EventList<Media.SupportedMediaType> selectedTypes;
private JList mediaTypeJList;
private static final String[] iconFiles;
+ private static final String[] activeIconFiles;
static {
- iconFiles = new String[] { "images/folder_black.png", "images/folder_black_music.png",
- "images/folder_black_movies.png", "images/folder_black_i_movies.png", "images/folder_black_dvd.png",
- "images/folder_black_i_dvd.png", "images/folder_black_vdr_old.png",
- "images/folder_black_i_vdr_old.png", "images/folder_black_vdr.png", "images/folder_black_i_vdr.png",
- "images/folder_black_photos.png", "images/folder_black.png" };
+ iconFiles = new String[] { "images/sr_default.png", "images/sr_music.png", "images/sr_movies.png",
+ "images/sr_movies_i.png", "images/sr_dvd.png", "images/sr_dvd_i.png", "images/sr_lvdr.png",
+ "images/sr_lvdr_i.png", "images/sr_vdr.png", "images/sr_vdr_i.png", "images/sr_photos.png",
+ "images/sr_default.png" };
+ activeIconFiles = new String[] { "images/sradefault.png", "images/sramusic.png", "images/sramovies.png",
+ "images/sramovies_i.png", "images/sradvd.png", "images/sradvd_i.png", "images/sralvdr.png",
+ "images/sralvdr_i.png", "images/sravdr.png", "images/sravdr_i.png", "images/sraphotos.png",
+ "images/sradefault.png" };
}
}
diff --git a/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java b/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
new file mode 100644
index 0000000..8f69af0
--- /dev/null
+++ b/cmpcj/src/de/schwarzrot/cmpc/util/MedialistParser.java
@@ -0,0 +1,173 @@
+package de.schwarzrot.cmpc.util;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+import com.google.gson.stream.JsonReader;
+import de.schwarzrot.cmpc.domain.Media;
+import de.schwarzrot.cmpc.domain.MediaType;
+import de.schwarzrot.cmpc.domain.PlayList;
+
+
+public class MedialistParser {
+ public PlayList parseListChunk(InputStream is) {
+ JsonReader reader = null;
+ PlayList rv = null;
+
+ try {
+ reader = new JsonReader(new InputStreamReader(is, "UTF-8"));
+
+ rv = readPlayList(reader);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ try {
+ reader.close();
+ } catch (Throwable t) {
+ }
+ }
+ return rv;
+ }
+
+
+ @Test
+ public void testJSonParsing() {
+ FileInputStream fis = null;
+
+ try {
+ fis = new FileInputStream(new File("test.json"));
+ parseListChunk(fis);
+ fis.close();
+ fis = null;
+ } catch (Throwable t) {
+ t.printStackTrace();
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+
+ protected Media readMedia(JsonReader reader) {
+ Media rv = new Media();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("name".equals(name)) {
+ rv.setName(reader.nextString());
+ } else if ("type".equals(name)) {
+ rv.setType(reader.nextInt());
+ } else if ("format".equals(name)) {
+ rv.setFormat(reader.nextString());
+ } else if ("width".equals(name)) {
+ rv.setWidth(reader.nextInt());
+ } else if ("height".equals(name)) {
+ rv.setHeight(reader.nextInt());
+ } else if ("path".equals(name)) {
+ rv.setPath(reader.nextString());
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected List<Media> readMediaArray(JsonReader reader) {
+ List<Media> rv = new ArrayList<Media>();
+
+ try {
+ reader.beginArray();
+ while (reader.hasNext()) {
+ rv.add(readMedia(reader));
+ }
+ reader.endArray();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected MediaType readMediaType(JsonReader reader) {
+ MediaType rv = new MediaType();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("name".equals(name)) {
+ rv.setName(reader.nextString());
+ } else if ("start".equals(name)) {
+ rv.setStart(reader.nextLong());
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+
+
+ protected PlayList readPlayList(JsonReader reader) {
+ PlayList rv = new PlayList();
+
+ try {
+ reader.beginObject();
+ while (reader.hasNext()) {
+ String name = reader.nextName();
+
+ if ("total".equals(name)) {
+ rv.setTotal(reader.nextLong());
+ } else if ("types".equals(name)) {
+ rv.setTypes(readTypeArray(reader));
+ } else if ("results".equals(name)) {
+ rv.setResults(readMediaArray(reader));
+ } else {
+ reader.skipValue();
+ }
+ }
+ reader.endObject();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ rv = null;
+ }
+ return rv;
+ }
+
+
+ protected List<MediaType> readTypeArray(JsonReader reader) {
+ List<MediaType> rv = new ArrayList<MediaType>();
+
+ try {
+ reader.beginArray();
+ while (reader.hasNext()) {
+ rv.add(readMediaType(reader));
+ }
+ reader.endArray();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return rv;
+ }
+}
diff --git a/cmps/main.cc b/cmps/main.cc
index a5d2b04..e1be73c 100644
--- a/cmps/main.cc
+++ b/cmps/main.cc
@@ -29,6 +29,7 @@
#include <MediaFactory.h>
#include <MediaListHandler.h>
#include <MediaFileHandler.h>
+#include <MediaServerConfig.h>
#include <ConnectionHandler.h>
#include <CommandHandler.h>
#include <JSonListAssembler.h>
@@ -56,10 +57,23 @@ static int refreshScanner(void *opaque, cHTTPRequest &Request)
return -1;
}
+static void appID(void)
+{
+ fprintf(stderr, "\ncmps - the backend of CMP (compound media player)\n");
+}
+
+static void appInfo(void)
+{
+ appID();
+ fprintf(stderr, " is a streaming- and HTTP-server\n");
+ fprintf(stderr, " (c) 2012 - Reinhard Mantey - some rights reserved.\n");
+ fprintf(stderr, " CMP is published as open source under Creative Commons by-sa\n\n");
+}
+
static void usage(void)
{
- fprintf(stderr, "cmps - the backend of CMP (compound media player)\n");
- fprintf(stderr, " is streaming- and HTTP-server and accepts these commandline options:\n");
+ appID();
+ fprintf(stderr, " is streaming- and HTTP-server and accepts these commandline options:\n");
fprintf(stderr, "-h, --help the help, you are reading\n");
fprintf(stderr, "-d, --appDir <path> the directory, where the server may write config files\n");
fprintf(stderr, " (default is /var/lib/cmp)\n");
@@ -107,7 +121,8 @@ static void setup(int argc, char *argv[], cServerConfig &config)
int main(int argc, char** argv)
{
- cServerConfig config("/var/lib/cmp");
+ appInfo();
+ cMediaServerConfig config("/var/lib/cmp");
setup(argc, argv, config);
cFSMediaScanner *scanner = new cFSMediaScanner();
@@ -142,11 +157,13 @@ int main(int argc, char** argv)
* register/enable internal commands
*/
cCommandHandler::RegisterCallback("refresh", refreshScanner, scanner);
+ fprintf(stderr, "start searching for media at %s\n", config.DocumentRoot());
scanner->Refresh();
/*
* now start the server
*/
+ fprintf(stderr, "ok, ready for client connections.\n");
if (!server->Start()) {
fprintf(stderr, "failed to start application (3)");
exit(-3);
diff --git a/cmps/nbproject/Makefile-Debug.mk b/cmps/nbproject/Makefile-Debug.mk
index af8aa89..d825972 100644
--- a/cmps/nbproject/Makefile-Debug.mk
+++ b/cmps/nbproject/Makefile-Debug.mk
@@ -42,6 +42,7 @@ TESTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tests
# Test Files
TESTFILES= \
+ ${TESTDIR}/TestFiles/f8 \
${TESTDIR}/TestFiles/codecTest \
${TESTDIR}/TestFiles/connectionHandlerTest \
${TESTDIR}/TestFiles/fileSystemTest \
@@ -89,7 +90,7 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps: ${OBJECTFILES}
${OBJECTDIR}/main.o: nbproject/Makefile-${CND_CONF}.mk main.cc
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cc
# Subprojects
.build-subprojects:
@@ -107,6 +108,10 @@ ${OBJECTDIR}/main.o: nbproject/Makefile-${CND_CONF}.mk main.cc
# Build Test Targets
.build-tests-conf: .build-conf ${TESTFILES}
+${TESTDIR}/TestFiles/f8: ${TESTDIR}/tests/BaseScanTest.o ${OBJECTFILES:%.o=%_nomain.o}
+ ${MKDIR} -p ${TESTDIR}/TestFiles
+ ${LINK.cc} -o ${TESTDIR}/TestFiles/f8 $^ ${LDLIBSOPTIONS}
+
${TESTDIR}/TestFiles/codecTest: ${TESTDIR}/tests/CodecTest.o ${OBJECTFILES:%.o=%_nomain.o}
${MKDIR} -p ${TESTDIR}/TestFiles
${LINK.cc} -o ${TESTDIR}/TestFiles/codecTest $^ ${LDLIBSOPTIONS}
@@ -136,46 +141,52 @@ ${TESTDIR}/TestFiles/stringBuilderTest: ${TESTDIR}/tests/StringBuilderTest.o ${O
${LINK.cc} -o ${TESTDIR}/TestFiles/stringBuilderTest $^ ${LDLIBSOPTIONS}
+${TESTDIR}/tests/BaseScanTest.o: tests/BaseScanTest.cc
+ ${MKDIR} -p ${TESTDIR}/tests
+ ${RM} $@.d
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/BaseScanTest.o tests/BaseScanTest.cc
+
+
${TESTDIR}/tests/CodecTest.o: tests/CodecTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/CodecTest.o tests/CodecTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/CodecTest.o tests/CodecTest.cc
${TESTDIR}/tests/ConnectionHandlerTest.o: tests/ConnectionHandlerTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/ConnectionHandlerTest.o tests/ConnectionHandlerTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/ConnectionHandlerTest.o tests/ConnectionHandlerTest.cc
${TESTDIR}/tests/FileSystemTest.o: tests/FileSystemTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/FileSystemTest.o tests/FileSystemTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/FileSystemTest.o tests/FileSystemTest.cc
${TESTDIR}/tests/FScanTest.o: tests/FScanTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/FScanTest.o tests/FScanTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/FScanTest.o tests/FScanTest.cc
${TESTDIR}/tests/JSonTest.o: tests/JSonTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/JSonTest.o tests/JSonTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/JSonTest.o tests/JSonTest.cc
${TESTDIR}/tests/MetaScanTest.o: tests/MetaScanTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/MetaScanTest.o tests/MetaScanTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/MetaScanTest.o tests/MetaScanTest.cc
${TESTDIR}/tests/StringBuilderTest.o: tests/StringBuilderTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/StringBuilderTest.o tests/StringBuilderTest.cc
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -I. -MMD -MP -MF $@.d -o ${TESTDIR}/tests/StringBuilderTest.o tests/StringBuilderTest.cc
${OBJECTDIR}/main_nomain.o: ${OBJECTDIR}/main.o main.cc
@@ -186,7 +197,7 @@ ${OBJECTDIR}/main_nomain.o: ${OBJECTDIR}/main.o main.cc
(echo "$$NMOUTPUT" | ${GREP} 'T _main$$'); \
then \
${RM} $@.d;\
- $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -Dmain=__nomain -MMD -MP -MF $@.d -o ${OBJECTDIR}/main_nomain.o main.cc;\
+ $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -Iserverlib/include -I../libs/mediaScan/include -I../libs/networking/include -I../libs/IO/include -I../libs/util/include -I../libs/vdr/include -I. -Dmain=__nomain -MMD -MP -MF $@.d -o ${OBJECTDIR}/main_nomain.o main.cc;\
else \
${CP} ${OBJECTDIR}/main.o ${OBJECTDIR}/main_nomain.o;\
fi
@@ -195,6 +206,7 @@ ${OBJECTDIR}/main_nomain.o: ${OBJECTDIR}/main.o main.cc
.test-conf:
@if [ "${TEST}" = "" ]; \
then \
+ ${TESTDIR}/TestFiles/f8 || true; \
${TESTDIR}/TestFiles/codecTest || true; \
${TESTDIR}/TestFiles/connectionHandlerTest || true; \
${TESTDIR}/TestFiles/fileSystemTest || true; \
diff --git a/cmps/nbproject/Makefile-Release.mk b/cmps/nbproject/Makefile-Release.mk
index 4232298..550c27f 100644
--- a/cmps/nbproject/Makefile-Release.mk
+++ b/cmps/nbproject/Makefile-Release.mk
@@ -48,6 +48,7 @@ TESTFILES= \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps \
+ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps
# C Compiler Flags
@@ -84,6 +85,10 @@ ${OBJECTDIR}/main.o: nbproject/Makefile-${CND_CONF}.mk main.cc
# Build Test Targets
.build-tests-conf: .build-conf ${TESTFILES}
+${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps: ${TESTDIR}/tests/BaseScanTest.o ${OBJECTFILES:%.o=%_nomain.o}
+ ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
+ ${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps $^ ${LDLIBSOPTIONS}
+
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps: ${TESTDIR}/tests/CodecTest.o ${OBJECTFILES:%.o=%_nomain.o}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps $^ ${LDLIBSOPTIONS}
@@ -113,6 +118,12 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps: ${TESTDIR}/tests/StringBuilderT
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps $^ ${LDLIBSOPTIONS}
+${TESTDIR}/tests/BaseScanTest.o: tests/BaseScanTest.cc
+ ${MKDIR} -p ${TESTDIR}/tests
+ ${RM} $@.d
+ $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${TESTDIR}/tests/BaseScanTest.o tests/BaseScanTest.cc
+
+
${TESTDIR}/tests/CodecTest.o: tests/CodecTest.cc
${MKDIR} -p ${TESTDIR}/tests
${RM} $@.d
@@ -179,6 +190,7 @@ ${OBJECTDIR}/main_nomain.o: ${OBJECTDIR}/main.o main.cc
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps || true; \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps || true; \
${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps || true; \
+ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/cmps || true; \
else \
./${TEST} || true; \
fi
diff --git a/cmps/nbproject/configurations.xml b/cmps/nbproject/configurations.xml
index de3675f..d2880dd 100644
--- a/cmps/nbproject/configurations.xml
+++ b/cmps/nbproject/configurations.xml
@@ -18,6 +18,12 @@
displayName="Test Files"
projectFiles="false"
kind="TEST_LOGICAL_FOLDER">
+ <logicalFolder name="f8"
+ displayName="BaseScanTest"
+ projectFiles="true"
+ kind="TEST">
+ <itemPath>tests/BaseScanTest.cc</itemPath>
+ </logicalFolder>
<logicalFolder name="f1"
displayName="CodecTest"
projectFiles="true"
@@ -75,6 +81,11 @@
<compilerSet>default</compilerSet>
</toolsSet>
<compileType>
+ <cTool>
+ <incDir>
+ <pElem>.</pElem>
+ </incDir>
+ </cTool>
<ccTool>
<incDir>
<pElem>include</pElem>
@@ -84,6 +95,7 @@
<pElem>../libs/IO/include</pElem>
<pElem>../libs/util/include</pElem>
<pElem>../libs/vdr/include</pElem>
+ <pElem>.</pElem>
</incDir>
<commandLine>-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration</commandLine>
<preprocessorList>
diff --git a/cmps/tests/StringBuilderTest.cc b/cmps/tests/StringBuilderTest.cc
index 9814411..8d2b150 100644
--- a/cmps/tests/StringBuilderTest.cc
+++ b/cmps/tests/StringBuilderTest.cc
@@ -75,6 +75,22 @@ void basicTests()
free(result);
}
+void replaceTest()
+{
+ const char char2Replace[] = { '"', '\0' };
+ const char *replacements[] = { "\\\"", NULL };
+ const char *sample = "mal sehen, was \"hier\" so abgeht?!";
+ cStringBuilder sb(17);
+
+ sb.Append(sample, char2Replace, replacements);
+ char *result = sb.toString();
+
+ std::cout << "result with replace: " << result << std::endl;
+// std::cout << "result with replace (size " << sb.Size() << "): " << result << std::endl;
+ std::cout << "size-check: " << strlen(sample) << " <> " << strlen(result) << std::endl;
+ free(result);
+}
+
void lineReaderTest()
{
cLineReader lr(new cFileReader(new cFile("srclient.conf")));
@@ -92,6 +108,7 @@ int main()
lineReaderTest();
basicTests();
rangeTests();
+ replaceTest();
return 0;
}
diff --git a/libs/IO/src/CommandReader.cc b/libs/IO/src/CommandReader.cc
index 0bc6109..accd79f 100644
--- a/libs/IO/src/CommandReader.cc
+++ b/libs/IO/src/CommandReader.cc
@@ -51,17 +51,10 @@ void cCommandReader::Close(void)
int status = 0;
if (!fdMax) fdMax = getdtablesize();
- if (fd > 0 && fd < fdMax) {
- close(fd);
- isyslog("closed fd #%d", fd);
- }
+ if (fd > 0 && fd < fdMax) close(fd);
fd = -1;
- if (pid != waitpid(pid, &status, 0)) {
+ if (pid != waitpid(pid, &status, 0))
esyslog("ERROR: failed to wait for child #%d - error #%d", pid, errno);
- }
- else {
- isyslog("child exit status: %d", WEXITSTATUS(status));
- }
pid = -1;
}
@@ -110,7 +103,6 @@ bool cCommandReader::Open(void)
esyslog("ERROR: failed to close write end from parent side!");
exit(-1);
}
- isyslog("child process #%d started ... fd %d", pid, child2Parent[FDRead]);
fd = child2Parent[FDRead];
return true;
}
diff --git a/libs/mediaScan/src/Audio.cc b/libs/mediaScan/src/Audio.cc
index 9420db6..62e9379 100644
--- a/libs/mediaScan/src/Audio.cc
+++ b/libs/mediaScan/src/Audio.cc
@@ -24,6 +24,7 @@
*/
#include <Audio.h>
#include <StringBuilder.h>
+#include <Logging.h>
#include <stddef.h>
#include <string.h>
#include <util.h>
@@ -74,6 +75,7 @@ void cAudio::AddMeta(cMediainfoReader::InfoEntry* Entry)
void cAudio::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cAudio::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
const char *cAudio::ContentType(const char* Extension)
diff --git a/libs/mediaScan/src/DVDImage.cc b/libs/mediaScan/src/DVDImage.cc
index 0ddcdac..1a78581 100644
--- a/libs/mediaScan/src/DVDImage.cc
+++ b/libs/mediaScan/src/DVDImage.cc
@@ -23,6 +23,7 @@
* --------------------------------------------------------------
*/
#include <DVDImage.h>
+#include <Logging.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -55,6 +56,7 @@ size_t cDVDImage::Size(void) const
void cDVDImage::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cDVDImage::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
bool cDVDImage::NeedsFurtherScan(void) const
diff --git a/libs/mediaScan/src/LegacyVdrRecording.cc b/libs/mediaScan/src/LegacyVdrRecording.cc
index 2b4d7af..b12d693 100644
--- a/libs/mediaScan/src/LegacyVdrRecording.cc
+++ b/libs/mediaScan/src/LegacyVdrRecording.cc
@@ -25,6 +25,7 @@
#include <LegacyVdrRecording.h>
#include <StringBuilder.h>
#include <File.h>
+#include <Logging.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -53,6 +54,7 @@ cLegacyVdrRecording::~cLegacyVdrRecording()
void cLegacyVdrRecording::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cLegacyVdrRecording::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
bool cLegacyVdrRecording::NeedsFurtherScan(void) const
diff --git a/libs/mediaScan/src/Movie.cc b/libs/mediaScan/src/Movie.cc
index 19fc629..7194f54 100644
--- a/libs/mediaScan/src/Movie.cc
+++ b/libs/mediaScan/src/Movie.cc
@@ -23,6 +23,7 @@
* --------------------------------------------------------------
*/
#include <Movie.h>
+#include <Logging.h>
#include <stddef.h>
#include <string.h>
#include <util.h>
@@ -82,6 +83,7 @@ void cMovie::AddMeta(cMediainfoReader::InfoEntry *Entry)
void cMovie::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cMovie::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
bool cMovie::NeedsFurtherScan(void) const
diff --git a/libs/mediaScan/src/Picture.cc b/libs/mediaScan/src/Picture.cc
index 0401401..a480e45 100644
--- a/libs/mediaScan/src/Picture.cc
+++ b/libs/mediaScan/src/Picture.cc
@@ -23,6 +23,7 @@
* --------------------------------------------------------------
*/
#include <Picture.h>
+#include <Logging.h>
#include <stddef.h>
#include <string.h>
@@ -72,6 +73,7 @@ const char *cPicture::ContentType(const char* Extension)
void cPicture::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cPicture::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
bool cPicture::NeedsFurtherScan(void) const
diff --git a/libs/mediaScan/src/VdrRecording.cc b/libs/mediaScan/src/VdrRecording.cc
index bf1eaab..afb930a 100644
--- a/libs/mediaScan/src/VdrRecording.cc
+++ b/libs/mediaScan/src/VdrRecording.cc
@@ -25,6 +25,7 @@
#include <VdrRecording.h>
#include <StringBuilder.h>
#include <File.h>
+#include <Logging.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -52,6 +53,7 @@ cVdrRecording::~cVdrRecording()
void cVdrRecording::EnableDeepScan(bool DoScan)
{
deepScanEnabled = DoScan;
+ isyslog("cVdrRecording::enableDeepScan(%s)", deepScanEnabled ? "true" : "false");
}
bool cVdrRecording::NeedsFurtherScan(void) const
diff --git a/libs/networking/src/HTTPServer.cc b/libs/networking/src/HTTPServer.cc
index ba62283..a857ff1 100644
--- a/libs/networking/src/HTTPServer.cc
+++ b/libs/networking/src/HTTPServer.cc
@@ -65,8 +65,6 @@ void cHTTPServer::Action()
cleaner->Start();
}
#endif
- fprintf(stderr, "startup server now\n");
-
ServerSocket().Open();
while (Running()) {
cConnectionPoint *cp = ServerSocket().Accept();
diff --git a/libs/util/include/StringBuilder.h b/libs/util/include/StringBuilder.h
index db98934..977c4e7 100644
--- a/libs/util/include/StringBuilder.h
+++ b/libs/util/include/StringBuilder.h
@@ -34,7 +34,7 @@ public:
cStringBuilder(int chunkSize = 127);
virtual ~cStringBuilder();
- cStringBuilder &Append(const char *Text);
+ cStringBuilder &Append(const char *Text, const char char2Replace[] = NULL, const char *replacements[] = NULL);
cStringBuilder &Append(char c);
cStringBuilder &Append(bool v, const char *TrueValue = "X", const char *FalseValue="-");
cStringBuilder &Append(double v);
@@ -48,9 +48,12 @@ public:
size_t Copy(char *Buf, size_t BufSize);
char *toString(void);
+protected:
+ void Write(const char *Text);
+ void WriteAndReplace(const char *Text, const char char2Replace[], const char *replacements[]);
+
private:
void init(void);
- void Write(const char *p);
int chunkSize;
size_t readOffset; ///< read offest is the offset over all chunks (thus goes from 0 to size)
///< Copy can be called subsequently, if Buf is smaller than StringBuilders size
diff --git a/libs/util/src/JSonWriter.cc b/libs/util/src/JSonWriter.cc
index ec9b1dc..8fcb140 100644
--- a/libs/util/src/JSonWriter.cc
+++ b/libs/util/src/JSonWriter.cc
@@ -28,6 +28,9 @@
#include <stdio.h>
#define DEBUG 1
+static const char char2Replace[] = { '"', '\0' };
+static const char *replacements[] = { "\\\"", NULL };
+
cJSonWriter::cJSonWriter(cStringBuilder &StringBuilder)
: lastState(JS_Unknown)
, sb(StringBuilder)
@@ -130,7 +133,7 @@ cJSonWriter &cJSonWriter::Value(const char *Text) {
}
else {
PopState();
- sb.Append("\"").Append(Text).Append("\"");
+ sb.Append("\"").Append(Text, char2Replace, replacements).Append("\"");
}
return *this;
}
diff --git a/libs/util/src/StringBuilder.cc b/libs/util/src/StringBuilder.cc
index 28b048e..7da1aac 100644
--- a/libs/util/src/StringBuilder.cc
+++ b/libs/util/src/StringBuilder.cc
@@ -91,6 +91,51 @@ void cStringBuilder::Write(const char *Text)
}
}
+void cStringBuilder::WriteAndReplace(const char *Text, const char char2Replace[], const char *replacements[])
+{
+ if (!Text) {
+ esyslog("ERROR: text to add is a NULL-pointer!");
+ return;
+ }
+ int done;
+ char *curChunk = (char *) pool[pool.size() - 1];
+ char *chunkLast = curChunk + chunkSize;
+ char *pd;
+ const char *ps, *srcLast = Text + strlen(Text), *pChk;
+
+ for (ps = Text, pd = curChunk + writeOffset; ps < srcLast; ++ps) {
+ done = 0;
+ for (pChk = char2Replace; pChk && *pChk; ++pChk) {
+ if (*ps == *pChk) {
+ const char *rps = replacements[pChk - char2Replace];
+ done = 1;
+
+ while (rps && *rps) {
+ if (writeOffset == chunkSize) {
+ curChunk = (char *) malloc(chunkSize);
+ pool.push_back(curChunk);
+ writeOffset = 0;
+ pd = curChunk;
+ chunkLast = curChunk + chunkSize;
+ }
+ *pd++ = *rps++;
+ ++writeOffset;
+ }
+ }
+ }
+ if (done) continue;
+ if (writeOffset == chunkSize) {
+ curChunk = (char *) malloc(chunkSize);
+ pool.push_back(curChunk);
+ writeOffset = 0;
+ pd = curChunk;
+ chunkLast = curChunk + chunkSize;
+ }
+ *pd++ = *ps;
+ ++writeOffset;
+ }
+}
+
size_t cStringBuilder::Size()
{
return (pool.size() - 1) * chunkSize + writeOffset;
@@ -125,10 +170,11 @@ size_t cStringBuilder::Copy(char* Buf, size_t BufSize)
return bytesWritten;
}
-cStringBuilder &cStringBuilder::Append(const char* Text)
+cStringBuilder &cStringBuilder::Append(const char* Text, const char char2Replace[], const char *replacements[])
{
if (!Text) Write("(null)");
- Write(Text);
+ if (char2Replace && replacements) WriteAndReplace(Text, char2Replace, replacements);
+ else Write(Text);
return *this;
}