public static void SetMood(Enums.MoodType type, string message) { try { JABBER_CLIENT.Presence.setMood(type, message); } catch (Exception e) { Log.Error(e); } }
/// <summary> /// Change son hummeur /// </summary> /// <param name="type">Type de l'hummeur</param> /// <param name="text">Description</param> public void setMood(Enums.MoodType type, string text) { if (Jabber.xmpp.Authenticated && Jabber._pepCapable) { agsXMPP.protocol.client.IQ iq = new agsXMPP.protocol.client.IQ(); iq.Type = agsXMPP.protocol.client.IqType.set; iq.GenerateId(); agsXMPP.Xml.Dom.Element pb = new agsXMPP.Xml.Dom.Element("pubsub"); pb.Namespace = "http://jabber.org/protocol/pubsub"; agsXMPP.Xml.Dom.Element ps = new agsXMPP.Xml.Dom.Element("publish"); ps.Attributes.Add("node", "http://jabber.org/protocol/mood"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element mood = new agsXMPP.Xml.Dom.Element("mood"); mood.Namespace = "http://jabber.org/protocol/mood"; agsXMPP.Xml.Dom.Element moodType = new agsXMPP.Xml.Dom.Element(Enum.GetName(typeof(Enums.MoodType), type)); mood.AddChild(moodType); agsXMPP.Xml.Dom.Element moodText = new agsXMPP.Xml.Dom.Element("text"); moodText.Value = text; mood.AddChild(moodText); item.AddChild(mood); ps.AddChild(item); pb.AddChild(ps); agsXMPP.Xml.Dom.Element conf = new agsXMPP.Xml.Dom.Element("configure"); agsXMPP.Xml.Dom.Element x = new agsXMPP.Xml.Dom.Element("x"); agsXMPP.Xml.Dom.Element field1 = new agsXMPP.Xml.Dom.Element("field"); field1.Attributes.Add("type", "hidden"); field1.Attributes.Add("var", "FORM_TYPE"); agsXMPP.Xml.Dom.Element value1 = new agsXMPP.Xml.Dom.Element("value"); value1.Value = "http://jabber.org/protocol/pubsub#node_config"; field1.AddChild(value1); x.AddChild(field1); agsXMPP.Xml.Dom.Element field2 = new agsXMPP.Xml.Dom.Element("field"); field2.Attributes.Add("var", "pubsub#access_model"); agsXMPP.Xml.Dom.Element value2 = new agsXMPP.Xml.Dom.Element("value"); value2.Value = "presence"; field2.AddChild(value2); x.AddChild(field2); conf.AddChild(x); pb.AddChild(conf); iq.AddChild(pb); Jabber.xmpp.Send(iq); _mood = new Mood(); _mood.type = type; _mood.text = text; } }
/// <summary> /// Load the settings from the mediaportal config /// </summary> public static void Load() { using (MediaPortal.Profile.Settings reader = new MediaPortal.Profile.Settings(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Config, "MediaPortal.xml"))) { username = reader.GetValue(Helper.PLUGIN_NAME, "username"); server = reader.GetValue(Helper.PLUGIN_NAME, "server"); string tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "resource"); if (!String.IsNullOrEmpty(tmpSettingsString)) { resource = tmpSettingsString; } string encryptedPassword = reader.GetValue(Helper.PLUGIN_NAME, "password"); password = decryptString(encryptedPassword); autoConnectStartup = reader.GetValueAsBool(Helper.PLUGIN_NAME, "autoConnectStartup", autoConnectStartup); notifyOnMessagePlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMessagePlugin", notifyOnMessagePlugin); notifyOnMessageGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMessageGlobally", notifyOnMessageGlobally); notifyOnStatusPlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnStatusPlugin", notifyOnStatusPlugin); notifyOnStatusGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnStatusGlobally", notifyOnStatusGlobally); notifyOnMoodPlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMoodPlugin", notifyOnMoodPlugin); notifyOnMoodGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnMoodGlobally", notifyOnMoodGlobally); notifyOnActivityPlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnActivityPlugin", notifyOnActivityPlugin); notifyOnActivityGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnActivityGlobally", notifyOnActivityGlobally); notifyOnTunePlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnTunePlugin", notifyOnTunePlugin); notifyOnTuneGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnTuneGlobally", notifyOnTuneGlobally); notifyOnErrorPlugin = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnErrorPlugin", notifyOnErrorPlugin); notifyOnErrorGlobally = reader.GetValueAsBool(Helper.PLUGIN_NAME, "notifyOnErrorGlobally", notifyOnErrorGlobally); selectStatusOnStartup = reader.GetValueAsBool(Helper.PLUGIN_NAME, "selectStatusOnStartup", selectStatusOnStartup); notifyTimeOut = reader.GetValueAsInt(Helper.PLUGIN_NAME, "notifyTimeOut", notifyTimeOut); autoIdleTimeOut = reader.GetValueAsInt(Helper.PLUGIN_NAME, "autoIdleTimeOut", autoIdleTimeOut); autoIdleStatusType = (Enums.StatusType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "autoIdleStatusType", (int)autoIdleStatusType); tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "autoIdleStatusMessage"); if (!String.IsNullOrEmpty(tmpSettingsString)) { autoIdleStatusMessage = tmpSettingsString; } defaultStatusType = (Enums.StatusType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultStatusType", (int)defaultStatusType); tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "defaultStatusMessage"); if (!String.IsNullOrEmpty(tmpSettingsString)) { defaultStatusMessage = tmpSettingsString; } defaultMoodType = (Enums.MoodType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultMoodType", (int)defaultMoodType); tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "defaultMoodMessage"); if (!String.IsNullOrEmpty(tmpSettingsString)) { defaultMoodMessage = tmpSettingsString; } defaultActivityType = (Enums.ActivityType)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultActivityType", (int)defaultActivityType); tmpSettingsString = reader.GetValue(Helper.PLUGIN_NAME, "defaultActivityMessage"); if (!String.IsNullOrEmpty(tmpSettingsString)) { defaultActivityMessage = tmpSettingsString; } notifyWindowType = (Helper.PLUGIN_NOTIFY_WINDOWS)reader.GetValueAsInt(Helper.PLUGIN_NAME, "notifyWindowType", (int)notifyWindowType); defaultKeyboardType = (Dialog.KeyBoardTypes)reader.GetValueAsInt(Helper.PLUGIN_NAME, "defaultKeyboardType", (int)Dialog.KeyBoardTypes.Default); publishTuneInfo = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishTuneInfo", publishTuneInfo); publishActivityMusic = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityMusic", publishActivityMusic); publishActivityRadio = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityRadio", publishActivityRadio); publishActivityMovie = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityMovie", publishActivityMovie); publishActivityTV = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityTV", publishActivityTV); publishActivityRecording = reader.GetValueAsBool(Helper.PLUGIN_NAME, "publishActivityRecording", publishActivityRecording); } }