d894ae032e466bb264645ca4902f14b3b63a21b4
[jpim.git] / src / de / j32 / pimstuff / conduit / FritzAddressbookConduit.java
1 package de.j32.pimstuff.conduit;
2
3 import java.io.IOException;
4
5 import org.xml.sax.SAXException;
6
7 import de.j32.avmfritz.FritzBox;
8
9 public class FritzAddressbookConduit
10         implements Conduit
11 {
12         FritzBox fb_;
13         
14         public FritzAddressbookConduit()
15                 throws ConduitException
16         {
17                 try {
18                         fb_ = new FritzBox(
19                                                 Config.get("fritzbox-password"),
20                                                 Config.get("fritzbox-url","http://fritz.box"));
21                 } catch (SAXException e) {
22                         throw new ConduitException(e);
23                 } catch (IOException e) {
24                         throw new ConduitException(e);
25                 }
26         }
27
28         @Override
29         public Exporter exporter()
30                 throws ConduitException
31         {
32                 try {
33                         return new FritzAddressbookExporter(fb_.importAddressbook());
34                 }
35                 catch (IOException e) {
36                         throw new ConduitException(e);
37                 }
38         }
39
40         @Override
41         public Importer importer()
42                 throws ConduitException
43         {
44                 try {
45                         return new FritzAddressbookImporter(fb_.exportAddressbook());
46                 }
47                 catch (IOException e) {
48                         throw new ConduitException(e);
49                 } catch (SAXException e) {
50                         throw new ConduitException(e);
51                 }
52         }
53 }