1 package de.j32.pimstuff;
3 import java.io.FileInputStream;
4 import java.io.FileNotFoundException;
5 import java.io.FileOutputStream;
6 import java.io.IOException;
7 import java.io.InputStream;
8 import java.io.OutputStream;
9 import java.util.Properties;
11 import org.xml.sax.SAXException;
13 import de.j32.avmfritz.FritzBox;
14 import de.j32.pimstuff.conduit.FritzAddressbookImporter;
15 import de.j32.pimstuff.conduit.FritzAddressbookExporter;
16 import de.j32.pimstuff.data.Addressbook;
17 import de.j32.util.Util;
21 public static void main(String[] args)
25 System.out.println("Launching pimstuff ...");
26 Properties config = new Properties();
29 config.loadFromXML(new FileInputStream("config.xml"));
31 catch (FileNotFoundException e) {
32 config.setProperty("password", "password");
33 config.setProperty("url", "http://fritz.box");
35 config.storeToXML(new FileOutputStream("config.xml"), null, "UTF-8");
41 pw = Util.nonnull(config.getProperty("password"));
42 url = Util.nonnull(config.getProperty("url"));
44 catch (NullPointerException e) {
45 throw new RuntimeException("Missing configuration parameter");
48 Addressbook ab = new Addressbook();
49 FritzBox fb = new FritzBox(pw, url);
51 System.out.println("loading ...");
52 // Load Addressbook from FritzBox
53 InputStream is = null;
54 FritzAddressbookImporter reader = null;
56 ab = new Addressbook();
57 is = fb.exportAddressbook();
58 reader = new FritzAddressbookImporter(is);
66 Util.nothrowClose(is);
69 System.out.println("saving ...");
70 // Save Addressbook back to FritzBox
71 FritzAddressbookExporter writer = null;
72 OutputStream os = null;
74 os = fb.importAddressbook();
75 writer = new FritzAddressbookExporter(os);
83 Util.nothrowClose(writer);
84 Util.nothrowClose(os);
87 } catch (SAXException e) {
88 // TODO Auto-generated catch block
90 } catch (IOException e) {
91 // TODO Auto-generated catch block