Pārlūkot izejas kodu

various bugfixes

LH 6 gadi atpakaļ
vecāks
revīzija
9bdcda343a

+ 1 - 1
iZplPlugins/JukeBox/build.gradle

@@ -3,7 +3,7 @@ apply plugin:'java'
 apply plugin: 'application'
 apply from: "$rootDir/utils/IO.gradle"
 
-version = '0.10.2.1'
+version = '0.11.0.0-SNAPSHOT'
 mainClassName = 'de.nplusc.izc.izpl.plugins.jukebox.StandaloneMain'
 
 //task distZip(dependsOn: 'jar') {

+ 17 - 0
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/APIWrapper.java

@@ -71,6 +71,23 @@ public class APIWrapper
         }
     }
     
+    public static void quickQuitWithSave()
+    {
+        try
+        {
+            Class c = Class.forName("de.nplusc.izc.iZpl.API.IZPLApi");
+            Method m = getMethod("shutdownWithSave", c);
+            
+            m.invoke(null, (Object[]) null);
+        }
+        catch(ClassNotFoundException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ignored)
+        {
+            //only legit case inside here.
+            System.exit(0);
+        }
+    }
+    
+    
     public static void quickQuit()
     {
         try

+ 3 - 3
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/JukeBox.form

@@ -39,11 +39,11 @@
                       <EmptySpace type="unrelated" max="-2" attributes="0"/>
                       <Component id="btnSkip" max="32767" attributes="0"/>
                   </Group>
-                  <Group type="102" attributes="0">
-                      <Component id="lblTrackName" min="-2" pref="303" max="-2" attributes="0"/>
+                  <Group type="102" alignment="1" attributes="0">
+                      <Component id="lblTrackName" max="32767" attributes="0"/>
                       <EmptySpace max="-2" attributes="0"/>
                       <Component id="lblStatus" min="-2" pref="158" max="-2" attributes="0"/>
-                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+                      <EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
                   </Group>
               </Group>
               <EmptySpace max="-2" attributes="0"/>

+ 14 - 10
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/JukeBox.java

@@ -41,6 +41,7 @@ public class JukeBox extends javax.swing.JFrame implements MouseListener,Playbac
     public static final int JUKEBOX_PORT=0x6767;
     private static final Logger l = LogManager.getLogger();
     private Backend backend;
+    private boolean UIPlugin = false;
     /**
      * Creates new form JukeBoxGUI
      */
@@ -174,11 +175,11 @@ public class JukeBox extends javax.swing.JFrame implements MouseListener,Playbac
                         .addComponent(btnPlayPause, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                         .addComponent(btnSkip, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
-                    .addGroup(layout.createSequentialGroup()
-                        .addComponent(lblTrackName, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                        .addComponent(lblTrackName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                         .addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addGap(0, 0, Short.MAX_VALUE)))
+                        .addGap(1, 1, 1)))
                 .addContainerGap())
         );
         layout.setVerticalGroup(
@@ -218,7 +219,14 @@ public class JukeBox extends javax.swing.JFrame implements MouseListener,Playbac
         }
         if((modified&evt.ALT_MASK)!=0)
         {
-            APIWrapper.quickQuit();
+            if(UIPlugin)
+            {
+                APIWrapper.quickQuitWithSave();
+            }
+            else
+            {
+                APIWrapper.quickQuit();
+            }
         }
         backend.skip();
         
@@ -254,10 +262,7 @@ public class JukeBox extends javax.swing.JFrame implements MouseListener,Playbac
             
             String[] titles = backend.getTitles(); //TODO
             DefaultTableModel mdl = ((DefaultTableModel)tblPLE.getModel());
-            for(int i=tblPLE.getRowCount()-1;i>0;i--)
-            {
-                mdl.removeRow(i-1);
-            }
+            mdl.setRowCount(titles.length>0?titles.length:1);
             if(titles.length>0)
             {
                 mdl.setValueAt(0,0,0);
@@ -270,12 +275,11 @@ public class JukeBox extends javax.swing.JFrame implements MouseListener,Playbac
             }
             for (int i = 0; i < titles.length; i++)
             {
-                ((DefaultTableModel)tblPLE.getModel()).addRow(new Object[]{null,null,null,null});
                 mdl.setValueAt(i,i,0);
                 mdl.setValueAt(titles[i],i,1);
             }
             
