/// <summary> /// Constructeur /// </summary> public Presence() { _status = new Status(); _status.type = Enums.StatusType.Normal; _status.message = string.Empty; _mood = new Mood(); _mood.type = Enums.MoodType.none; _mood.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; _autoIdleStatus = new Status(); _autoIdleStatus.type = Enums.StatusType.Away; _autoIdleStatus.message = "(Auto Idle)"; autoIdleTimer.Elapsed += new System.Timers.ElapsedEventHandler(autoIdleTimerElapsed); autoIdleTimer.Enabled = true; }
/// <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 } } } }
private void OnLocationUpdated(Contact contact, Location location) { try { LocationUpdated(contact, location); } catch { } }
/// <summary> /// D�finit un nouvel emplacement g�ographique /// </summary> /// <param name="location">Informations compl�te sur l'emplacement</param> public void setLocation(Location location) { 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/geoloc"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element geoloc = new agsXMPP.Xml.Dom.Element("geoloc"); geoloc.Namespace = "http://jabber.org/protocol/geoloc"; geoloc.AddChild(new agsXMPP.Xml.Dom.Element("alt", Convert.ToString(location.altitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("lat", Convert.ToString(location.latitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("lon", Convert.ToString(location.longitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("bearing", Convert.ToString(location.bearing, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("error", Convert.ToString(location.error, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("speed", Convert.ToString(location.speed, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("area", (location.area != null) ? location.area.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("building", (location.building != null) ? location.building.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("country", (location.country != null) ? location.country.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("datum", (location.datum != null) ? location.datum.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("description", (location.description != null) ? location.description.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("floor", (location.floor != null) ? location.floor.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("locality", (location.locality != null) ? location.locality.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("postalcode", (location.postalcode != null) ? location.postalcode.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("region", (location.region != null) ? location.region.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("room", (location.room != null) ? location.room.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("street", (location.street != null) ? location.street.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("text", (location.text != null) ? location.text.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("timestamp", agsXMPP.util.Time.ISO_8601Date(location.timestamp))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("uri", (location.uri != null) ? location.uri.Trim() : string.Empty)); item.AddChild(geoloc); 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); _location = new Location(); _location.altitude = location.altitude; _location.area = (location.area != null) ? location.area.Trim() : string.Empty; _location.bearing = location.bearing; _location.building = (location.building != null) ? location.building.Trim() : string.Empty; _location.country = (location.country != null) ? location.country.Trim() : string.Empty; _location.datum = (location.datum != null) ? location.datum.Trim() : string.Empty; _location.description = (location.description != null) ? location.description.Trim() : string.Empty; _location.error = location.error; _location.floor = (location.floor != null) ? location.floor.Trim() : string.Empty; _location.latitude = location.latitude; _location.locality = (location.locality != null) ? location.locality.Trim() : string.Empty; _location.longitude = location.longitude; _location.postalcode = (location.postalcode != null) ? location.postalcode.Trim() : string.Empty; _location.region = (location.region != null) ? location.region.Trim() : string.Empty; _location.room = (location.room != null) ? location.room.Trim() : string.Empty; _location.speed = location.speed; _location.street = (location.street != null) ? location.street.Trim() : string.Empty; _location.text = (location.text != null) ? location.text.Trim() : string.Empty; _location.timestamp = location.timestamp; _location.uri = (location.uri != null) ? location.uri.Trim() : string.Empty; } }
/// <summary> /// D�finit un nouvek emplacement g�ographique /// </summary> /// <param name="geoStructure">Strucure d'informations provenant directement d'un outils de g�olocalisation incorpor� � la librairie</param> public void setLocation(GeoLocTools.GeoStructure geoStructure) { Location location = new Location(); location.locality = geoStructure.city; location.country = geoStructure.country; location.description = geoStructure.location; location.latitude = geoStructure.latitude; location.longitude = geoStructure.longitude; location.postalcode = geoStructure.zipcode; location.street = geoStructure.street; setLocation(location); }
/// <summary> /// D�finit un nouvel emplacement g�ographique /// </summary> /// <param name="latitude">Latitude</param> /// <param name="longitude">Longitude</param> /// <param name="country">Pays</param> public void setLocation(double latitude, double longitude, string country) { Location location = new Location(); location.latitude = latitude; location.longitude = longitude; location.country = country; setLocation(location); }
private void OnLocationUpdated(Contact contact, Location location) { try { LocationUpdated(contact, location); } catch (Exception e) { Debug.WriteLine(e.ToString()); } }
/// <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; }