Esempio n. 1
0
        private bool ValidateConnectionConfig(ConnectionConfig config)
        {
            var context = new ValidationContext(config, null, null);
            var results = new List<ValidationResult>();
            bool result = Validator.TryValidateObject(config, context, results);

            if (!result)
                Authenticated(this, new AuthenticationEventArgs(ConnectionErrorKind.InvalidConfig,
                                                                results.CollectionToString(i => i.ErrorMessage)));

            return result;
        }
Esempio n. 2
0
 public Profile()
 {
     Theme = "Default";
     ConnectionConfig = new ConnectionConfig();
 }
Esempio n. 3
0
        /// <summary>
        /// Start authentication proccess.
        /// You have to add handler for <code>OnAuthenticated</code> to recieve the result
        /// </summary>
        public void BeginAuthentication(ConnectionConfig info)
        {
            if (!ValidateConnectionConfig(info))
                return;

            jabberClient.Server = info.Server;
            jabberClient.NetworkHost = info.NetworkHost;
            jabberClient.User = info.User;
            jabberClient.Password = info.Password;
            jabberClient.Port = info.Port;
            jabberClient.Resource = "cyclops v." + Assembly.GetAssembly(GetType()).GetName().Version.ToString(3);


            Jid = new JID(info.User, info.Server, jabberClient.Resource);
            ConnectionConfig = info;

            // some default settings
            jabberClient.AutoReconnect = -1;


            jabberClient[Options.SASL_MECHANISMS] = MechanismType.PLAIN;
            jabberClient.KeepAlive = 20F;

            //let's go!
            IsAuthenticating = true;
            jabberClient.Connect();
        }