コード例 #1
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
 private static void _ReadUniqueIdentifier(_Property nameProp, Contact contact)
 {
     // Someone (maybe us) bothered to put a UID on the contact, so if it matches
     //    our ContactId's GUID format then go ahead and use it.
     Guid id;
     if (Utility.GuidTryParse(nameProp.ValueString, out id))
     {
         contact.ContactIds.Default = id;
     }
 }
コード例 #2
0
			private extern static void alljoyn_interfacedescription_property_getannotationatindex(_Property property,
				UIntPtr index, IntPtr name, ref UIntPtr name_size,
				IntPtr value, ref UIntPtr value_size);
コード例 #3
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadPhoto(_Property photoProp, Contact contact)
        {
            Assert.IsNotNull(photoProp);
            Assert.IsNotNull(contact);

            Photo photo = _ReadPhotoProperty(photoProp);

            // Add any other labels on the Photo.  UserTile is implied by the PHOTO type.
            contact.Photos.Add(photo, photoProp.GetLabels(PhotoLabels.UserTile, null));
        }
コード例 #4
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadOrganization(_Property orgProp, Contact contact)
        {
            // In VCF there are three related properties: ORG, ROLE, and TITLE.
            // There reasonably could be multiple organizations on a vcard but short
            // of property groupings there's no way to distinguish, and even then
            // no guarantee that the property groupings will be present in the case
            // of multiple sets of these properties.
            // So instead, treat this like name and assume only the default, but rather
            // than use .Default, use the PropertyLabels.Business indexer.
            Assert.IsNotNull(orgProp);
            Assert.IsNotNull(contact);

            var position = new PositionBuilder(contact.Positions[PropertyLabels.Business]);
            string[] elements = _TokenizeEscapedMultipropString(orgProp.ValueString);
            Assert.BoundedInteger(1, elements.Length, int.MaxValue);

            // ORG is weird in that it doesn't actually say what the tokens represent.
            // The first one can be safely assumed to be Company, but anything else it's probably
            // best to just put back the ';'s and stick the string somewhere visible.
            position.Company = elements[0];
            if (elements.Length > 1)
            {
                position.Office = string.Join(";", elements, 1, elements.Length -1);
            }
            contact.Positions[PropertyLabels.Business] = position;
        }
コード例 #5
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadName(_Property nameProp, Contact contact)
        {
            Assert.IsNotNull(nameProp);
            Assert.IsNotNull(contact);

            var nb = new NameBuilder(contact.Names.Default);
            string[] names = _TokenizeEscapedMultipropString(nameProp.ValueString);

            switch (names.Length)
            {
                default: // too many.  Ignore extras
                case 5:
                    nb.Suffix = names[4];
                    goto case 4;
                case 4:
                    nb.Prefix = names[3];
                    goto case 3;
                case 3:
                    nb.MiddleName = names[2];
                    goto case 2;
                case 2:
                    nb.GivenName = names[1];
                    goto case 1;
                case 1:
                    nb.FamilyName = names[0];
                    break;
                case 0:
                    Assert.Fail("Tokenize shouldn't have yielded an empty array.");
                    break;
            }
            contact.Names.Default = nb;
        }
コード例 #6
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadPhoneNumbers(_Property phoneProp, Contact contact)
        {
            Assert.IsNotNull(phoneProp);
            Assert.IsNotNull(contact);

            contact.PhoneNumbers.Add(new PhoneNumber(phoneProp.ValueString), phoneProp.GetLabels());
        }
コード例 #7
0
			public Property GetProperty(string name)
			{
				_Property retProp = new _Property();
				if(alljoyn_interfacedescription_getproperty(_interfaceDescription, name, ref retProp) == 1)
				{
					return new Property(retProp);
				}
				else
				{
					return null;
				}
			}
コード例 #8
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadLogo(_Property logoProp, Contact contact)
        {
            Assert.IsNotNull(logoProp);
            Assert.IsNotNull(contact);
            Assert.IsNotNull(logoProp);
            Assert.IsNotNull(contact);

            Photo photo = _ReadPhotoProperty(logoProp);

            // Add any other labels on the Photo.  Business and Logo are implied by the LOGO type.
            contact.Photos.Add(photo, logoProp.GetLabels(PhotoLabels.Logo, PropertyLabels.Business));
        }
