Esempio n. 1
0
 private void UpdateView(byte[] raw)
 {
     tagPageControl.Clear();
     xmlView.Clear();
     textView.txtRaw.Clear();
     wbxmlDoc.RemoveAll();
     rawBody = raw;
     if (validHeader)
     {
         tagPageControl.Add(xmlView);
         tagPageControl[0].Dock = DockStyle.Fill;
         wbxmlDoc.LoadBytes(rawBody);
         xmlView.SetXML(wbxmlDoc);
     }
     else
     {
         tagPageControl.Add(textView);
         tagPageControl[0].Dock = DockStyle.Fill;
         textView.txtRaw.AppendText("invalid vnd.ms-sync.wbxml package");
     }
 }
Esempio n. 2
0
            public Response(HttpResponseMessage response)
            {
                Logger.Instance.Trace(this, "Response received: {0} {1}\n{2}", (int)response.StatusCode, response.ReasonPhrase, response.Headers);

                // Check for ZPush headers
                // GAB name is now hex encoded, but also support old-style for transition
                string gabNameOrig = GetStringHeader(response, Constants.ZPUSH_HEADER_GAB_NAME);

                if (gabNameOrig != null && new Regex("^[0-9a-fA-F]+$").IsMatch(gabNameOrig))
                {
                    GABName = StringUtil.HexToUtf8(gabNameOrig);
                }
                else
                {
                    GABName = gabNameOrig;
                }

                Capabilities   = ZPushCapabilities.Parse(GetStringHeader(response, Constants.ZPUSH_HEADER_CAPABILITIES));
                ZPushVersion   = GetStringHeader(response, Constants.ZPUSH_HEADER_VERSION);
                SignaturesHash = GetStringHeader(response, Constants.ZPUSH_HEADER_SIGNATURES_HASH);

                // Check for success
                Success = response.IsSuccessStatusCode;
                if (Success)
                {
                    // Parse the body
                    using (HttpContent responseContent = response.Content)
                    {
                        byte[] result = responseContent.ReadAsByteArrayAsync().Result;
                        Body = new WBXMLDocument();
                        Body.VersionNumber = 1.3;
                        Body.TagCodeSpace  = new ActiveSyncCodeSpace();
                        Body.Encoding      = Encoding.UTF8;
                        Body.LoadBytes(result);
                    }
                }

                Logger.Instance.Trace(this, "Response parsed: {0}", Body == null ? "Failure" : Body.ToXMLString());
            }