Ejemplo n.º 1
0
 public override void OnHttpStatusOK(QQHttpResponse response)
 {
     string content = response.GetResponseString();
     // LOG.info("Poll email content: " + content);
     if (content.StartsWith("({e:-101"))
     {
         // 空,没有新邮件
         NotifyActionEvent(QQActionEventType.EVT_OK, null);
     }
     else if (content.StartsWith("({e:-100"))
     {
         // 凭证已经失效,需要重新登录或者获取wpkey	
         NotifyActionEvent(QQActionEventType.EVT_ERROR,
                 new QQException(QQErrorCode.INVALID_LOGIN_AUTH, content));
     }
     else
     {
         content = content.Substring(1, content.Length - 1);
         JArray arr = JArray.Parse(content);
         // 封装返回的邮件列表
         List<QQEmail> list = new List<QQEmail>();
         for (int i = 0; i < arr.Count; i++)
         {
             JObject json = arr[i].ToObject<JObject>();
             JObject ct = json["c"].ToObject<JObject>();
             QQEmail mail = new QQEmail();
             mail.Flag = json["t"].ToObject<long>();
             mail.Id = ct["mailid"].ToString();
             mail.Sender = ct["sender"].ToString();
             mail.SenderNick = ct["senderNick"].ToString();
             mail.SenderEmail = ct["senderEmail"].ToString();
             mail.Subject = ct["subject"].ToString();
             mail.Summary = ct["summary"].ToString();
             mail.Unread = true;
             list.Add(mail);
         }
         NotifyActionEvent(QQActionEventType.EVT_OK, new QQNotifyEvent(QQNotifyEventType.EMAIL_NOTIFY, list));
     }
 }