/// <summary> /// Sets the user's mood to the specified mood value. /// </summary> /// <param name="mood">A value from the Mood enumeration to set the user's /// mood to.</param> /// <param name="description">A natural-language description of, or reason /// for, the mood.</param> public void SetMood(Mood mood, string description = null) { var xml = Xml.Element("mood", "http://jabber.org/protocol/mood") .Child(Xml.Element(MoodToTagName(mood))); if (description != null) { xml.Child(Xml.Element("text").Text(description)); } pep.Publish("http://jabber.org/protocol/mood", null, xml); }
/// <summary> /// Sets the user's activity to the specified activity value(s). /// </summary> /// <param name="activity">A value from the GeneralActivity enumeration to /// set the user's general activity to.</param> /// <param name="specific">A value from the SpecificActivity enumeration /// best describing the user's activity in more detail.</param> /// <param name="description">A natural-language description of, or reason /// for, the activity.</param> public void SetActivity(GeneralActivity activity, SpecificActivity specific = SpecificActivity.Other, string description = null) { var xml = Xml.Element("activity", "http://jabber.org/protocol/activity"); var e = Xml.Element(GeneralActivityToTagName(activity)); if (specific != SpecificActivity.Other) { e.Child(Xml.Element(SpecificActivityToTagName(specific))); } xml.Child(e); if (description != null) { xml.Child(Xml.Element("text").Text(description)); } pep.Publish("http://jabber.org/protocol/activity", null, xml); }
/// <summary> /// Publishes the specified music information to contacts on the user's /// roster. /// </summary> /// <param name="title">The title of the song or piece.</param> /// <param name="artist">The artist or performer of the song or piece.</param> /// <param name="track">A unique identifier for the tune; e.g., the track number /// within a collection or the specific URI for the object (e.g., a /// stream or audio file).</param> /// <param name="length">The duration of the song or piece in seconds.</param> /// <param name="rating">The user's rating of the song or piece, from 1 /// (lowest) to 10 (highest).</param> /// <param name="source">The collection (e.g., album) or other source /// (e.g., a band website that hosts streams or audio files).</param> /// <param name="uri">A URI or URL pointing to information about the song, /// collection, or artist</param> /// <exception cref="NotSupportedException">The server does not support the /// 'Personal Eventing Protocol' extension.</exception> /// <exception cref="XmppErrorException">The server returned an XMPP error code. /// Use the Error property of the XmppErrorException to obtain the specific /// error condition.</exception> /// <exception cref="XmppException">The server returned invalid data or another /// unspecified XMPP error occurred.</exception> /// <remarks>Publishing no information (i.e. calling Publish without any parameters /// is considered a "stop command" to disable publishing).</remarks> public void Publish(string title = null, string artist = null, string track = null, int length = 0, int rating = 0, string source = null, string uri = null) { length.ThrowIfOutOfRange(0, Int16.MaxValue); rating.ThrowIfOutOfRange(0, 10); var tune = Xml.Element("tune", "http://jabber.org/protocol/tune"); if (!String.IsNullOrEmpty(title)) { tune.Child(Xml.Element("title").Text(title)); } if (!String.IsNullOrEmpty(artist)) { tune.Child(Xml.Element("artist").Text(artist)); } if (!String.IsNullOrEmpty(track)) { tune.Child(Xml.Element("track").Text(track)); } if (length > 0) { tune.Child(Xml.Element("length").Text(length.ToString())); } if (rating > 0) { tune.Child(Xml.Element("rating").Text(rating.ToString())); } if (!String.IsNullOrEmpty(source)) { tune.Child(Xml.Element("source").Text(source)); } if (!String.IsNullOrEmpty(uri)) { tune.Child(Xml.Element("uri").Text(uri)); } pep.Publish("http://jabber.org/protocol/tune", null, tune); }