Ejemplo n.º 1
0
        // Token: 0x06000C3D RID: 3133 RVA: 0x000402AC File Offset: 0x0003E4AC
        internal MailboxItemFetchProvider(SyncStateStorage syncStateStorage, int protocolVersion, MailboxSession mailboxSession)
        {
            this.disposeTracker = this.GetDisposeTracker();
            AirSyncCounters.NumberOfMailboxItemFetches.Increment();
            this.syncStateStorage = syncStateStorage;
            this.mailboxSession   = mailboxSession;
            IAirSyncVersionFactory airSyncVersionFactory = AirSyncProtocolVersionParserBuilder.FromVersion(protocolVersion);

            this.syncStates             = new Dictionary <string, FolderSyncState>();
            this.schemaStates           = new Dictionary <string, AirSyncSchemaState>();
            this.bodyPreferences        = new List <BodyPreference>();
            this.bodyPartPreferences    = new List <BodyPartPreference>();
            this.schemaConverterOptions = new Hashtable();
            this.schemaStates.Add("Email", airSyncVersionFactory.CreateEmailSchema(null));
            this.schemaStates.Add("Calendar", airSyncVersionFactory.CreateCalendarSchema());
            this.schemaStates.Add("Contacts", airSyncVersionFactory.CreateContactsSchema());
            this.schemaStates.Add("Tasks", airSyncVersionFactory.CreateTasksSchema());
            AirSyncSchemaState airSyncSchemaState = airSyncVersionFactory.CreateNotesSchema();

            if (airSyncSchemaState != null)
            {
                this.schemaStates.Add("Notes", airSyncSchemaState);
            }
            airSyncSchemaState = airSyncVersionFactory.CreateSmsSchema();
            if (airSyncSchemaState != null)
            {
                this.schemaStates.Add("SMS", airSyncSchemaState);
            }
        }
            public SchemaCacheItem(AirSyncSchemaState schemaState, IAirSyncMissingPropertyStrategy missingPropertyStrategy)
            {
                this.schemaState = schemaState;
                AirSyncEntitySchemaState airSyncEntitySchemaState = this.schemaState as AirSyncEntitySchemaState;
                AirSyncXsoSchemaState    airSyncXsoSchemaState    = this.schemaState as AirSyncXsoSchemaState;

                if (airSyncEntitySchemaState != null)
                {
                    this.mailboxDataObject = airSyncEntitySchemaState.GetEntityDataObject();
                }
                else
                {
                    if (airSyncXsoSchemaState == null)
                    {
                        throw new ApplicationException(string.Format("SchemaState of type {0} is not supported", schemaState.GetType().FullName));
                    }
                    this.mailboxDataObject = airSyncXsoSchemaState.GetXsoDataObject();
                }
                this.airSyncDataObject = this.schemaState.GetAirSyncDataObject(new Hashtable(), missingPropertyStrategy);
            }
