public void CreateInformative(NotificationInfoType infoType, string account, string from) { try { var accountObj = Frontend.Accounts[account]; if (accountObj == null) return; var fromJID = new JID(from); var contact = accountObj.Roster[fromJID.Bare]; if (contact == null) return; var notification = new Notification(); notification.Account = account; notification.Type = NotificationType.Request; switch (infoType) { case NotificationInfoType.Subscribed: // Notify that he now sends you updates to his status notification.Message = fromJID.Bare + " " + Helper.Translate("SubscriptionAllowed"); break; case NotificationInfoType.Unsubscribed: // Notify that he dosn't send you updates to his status anymore notification.Message = fromJID.Bare + " " + Helper.Translate("SubscriptionRevoked"); break; case NotificationInfoType.Unsubscribe: // Notify that he dosn't want to see your updates anymore notification.Message = fromJID.Bare + " " + Helper.Translate("SubscriptionUnsubscribed"); break; } notification.Action = FlyoutType.Subscription; notification.Data = contact; AddNotification(notification); } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
public void CreateError(ErrorPolicyType errorType, string account, string message, string details = "") { try { if (errorType != ErrorPolicyType.Informative || Frontend.Settings.showInformativeErrors) { var notification = new Notification(); notification.Account = account; notification.Type = NotificationType.Error; notification.Message = message; notification.Details = details; switch (errorType) { case ErrorPolicyType.Deactivate: { notification.Action = FlyoutType.AccountListEdit; break; } case ErrorPolicyType.Informative: { notification.Action = FlyoutType.None; break; } case ErrorPolicyType.Severe: { notification.Action = FlyoutType.None; break; } } notification.Data = null; AddNotification(notification); } } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
public void CreateRequest(NotificationRequestType requestType, string account, string from) { try { var accountObj = Frontend.Accounts[account]; if (accountObj == null) return; var fromJID = new JID(from); var contact = accountObj.Roster[fromJID.Bare]; if (contact == null) return; var notification = new Notification(); notification.Account = account; notification.Type = NotificationType.Request; if (requestType == NotificationRequestType.Subscribe) { notification.Message = fromJID.Bare + " " + Helper.Translate("SubscriptionRequest"); notification.Action = FlyoutType.Subscription; notification.Data = contact; } AddNotification(notification); } catch (Exception uiEx) { Frontend.UIError(uiEx); } }
private void AddNotification(Notification notification) { foreach (var not in NotificationList) { if (not.Equals(notification)) return; } NotificationList.Add(notification); }