Пример #1
0
        /// <summary>
        /// Retrieves the vCard stream from a contacts record.
        /// </summary>
        /// <param name="record">The contacts record</param>
        /// <returns>
        /// The vCard stream.
        /// </returns>
        /// <privilege>http://tizen.org/privilege/contact.read</privilege>
        /// <feature>http://tizen.org/feature/contact</feature>
        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid</exception>
        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
        /// <exception cref="NotSupportedException">Thrown when feature is not supported</exception>
        /// <since_tizen> 4 </since_tizen>
        public static string Compose(ContactsRecord record)
        {
            int    error  = 0;
            string stream = null;

            if (record.Uri.Equals(Person.Uri))
            {
                error = Interop.Vcard.ContactsVcardMakeFromPerson(record._recordHandle, out stream);
            }
            else if (record.Uri.Equals(Contact.Uri))
            {
                error = Interop.Vcard.ContactsVcardMakeFromContact(record._recordHandle, out stream);
            }
            else if (record.Uri.Equals(MyProfile.Uri))
            {
                error = Interop.Vcard.ContactsVcardMakeFromMyProfile(record._recordHandle, out stream);
            }
            else
            {
                throw new ArgumentException("Invalid Parameters Provided");
            }

            if ((int)ContactsError.None != error)
            {
                Log.Error(Globals.LogTag, "Compose Failed with error " + error);
                throw ContactsErrorFactory.CheckAndCreateException(error);
            }

            return(stream);
        }
Пример #2
0
        /// <summary>
        /// Insert item.
        /// </summary>
        public int Insert(RecordItem item)
        {
            var record = new TPC.ContactsRecord(Contact.Uri);

            ItemToRecord(item, record);
            int recordId = manager.Database.Insert(record);

            return(recordId);
        }
Пример #3
0
        public void Replace(ContactsRecord record, int recordId)
        {
            int error = Interop.Database.Replace(record._recordHandle, recordId);

            if ((int)ContactsError.None != error)
            {
                Log.Error(Globals.LogTag, "Replace Failed with error " + error);
                throw ContactsErrorFactory.CheckAndCreateException(error);
            }
        }
Пример #4
0
        /// <summary>
        /// Removes a child record from the parent record.
        /// </summary>
        /// <param name="propertyId">The property ID.</param>
        /// <param name="childRecord">The child record to remove from the parent record.</param>
        /// <feature>http://tizen.org/feature/contact</feature>
        /// <exception cref="NotSupportedException">Thrown when feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid.</exception>
        /// <since_tizen> 4 </since_tizen>
        public void RemoveChildRecord(uint propertyId, ContactsRecord childRecord)
        {
            int error = Interop.Record.RemoveChildRecord(_recordHandle, propertyId, childRecord._recordHandle);

            if ((int)ContactsError.None != error)
            {
                Log.Error(Globals.LogTag, "RemoveChildRecord Failed with error " + error);
                throw ContactsErrorFactory.CheckAndCreateException(error);
            }
            childRecord._disposedValue = false;
        }
Пример #5
0
        /// <summary>
        /// Removes a record from the contacts list.
        /// </summary>
        /// <param name="record">The record to remove.</param>
        /// <feature>http://tizen.org/feature/contact</feature>
        /// <exception cref="NotSupportedException">Thrown when the feature is not supported.</exception>
        /// <exception cref="ArgumentException">Thrown when one of the arguments provided to a method is not valid.</exception>
        /// <since_tizen> 4 </since_tizen>
        public void RemoveRecord(ContactsRecord record)
        {
            int error = Interop.List.ContactsListRemove(_listHandle, record._recordHandle);

            if ((int)ContactsError.None != error)
            {
                Log.Error(Globals.LogTag, "RemoveRecord Failed with error " + error);
                throw ContactsErrorFactory.CheckAndCreateException(error);
            }
            record._disposedValue = false;
            _memoryPressure      -= ContactsViews.Record.AverageSize;
        }
Пример #6
0
        public int Insert(ContactsRecord record)
        {
            int id    = -1;
            int error = Interop.Database.Insert(record._recordHandle, out id);

            if ((int)ContactsError.None != error)
            {
                Log.Error(Globals.LogTag, "Insert Failed with error " + error);
                throw ContactsErrorFactory.CheckAndCreateException(error);
            }
            return(id);
        }