Ejemplo n.º 3
0
        // Token: 0x06000C40 RID: 3136 RVA: 0x000404C0 File Offset: 0x0003E6C0
        public void BuildResponse(XmlNode responseNode)
        {
            XmlNode xmlNode  = responseNode.OwnerDocument.CreateElement("Fetch", "ItemOperations:");
            XmlNode xmlNode2 = responseNode.OwnerDocument.CreateElement("Status", "ItemOperations:");
            XmlNode xmlNode3 = responseNode.OwnerDocument.CreateElement("Class", "AirSync:");
            XmlNode xmlNode4 = responseNode.OwnerDocument.CreateElement("Properties", "ItemOperations:");
            XmlNode xmlNode5 = responseNode.OwnerDocument.CreateElement("ServerId", "AirSync:");
            XmlNode xmlNode6 = responseNode.OwnerDocument.CreateElement("CollectionId", "AirSync:");
            XmlNode xmlNode7 = responseNode.OwnerDocument.CreateElement("LongId", "Search:");
            FlexibleSchemaStrategy missingPropertyStrategy = new FlexibleSchemaStrategy(this.schemaTags);

            this.schemaConverterOptions["BodyPreference"]     = this.bodyPreferences;
            this.schemaConverterOptions["BodyPartPreference"] = this.bodyPartPreferences;
            this.schemaConverterOptions["MIMESupport"]        = this.mimeSupport;
            bool flag = false;

            try
            {
                using (Item item = Item.Bind(this.mailboxSession, this.storeObjectId))
                {
                    if (this.removeRightsManagementProtection)
                    {
                        this.IrmRemoveRestriction(item);
                    }
                    if (this.bodyPartPreferences != null && this.bodyPartPreferences.Count > 0)
                    {
                        ConversationId valueOrDefault = item.GetValueOrDefault <ConversationId>(ItemSchema.ConversationId, null);
                        if (valueOrDefault != null)
                        {
                            Conversation conversation;
                            Command.CurrentCommand.GetOrCreateConversation(valueOrDefault, true, out conversation);
                            conversation.LoadItemParts(new List <StoreObjectId>
                            {
                                item.StoreObjectId
                            });
                        }
                    }
                    foreach (KeyValuePair <string, AirSyncSchemaState> keyValuePair in this.schemaStates)
                    {
                        AirSyncSchemaState       value = keyValuePair.Value;
                        AirSyncXsoSchemaState    airSyncXsoSchemaState    = value as AirSyncXsoSchemaState;
                        AirSyncEntitySchemaState airSyncEntitySchemaState = value as AirSyncEntitySchemaState;
                        IServerDataObject        serverDataObject;
                        if (airSyncXsoSchemaState != null)
                        {
                            serverDataObject = airSyncXsoSchemaState.GetXsoDataObject();
                        }
                        else
                        {
                            if (airSyncEntitySchemaState == null)
                            {
                                throw new NotImplementedException(string.Format("Schema state for \"{0}\" is not implemented yet.", keyValuePair.Key));
                            }
                            serverDataObject = airSyncEntitySchemaState.GetEntityDataObject();
                        }
                        if (serverDataObject.CanConvertItemClassUsingCurrentSchema(item.ClassName))
                        {
                            AirSyncDataObject airSyncDataObject = value.GetAirSyncDataObject(this.schemaConverterOptions, missingPropertyStrategy);
                            if (this.rightsManagementSupport)
                            {
                                Command.CurrentCommand.DecodeIrmMessage(item, true);
                            }
                            item.Load(serverDataObject.GetPrefetchProperties());
                            try
                            {
                                serverDataObject.Bind(item);
                                airSyncDataObject.Bind(xmlNode4);
                                airSyncDataObject.CopyFrom(serverDataObject);
                            }
                            finally
                            {
                                airSyncDataObject.Unbind();
                                serverDataObject.Unbind();
                            }
                            if (this.rightsManagementSupport)
                            {
                                Command.CurrentCommand.SaveLicense(item);
                            }
                            xmlNode3.InnerText = keyValuePair.Key;
                            flag = true;
                            break;
                        }
                    }
                }
            }
            catch (ObjectNotFoundException innerException)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_ClientServerConversion, innerException, false)
                      {
                          ErrorStringForProtocolLogger = "NotFoundInMbxFetch"
                      };
            }
            catch (AirSyncPermanentException)
            {
                throw;
            }
            catch (Exception ex)
            {
                if (!SyncCommand.IsItemSyncTolerableException(ex))
                {
                    throw;
                }
                AirSyncDiagnostics.TraceError <Exception>(ExTraceGlobals.ConversionTracer, this, "Sync-tolerable Item conversion Exception was thrown. Location BuildResponse(). {0}", ex);
            }
            if (!flag)
            {
                throw new AirSyncPermanentException(StatusCode.Sync_InvalidWaitTime, false)
                      {
                          ErrorStringForProtocolLogger = "ConvertErrorInMbxFetch"
                      };
            }
            xmlNode2.InnerText = 1.ToString(CultureInfo.InvariantCulture);
            xmlNode.AppendChild(xmlNode2);
            if (this.longId != null)
            {
                xmlNode7.InnerText = this.longId;
                xmlNode.AppendChild(xmlNode7);
            }
            else
            {
                xmlNode6.InnerText = this.collectionId;
                xmlNode.AppendChild(xmlNode6);
                xmlNode5.InnerText = this.serverId;
                xmlNode.AppendChild(xmlNode5);
            }
            xmlNode.AppendChild(xmlNode3);
            xmlNode.AppendChild(xmlNode4);
            if (this.multiPartResponse)
            {
                XmlNode xmlNode8 = xmlNode4["Body"];
                if (xmlNode8 != null)
                {
                    XmlNode            xmlNode9           = xmlNode8["Data"];
                    AirSyncBlobXmlNode airSyncBlobXmlNode = xmlNode9 as AirSyncBlobXmlNode;
                    if (xmlNode9 != null && (!string.IsNullOrEmpty(xmlNode9.InnerText) || (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null)))
                    {
                        XmlNode xmlNode10 = responseNode.OwnerDocument.CreateElement("Part", "ItemOperations:");
                        xmlNode10.InnerText = this.partNumber.ToString(CultureInfo.InvariantCulture);
                        xmlNode8.ReplaceChild(xmlNode10, xmlNode9);
                        if (airSyncBlobXmlNode != null && airSyncBlobXmlNode.Stream != null)
                        {
                            this.outStream = airSyncBlobXmlNode.Stream;
                            if (airSyncBlobXmlNode.Stream is AirSyncStream)
                            {
                                this.delayStreamDispose = true;
                            }
                            AirSyncDiagnostics.TraceError <Type>(ExTraceGlobals.ConversionTracer, this, "blobNode.Stream is of {0} type.", airSyncBlobXmlNode.Stream.GetType());
                        }
                        else
                        {
                            UTF8Encoding utf8Encoding = new UTF8Encoding();
                            this.outStream = new MemoryStream(utf8Encoding.GetBytes(xmlNode9.InnerText));
                        }
                    }
                }
            }
            responseNode.AppendChild(xmlNode);
        }