Пример #1
0
        public StatusEdit(Flyout self)
        {
            this.InitializeComponent();
            flyoutSelf = self;

            this.DataContext = Frontend.Status;

            CurrentStatus = Frontend.Status;

            if( CurrentStatus != null )
            {
                this.Avatar.AvatarImage = CurrentStatus.ImageData;
                this.Message.Text = CurrentStatus.message;

                foreach (ComboBoxItem status in StatusSelector.Items)
                {
                    if (Convert.ToInt32(status.Tag) == (int)CurrentStatus.status)
                        StatusSelector.SelectedItem = status;
                }

                if (StatusSelector.SelectedItem == null)
                    StatusSelector.SelectedItem = Offline;
            }
        }
Пример #2
0
        private void OnReady(object sender, EventArgs e)
        {
            _lastError = ErrorType.None;
            PushEvent(StateType.Running);

            Status statusStore = new Status();
            Helper.PublishState(Id, statusStore.status, statusStore.message);
        }
Пример #3
0
        public void Update() 
        {
            _settingMutex.WaitOne(4000);
            _settingMutex.Reset();

            Accounts accounts = new Accounts();
            Status status = new Status();

            // get obsolete
            List<string> removeList = new List<string>();
            foreach( var connection in this._connectionList )
            {
                if( accounts[connection.Key] == null )
                    removeList.Add(connection.Key);
            }

            // Remove obsolete
            foreach (var item in removeList)
            {
                _connectionList[item].Clean();
                _connectionList.Remove(item);
            }
            // Add new and update existing
            foreach (Account server in accounts)
            {
                if (server.IsValid())
                {
                    // Create new parameters
                    var parameters = new ConnectionParameters();
                    parameters.Hostname = server.host;
                    parameters.JID = server.jid;
                    parameters.Password = server.password;
                    parameters.UseSSL = server.usesssl;
                    parameters.OldStyleSSL = server.oldstylessl;
                    parameters.AuthPlain = server.authplain;
                    parameters.AuthMD5 = server.authmd5;
                    parameters.AuthSCRAM = server.authscram;
                    parameters.AuthOAUTH2= server.authoauth2;
                    parameters.RequestConnectedStandby = server.requestConnectedStandby;
                    parameters.Port = server.port;

                    // Messanger is offline? Do so!
                    if (status.status == StatusType.Offline)
                        parameters.State = AccountState.Disabled;
                    else
                        parameters.State = server.persistantState;

                    parameters.UpdatedSettings = server.ResetChangedState();

                    if (parameters.RequestConnectedStandby && BackgroundExecutionManager.GetAccessStatus() != BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity)
                        _backend.OnConnectionEvent(this, new ConnectionEvent(new BackendEventError(parameters.JID, ErrorType.NoHardwareSlotsAllowed, ErrorPolicyType.Deactivate)));

                    // Add new server
                    if (!_connectionList.ContainsKey(server.jid))
                    {
                        try
                        {
                            Connection newConnection = new Connection(server.jid);
                            newConnection.OnEvent += _backend.OnConnectionEvent;
                            _connectionList[server.jid] = newConnection;

                            parameters.UpdatedSettings = true;
#if DEBUG
                            _backend.OnConnectionEvent(this, new ConnectionEvent(new BackendEventLog("", LogType.Info, "Server with name " + server.title + " added")));
#endif
                        }
                        catch
                        {
#if DEBUG
                            _backend.OnConnectionEvent(this, new ConnectionEvent(new BackendEventLog("", LogType.Error, "Adding server with name " + server.title + " failed")));
#endif
                            _settingMutex.Set();
                        }
                    }

                    // Get connection
                    Connection currentConnection = _connectionList[server.jid];

                    // Update
                    currentConnection.Update(parameters);
                }
                else if( !server.forceDisabled )
                {
                    _backend.OnConnectionEvent(this, new ConnectionEvent(new BackendEventError(server.jid, ErrorType.InvalidSettings, ErrorPolicyType.Deactivate)));
#if DEBUG
                    _backend.OnConnectionEvent(this, new ConnectionEvent(new BackendEventLog("", LogType.Error, "Server with name " + server.title + " is invalid")));
#endif
                }
            }

            _settingMutex.Set();        
        }