Пример #7
0
        /// <summary>
        /// Get item from record.
        /// </summary>
        private void RecordToItem(TPC.ContactsRecord record, RecordItem item)
        {
            item.DisplayName = record.Get <string>(Contact.DisplayName);

            item.Index = record.Get <int>(Contact.Id);

            if (record.GetChildRecordCount(Contact.Name) > 0)
            {
                var name = record.GetChildRecord(Contact.Name, 0);
                item.First = name.Get <string>(Name.First);
                item.Last  = name.Get <string>(Name.Last);
            }

            if (record.GetChildRecordCount(Contact.Number) > 0)
            {
                var number = record.GetChildRecord(Contact.Number, 0);
                item.Number = number.Get <string>(Number.NumberData);
            }

            if (record.GetChildRecordCount(Contact.Email) > 0)
            {
                var email = record.GetChildRecord(Contact.Email, 0);
                item.Email = email.Get <string>(Email.Address);
            }

            if (record.GetChildRecordCount(Contact.URL) > 0)
            {
                var url = record.GetChildRecord(Contact.URL, 0);
                item.Url = url.Get <string>(URL.URLData);
            }

            if (record.GetChildRecordCount(Contact.Company) > 0)
            {
                var company = record.GetChildRecord(Contact.Company, 0);
                item.Company = company.Get <string>(Company.Label);
            }

            if (record.GetChildRecordCount(Contact.Event) > 0)
            {
                var ievent = record.GetChildRecord(Contact.Event, 0);
                item.Event = ievent.Get <int>(Event.Date);
            }

            if (record.GetChildRecordCount(Contact.Note) > 0)
            {
                var note = record.GetChildRecord(Contact.Note, 0);
                item.Note = note.Get <string>(Note.Contents);
            }
        }
Пример #8
0
        /// <summary>
        /// Clean child record.
        /// </summary>
        private void CleanChildRecord(TPC.ContactsRecord record)
        {
            if (record.GetChildRecordCount(Contact.Name) > 0)
            {
                var name = record.GetChildRecord(Contact.Name, 0);
                record.RemoveChildRecord(Contact.Name, name);
            }

            if (record.GetChildRecordCount(Contact.Number) > 0)
            {
                var number = record.GetChildRecord(Contact.Number, 0);
                record.RemoveChildRecord(Contact.Number, number);
            }

            if (record.GetChildRecordCount(Contact.Email) > 0)
            {
                var email = record.GetChildRecord(Contact.Email, 0);
                record.RemoveChildRecord(Contact.Email, email);
            }

            if (record.GetChildRecordCount(Contact.URL) > 0)
            {
                var url = record.GetChildRecord(Contact.URL, 0);
                record.RemoveChildRecord(Contact.URL, url);
            }

            if (record.GetChildRecordCount(Contact.Company) > 0)
            {
                var company = record.GetChildRecord(Contact.Company, 0);
                record.RemoveChildRecord(Contact.Company, company);
            }

            if (record.GetChildRecordCount(Contact.Event) > 0)
            {
                var ievent = record.GetChildRecord(Contact.Event, 0);
                record.RemoveChildRecord(Contact.Event, ievent);
            }

            if (record.GetChildRecordCount(Contact.Note) > 0)
            {
                var note = record.GetChildRecord(Contact.Note, 0);
                record.RemoveChildRecord(Contact.Note, note);
            }
        }
Пример #9
0
        /// <summary>
        /// Get record from item.
        /// </summary>
        private void ItemToRecord(RecordItem item, TPC.ContactsRecord record)
        {
            var name = new TPC.ContactsRecord(Name.Uri);

            name.Set <string>(Name.First, item.First);
            name.Set <string>(Name.Last, item.Last);
            record.AddChildRecord(Contact.Name, name);

            var number = new TPC.ContactsRecord(Number.Uri);

            number.Set <string>(Number.NumberData, item.Number);
            record.AddChildRecord(Contact.Number, number);

            var email = new TPC.ContactsRecord(Email.Uri);

            email.Set <string>(Email.Address, item.Email);
            record.AddChildRecord(Contact.Email, email);

            var url = new TPC.ContactsRecord(URL.Uri);

            url.Set <string>(URL.URLData, item.Url);
            record.AddChildRecord(Contact.URL, url);

            var company = new TPC.ContactsRecord(Company.Uri);

            company.Set <string>(Company.Label, item.Company);
            record.AddChildRecord(Contact.Company, company);

            var ievent = new TPC.ContactsRecord(Event.Uri);

            ievent.Set <int>(Event.Date, item.Event);
            record.AddChildRecord(Contact.Event, ievent);

            var note = new TPC.ContactsRecord(Note.Uri);

            note.Set <string>(Note.Contents, item.Note);
            record.AddChildRecord(Contact.Note, note);
        }