func buildVerifyFingerprintDialog(accountName string, ourFp []byte, uid string, theirFp []byte) *gtk.Dialog { var message string var builderName string if theirFp == nil { builderName = "VerifyFingerprintUnknown" message = fmt.Sprintf(i18n.Local( "You can't verify the fingerprint for %s yet.\n"+ "You first have to start an encrypted conversation with them.", ), uid) } else { m := i18n.Local(` Is this the correct fingerprint for %[1]s? Fingerprint for you (%[3]s): %[4]s Purported fingerprint for %[1]s: %[2]s `) message = fmt.Sprintf(m, uid, config.FormatFingerprint(theirFp), accountName, config.FormatFingerprint(ourFp), ) builderName = "VerifyFingerprint" } builder := builderForDefinition(builderName) obj, _ := builder.GetObject("dialog") dialog := obj.(*gtk.Dialog) obj, _ = builder.GetObject("message") l := obj.(*gtk.Label) l.SetText(message) l.SetSelectable(true) dialog.SetTitle(fmt.Sprintf(i18n.Local("Verify fingerprint for %s"), uid)) return dialog }
func formattedFingerprintsFor(s access.Session) string { result := "" if s != nil { for _, sk := range s.PrivateKeys() { pk := sk.PublicKey() if pk != nil { result = fmt.Sprintf("%s%s%s\n", result, " ", config.FormatFingerprint(pk.Fingerprint())) } } } return result }
func (u *gtkUI) chooseKeyToImport(keys map[string][]byte) ([]byte, bool) { result := make(chan int) parsedKeys := make(map[string]otr3.PrivateKey) for v, vv := range keys { _, ok, parsedKey := otr3.ParsePrivateKey(vv) if ok { parsedKeys[v] = parsedKey } } sortedKeys := sortKeys(parsedKeys) doInUIThread(func() { builder := newBuilder("ChooseKeyToImport") d := builder.getObj("dialog").(gtki.Dialog) d.SetTransientFor(u.window) keyBox := builder.getObj("keys").(gtki.ComboBoxText) for _, s := range sortedKeys { kval := parsedKeys[s] keyBox.AppendText(fmt.Sprintf("%s -- %s", s, config.FormatFingerprint(kval.PublicKey().Fingerprint()))) } keyBox.SetActive(0) builder.ConnectSignals(map[string]interface{}{ "on_import_signal": func() { ix := keyBox.GetActive() if ix != -1 { result <- ix close(result) d.Destroy() } }, "on_cancel_signal": func() { close(result) d.Destroy() }, }) d.ShowAll() }) res, ok := <-result if ok { return keys[sortedKeys[res]], true } return nil, false }
func parseFromConfig(cu *config.Account) []otr3.PrivateKey { var result []otr3.PrivateKey allKeys := cu.AllPrivateKeys() log.Printf("Loading %d configured keys", len(allKeys)) for _, pp := range allKeys { _, ok, parsedKey := otr3.ParsePrivateKey(pp) if ok { result = append(result, parsedKey) log.Printf("Loaded key: %s", config.FormatFingerprint(parsedKey.PublicKey().Fingerprint())) } } return result }
func (u *gtkUI) showFingerprintsForPeer(jid string, account *account) { builder := builderForDefinition("PeerFingerprints") dialog := getObjIgnoringErrors(builder, "dialog").(*gtk.Dialog) info := getObjIgnoringErrors(builder, "information").(*gtk.Label) grid := getObjIgnoringErrors(builder, "grid").(*gtk.Grid) info.SetSelectable(true) fprs := []*config.Fingerprint{} p, ok := account.session.GetConfig().GetPeer(jid) if ok { fprs = p.Fingerprints } if len(fprs) == 0 { info.SetText(fmt.Sprintf(i18n.Local("There are no known fingerprints for %s"), jid)) } else { info.SetText(fmt.Sprintf(i18n.Local("These are the fingerprints known for %s:"), jid)) } for ix, fpr := range fprs { flabel, _ := gtk.LabelNew(config.FormatFingerprint(fpr.Fingerprint)) flabel.SetSelectable(true) trusted := i18n.Local("not trusted") if fpr.Trusted { trusted = i18n.Local("trusted") } ftrusted, _ := gtk.LabelNew(trusted) ftrusted.SetSelectable(true) grid.Attach(flabel, 0, ix, 1, 1) grid.Attach(ftrusted, 1, ix, 1, 1) } builder.ConnectSignals(map[string]interface{}{ "on_close_signal": func() { dialog.Destroy() }, }) dialog.SetTransientFor(u.window) dialog.ShowAll() }