// Return value determins persistancy for Event queue public bool Push(BackendEvent event_) { if (event_ is BackendEventMessage) { var messageEvent = event_ as BackendEventMessage; return(Process(messageEvent.Tag)); } else if (event_ is BackendEventState) { var stateEvent = event_ as BackendEventState; UpdateBadge(); } else if (event_ is BackendEventError) { var errorEvent = event_ as BackendEventError; NotifyError(errorEvent.Policy, Helper.Translate("Error") + ": " + Helper.Translate("ErrorType" + errorEvent.Error.ToString())); } else if (event_ is BackendEventRequest) { var requestEvent = event_ as BackendEventRequest; if (requestEvent.RequestType == RequestType.BackgroundAccess) { if (!windowVisible) { NotifyError(XMPP.ErrorPolicyType.Severe, Helper.Translate("NotifyBackgroundAccess")); } } } else if (event_ is BackendEventWindows) { var windowsEvent = event_ as BackendEventWindows; if (windowsEvent.WindowsType == WindowsType.UserAway || windowsEvent.WindowsType == WindowsType.UserPresent) // Es hat mit autoaway zutun { var settings = new Settings(); if (settings.autoAway) // Autoaway ist an { var status = new Status(); // Der user ist nicht am rechner und war bisher online also sind alle voraussetzungen erfuellt if (windowsEvent.WindowsType == WindowsType.UserAway && status.status == StatusType.Available) { Helper.PublishState(StatusType.Away, settings.autoAwayMessage); } // Der nutzer ist am rechner, egal was vorher war, er will seinen eigentlichen status gebroadcasted haben if (windowsEvent.WindowsType == WindowsType.UserPresent) { Helper.PublishState(status.status, status.message); } } } } return(false); }
public void Enqueue(BackendEvent newEvent) { _accessMutex.WaitOne(10000); _accessMutex.Reset(); if (newEvent.Type == EventType.Message) { var messageEvent = newEvent as BackendEventMessage; if (newEvent.Persist) { AddPersistant(messageEvent.UUID, messageEvent.Tag.ToString()); } } _events.Enqueue(newEvent); _accessMutex.Set(); NewEvent(); }
public BackendEvent Dequeue() { BackendEvent dequeueEvent = null; _accessMutex.WaitOne(10000); _accessMutex.Reset(); if (_events.Count > 0) { dequeueEvent = _events.Dequeue(); if (dequeueEvent != null && dequeueEvent.Type == EventType.Message) { var messageEvent = dequeueEvent as BackendEventMessage; RemovePersistant(messageEvent.UUID); } } _accessMutex.Set(); return(dequeueEvent); }
private void OnEvent(BackendEvent newEvent) { if (newEvent is BackendEventError) { var error = newEvent as BackendEventError; if (error.Policy == ErrorPolicyType.Deactivate) { try { var accounts = new Accounts(); var account = accounts[error.Id]; if (account != null) { account.persistantState = AccountState.Disabled; account.forceDisabled = true; } } catch { } } } if (_notifier != null) { // Returns true if user relevant if (_notifier.Push(newEvent)) newEvent.Persist = true; } _events.Enqueue(newEvent); }
public ConnectionEvent(BackendEvent event_) {Event = event_; }
private void PushEvent(BackendEvent event_) { PushEvent(this, new ConnectionEvent(event_)); }
public ConnectionEvent(BackendEvent event_) { Event = event_; }
public void Enqueue(BackendEvent newEvent) { _accessMutex.WaitOne(4000); _accessMutex.Reset(); if (newEvent.Type == EventType.Message) { var messageEvent = newEvent as BackendEventMessage; if( newEvent.Persist ) AddPersistant(messageEvent.UUID, messageEvent.Tag.ToString()); } _events.Enqueue(newEvent); _accessMutex.Set(); NewEvent(); }