From 63dab0db05f95c82714741eee8731c59c928eab8 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 13 Sep 2008 15:03:18 +0000 Subject: Client: Added the "page-change" category Refs #19 --- .../instadisc/Database/Subscription.java | 5 ++ .../src/com/fourisland/instadisc/Functions.java | 93 ++++++++++++++-------- .../com/fourisland/instadisc/InstaDiscThread.java | 28 ++++++- .../instadisc/Item/Categories/Category.java | 6 +- .../instadisc/Item/Categories/Page_edit.java | 6 ++ .../fourisland/instadisc/Item/WellFormedItem.java | 14 ++-- 6 files changed, 106 insertions(+), 46 deletions(-) create mode 100644 client/trunk/src/com/fourisland/instadisc/Item/Categories/Page_edit.java (limited to 'client/trunk/src') 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 { private String title; private String password; + public Subscription() + { + password = ""; + } + public String getURL() { 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 @@ package com.fourisland.instadisc; public class Functions { - - public static boolean xor(boolean x, boolean y) - { + + public static boolean xor(boolean x, boolean y) { return (x == y); } - - public static int max(int x, int y) - { + + public static int max(int x, int y) { return (x > y ? x : y); } - - public static String padleft(String in, String pad, int len) - { + + public static String padleft(String in, String pad, int len) { while (in.length() < len) { in = pad + in; } - + if (in.length() > len) { - in = in.substring(0,len); + in = in.substring(0, len); } - + return in; } - - public static String reverse(String in) - { + + public static String reverse(String in) { String out = ""; - int i=0; - - for (i=0;i len) { - in = in.substring(0,len); + in = in.substring(0, len); } - + return in; } + public static byte[] pad(byte[] buffer) { + while (buffer.length % 16 != 0) + { + byte[] tmp = new byte[buffer.length + 1]; + int i = 0; + for (i = 0; i < buffer.length; i++) + { + tmp[i] = buffer[i]; + } + tmp[buffer.length] = 0; + buffer = tmp; + } + return buffer; + } + + public static String bytesToHex(byte[] buffer) { + if (buffer == null) + { + return null; + } else + { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < buffer.length; i++) + { + String hex = Integer.toHexString(Integer.decode(new Byte(buffer[i]).toString())); + result.append(padleft(hex.substring(max(hex.length() - 2, 0)), "0", 2)); + } + + return result.toString(); + } + } } \ 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 { boolean cancelled = false; InstaDiscView idv; + public InstaDiscThread() + { + this.idv = null; + } + public InstaDiscThread(InstaDiscView idv) { this.idv = idv; @@ -76,8 +81,13 @@ class HandleItemThread implements Runnable { } public void run() { - idv.startProgress(); - idv.doText("Downloading Item...."); + try + { + idv.startProgress(); + idv.doText("Downloading Item...."); + } catch (NullPointerException ex) + { + } try { @@ -97,7 +107,12 @@ class HandleItemThread implements Runnable { buffer[i] = rs; } - idv.doProgress(buffer.length / (is.available()+1)); + try + { + idv.doProgress(buffer.length / (is.available()+1)); + } catch (NullPointerException ex) + { + } i++; } catch (SocketException ex) @@ -150,6 +165,11 @@ class HandleItemThread implements Runnable { Logger.getLogger(HandleItemThread.class.getName()).log(Level.SEVERE, null, ex); } - idv.doneProgress(); + try + { + idv.doneProgress(); + } catch (NullPointerException ex) + { + } } } 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 { } else if (category.equals("forum-post")) { return new ImageIcon(Fourm.fourm); - } else if (category.equals("instadisc")) - { - return new ImageIcon(InstaDiscIcon.instadiscicon); } else if (category.equals("email")) { return new ImageIcon(Email.email); } else if (category.equals("vcs-rev")) { return new ImageIcon(Vcsrev.vcsrev); + } else if (category.equals("page-change")) + { + return new ImageIcon(Page_edit.page_edit); } return null; } 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 @@ +package com.fourisland.instadisc.Item.Categories; + +public class Page_edit +{ + 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}; +} 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 { good = (good ? checkForRequiredHeader("Author") : false); good = (good ? checkForRequiredHeader("URL") : false); - if (!Wrapper.getSubscription(aThis.headerMap.get("Subscription")).getPassword().equals("")) - { - good = (good ? checkForRequiredHeader("Encryption-ID") : false); - } - return good; } @@ -237,12 +232,19 @@ public class WellFormedItem { private boolean checkForSubscription() { boolean good = Wrapper.existsSubscription(aThis.headerMap.get("Subscription")); - if (!good) { + if (!good) + { Subscription s = new Subscription(); s.setURL(aThis.headerMap.get("Subscription")); SubscriptionFile.deleteSubscription(s, false); + } else { + if (!Wrapper.getSubscription(aThis.headerMap.get("Subscription")).getPassword().equals("")) + { + good = (good ? checkForRequiredHeader("Encryption-ID") : false); + } } + return good; } } -- cgit 1.4.1