-            mdl.setRowCount(titles.length>0?titles.length:1);
+            
         }
         catch(InvalidPlayListFileException e)
         {

+ 7 - 0
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/JukeBoxPlugin.java

@@ -28,6 +28,7 @@ import org.apache.logging.log4j.Logger;
  */
 public class JukeBoxPlugin implements UIPlugin, FeaturePlugin
 {
+    private static boolean UIPlugin = false;
     private static final Logger l = LogManager.getLogger();
     private Backend backend;
     private JukeBox frontend = new JukeBox();
@@ -98,6 +99,7 @@ public class JukeBoxPlugin implements UIPlugin, FeaturePlugin
     {
         if(APIWrapper.getUiPlugin()==this)
         {
+            UIPlugin = true;
         }
         else
         {
@@ -145,5 +147,10 @@ public class JukeBoxPlugin implements UIPlugin, FeaturePlugin
     {
         return false;
     }
+
+    public static boolean isUIPlugin()
+    {
+        return UIPlugin;
+    }
     
 }

+ 8 - 0
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/RemoteBackend.java

@@ -18,6 +18,7 @@ package de.nplusc.izc.izpl.plugins.jukebox;
 
 import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
 import de.nplusc.izc.iZpl.API.shared.networking.Packet;
+import de.nplusc.izc.tools.baseTools.Detectors;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -29,6 +30,7 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
+import javax.swing.JOptionPane;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.yaml.snakeyaml.Yaml;
@@ -154,6 +156,12 @@ public class RemoteBackend implements Backend
         catch (IOException ex) 
         {   
             ex.printStackTrace();
+            l.error(" Unable to connect to Host. Aborting now");
+            if(Detectors.isJavaw())
+            {
+                JOptionPane.showMessageDialog(null, "Host given to Program is invalid", "ERROR", JOptionPane.ERROR_MESSAGE);
+            }
+            APIWrapper.quickQuit();
         }
     }
 

+ 15 - 0
iZplPlugins/JukeBox/src/main/java/de/nplusc/izc/izpl/plugins/jukebox/StandaloneMain.java

@@ -16,12 +16,18 @@
  */
 package de.nplusc.izc.izpl.plugins.jukebox;
 
+import de.nplusc.izc.tools.baseTools.Detectors;
+import javax.swing.JOptionPane;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
 /**
  *
  * @author iZc <nplusc.de>
  */
 public class StandaloneMain
 {
+    private static final Logger l = LogManager.getLogger();
     public static void main(String[] args)
     {
         /* Set the Nimbus look and feel */
@@ -47,6 +53,15 @@ public class StandaloneMain
 
         //</editor-fold>
         
+        if(args.length!=1)
+        {
+            l.error("No Hostname given, Aborting now");
+            if(Detectors.isJavaw())
+            {
+                JOptionPane.showMessageDialog(null, "No Host given as Parameter", "ERROR", JOptionPane.ERROR_MESSAGE);
+            }
+            APIWrapper.quickQuit();
+        }
         JukeBoxPlugin p = new JukeBoxPlugin();
         p.parseParameter(args[0]); //TODO verboseLogging etc
         

+ 8 - 1
izpl-shared/src/main/java/de/nplusc/izc/iZpl/Utils/shared/PLFileIO.java

@@ -558,7 +558,14 @@ public class PLFileIO
         String metadata = "#EXTINF:"+length+",";
         if(tag!=null)
         {
-            metadata+= tag.getFirst(FieldKey.ARTIST)+" - "+tag.getFirst(FieldKey.TITLE);
+            String artist = tag.getFirst(FieldKey.ARTIST);
+            String titletag = ((!artist.equals(""))?(artist+" - "):"")+tag.getFirst(FieldKey.TITLE);
+            if(titletag.length()<2) // kann nichts sinnvolles sein
+            {
+                l.info("No ID3-Data for file, falling back to nabe based implementation. ({})",path);
+                titletag = element.getName();
+            }
+            metadata+= titletag;
         }
         else
         {