Example #1
1
func (g *gajimImporter) importOTRSettings(f string) (map[string]gajimOTRSettings, map[gajimAccountAndPeer]gajimOTRSettings, bool) {
	file, err := os.Open(f)
	if err != nil {
		return nil, nil, false
	}
	defer file.Close()
	res, err := stalecucumber.DictString(stalecucumber.Unpickle(file))
	if err != nil {
		return nil, nil, false
	}

	resAccount := make(map[string]gajimOTRSettings)
	resAccountToPeer := make(map[gajimAccountAndPeer]gajimOTRSettings)

	for k, v := range res {
		vv, err := stalecucumber.Dict(v, nil)
		if err == nil {
			for k2, v2 := range vv {
				vv2, _ := stalecucumber.DictString(v2, nil)
				settings := intoGajimOTRSettings(vv2)
				switch k2.(type) {
				case string:
					resAccountToPeer[gajimAccountAndPeer{k, k2.(string)}] = settings
				default:
					resAccount[k] = settings
				}
			}
		}
	}

	return resAccount, resAccountToPeer, true
}
Example #2
0
func (p *PickleSerializer) Loads(reader *strings.Reader) (map[string]interface{}, error) {
	return stalecucumber.DictString(stalecucumber.Unpickle(reader))
}