Beispiel #1
0
        public PhoneBook[] GetPhoneBooks(PbapFolder Folder, int MaxNum)
        {
            List <PhoneBook> phoneBookList = new List <PhoneBook>();

            var t = Task.Factory.StartNew(() =>
            {
                int length = GetPhoneBookCount(Folder);
                if (MaxNum > 0)
                {
                    length = Math.Min(length, MaxNum);
                }

                for (int i = 0; i < length; i += 10)
                {
                    using (ObexGetStream Stream = PullPhoneBook(Folder, 10, i))
                    {
                        byte[] ba    = new byte[UInt16.MaxValue];
                        int readSize = Stream.Read(ba, 0, UInt16.MaxValue);

                        phoneBookList.AddRange(VCardReader.ParseVCard(UTF8Encoding.UTF8.GetString(ba, 0, readSize)));
                    }
                }

                SessionConnect();
            });

            t.Wait();

            return(phoneBookList.ToArray());
        }
Beispiel #2
0
        public PhoneBook GetPhoneBookFromPhoneNumber(PbapFolder Folder, string PhoneNumber)
        {
            PhoneBook book = null;

            var t = Task.Factory.StartNew(() =>
            {
                string handle = String.Empty;

                using (ObexGetStream Stream = PullvCardListing(Folder, 1, 0, PhoneNumber))
                {
                    byte[] ba    = new byte[UInt16.MaxValue];
                    int readSize = Stream.Read(ba, 0, UInt16.MaxValue);

                    handle = VCardReader.ParseVCardListenXML(UTF8Encoding.UTF8.GetString(ba, 0, readSize));
                }

                if (!String.IsNullOrWhiteSpace(handle))
                {
                    book = GetPhoneBook(Folder, handle);
                }
            });

            t.Wait();

            return(book);
        }
Beispiel #3
0
        private PhoneBook GetPhoneBook(PbapFolder Folder, string handle)
        {
            using (ObexGetStream Stream = PullvCardEntry(Folder, handle))
            {
                byte[] ba       = new byte[UInt16.MaxValue];
                int    readSize = Stream.Read(ba, 0, UInt16.MaxValue);

                List <PhoneBook> phoneBookList = VCardReader.ParseVCard(UTF8Encoding.UTF8.GetString(ba, 0, readSize));
                if (phoneBookList.Count > 0)
                {
                    return(phoneBookList[0]);
                }
            }

            return(null);
        }