Esempio n. 1
0
        private string InternalHandleNotificationsCommand(MsnConversation msnConversation, IList <string> arguments)
        {
            string contactMail = msnConversation.Contact.Account;

            lock (_notificationsLock)
            {
                EnsureNotificationContactFilter();

                bool   settingChanged = false;
                string onOff          = arguments.Count > 0 ? arguments[0].Trim() : String.Empty;
                if (onOff == "off")
                {
                    settingChanged = _notificationContactFilter.AddAddress(contactMail);
                }
                else if (onOff == "on")
                {
                    settingChanged = _notificationContactFilter.RemoveAddress(contactMail);
                }
                if (settingChanged)
                {
                    using (ConfigurationServiceAgent configurationAgent = new ConfigurationServiceAgent())
                    {
                        configurationAgent.SetStringValue(ConfigurationModule.Messenger, ConfigurationKey.Messenger.MsnNotificationFilterList, _notificationContactFilter.ToString());
                    }
                }
                return(_notificationContactFilter.ContainsAddress(contactMail) ? "Notifications are off." : "Notifications are on.");
            }
        }
Esempio n. 2
0
        private bool BroadcastAlert(AddressList alertContactFilter, UpcomingProgram upcomingAlert)
        {
            bool result = false;

            if (_messenger.Nameserver.IsSignedIn)
            {
                foreach (Contact contact in _messenger.ContactList.Allowed)
                {
                    if (!alertContactFilter.ContainsAddress(contact.Account) &&
                        BroadcastingAllowed(contact.Status))
                    {
                        StringBuilder text = new StringBuilder();
                        if (upcomingAlert.StartTime > DateTime.Now)
                        {
                            text.AppendLine("ALERT! This program is about to start:");
                        }
                        else
                        {
                            text.AppendLine("ALERT! This program has already started:");
                        }
                        Utility.AppendProgramDetails(text, upcomingAlert.Channel, upcomingAlert);

                        if (result)
                        {
                            // We just sent out an alert, seems this is needed to give the system
                            // some extra time :-(
                            Thread.Sleep(100);
                        }
                        BroadcastMessage(contact, text.ToString());
                        result = true;
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        private string InternalHandleAlertsCommand(MsnConversation msnConversation, IList <string> arguments)
        {
            string contactMail = msnConversation.Contact.Account;

            lock (_alertsLock)
            {
                EnsureAlertContactFilter();

                bool   settingChanged = false;
                string onOff          = arguments.Count > 0 ? arguments[0].Trim() : String.Empty;
                if (onOff == "off")
                {
                    settingChanged = _alertContactFilter.AddAddress(contactMail);
                }
                else if (onOff == "on")
                {
                    settingChanged = _alertContactFilter.RemoveAddress(contactMail);
                }
                if (settingChanged)
                {
                    Proxies.ConfigurationService.SetStringValue(ConfigurationModule.Messenger, ConfigurationKey.Messenger.MsnAlertFilterList, _alertContactFilter.ToString()).Wait();
                }
                return(_alertContactFilter.ContainsAddress(contactMail) ? "Alerts are off." : "Alerts are on.");
            }
        }
Esempio n. 4
0
        private bool BroadcastMessageToAddressList(AddressList addressList, string message)
        {
            bool result = false;

            if (_messenger.Nameserver.IsSignedIn)
            {
                foreach (Contact contact in _messenger.ContactList.Allowed)
                {
                    if (!addressList.ContainsAddress(contact.Account) &&
                        BroadcastingAllowed(contact.Status))
                    {
                        if (result)
                        {
                            // We just sent out a message, seems this is needed to give the system
                            // some extra time :-(
                            Thread.Sleep(100);
                        }
                        BroadcastMessage(contact, message);
                        result = true;
                    }
                }
            }
            return(result);
        }
Esempio n. 5
0
        private bool BroadcastMessageToAddressList(AddressList addressList, string message)
        {
            bool result = false;

            if (_messenger.Nameserver.IsSignedIn)
            {
                foreach (Contact contact in _messenger.ContactList.Allowed)
                {
                    if (!addressList.ContainsAddress(contact.Account) &&
                        BroadcastingAllowed(contact.Status))
                    {                        
                        if (result)
                        {
                            // We just sent out a message, seems this is needed to give the system
                            // some extra time :-(
                            Thread.Sleep(100);
                        }
                        BroadcastMessage(contact, message);
                        result = true;
                    }
                }
            }
            return result;
        }
Esempio n. 6
0
        private bool BroadcastAlert(AddressList alertContactFilter, UpcomingProgram upcomingAlert)
        {
            bool result = false;

            if (_messenger.Nameserver.IsSignedIn)
            {
                foreach (Contact contact in _messenger.ContactList.Allowed)
                {
                    if (!alertContactFilter.ContainsAddress(contact.Account) &&
                        BroadcastingAllowed(contact.Status) )
                    {                        
                        StringBuilder text = new StringBuilder();
                        if (upcomingAlert.StartTime > DateTime.Now)
                        {
                            text.AppendLine("ALERT! This program is about to start:");
                        }
                        else
                        {
                            text.AppendLine("ALERT! This program has already started:");
                        }
                        Utility.AppendProgramDetails(text, upcomingAlert.Channel, upcomingAlert);

                        if (result)
                        {
                            // We just sent out an alert, seems this is needed to give the system
                            // some extra time :-(
                            Thread.Sleep(100);
                        }
                        BroadcastMessage(contact, text.ToString());
                        result = true;
                    }
                }
            }
            return result;
        }