about summary refs log tree commit diff stats
path: root/data/maps/the_bearer/rooms/Blue Planet (View).txtpb
blob: e7457180c6a4120ce1d7f3c59bb8ca9bbc8cb3ef (plain) (blame)
1
2
3
4
5
6
7
8
name: "Blue Planet (View)"
panels {
  name: "TUNE"
  path: "Panels/Blue/panel_4"
  clue: "tune"
  answer: "neptune"
  symbols: SPARKLES
}
{ color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.fourisland.instadisc.Item;

import com.fourisland.instadisc.Database.Wrapper;
import com.fourisland.instadisc.InstaDiscApp;
import com.fourisland.instadisc.InstaDiscView;
import com.fourisland.instadisc.XmlRpc;
import java.awt.SystemTray;
import java.awt.TrayIcon.MessageType;
import java.util.HashMap;

/**
 *
 * @author hatkirby
 */
public class Item {

    HashMap<String, String> headerMap;

    public Item(HashMap<String, String> headerMap) {
        this.headerMap = headerMap;
    }

    public void start() {
        WellFormedItem wfi = new WellFormedItem(this);
        if (wfi.check()) {
            XmlRpc xmlrpc = new XmlRpc("deleteItem");
            xmlrpc.addParam(Integer.decode(headerMap.get("ID")));
            xmlrpc.execute();
            
            if (Wrapper.countItem() >= Integer.decode(Wrapper.getConfig("itemBufferSize"))) {
                while (Wrapper.countItem() >= Integer.decode(Wrapper.getConfig("itemBufferSize"))) {
                    Wrapper.dropFromTopItem();
                }
            }

            com.fourisland.instadisc.Database.Item item = new com.fourisland.instadisc.Database.Item();
            item.setID(Integer.decode(headerMap.get("ID")));
            item.setSubscription(headerMap.get("Subscription"));
            item.setTitle(headerMap.get("Title"));
            item.setAuthor(headerMap.get("Author"));
            item.setURL(headerMap.get("URL"));

            HashMap<String, String> temp = new HashMap<String, String>(headerMap);
            temp.remove("ID");
            temp.remove("Verification");
            temp.remove("Verification-ID");
            temp.remove("Subscription");
            temp.remove("Title");
            temp.remove("Author");
            temp.remove("URL");
            item.setSemantics(temp);
            
            Wrapper.addItem(item);

            ((InstaDiscView) InstaDiscApp.getApplication().getMainView()).refreshItemPane();

            if (SystemTray.isSupported()) {
                InstaDiscApp.ti.displayMessage("New item recieved!", Wrapper.getSubscription(headerMap.get("Subscription")).getTitle() + ", " + headerMap.get("Title") + " by " + headerMap.get("Author"), MessageType.INFO);
            }
        }
    }
}