コード例 #9
0
			private extern static UIntPtr alljoyn_interfacedescription_property_getannotationscount(_Property property);
コード例 #10
0
			private extern static void alljoyn_interfacedescription_property_getannotationatindex(_Property property,
				UIntPtr index, IntPtr name, ref UIntPtr name_size,
				IntPtr value, ref UIntPtr value_size);
コード例 #11
0
			private extern static int alljoyn_interfacedescription_getproperty(IntPtr iface,
				[MarshalAs(UnmanagedType.LPStr)] string name,
				ref _Property property);
コード例 #12
0
 private ArrayList getControlProperties(string name, PropertiesCollection.CategoryKind enCategoryKind)
 {
     ArrayList expansion = null;
     _Property property = new _Property();
     for (int i = 0; i < this.mPropertyList.Count; i++)
     {
         property = (_Property) this.mPropertyList[i];
         if (property.name == name)
         {
             if (enCategoryKind == PropertiesCollection.CategoryKind.Basic)
             {
                 return property.Basic;
             }
             if (enCategoryKind == PropertiesCollection.CategoryKind.Expansion)
             {
                 return property.Expansion;
             }
         }
     }
     property.name = name;
     string controlName = PrtProperties.getControlName(name);
     property.Basic = this.mCollection.getPropertyList(controlName, PropertiesCollection.CategoryKind.Basic, PropertiesCollection.BooleanKind.True);
     property.Expansion = this.mCollection.getPropertyList(controlName, PropertiesCollection.CategoryKind.Expansion, PropertiesCollection.BooleanKind.True);
     this.mPropertyList.Add(property);
     if (enCategoryKind == PropertiesCollection.CategoryKind.Basic)
     {
         return property.Basic;
     }
     if (enCategoryKind == PropertiesCollection.CategoryKind.Expansion)
     {
         expansion = property.Expansion;
     }
     return expansion;
 }
コード例 #13
0
			private extern static bool alljoyn_interfacedescription_property_getannotation(_Property property,
				[MarshalAs(UnmanagedType.LPStr)] string name, IntPtr value, ref UIntPtr value_size);
コード例 #14
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
 private static void _ReadLabel(_Property labelProp, Contact contact)
 {
     // This is directly related to the physical addresses.
     // Without supporting property grouping there's no good way to tell whether
     // this label corresponds to an existing address node (or vice versa).
     // I'm okay with skipping this property on read since the ADR should be present.
     // Better to not get this wrong in the 5% (probably more) case.
 }
コード例 #15
0
			public Property[] GetProperties()
			{
				UIntPtr numProperties = alljoyn_interfacedescription_getproperties(_interfaceDescription,
					IntPtr.Zero, (UIntPtr)0);
				_Property[] props = new _Property[(int)numProperties];
				GCHandle gch = GCHandle.Alloc(props, GCHandleType.Pinned);
				UIntPtr numFilledProperties = alljoyn_interfacedescription_getproperties(_interfaceDescription,
					gch.AddrOfPinnedObject(), numProperties);
				if(numProperties != numFilledProperties)
				{
					// Warn?
				}
				Property[] ret = new Property[(int)numFilledProperties];
				for(int i = 0; i < ret.Length; i++)
				{
					ret[i] = new Property(props[i]);
				}

				return ret;
			}
コード例 #16
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadFormattedName(_Property nameProp, Contact contact)
        {
            Assert.IsNotNull(nameProp);
            Assert.IsNotNull(contact);

            // Don't expect multiple names so just coalesce FN, N, and SOUND to the default Name.
            // Explicitly ignoring any labels set on the name.
            contact.Names.Default = new NameBuilder(contact.Names.Default)
            {
                FormattedName = nameProp.ValueString
            };
        }
コード例 #17
0
				internal Property(_Property property)
				{
					_property = property;
				}
