* Send feeback to yaams
*
* @param data
*/
public static void sendData(String type, String title, final HashMap<String, String> data) {
YProgressWindowRepeat y = new YProgressWindowRepeat(I18N.t("Send Data to yaams.de"), "web");
try {
File cap = new File(YrgssCore.tmpFolder, "cap.jpg");
if (cap.exists()) {
FileHelper.deleteFile(cap);
}
// create screenshot
try {
BufferedImage bufferedImage = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(bufferedImage, "jpg", cap);
} catch (Throwable t) {
Log.ger.info("Can not create capture " + cap, t);
FileHelper.deleteFile(cap);
}
// add basic data
data.put("title", title);
data.put("type", type);
data.put("yaams", YrgssCore.TITLE);
data.put("log", FileHelper.readFileToString(Log.file));
ClientHttpRequest post = new ClientHttpRequest("http://www.yaams.de/file/sendFeedback.php");
// add files
post.setParameter("cap", cap);
// Construct data
// final StringBuffer send = new StringBuffer("1=1");
for (final String key : data.keySet()) {
post.setParameter(key, data.get(key));
}
// // data
// final URL url = new
// URL("http://www.yaams.de/launcher/feedback.php");
// final URLConnection conn = url.openConnection();
// conn.setDoOutput(true);
// final OutputStreamWriter wr = new
// OutputStreamWriter(conn.getOutputStream());
// wr.write(send.toString());
// wr.flush();
//
// Get the response
final BufferedReader rd = new BufferedReader(new InputStreamReader(post.post()));
String line;
final StringBuffer erg = new StringBuffer("");
while ((line = rd.readLine()) != null) {
erg.append(line);
}
// clean up
FileHelper.deleteFile(cap);
// show it & close all
YDialog.ok(I18N.t("Feedback"), erg.toString(), "monitor");
// wr.close();
rd.close();
} catch (final Throwable t) {
YEx.info("Can not send feedback to http://www.yaams.de/launcher/feedback.php", t);
}
y.close();
}