public void ParseOptions(XmlElement optionsNode) { if (optionsNode != null) { XmlNode xmlNode = optionsNode["Range", "Search:"]; if (xmlNode != null) { string[] array = xmlNode.InnerText.Split(new char[] { '-' }); AirSyncDiagnostics.Assert(array.Length == 2); this.minRange = int.Parse(array[0], CultureInfo.InvariantCulture); this.maxRange = int.Parse(array[1], CultureInfo.InvariantCulture); if (this.minRange > this.maxRange || (this.protocolVersion < 120 && this.minRange != 0)) { throw new AirSyncPermanentException(StatusCode.Sync_ProtocolVersionMismatch, false) { ErrorStringForProtocolLogger = "MinMoreThanMaxinGalSearch" }; } this.rangeSpecified = true; } XmlNode pictureOptionsNode = optionsNode["Picture", "Search:"]; this.pictureOptions = PictureOptions.Parse(pictureOptionsNode, StatusCode.Sync_ProtocolVersionMismatch); } this.user.Context.ProtocolLogger.SetValue(ProtocolLoggerData.PictureRequested, (this.pictureOptions != null) ? 1 : 0); }
internal PictureOptions() { this.MaxSize = int.MaxValue; this.MaxPictures = int.MaxValue; this.MaxResolution = GlobalSettings.HDPhotoDefaultSupportedResolution; this.userPhotoSize = PictureOptions.GetUserPhotoSize(this.MaxResolution); }
private void ParseOptionsNode(XmlNode optionsNode) { foreach (object obj in optionsNode.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; string localName; if ((localName = xmlNode.LocalName) != null) { if (!(localName == "CertificateRetrieval")) { if (!(localName == "MaxCertificates")) { if (!(localName == "MaxAmbiguousRecipients")) { if (localName == "Availability") { this.ParseAvailabilityNode(xmlNode); continue; } if (localName == "Picture") { this.pictureOptions = PictureOptions.Parse(xmlNode, StatusCode.Sync_ServerError); continue; } } else { if (!int.TryParse(xmlNode.InnerText, out this.maxAmbiguousRecipients)) { throw new AirSyncPermanentException(StatusCode.Sync_ServerError, this.GetValidationErrorXml(), null, false) { ErrorStringForProtocolLogger = "BadMaxAmbigValueInResolveRecipients" }; } continue; } } else { if (!int.TryParse(xmlNode.InnerText, out this.maxCertificates)) { throw new AirSyncPermanentException(StatusCode.Sync_ServerError, this.GetValidationErrorXml(), null, false) { ErrorStringForProtocolLogger = "BadMaxCertsValueInResolveRecipients" }; } continue; } } else { int num; if (!int.TryParse(xmlNode.InnerText, out num)) { throw new AirSyncPermanentException(StatusCode.Sync_ServerError, this.GetValidationErrorXml(), null, false) { ErrorStringForProtocolLogger = "BadCertRetrievalValueInResolveRecipients" }; } this.certificateRetrieval = (ResolveRecipientsCommand.CertificateRetrievalType)num; if (this.certificateRetrieval != ResolveRecipientsCommand.CertificateRetrievalType.None && this.maxCertificates == 0) { this.maxCertificates = 65535; continue; } continue; } } throw new AirSyncPermanentException(StatusCode.Sync_ServerError, this.GetValidationErrorXml(), null, false) { ErrorStringForProtocolLogger = "BadOptionNode(" + xmlNode.LocalName + ")InResolveRecipients" }; } }
internal static PictureOptions Parse(XmlNode pictureOptionsNode, StatusCode protocolError) { if (pictureOptionsNode == null) { return(null); } PictureOptions pictureOptions = new PictureOptions(); foreach (object obj in pictureOptionsNode.ChildNodes) { XmlNode xmlNode = (XmlNode)obj; string localName; if ((localName = xmlNode.LocalName) != null) { if (!(localName == "MaxSize")) { if (!(localName == "MaxPictures")) { if (localName == "MaxResolution") { UserPhotoResolution userPhotoResolution; if (!Enum.TryParse <UserPhotoResolution>(xmlNode.InnerText, out userPhotoResolution)) { throw new AirSyncPermanentException(protocolError, false) { ErrorStringForProtocolLogger = "InvalidMaxResolution" }; } pictureOptions.MaxResolution = userPhotoResolution; pictureOptions.userPhotoSize = PictureOptions.GetUserPhotoSize(userPhotoResolution); continue; } } else { int num; if (!int.TryParse(xmlNode.InnerText, out num)) { throw new AirSyncPermanentException(protocolError, false) { ErrorStringForProtocolLogger = "InvalidMaxPictures" }; } pictureOptions.MaxPictures = num; continue; } } else { int num; if (!int.TryParse(xmlNode.InnerText, out num)) { throw new AirSyncPermanentException(protocolError, false) { ErrorStringForProtocolLogger = "InvalidMaxSize" }; } pictureOptions.MaxSize = num; continue; } } throw new AirSyncPermanentException(protocolError, false) { ErrorStringForProtocolLogger = "UnexpectedPictureOption:" + xmlNode.Name }; } return(pictureOptions); }