about summary refs log tree commit diff stats
path: root/client/trunk/src
diff options
context:
space:
mode:
Diffstat (limited to 'client/trunk/src')
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java114
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscView.form29
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscView.java20
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Item/Item.java27
4 files changed, 184 insertions, 6 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java new file mode 100644 index 0000000..69a8e49 --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java
@@ -0,0 +1,114 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package com.fourisland.instadisc;
6
7import com.fourisland.instadisc.Item.Item;
8import java.io.IOException;
9import java.io.InputStream;
10import java.net.ServerSocket;
11import java.net.Socket;
12import java.util.HashMap;
13import java.util.logging.Level;
14import java.util.logging.Logger;
15
16/**
17 *
18 * @author hatkirby
19 */
20public class InstaDiscThread implements Runnable {
21
22 boolean cancelled = false;
23
24 public void cancel() {
25 cancelled = true;
26 }
27
28 public void run() {
29 try {
30 ServerSocket svr = new ServerSocket();
31 java.net.InetSocketAddress addr = new java.net.InetSocketAddress(4444);
32 svr.bind(addr);
33 while (!cancelled) {
34 try {
35 Socket s = svr.accept();
36 HandleItemThread hit = new HandleItemThread(s);
37 Thread hitt = new Thread(hit);
38 hitt.start();
39 } catch (Exception ex) {
40 cancel();
41 Logger.getLogger(InstaDiscThread.class.getName()).log(Level.SEVERE, null, ex);
42 }
43 }
44 svr.close();
45 } catch (IOException ex) {
46 Logger.getLogger(InstaDiscThread.class.getName()).log(Level.SEVERE, null, ex);
47 }
48
49 }
50}
51
52class HandleItemThread implements Runnable {
53
54 Socket s;
55
56 public HandleItemThread(Socket s) {
57 this.s = s;
58 }
59
60 public void run() {
61 try {
62 InputStream is = s.getInputStream();
63 int buffer[] = new int[1000];
64 int rs = 0;
65 int i = 0;
66
67 while (rs != -1) {
68 try {
69 rs = is.read();
70
71 if (rs != -1) {
72 buffer[i] = rs;
73 }
74 i++;
75 } catch (IOException ex) {
76 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex);
77 }
78 }
79
80 StringBuilder result = new StringBuilder();
81 int j = 0;
82 for (j = 0; j < i; j++) {
83 result.append(Character.toString((char) buffer[j]));
84 }
85
86 String[] headers = result.toString().split("\n");
87 HashMap<String, String> headerMap = new HashMap<String, String>();
88 i = 0;
89 while (1 == 1) {
90 try {
91 String[] nameVal = headers[i].split(": ");
92 String name = nameVal[0];
93 String value = nameVal[1];
94 headerMap.put(name, value);
95 } catch (Exception ex) {
96 break;
97 }
98 i++;
99 }
100
101 Logger.getLogger(HandleItemThread.class.getName()).log(Level.INFO, headerMap.toString());
102 try {
103 s.close();
104 } catch (IOException ex) {
105 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex);
106 }
107
108 Item idI = new Item(headerMap);
109 idI.start();
110 } catch (IOException ex) {
111 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex);
112 }
113 }
114}
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form index 90b1160..bb3cc48 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.form
@@ -10,15 +10,38 @@
10 <Layout> 10 <Layout>
11 <DimensionLayout dim="0"> 11 <DimensionLayout dim="0">
12 <Group type="103" groupAlignment="0" attributes="0"> 12 <Group type="103" groupAlignment="0" attributes="0">
13 <EmptySpace min="0" pref="400" max="32767" attributes="0"/> 13 <Component id="jScrollPane1" alignment="0" pref="400" max="32767" attributes="0"/>
14 </Group> 14 </Group>
15 </DimensionLayout> 15 </DimensionLayout>
16 <DimensionLayout dim="1"> 16 <DimensionLayout dim="1">
17 <Group type="103" groupAlignment="0" attributes="0"> 17 <Group type="103" groupAlignment="0" attributes="0">
18 <EmptySpace min="0" pref="252" max="32767" attributes="0"/> 18 <Component id="jScrollPane1" alignment="0" pref="244" max="32767" attributes="0"/>
19 </Group> 19 </Group>
20 </DimensionLayout> 20 </DimensionLayout>
21 </Layout> 21 </Layout>
22 <SubComponents>
23 <Container class="javax.swing.JScrollPane" name="jScrollPane1">
24 <Properties>
25 <Property name="name" type="java.lang.String" value="jScrollPane1" noResource="true"/>
26 </Properties>
27 <AuxValues>
28 <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
29 </AuxValues>
30
31 <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
32 <SubComponents>
33 <Component class="javax.swing.JList" name="jList1">
34 <Properties>
35 <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
36 <StringArray count="0"/>
37 </Property>
38 <Property name="selectionMode" type="int" value="0"/>
39 <Property name="name" type="java.lang.String" value="jList1" noResource="true"/>
40 </Properties>
41 </Component>
42 </SubComponents>
43 </Container>
44 </SubComponents>
22 </Container> 45 </Container>
23 <Container class="javax.swing.JMenuBar" name="menuBar"> 46 <Container class="javax.swing.JMenuBar" name="menuBar">
24 <Properties> 47 <Properties>
@@ -91,7 +114,7 @@
91 <Group type="102" alignment="0" attributes="0"> 114 <Group type="102" alignment="0" attributes="0">
92 <EmptySpace max="-2" attributes="0"/> 115 <EmptySpace max="-2" attributes="0"/>
93 <Component id="statusMessageLabel" min="-2" max="-2" attributes="0"/> 116 <Component id="statusMessageLabel" min="-2" max="-2" attributes="0"/>
94 <EmptySpace pref="226" max="32767" attributes="0"/> 117 <EmptySpace pref="214" max="32767" attributes="0"/>
95 <Component id="progressBar" min="-2" max="-2" attributes="0"/> 118 <Component id="progressBar" min="-2" max="-2" attributes="0"/>
96 <EmptySpace max="-2" attributes="0"/> 119 <EmptySpace max="-2" attributes="0"/>
97 <Component id="statusAnimationLabel" min="-2" max="-2" attributes="0"/> 120 <Component id="statusAnimationLabel" min="-2" max="-2" attributes="0"/>
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java index 3b4daf4..d43589a 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscView.java
@@ -79,6 +79,10 @@ public class InstaDiscView extends FrameView {
79 } 79 }
80 } 80 }
81 }); 81 });
82
83 InstaDiscThread idt = new InstaDiscThread();
84 Thread idtt = new Thread(idt);
85 idtt.start();
82 } 86 }
83 87
84 @Action 88 @Action
@@ -100,6 +104,8 @@ public class InstaDiscView extends FrameView {
100 private void initComponents() { 104 private void initComponents() {
101 105
102 mainPanel = new javax.swing.JPanel(); 106 mainPanel = new javax.swing.JPanel();
107 jScrollPane1 = new javax.swing.JScrollPane();
108 jList1 = new javax.swing.JList();
103 menuBar = new javax.swing.JMenuBar(); 109 menuBar = new javax.swing.JMenuBar();
104 javax.swing.JMenu fileMenu = new javax.swing.JMenu(); 110 javax.swing.JMenu fileMenu = new javax.swing.JMenu();
105 javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem(); 111 javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
@@ -113,15 +119,21 @@ public class InstaDiscView extends FrameView {
113 119
114 mainPanel.setName("mainPanel"); // NOI18N 120 mainPanel.setName("mainPanel"); // NOI18N
115 121
122 jScrollPane1.setName("jScrollPane1"); // NOI18N
123
124 jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
125 jList1.setName("jList1"); // NOI18N
126 jScrollPane1.setViewportView(jList1);
127
116 javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); 128 javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
117 mainPanel.setLayout(mainPanelLayout); 129 mainPanel.setLayout(mainPanelLayout);
118 mainPanelLayout.setHorizontalGroup( 130 mainPanelLayout.setHorizontalGroup(
119 mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 131 mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
120 .addGap(0, 400, Short.MAX_VALUE) 132 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
121 ); 133 );
122 mainPanelLayout.setVerticalGroup( 134 mainPanelLayout.setVerticalGroup(
123 mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 135 mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addGap(0, 252, Short.MAX_VALUE) 136 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
125 ); 137 );
126 138
127 menuBar.setName("menuBar"); // NOI18N 139 menuBar.setName("menuBar"); // NOI18N
@@ -165,7 +177,7 @@ public class InstaDiscView extends FrameView {
165 .addGroup(statusPanelLayout.createSequentialGroup() 177 .addGroup(statusPanelLayout.createSequentialGroup()
166 .addContainerGap() 178 .addContainerGap()
167 .addComponent(statusMessageLabel) 179 .addComponent(statusMessageLabel)
168 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 226, Short.MAX_VALUE) 180 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 214, Short.MAX_VALUE)
169 .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 181 .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
170 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 182 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
171 .addComponent(statusAnimationLabel) 183 .addComponent(statusAnimationLabel)
@@ -189,6 +201,8 @@ public class InstaDiscView extends FrameView {
189 }// </editor-fold>//GEN-END:initComponents 201 }// </editor-fold>//GEN-END:initComponents
190 202
191 // Variables declaration - do not modify//GEN-BEGIN:variables 203 // Variables declaration - do not modify//GEN-BEGIN:variables
204 private javax.swing.JList jList1;
205 private javax.swing.JScrollPane jScrollPane1;
192 private javax.swing.JPanel mainPanel; 206 private javax.swing.JPanel mainPanel;
193 private javax.swing.JMenuBar menuBar; 207 private javax.swing.JMenuBar menuBar;
194 private javax.swing.JProgressBar progressBar; 208 private javax.swing.JProgressBar progressBar;
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Item.java b/client/trunk/src/com/fourisland/instadisc/Item/Item.java new file mode 100644 index 0000000..f13ec3d --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/Item/Item.java
@@ -0,0 +1,27 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package com.fourisland.instadisc.Item;
7
8import java.util.HashMap;
9
10/**
11 *
12 * @author hatkirby
13 */
14public class Item {
15
16 HashMap<String,String> headerMap;
17
18 public Item(HashMap<String,String> headerMap)
19 {
20 this.headerMap = headerMap;
21 }
22
23 public void start()
24 {
25 WellFormedItem wfi = new WellFormedItem(this);
26 }
27}