예제 #1
0
func newAccount(conf *config.ApplicationConfig, currentConf *config.Account) *account {
	return &account{
		session:              session.NewSession(conf, currentConf),
		conversations:        make(map[string]*conversationWindow),
		delayedConversations: make(map[string][]func(*conversationWindow)),
	}
}
예제 #2
0
파일: ui.go 프로젝트: PMaynard/coyim
func (c *cliUI) loadConfig(configFile string) error {
	accounts, ok, err := config.LoadOrCreate(configFile, config.FunctionKeySupplier(c.getMasterPassword))
	if !ok {
		c.alert("Couldn't open encrypted file - did you enter your password correctly?")
		return errors.New("couldn't open encrypted file - did you supply the wrong password?")
	}
	if err != nil {
		c.alert(err.Error())
		acc, e := accounts.AddNewAccount()
		if e != nil {
			return e
		}
		if !enroll(accounts, acc, c.term) {
			return errors.New("asked to quit")
		}
	}

	account := findAccount(config.AccountFlag, accounts.Accounts)

	var password string
	if len(account.Password) == 0 {
		var err error

		password, err = c.term.ReadPassword(
			fmt.Sprintf("Password for %s (will not be saved to disk): ", account.Account),
		)
		if err != nil {
			c.alert(err.Error())
			return err
		}
	} else {
		password = account.Password
	}

	logger := &lineLogger{c.term, nil}

	//TODO: call session.ConnectAndRegister() in this case
	//var registerCallback xmpp.FormCallback
	//if *config.CreateAccount {
	//	registerCallback = c.RegisterCallback
	//}

	c.session = session.NewSession(accounts, account)
	c.session.SessionEventHandler = c
	c.session.Subscribe(c.events)

	c.session.ConnectionLogger = logger
	if err := c.session.Connect(password); err != nil {
		c.alert(err.Error())
		return err
	}

	return nil
}
예제 #3
0
파일: account.go 프로젝트: 0x27/coyim
func newAccount(conf *config.ApplicationConfig, currentConf *config.Account) (acc *account, err error) {
	return &account{
		session:       session.NewSession(conf, currentConf),
		conversations: make(map[string]*conversationWindow),
	}, nil
}