Esempio n. 1
0
        public void UpdateContact(VCard contact)
        {
            var command = new SQLiteCommand(connection);

            if (HasContact(contact))
            {
                command.CommandText = "UPDATE friends SET vCard = @vCard WHERE sip_uri = @sipUri";
                command.Parameters.AddWithValue("@vCard", contact.ToRawString);
                command.Parameters.AddWithValue("@sipUri", GetSipURI(contact.Phone));
            }
            else
            {
                command.CommandText = "INSERT INTO friends (friend_list_id, sip_uri, subscribe_policy, send_subscribe, vCard, presence_received) VALUES(@listID, @sipUri, @sp, @ss, @vCard, @pr)";
                command.Parameters.AddWithValue("@listID", 1);
                command.Parameters.AddWithValue("@sipUri", GetSipURI(contact.Phone));
                command.Parameters.AddWithValue("@sp", 1);
                command.Parameters.AddWithValue("@ss", 1);
                command.Parameters.AddWithValue("@vCard", contact.ToRawString);
                command.Parameters.AddWithValue("@pr", 0);
            }

            command.Prepare();
            command.ExecuteNonQuery();
        }