Пример #1
0
        public static void SaveMetaContact(MetaContact metaContact)
        {
            try
            {
                Dictionary<string, object> values = metaContact.GetData();

                metaContact.Id = SaveOrUpdate(values, "Id", "MetaContact", true, _connection);
            }

            catch (Exception e)
            {
                Events.Instance.OnEvent(e, new EventError(e.Message, null));
            }
        }
Пример #2
0
        private Contact AddRosterItem(RosterItem item)
        {
            Contact contact;

            lock (_items._syncObject)
            {
                // for now
                contact = Database.GetContact(item);

                MetaContact metaContact = null;

                if (contact != null)
                {
                    metaContact = Database.GetMetaContact(contact.MetaId);
                }

                if (metaContact == null)
                {
                    metaContact = new MetaContact();
                    Database.SaveMetaContact(metaContact);

                    contact = new Contact(item, metaContact.Id);
                    Database.SaveContact(contact);
                }

                metaContact.AddContact(contact);

                _realContacts.Add(item.Jid.Bare.ToLowerInvariant(), contact);

                _items.Add(metaContact);
            }

            Vcard vcard = Storage.GetVcard(contact.Jid, 99999);

            if (vcard != null)
            {
                contact.SetVcard(vcard);
                contact.HasVCardRecieved = false;
            }

            return contact;
        }
Пример #3
0
        public static MetaContact GetMetaContact(int id)
        {
            MetaContact metaContact = null;

            try
            {
                using (SQLiteCommand command = _connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM [MetaContact] WHERE [Id]=@id";

                    command.Parameters.Add(new SQLiteParameter("id", id));

                    SQLiteDataReader reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        metaContact = new MetaContact(reader);
                    }

                    reader.Close();
                }
            }

            catch (Exception e)
            {
                Events.Instance.OnEvent(e, new EventError(e.Message, null));
            }

            return metaContact;
        }
Пример #4
0
 public void AddFomMetaContact(MetaContact metaContact)
 {
     foreach (Contact contact in metaContact.SubContacts)
     {
         AddContact(contact);
     }
 }