コード例 #18
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadMailer(_Property mailerProp, Contact contact)
        {
            Assert.IsNotNull(mailerProp);
            Assert.IsNotNull(contact);

            contact.Mailer = mailerProp.ValueString;
        }
コード例 #19
0
			private extern static int alljoyn_interfacedescription_getproperty(IntPtr iface,
				[MarshalAs(UnmanagedType.LPStr)] string name,
				ref _Property property);
コード例 #20
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadNotes(_Property notesProp, Contact contact)
        {
            Assert.IsNotNull(notesProp);
            Assert.IsNotNull(contact);

            contact.Notes = notesProp.ValueString;
        }
コード例 #21
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static bool _TryParseVCardProperty(string line, out _Property prop)
        {
            Assert.IsNotNull(line);
            prop = null;

            string valueString;
            byte[] valueBinary = null;

            int colonIndex = line.IndexOf(':');
            // If this doesn't contain a colon it's not a property.
            if (colonIndex == -1)
            {
                return false;
            }

            prop = new _Property();
            
            // Note some properties, such as AGENT may be empty.
            // AGENT is actually a weird case, because its property is the embedded vcard object
            // that follows on the next line.
            valueString = line.Substring(colonIndex + 1);
            
            string[] propTags = _TokenizeEscapedMultipropString(line.Substring(0, colonIndex));
            Assert.BoundedInteger(1, propTags.Length, int.MaxValue);
            
            // Ignoring group tags for now.
            // Don't know of any clients that write them with an expectation of their consumption.
            int dotIndex = propTags[0].IndexOf('.');
            if (-1 != dotIndex)
            {
                // Mildly concerned about property strings that look like "GROUP.;TYPE=..."
                // which isn't a property... Shouldn't need to special case it though.
                propTags[0] = propTags[0].Substring(dotIndex);
            }
            prop.Name = propTags[0];
            for (int i = 1; i < propTags.Length; ++i)
            {
                // Look for encodings before putting it into the _Property.
                // Ignoring CHARSETs altogether here.
                if (propTags[i].StartsWith(_DeclareEncoding, StringComparison.OrdinalIgnoreCase))
                {
                    propTags[i] = propTags[i].Substring(_DeclareEncoding.Length);
                }

                // These strings don't strictly require the ENCODING= prefix.
                // They're unambiguous even without it, so look for them directly as well.
                if (propTags[i].Equals(_EncodingBase64))
                {
                    valueBinary = Convert.FromBase64String(valueString);
                    valueString = null;

                    // skip assigning this as a type.
                    continue;
                }

                if (propTags[i].Equals(_EncodingQuotedPrintable))
                {
                    valueString = _DecodeQuotedPrintable(valueString);
                    // skip assigning this as a type.
                    continue;
                }

                prop.Types.Add(propTags[i]);
            }

            prop.ValueString = valueString;
            prop.ValueBinary = valueBinary;

            return true;
        }
コード例 #22
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadPhonetic(_Property nameProp, Contact contact)
        {
            Assert.IsNotNull(nameProp);
            Assert.IsNotNull(contact);

            // Don't expect multiple names so just coalesce FN, N, and SOUND to the default Name.
            // Explicitly ignoring any labels set on the name, except that phonetic must be a URL.
            if (nameProp.Types.Contains(_DeclareValue + _UrlType))
            {
                contact.Names.Default = new NameBuilder(contact.Names.Default)
                {
                    Phonetic = nameProp.ValueString
                };
            }
        }
コード例 #23
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadAddresses(_Property addressProp, Contact contact)
        {
            Assert.IsNotNull(addressProp);
            Assert.IsNotNull(contact);

            // Always create a new address node for any ADR property.
            var addr = new PhysicalAddressBuilder();
            string[] elements = _TokenizeEscapedMultipropString(addressProp.ValueString);

            switch (elements.Length)
            {
                default: // too many.  Ignore extras
                case 7:
                    addr.Country = elements[6];
                    goto case 6;
                case 6:
                    addr.ZipCode = elements[5];
                    goto case 5;
                case 5:
                    addr.State = elements[4];
                    goto case 4;
                case 4:
                    addr.City = elements[3];
                    goto case 3;
                case 3:
                    addr.Street = elements[2];
                    goto case 2;
                case 2:
                    addr.ExtendedAddress = elements[1];
                    goto case 1;
                case 1:
                    addr.POBox = elements[0];
                    break;
                case 0:
                    Assert.Fail("Tokenize shouldn't have yielded an empty array.");
                    break;
            }

            contact.Addresses.Add(addr, addressProp.GetLabels());
        }
