Example #1
0
    def saveFile(self, file):
        json = pj.JsonDocument()

        # Write endpoint config
        json.writeObject(self.epConfig)

        # Write transport config
        tp_node = json.writeNewArray("transports")
        self.udp.writeObject(tp_node)
        self.tcp.writeObject(tp_node)
        self.tls.writeObject(tp_node)

        # Write account configs
        node = json.writeNewArray("accounts")
        for acc in self.accounts:
            acc.writeObject(node)
        json.saveFile(file)
Example #2
0
    def loadFile(self, file):
        json = pj.JsonDocument()
        json.loadFile(file)
        root = json.getRootContainer()
        self.epConfig = pj.EpConfig()
        self.epConfig.readObject(root)

        tp_node = root.readArray("transports")
        self.udp.readObject(tp_node)
        self.tcp.readObject(tp_node)
        if tp_node.hasUnread():
            self.tls.readObject(tp_node)

        acc_node = root.readArray("accounts")
        while acc_node.hasUnread():
            acfg = AccConfig()
            acfg.readObject(acc_node)
            self.accounts.append(acfg)