Пример #1
0
 private void OnActivityUpdated(Contact contact, Activity activity)
 {
     try
     {
         ActivityUpdated(contact, activity);
     }
     catch { }
 }
Пример #2
0
 /// <summary>
 /// Se produit lorsqu'un message est disponible
 /// </summary>
 /// <param name="sender">Objet parent</param>
 /// <param name="message">Message en question</param>
 private void xmppOnMessage(object sender, agsXMPP.protocol.client.Message message)
 {
     if (message.From != null)
     {
         string bare = message.From.Bare;
         if (message.From.Resource != null && message.Nickname != null)
         {
             if (contacts.ContainsKey(bare) && contacts[bare].ContainsKey(message.From.Resource) && message.Nickname.ToString().Trim() != string.Empty)
             {
                 contacts[bare][message.From.Resource].identity.nickname = message.Nickname.ToString().Trim();
             }
         }
         if (message.HasTag("event"))
         {
             agsXMPP.Xml.Dom.Element evt = message.SelectSingleElement("event");
             if (evt.Namespace == "http://jabber.org/protocol/pubsub#event" && evt.HasChildElements)
             {
                 #region PubSub Events
                 // HACK: Bug serveur. Suivant la XEP c'est Items, ejabberd2.0 retourne parfois Item sans S
                 if (evt.HasTag("items") || evt.HasTag("item"))
                 {
                     agsXMPP.Xml.Dom.Element items = evt.SelectSingleElement("items");
                     if (items == null)
                     {
                         items = evt.SelectSingleElement("item");
                     }
                     if (items.HasTag("item"))
                     {
                         agsXMPP.Xml.Dom.Element item = items.SelectSingleElement("item");
                         // TODO: g�rer le User mood dans les messages chat
                         #region User mood
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/mood" && (item.HasTag("mood") || item.HasTag("retract")))
                         {
                             agsXMPP.Xml.Dom.Element mood = item.SelectSingleElement("mood");
                             if (mood != null)
                             {
                                 // HACK: mood.Namespace == "http://jabber.org/protocol/mood"
                                 if (mood.HasChildElements)
                                 {
                                     Enumerations.MoodType moodType = Enumerations.MoodType.none;
                                     foreach (Enumerations.MoodType mt in Enum.GetValues(typeof(Enumerations.MoodType)))
                                     {
                                         string mtn = Enum.GetName(typeof(Enumerations.MoodType), mt);
                                         if (mood.HasTag(mtn))
                                         {
                                             moodType = mt;
                                             break;
                                         }
                                     }
                                     string moodString = string.Empty;
                                     if (mood.HasTag("text") && mood.SelectSingleElement("text").Value != null)
                                     {
                                         moodString = mood.SelectSingleElement("text").Value.Trim();
                                     }
                                     if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                     {
                                         foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                         {
                                             Mood md = new Mood();
                                             md.type = moodType;
                                             md.text = moodString;
                                             r.Value.mood = md;
                                             OnMoodUpdated(r.Value, r.Value.mood);
                                         }
                                     }
                                     else
                                     {
                                         Mood md = new Mood();
                                         md.type = moodType;
                                         md.text = moodString;
                                         UserPEP up = new UserPEP();
                                         up.mood = md;
                                         if (!initialUserPEP.ContainsKey(bare))
                                         {
                                             initialUserPEP.Add(bare, up);
                                         }
                                         else
                                         {
                                             up.tune = initialUserPEP[bare].tune;
                                             up.activity = initialUserPEP[bare].activity;
                                             up.location = initialUserPEP[bare].location;
                                             initialUserPEP[bare] = up;
                                         }
                                     }
                                 }
                             }
                             else if (item.SelectSingleElement("retract") != null)
                             {
                                 if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                 {
                                     foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                     {
                                         Mood md = new Mood();
                                         md.type = Enumerations.MoodType.none;
                                         md.text = string.Empty;
                                         r.Value.mood = md;
                                         OnMoodUpdated(r.Value, r.Value.mood);
                                     }
                                 }
                                 else
                                 {
                                     Mood md = new Mood();
                                     md.type = Enumerations.MoodType.none;
                                     md.text = string.Empty;
                                     UserPEP up = new UserPEP();
                                     up.mood = md;
                                     if (!initialUserPEP.ContainsKey(bare))
                                     {
                                         initialUserPEP.Add(bare, up);
                                     }
                                     else
                                     {
                                         up.tune = initialUserPEP[bare].tune;
                                         up.activity = initialUserPEP[bare].activity;
                                         up.location = initialUserPEP[bare].location;
                                         initialUserPEP[bare] = up;
                                     }
                                 }
                             }
                         }
                         #endregion
                         #region User activity
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/activity" && (item.HasTag("activity") || item.HasTag("retract")))
                         {
                             agsXMPP.Xml.Dom.Element activity = item.SelectSingleElement("activity");
                             if (activity != null)
                             {
                                 // HACK: activity.Namespace == "http://jabber.org/protocol/activity"
                                 if (activity.HasChildElements)
                                 {
                                     Enumerations.ActivityType activityType = Enumerations.ActivityType.none;
                                     List<string> activityTypes = recurseActivityTags(activity, new List<string>());
                                     activityTypes.Remove("activity");
                                     if (activityTypes.Count > 0)
                                     {
                                         object o = Enum.Parse(typeof(Enumerations.ActivityType), activityTypes[0], true);
                                         if (o != null)
                                         {
                                             activityType = (Enumerations.ActivityType)o;
                                         }
                                     }
                                     string activityString = string.Empty;
                                     if (activity.HasTag("text") && activity.SelectSingleElement("text").Value != null)
                                     {
                                         activityString = activity.SelectSingleElement("text").Value.Trim();
                                     }
                                     if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                     {
                                         foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                         {
                                             Activity a = new Activity();
                                             a.type = activityType;
                                             a.text = activityString;
                                             r.Value.activity = a;
                                             OnActivityUpdated(r.Value, r.Value.activity);
                                         }
                                     }
                                     else
                                     {
                                         Activity a = new Activity();
                                         a.type = activityType;
                                         a.text = activityString;
                                         UserPEP up = new UserPEP();
                                         up.activity = a;
                                         if (!initialUserPEP.ContainsKey(bare))
                                         {
                                             initialUserPEP.Add(bare, up);
                                         }
                                         else
                                         {
                                             up.tune = initialUserPEP[bare].tune;
                                             up.mood = initialUserPEP[bare].mood;
                                             up.location = initialUserPEP[bare].location;
                                             initialUserPEP[bare] = up;
                                         }
                                     }
                                 }
                             }
                             else if (item.SelectSingleElement("retract") != null)
                             {
                                 if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                 {
                                     foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                     {
                                         Activity a = new Activity();
                                         a.type = Enumerations.ActivityType.none;
                                         a.text = string.Empty;
                                         r.Value.activity = a;
                                         OnActivityUpdated(r.Value, r.Value.activity);
                                     }
                                 }
                                 else
                                 {
                                     Activity a = new Activity();
                                     a.type = Enumerations.ActivityType.none;
                                     a.text = string.Empty;
                                     UserPEP up = new UserPEP();
                                     up.activity = a;
                                     if (!initialUserPEP.ContainsKey(bare))
                                     {
                                         initialUserPEP.Add(bare, up);
                                     }
                                     else
                                     {
                                         up.tune = initialUserPEP[bare].tune;
                                         up.mood = initialUserPEP[bare].mood;
                                         up.location = initialUserPEP[bare].location;
                                         initialUserPEP[bare] = up;
                                     }
                                 }
                             }
                         }
                         #endregion
                         #region User location
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/geoloc" && (item.HasTag("geoloc") || item.HasTag("retract")))
                         {
                             agsXMPP.Xml.Dom.Element geoloc = item.SelectSingleElement("geoloc");
                             if (geoloc != null)
                             {
                                 // HACK: geoloc.Namespace == "http://jabber.org/protocol/geoloc"
                                 if (geoloc.HasChildElements)
                                 {
                                     Location l = new Location();
                                     l.altitude = (geoloc.HasTag("alt") && geoloc.SelectSingleElement("alt").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("alt").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.latitude = (geoloc.HasTag("lat") && geoloc.SelectSingleElement("lat").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("lat").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.longitude = (geoloc.HasTag("lon") && geoloc.SelectSingleElement("lon").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("lon").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.bearing = (geoloc.HasTag("bearing") && geoloc.SelectSingleElement("bearing").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("bearing").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.error = (geoloc.HasTag("error") && geoloc.SelectSingleElement("error").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("error").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.speed = (geoloc.HasTag("speed") && geoloc.SelectSingleElement("speed").Value != null) ? Convert.ToDouble(geoloc.SelectSingleElement("speed").Value, System.Globalization.CultureInfo.InvariantCulture) : 0.0d;
                                     l.area = (geoloc.HasTag("area") && geoloc.SelectSingleElement("area").Value != null) ? geoloc.SelectSingleElement("area").Value.Trim() : string.Empty;
                                     l.building = (geoloc.HasTag("building") && geoloc.SelectSingleElement("building").Value != null) ? geoloc.SelectSingleElement("building").Value.Trim() : string.Empty;
                                     l.country = (geoloc.HasTag("country") && geoloc.SelectSingleElement("country").Value != null) ? geoloc.SelectSingleElement("country").Value.Trim() : string.Empty;
                                     l.datum = (geoloc.HasTag("datum") && geoloc.SelectSingleElement("datum").Value != null) ? geoloc.SelectSingleElement("datum").Value.Trim() : string.Empty;
                                     l.description = (geoloc.HasTag("description") && geoloc.SelectSingleElement("description").Value != null) ? geoloc.SelectSingleElement("description").Value.Trim() : string.Empty;
                                     l.floor = (geoloc.HasTag("floor") && geoloc.SelectSingleElement("floor").Value != null) ? geoloc.SelectSingleElement("floor").Value.Trim() : string.Empty;
                                     l.locality = (geoloc.HasTag("locality") && geoloc.SelectSingleElement("locality").Value != null) ? geoloc.SelectSingleElement("locality").Value.Trim() : string.Empty;
                                     l.postalcode = (geoloc.HasTag("postalcode") && geoloc.SelectSingleElement("postalcode").Value != null) ? geoloc.SelectSingleElement("postalcode").Value.Trim() : string.Empty;
                                     l.region = (geoloc.HasTag("region") && geoloc.SelectSingleElement("region").Value != null) ? geoloc.SelectSingleElement("region").Value.Trim() : string.Empty;
                                     l.room = (geoloc.HasTag("room") && geoloc.SelectSingleElement("room").Value != null) ? geoloc.SelectSingleElement("room").Value.Trim() : string.Empty;
                                     l.street = (geoloc.HasTag("street") && geoloc.SelectSingleElement("street").Value != null) ? geoloc.SelectSingleElement("street").Value.Trim() : string.Empty; l.area = (geoloc.HasTag("area") && geoloc.SelectSingleElement("area").Value != null) ? geoloc.SelectSingleElement("area").Value.Trim() : string.Empty;
                                     l.text = (geoloc.HasTag("text") && geoloc.SelectSingleElement("text").Value != null) ? geoloc.SelectSingleElement("text").Value.Trim() : string.Empty;
                                     l.timestamp = (geoloc.HasTag("timestamp") && geoloc.SelectSingleElement("timestamp").Value != null) ? DateTime.Parse(geoloc.SelectSingleElement("timestamp").Value) : new DateTime();
                                     l.uri = (geoloc.HasTag("uri") && geoloc.SelectSingleElement("uri").Value != null) ? geoloc.SelectSingleElement("uri").Value.Trim() : string.Empty;
                                     if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                     {
                                         foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                         {
                                             r.Value.location = l;
                                             OnLocationUpdated(r.Value, r.Value.location);
                                         }
                                     }
                                     else
                                     {
                                         UserPEP up = new UserPEP();
                                         up.location = l;
                                         if (!initialUserPEP.ContainsKey(bare))
                                         {
                                             initialUserPEP.Add(bare, up);
                                         }
                                         else
                                         {
                                             up.tune = initialUserPEP[bare].tune;
                                             up.mood = initialUserPEP[bare].mood;
                                             up.activity = initialUserPEP[bare].activity;
                                             initialUserPEP[bare] = up;
                                         }
                                     }
                                 }
                             }
                             else if (item.SelectSingleElement("retract") != null)
                             {
                                 Location l = new Location();
                                 l.altitude = 0;
                                 l.latitude = 0;
                                 l.longitude = 0;
                                 l.bearing = 0;
                                 l.error = 0;
                                 l.speed = 0;
                                 l.area = string.Empty;
                                 l.building = string.Empty;
                                 l.country = string.Empty;
                                 l.datum = string.Empty;
                                 l.description = string.Empty;
                                 l.floor = string.Empty;
                                 l.locality = string.Empty;
                                 l.postalcode = string.Empty;
                                 l.region = string.Empty;
                                 l.room = string.Empty;
                                 l.street = string.Empty;
                                 l.text = string.Empty;
                                 l.timestamp = new DateTime();
                                 l.uri = string.Empty;
                                 if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                 {
                                     foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                     {
                                         r.Value.location = l;
                                         OnLocationUpdated(r.Value, r.Value.location);
                                     }
                                 }
                                 else
                                 {
                                     UserPEP up = new UserPEP();
                                     up.location = l;
                                     if (!initialUserPEP.ContainsKey(bare))
                                     {
                                         initialUserPEP.Add(bare, up);
                                     }
                                     else
                                     {
                                         up.tune = initialUserPEP[bare].tune;
                                         up.mood = initialUserPEP[bare].mood;
                                         up.activity = initialUserPEP[bare].activity;
                                         initialUserPEP[bare] = up;
                                     }
                                 }
                             }
                         }
                         #endregion
                         #region User tune
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/tune" && (item.HasTag("tune") || item.HasTag("retract")))
                         {
                             agsXMPP.Xml.Dom.Element tune = item.SelectSingleElement("tune");
                             if (tune != null)
                             {
                                 // HACK: tune.Namespace == "http://jabber.org/protocol/tune"
                                 if (tune.HasChildElements)
                                 {
                                     Tune t = new Tune();
                                     t.length = (tune.HasTag("length") && tune.SelectSingleElement("length").Value != null) ? Convert.ToInt32(tune.SelectSingleElement("length").Value, System.Globalization.CultureInfo.InvariantCulture) : 0;
                                     t.rating = (tune.HasTag("rating") && tune.SelectSingleElement("rating").Value != null) ? Convert.ToInt32(tune.SelectSingleElement("rating").Value, System.Globalization.CultureInfo.InvariantCulture) : 0;
                                     t.track = (tune.HasTag("track") && tune.SelectSingleElement("track").Value != null) ? Convert.ToInt32(tune.SelectSingleElement("track").Value, System.Globalization.CultureInfo.InvariantCulture) : 0;
                                     t.artist = (tune.HasTag("artist") && tune.SelectSingleElement("artist").Value != null) ? tune.SelectSingleElement("artist").Value.Trim() : string.Empty;
                                     t.source = (tune.HasTag("source") && tune.SelectSingleElement("source").Value != null) ? tune.SelectSingleElement("source").Value.Trim() : string.Empty;
                                     t.title = (tune.HasTag("title") && tune.SelectSingleElement("title").Value != null) ? tune.SelectSingleElement("title").Value.Trim() : string.Empty;
                                     t.uri = (tune.HasTag("uri") && tune.SelectSingleElement("uri").Value != null) ? tune.SelectSingleElement("uri").Value.Trim() : string.Empty;
                                     if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                     {
                                         foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                         {
                                             r.Value.tune = t;
                                             OnTuneUpdated(r.Value, r.Value.tune);
                                         }
                                     }
                                     else
                                     {
                                         UserPEP up = new UserPEP();
                                         up.tune = t;
                                         if (!initialUserPEP.ContainsKey(bare))
                                         {
                                             initialUserPEP.Add(bare, up);
                                         }
                                         else
                                         {
                                             up.mood = initialUserPEP[bare].mood;
                                             up.activity = initialUserPEP[bare].activity;
                                             up.location = initialUserPEP[bare].location;
                                             initialUserPEP[bare] = up;
                                         }
                                     }
                                 }
                             }
                             else if (item.SelectSingleElement("retract") != null)
                             {
                                 Tune t = new Tune();
                                 t.artist = string.Empty;
                                 t.length = 0;
                                 t.rating = 1;
                                 t.source = string.Empty;
                                 t.title = string.Empty;
                                 t.track = 0;
                                 t.uri = string.Empty;
                                 if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                 {
                                     foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                     {
                                         r.Value.tune = t;
                                         OnTuneUpdated(r.Value, r.Value.tune);
                                     }
                                 }
                                 else
                                 {
                                     UserPEP up = new UserPEP();
                                     up.tune = t;
                                     if (!initialUserPEP.ContainsKey(bare))
                                     {
                                         initialUserPEP.Add(bare, up);
                                     }
                                     else
                                     {
                                         up.mood = initialUserPEP[bare].mood;
                                         up.activity = initialUserPEP[bare].activity;
                                         up.location = initialUserPEP[bare].location;
                                         initialUserPEP[bare] = up;
                                     }
                                 }
                             }
                         }
                         #endregion
                         #region User nickname
                         if (items.HasAttribute("node") && (items.Attributes["node"] as string) == "http://jabber.org/protocol/nick" && item.HasTag("nick"))
                         {
                             agsXMPP.Xml.Dom.Element nick = item.SelectSingleElement("nick");
                             if (nick != null)
                             {
                                 // HACK: nick.Namespace == "http://jabber.org/protocol/nick"
                                 if (nick.HasChildElements)
                                 {
                                     string nm = (nick.Value != null) ? nick.Value.Trim() : string.Empty;
                                     if (nm != string.Empty)
                                     {
                                         if (contacts.ContainsKey(bare) && contacts[bare].Values.Count > 0)
                                         {
                                             foreach (KeyValuePair<string, Contact> r in contacts[bare])
                                             {
                                                 r.Value.identity.nickname = nm;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         #endregion
                     }
                 }
                 #endregion
             }
         }
     }
 }
Пример #3
0
 /// <summary>
 /// Change son activit�
 /// </summary>
 /// <param name="type">Type de l'activit�</param>
 /// <param name="text">Description</param>
 public void setActivity(Enumerations.ActivityType 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/activity");
         agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item");
         item.Attributes.Add("id", "current");
         agsXMPP.Xml.Dom.Element activity = new agsXMPP.Xml.Dom.Element("activity");
         activity.Namespace = "http://jabber.org/protocol/activity";
         agsXMPP.Xml.Dom.Element activityType = new agsXMPP.Xml.Dom.Element(Enum.GetName(typeof(Enumerations.ActivityType), type));
         activity.AddChild(activityType);
         agsXMPP.Xml.Dom.Element activityText = new agsXMPP.Xml.Dom.Element("text");
         activityText.Value = text;
         activity.AddChild(activityText);
         item.AddChild(activity);
         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);
         _activity = new Activity();
         _activity.type = type;
         _activity.text = text;
     }
 }
Пример #4
0
 private void OnActivityUpdated(Contact contact, Activity activity)
 {
     //try {
         ActivityUpdated(contact, activity);
     //} catch (Exception e) { Debug.WriteLine(e.ToString()); }
 }
Пример #5
0
        void Roster_ActivityUpdated(nJim.Contact contact, Activity activity)
        {
            if ((Settings.notifyOnActivityPlugin && Helper.PLUGIN_WINDOW_ACTIVE) || Settings.notifyOnActivityGlobally && !Helper.PLUGIN_WINDOW_ACTIVE) {
                NotifyPresMooActTun(contact, null, activity, null);

            }
            OnUpdatedPresence(contact);
            AppendLogEvent(contact.lastUpdated, "Activity", contact.identity.nickname, Translations.GetByName(activity.type.ToString()));
        }
Пример #6
0
        private void NotifyPresMooActTun(nJim.Contact contact, Mood? mood, Activity? activity, Tune? tune)
        {
            string message = String.Empty;
            Helper.PresMooActNotifyInfo notifyInfo = new Helper.PresMooActNotifyInfo();
            if (contact.identity.nickname != String.Empty) {
                notifyInfo.nickname = contact.identity.nickname;
            } else {
                notifyInfo.nickname = contact.identity.jabberID.user;
            }
            message = notifyInfo.nickname;

            notifyInfo.resource = contact.identity.jabberID.resource;
            notifyInfo.stamp = contact.lastUpdated;
            notifyInfo.status = Translations.GetByName(contact.status.type.ToString());
            notifyInfo.message = contact.status.message;
            notifyInfo.icon = Helper.GetStatusIcon(contact.status.type.ToString());

            if (mood.HasValue) {
                notifyInfo.mood = mood.Value.type.ToString().ToUpperInvariant();
                notifyInfo.message = notifyInfo.mood;
                if (!String.IsNullOrEmpty(mood.Value.text)) {
                    notifyInfo.message += "\n'" + mood.Value.text + "'";
                }
                notifyInfo.icon = Helper.GetMoodIcon(mood.Value.type.ToString());
            }
            if (activity.HasValue) {
                notifyInfo.activity = activity.Value.type.ToString().ToUpperInvariant();
                notifyInfo.message = notifyInfo.activity;
                if (!String.IsNullOrEmpty(activity.Value.text)) {
                    notifyInfo.message += "\n'" + activity.Value.text + "'";
                }
                notifyInfo.icon = Helper.GetActivityIcon(activity.Value.type.ToString());
            }
            if (tune.HasValue) {
                notifyInfo.tune = string.Format("{0}\n{1}\n{2}", tune.Value.artist, tune.Value.title, tune.Value.length);
                notifyInfo.message = notifyInfo.tune;
                notifyInfo.icon = Helper.GetTuneIcon(tune.Value);
            }
            if (!String.IsNullOrEmpty(notifyInfo.message)) {
                message += "\n" + notifyInfo.message;
            }
            notifyInfo.header = string.Format("[{0}] {1} @ {2} ", notifyInfo.stamp.ToShortTimeString(), notifyInfo.status, notifyInfo.resource);

            Dialog.Instance.ShowNotifyDialog(notifyInfo.header, notifyInfo.icon, message, Settings.notifyWindowType);
        }
Пример #7
0
 /// <summary>
 /// Constructeur
 /// </summary>
 public Contact(agsXMPP.Jid jid, string nickname, agsXMPP.Xml.Dom.ElementList grps)
 {
     _identity = new Identity(jid);
     if (nickname != null && nickname.Trim() != string.Empty)
     {
         _identity.nickname = nickname;
     }
     if (grps != null)
     {
         foreach (agsXMPP.protocol.Base.Group g in grps)
         {
             if (!_groups.Contains(g.Name))
             {
                 _groups.Add(g.Name);
             }
         }
     }
     _status = new Status();
     _status.type = Enums.StatusType.Unavailable;
     _status.message = string.Empty;
     _mood = new Mood();
     _mood.type = Enums.MoodType.none;
     _mood.text = string.Empty;
     _activity = new Activity();
     _activity.type = Enums.ActivityType.none;
     _activity.text = string.Empty;
     _location = new Location();
     _location.altitude = 0;
     _location.latitude = 0;
     _location.longitude = 0;
     _location.bearing = 0;
     _location.error = 0;
     _location.speed = 0;
     _location.area = string.Empty;
     _location.building = string.Empty;
     _location.country = string.Empty;
     _location.datum = string.Empty;
     _location.description = string.Empty;
     _location.floor = string.Empty;
     _location.locality = string.Empty;
     _location.postalcode = string.Empty;
     _location.region = string.Empty;
     _location.room = string.Empty;
     _location.street = string.Empty;
     _location.text = string.Empty;
     _location.timestamp = new DateTime();
     _location.uri = string.Empty;
     _tune = new Tune();
     _tune.artist = string.Empty;
     _tune.length = 0;
     _tune.rating = 1;
     _tune.source = string.Empty;
     _tune.title = string.Empty;
     _tune.track = 0;
     _tune.uri = string.Empty;
 }