コード例 #24
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static Photo _ReadPhotoProperty(_Property photoProp)
        {
            var pb = new PhotoBuilder();

            // support either URLs or inline streams.
            if (photoProp.Types.Contains(_DeclareValue + _UrlType))
            {
                Uri uri;
                if (Uri.TryCreate(photoProp.ValueString, UriKind.RelativeOrAbsolute, out uri))
                {
                    pb.Url = uri;
                }
            }
            else if (null != photoProp.ValueBinary)
            {
                pb.Value = new MemoryStream(photoProp.ValueBinary);

                // look for a type to put into it also.
                pb.ValueType = "image";
                foreach (string token in photoProp.Types)
                {
                    if (token.StartsWith(_DeclareType, StringComparison.OrdinalIgnoreCase))
                    {
                        pb.ValueType = "image/" + token.Substring(_DeclareType.Length);
                        break;
                    }
                }
            }
            return pb;
        }
コード例 #25
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadBirthday(_Property bdayProp, Contact contact)
        {
            Assert.IsNotNull(bdayProp);
            Assert.IsNotNull(contact);

            DateTime bday;
            if (DateTime.TryParse(bdayProp.ValueString, out bday))
            {
                contact.Dates[DateLabels.Birthday] = bday;
            }
        }
コード例 #26
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadTitle(_Property titleProp, Contact contact)
        {
            // In VCF there are three related properties: ORG, ROLE, and TITLE.
            // There reasonably could be multiple organizations on a vcard but short
            // of property groupings there's no way to distinguish, and even then
            // no guarantee that the property groupings will be present in the case
            // of multiple sets of these properties.
            // So instead, treat this like name and assume only the default, but rather
            // than use .Default, use the PropertyLabels.Business indexer.
            Assert.IsNotNull(titleProp);
            Assert.IsNotNull(contact);

            var position = new PositionBuilder(contact.Positions[PropertyLabels.Business])
            {
                JobTitle = titleProp.ValueString
            };
            contact.Positions[PropertyLabels.Business] = position;
        }
コード例 #27
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadEmailAddress(_Property emailProp, Contact contact)
        {
            Assert.IsNotNull(emailProp);
            Assert.IsNotNull(contact);

            var email = new EmailAddressBuilder
            {
                Address = emailProp.ValueString
            };
            // Try to determine a type from this
            if (emailProp.Types.Contains("INTERNET") || emailProp.Types.Contains("TYPE=INTERNET"))
            {
                email.AddressType = "SMTP";
            }
            else
            {
                // Try to coerce a type.  Otherwise leave it blank.  Smtp is already implicitly default.
                foreach(string type in emailProp.Types)
                {
                    if (type.StartsWith(_DeclareType, StringComparison.OrdinalIgnoreCase))
                    {
                        email.AddressType = type.Substring(_DeclareType.Length);
                        break;
                    }
                }
            }
            contact.EmailAddresses.Add(email, emailProp.GetLabels());
        }
コード例 #28
0
ファイル: VCard.cs プロジェクト: cystbear/contacts
        private static void _ReadUrl(_Property urlProp, Contact contact)
        {
            Assert.IsNotNull(urlProp);
            Assert.IsNotNull(contact);

            Uri uri;
            if (Uri.TryCreate(urlProp.ValueString, UriKind.RelativeOrAbsolute, out uri))
            {
                contact.Urls.Add(uri, urlProp.GetLabels());
            }
        }
コード例 #29
0
			private extern static UIntPtr alljoyn_interfacedescription_property_getannotationscount(_Property property);