about summary refs log tree commit diff stats
path: root/client/trunk/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-09-13 15:03:18 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-13 15:03:18 +0000
commit63dab0db05f95c82714741eee8731c59c928eab8 (patch)
tree92985278c3e5cb2322cda3c259c57947b2fb17fd /client/trunk/src
parentd5b8fba902d5b337b74aa064701cc50f83e14cfb (diff)
downloadinstadisc-63dab0db05f95c82714741eee8731c59c928eab8.tar.gz
instadisc-63dab0db05f95c82714741eee8731c59c928eab8.tar.bz2
instadisc-63dab0db05f95c82714741eee8731c59c928eab8.zip
Client: Added the "page-change" category
Refs #19
Diffstat (limited to 'client/trunk/src')
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Database/Subscription.java5
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Functions.java93
-rw-r--r--client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java28
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java6
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Item/Categories/Page_edit.java6
-rw-r--r--client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java14
6 files changed, 106 insertions, 46 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/Database/Subscription.java b/client/trunk/src/com/fourisland/instadisc/Database/Subscription.java index a3ab6ed..c71b0ca 100644 --- a/client/trunk/src/com/fourisland/instadisc/Database/Subscription.java +++ b/client/trunk/src/com/fourisland/instadisc/Database/Subscription.java
@@ -21,6 +21,11 @@ public class Subscription {
21 private String title; 21 private String title;
22 private String password; 22 private String password;
23 23
24 public Subscription()
25 {
26 password = "";
27 }
28
24 public String getURL() 29 public String getURL()
25 { 30 {
26 return url; 31 return url;
diff --git a/client/trunk/src/com/fourisland/instadisc/Functions.java b/client/trunk/src/com/fourisland/instadisc/Functions.java index 78c6eec..a46b641 100644 --- a/client/trunk/src/com/fourisland/instadisc/Functions.java +++ b/client/trunk/src/com/fourisland/instadisc/Functions.java
@@ -1,48 +1,43 @@
1package com.fourisland.instadisc; 1package com.fourisland.instadisc;
2 2
3public class Functions { 3public class Functions {
4 4
5 public static boolean xor(boolean x, boolean y) 5 public static boolean xor(boolean x, boolean y) {
6 {
7 return (x == y); 6 return (x == y);
8 } 7 }
9 8
10 public static int max(int x, int y) 9 public static int max(int x, int y) {
11 {
12 return (x > y ? x : y); 10 return (x > y ? x : y);
13 } 11 }
14 12
15 public static String padleft(String in, String pad, int len) 13 public static String padleft(String in, String pad, int len) {
16 {
17 while (in.length() < len) 14 while (in.length() < len)
18 { 15 {
19 in = pad + in; 16 in = pad + in;
20 } 17 }
21 18
22 if (in.length() > len) 19 if (in.length() > len)
23 { 20 {
24 in = in.substring(0,len); 21 in = in.substring(0, len);
25 } 22 }
26 23
27 return in; 24 return in;
28 } 25 }
29 26
30 public static String reverse(String in) 27 public static String reverse(String in) {
31 {
32 String out = ""; 28 String out = "";
33 int i=0; 29 int i = 0;
34 30
35 for (i=0;i<in.length();i++) 31 for (i = 0; i < in.length(); i++)
36 { 32 {
37 out = in.charAt(i) + out; 33 out = in.charAt(i) + out;
38 } 34 }
39 35
40 return out; 36 return out;
41 } 37 }
42 38
43 public static byte[] hexToBytes(String str) 39 public static byte[] hexToBytes(String str) {
44 { 40 if (str == null)
45 if (str==null)
46 { 41 {
47 return null; 42 return null;
48 } else if (str.length() < 2) 43 } else if (str.length() < 2)
@@ -51,31 +46,63 @@ public class Functions {
51 } else if (str.length() < 2) 46 } else if (str.length() < 2)
52 { 47 {
53 return null; 48 return null;
54 } else { 49 } else
50 {
55 int len = str.length() / 2; 51 int len = str.length() / 2;
56 byte[] buffer = new byte[len]; 52 byte[] buffer = new byte[len];
57 for (int i=0; i<len; i++) { 53 for (int i = 0; i < len; i++)
58 buffer[i] = (byte) Integer.parseInt(str.substring(i*2,i*2+2),16); 54 {
55 buffer[i] = (byte) Integer.parseInt(str.substring(i * 2, i * 2 + 2), 16);
59 } 56 }
60 57
61 return buffer; 58 return buffer;
62 } 59 }
63 } 60 }
64 61
65 public static String padright(String in, String pad, int len) 62 public static String padright(String in, String pad, int len) {
66 {
67 while (in.length() < len) 63 while (in.length() < len)
68 { 64 {
69 in += pad; 65 in += pad;
70 } 66 }
71 67
72 if (in.length() > len) 68 if (in.length() > len)
73 { 69 {
74 in = in.substring(0,len); 70 in = in.substring(0, len);
75 } 71 }
76 72
77 return in; 73 return in;
78 } 74 }
79 75
76 public static byte[] pad(byte[] buffer) {
77 while (buffer.length % 16 != 0)
78 {
79 byte[] tmp = new byte[buffer.length + 1];
80 int i = 0;
81 for (i = 0; i < buffer.length; i++)
82 {
83 tmp[i] = buffer[i];
84 }
85 tmp[buffer.length] = 0;
86 buffer = tmp;
87 }
88 return buffer;
89 }
90
91 public static String bytesToHex(byte[] buffer) {
92 if (buffer == null)
93 {
94 return null;
95 } else
96 {
97 StringBuilder result = new StringBuilder();
98 for (int i = 0; i < buffer.length; i++)
99 {
100 String hex = Integer.toHexString(Integer.decode(new Byte(buffer[i]).toString()));
101 result.append(padleft(hex.substring(max(hex.length() - 2, 0)), "0", 2));
102 }
103
104 return result.toString();
105 }
106 }
80} 107}
81 \ No newline at end of file 108 \ No newline at end of file
diff --git a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java index d4a293c..05af63c 100644 --- a/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java +++ b/client/trunk/src/com/fourisland/instadisc/InstaDiscThread.java
@@ -23,6 +23,11 @@ public class InstaDiscThread implements Runnable {
23 boolean cancelled = false; 23 boolean cancelled = false;
24 InstaDiscView idv; 24 InstaDiscView idv;
25 25
26 public InstaDiscThread()
27 {
28 this.idv = null;
29 }
30
26 public InstaDiscThread(InstaDiscView idv) 31 public InstaDiscThread(InstaDiscView idv)
27 { 32 {
28 this.idv = idv; 33 this.idv = idv;
@@ -76,8 +81,13 @@ class HandleItemThread implements Runnable {
76 } 81 }
77 82
78 public void run() { 83 public void run() {
79 idv.startProgress(); 84 try
80 idv.doText("Downloading Item...."); 85 {
86 idv.startProgress();
87 idv.doText("Downloading Item....");
88 } catch (NullPointerException ex)
89 {
90 }
81 91
82 try 92 try
83 { 93 {
@@ -97,7 +107,12 @@ class HandleItemThread implements Runnable {
97 buffer[i] = rs; 107 buffer[i] = rs;
98 } 108 }
99 109
100 idv.doProgress(buffer.length / (is.available()+1)); 110 try
111 {
112 idv.doProgress(buffer.length / (is.available()+1));
113 } catch (NullPointerException ex)
114 {
115 }
101 116
102 i++; 117 i++;
103 } catch (SocketException ex) 118 } catch (SocketException ex)
@@ -150,6 +165,11 @@ class HandleItemThread implements Runnable {
150 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex); 165 Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex);
151 } 166 }
152 167
153 idv.doneProgress(); 168 try
169 {
170 idv.doneProgress();
171 } catch (NullPointerException ex)
172 {
173 }
154 } 174 }
155} 175}
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java index 03b1435..07ff967 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Category.java
@@ -28,15 +28,15 @@ public class Category {
28 } else if (category.equals("forum-post")) 28 } else if (category.equals("forum-post"))
29 { 29 {
30 return new ImageIcon(Fourm.fourm); 30 return new ImageIcon(Fourm.fourm);
31 } else if (category.equals("instadisc"))
32 {
33 return new ImageIcon(InstaDiscIcon.instadiscicon);
34 } else if (category.equals("email")) 31 } else if (category.equals("email"))
35 { 32 {
36 return new ImageIcon(Email.email); 33 return new ImageIcon(Email.email);
37 } else if (category.equals("vcs-rev")) 34 } else if (category.equals("vcs-rev"))
38 { 35 {
39 return new ImageIcon(Vcsrev.vcsrev); 36 return new ImageIcon(Vcsrev.vcsrev);
37 } else if (category.equals("page-change"))
38 {
39 return new ImageIcon(Page_edit.page_edit);
40 } 40 }
41 return null; 41 return null;
42 } 42 }
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/Categories/Page_edit.java b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Page_edit.java new file mode 100644 index 0000000..3ec45fc --- /dev/null +++ b/client/trunk/src/com/fourisland/instadisc/Item/Categories/Page_edit.java
@@ -0,0 +1,6 @@
1package com.fourisland.instadisc.Item.Categories;
2
3public class Page_edit
4{
5 public static byte[] page_edit = new byte[] {-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,16,0,0,0,16,8,6,0,0,0,31,-13,-1,97,0,0,0,4,103,65,77,65,0,0,-81,-56,55,5,-118,-23,0,0,0,25,116,69,88,116,83,111,102,116,119,97,114,101,0,65,100,111,98,101,32,73,109,97,103,101,82,101,97,100,121,113,-55,101,60,0,0,2,-71,73,68,65,84,24,25,5,-63,79,104,-106,117,28,0,-16,-49,-17,121,-97,119,-70,-71,57,-47,16,103,101,-115,18,-83,24,38,34,29,50,-15,-112,-123,38,65,-25,-126,58,117,-13,86,116,8,-94,46,65,65,93,60,76,-54,58,24,-120,-121,-120,-94,58,100,69,-96,-77,60,-60,-102,-38,106,72,51,-5,-77,-36,-100,-101,-45,77,-9,-66,-17,-98,-25,-9,-19,-13,73,17,97,-1,27,-89,95,-22,94,-69,-22,-7,34,-39,-123,-43,72,32,33,18,-111,85,57,79,46,-52,-59,-9,-23,-42,-115,87,-49,12,31,-22,0,-92,-120,112,-16,-19,-77,103,62,57,-68,-21,-95,-94,72,-21,-126,-122,0,32,2,-62,-20,-46,-118,19,63,47,-104,-2,-69,125,-25,-73,95,39,-42,-113,12,31,106,67,9,69,35,109,-21,42,27,-21,-58,-81,105,20,41,-111,-120,76,29,89,85,-123,-27,-107,-38,-66,-83,125,-10,15,-116,-40,-72,120,-68,-89,113,96,-88,117,-2,-29,35,82,107,-22,-59,18,82,74,-67,17,-47,-24,106,52,36,33,-112,11,100,-22,68,33,105,79,127,110,-21,-30,57,-35,67,47,-24,31,-36,105,-31,-49,109,38,78,29,123,-73,-124,32,65,-127,-108,8,9,68,74,-118,68,-1,-14,41,117,92,-80,126,-21,-29,-26,39,127,-41,-107,58,-6,-42,110,-46,-69,97,75,127,9,16,65,-39,32,73,34,37,-71,14,-118,-92,119,121,-60,-106,85,-93,-6,7,-97,-42,-66,122,82,87,79,-14,-41,-40,-124,-101,119,82,20,-19,-71,29,5,68,16,40,83,-95,72,73,-127,70,-111,-84,94,60,109,75,124,-85,-1,-127,-125,90,-1,125,40,53,111,104,-10,-10,-23,-50,-13,-114,94,63,-80,-78,-5,-16,103,-105,10,8,100,-92,68,-111,-110,34,37,-83,43,95,90,127,-5,-108,-2,7,-97,-43,-102,26,86,52,87,116,110,-35,111,-26,-52,121,-35,123,-33,50,85,15,100,40,32,87,68,-112,17,-72,125,-7,107,61,-117,63,-38,-8,-56,51,58,-45,-57,52,-70,66,-5,-42,125,102,70,70,-51,-19,25,-106,54,108,87,103,-96,-128,-100,67,68,16,76,-113,-98,-44,-67,-16,-109,-107,-68,-39,-43,-117,71,100,45,-73,-25,-17,54,115,110,-62,-30,-34,-93,82,-17,-128,-43,-51,-92,-82,2,20,80,103,-22,32,50,-77,23,63,-14,-16,-98,-105,-83,-6,103,-60,-91,47,-50,26,-5,102,-34,-8,119,99,-106,30,123,71,-43,-77,89,-96,-39,40,84,-99,10,-108,-112,-85,-112,35,-68,-7,75,-57,-48,-28,-84,-50,-8,87,6,119,60,-31,-26,-20,-100,-55,-79,73,63,-20,-5,-44,-11,43,-9,-54,42,112,98,83,-45,74,59,-125,18,-86,-86,86,-41,12,-84,109,26,-1,-29,-102,-9,63,24,-74,123,-5,-96,-27,-51,59,44,61,121,-36,-93,125,-9,-120,32,-126,11,-41,42,-111,-61,74,-85,2,37,84,-19,-100,-85,-100,-93,83,75,-21,94,-1,-41,-27,20,38,37,-112,-105,72,75,-107,28,68,-111,20,57,41,-53,-108,-85,58,87,80,-62,74,-85,-98,89,-45,-43,-72,-21,-75,-95,-50,-102,-120,40,4,25,-48,-33,93,-126,8,-70,-101,73,74,114,-77,-111,22,-21,42,79,65,9,41,-59,123,79,-67,114,-6,-71,-108,-46,-50,16,61,0,-126,64,8,32,64,43,-25,60,90,22,78,-64,-1,-110,20,88,-44,-28,87,121,127,0,0,0,0,73,69,78,68,-82,66,96,-126,-1};
6}
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java index 82211e0..05b5378 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java
@@ -204,11 +204,6 @@ public class WellFormedItem {
204 good = (good ? checkForRequiredHeader("Author") : false); 204 good = (good ? checkForRequiredHeader("Author") : false);
205 good = (good ? checkForRequiredHeader("URL") : false); 205 good = (good ? checkForRequiredHeader("URL") : false);
206 206
207 if (!Wrapper.getSubscription(aThis.headerMap.get("Subscription")).getPassword().equals(""))
208 {
209 good = (good ? checkForRequiredHeader("Encryption-ID") : false);
210 }
211
212 return good; 207 return good;
213 } 208 }
214 209
@@ -237,12 +232,19 @@ public class WellFormedItem {
237 232
238 private boolean checkForSubscription() { 233 private boolean checkForSubscription() {
239 boolean good = Wrapper.existsSubscription(aThis.headerMap.get("Subscription")); 234 boolean good = Wrapper.existsSubscription(aThis.headerMap.get("Subscription"));
240 if (!good) { 235 if (!good)
236 {
241 Subscription s = new Subscription(); 237 Subscription s = new Subscription();
242 s.setURL(aThis.headerMap.get("Subscription")); 238 s.setURL(aThis.headerMap.get("Subscription"));
243 239
244 SubscriptionFile.deleteSubscription(s, false); 240 SubscriptionFile.deleteSubscription(s, false);
241 } else {
242 if (!Wrapper.getSubscription(aThis.headerMap.get("Subscription")).getPassword().equals(""))
243 {
244 good = (good ? checkForRequiredHeader("Encryption-ID") : false);
245 }
245 } 246 }
247
246 return good; 248 return good;
247 } 249 }
248} 250}