internal override void Update(bool verbose, string page) { try { HttpResult ret = Account.GVPost("https://www.google.com/voice/m/x?m=list&l=sms&o=0&lm=10"); string json = ret.Page.Split('\n')[1]; JObject o = JObject.Parse(json); JToken conversation = o["conversations_response"]["conversationgroup"]; if (conversation == null) { return; } foreach (var convo in conversation) { //var convo = c_group["conversation"]; string cid = ((JValue)convo["conversation"]["id"]).Value.ToString(); foreach (var msg in convo["call"]) { string id = ((JValue)msg["id"]).Value.ToString(); string message_text = ((JValue)msg["message_text"]).Value.ToString(); string status = ((JValue)msg["status"]).Value.ToString(); //string name = ((JValue)msg["contact"]["name"]).Value.ToString(); string phone_number = ((JValue)msg["phone_number"]).Value.ToString(); string start_time = ((JValue)msg["start_time"]).Value.ToString(); SMS sms = new SMS { CID = cid, ID = id, Name = phone_number, Number = phone_number, Text = message_text, Time = GoogleUtils.UnixTimeToDateTime(start_time), Self = status == "1", }; if (!SeenMessage(sms)) { Account.OnMessage_Internal(sms); } } } } catch (Exception ex) { Trace.WriteLine("GoogleVoice/Feed_SMS/Update *** " + ex); } }
internal override void Update(bool verbose, string page) { // TODO verbose and page are not used! try { HttpResult ret = Account.GVPost("https://www.google.com/voice/m/x?m=list&l=" + this.MessageType.ToString().ToLower() + "&o=0&lm=10"); string json = ret.Page.Split('\n')[1]; JObject o = JObject.Parse(json); JToken conversation = o["conversations_response"]["conversationgroup"]; if (conversation == null) { return; } foreach (var convo in conversation) { string cid = ((JValue)convo["conversation"]["id"]).Value.ToString(); foreach (var msg in convo["call"]) { string id = ((JValue)msg["id"]).Value.ToString(); //string name = ((JValue)msg["contact"]["name"]).Value.ToString(); string phone_number = ((JValue)msg["phone_number"]).Value.ToString(); string start_time = ((JValue)msg["start_time"]).Value.ToString(); Message vm = new Message { ID = id, Number = phone_number, Time = GoogleUtils.UnixTimeToDateTime(start_time), Class = this.MessageType, }; if (!SeenMessage(vm)) { Account.OnMessage_Internal(vm); } } } } catch (Exception ex) { Trace.WriteLine("GoogleVoice/Feed_SMS/Update *** " + ex); } }
internal override void Update(bool verbose, string page) { try { HttpResult ret = Account.GVPost("https://www.google.com/voice/m/x?m=list&l=voicemail&o=0&lm=10"); string json = ret.Page.Split('\n')[1]; JObject o = JObject.Parse(json); JToken conversation = o["conversations_response"]["conversationgroup"]; if (conversation == null) { return; } foreach (var convo in conversation) { string cid = ((JValue)convo["conversation"]["id"]).Value.ToString(); foreach (var msg in convo["call"]) { string id = ((JValue)msg["id"]).Value.ToString(); //string name = ((JValue)msg["contact"]["name"]).Value.ToString(); string phone_number = ((JValue)msg["phone_number"]).Value.ToString(); string start_time = ((JValue)msg["start_time"]).Value.ToString(); string transcript_status = ((JValue)msg["transcript_status"]).Value.ToString(); string transcript_text = ""; if (transcript_status == "1") { try { JToken transcript = msg["transcript"]; if (transcript != null) { JToken word_tokens = transcript["word_tokens"]; if (word_tokens != null) { foreach (var word in word_tokens) { // TODO we can pull out the accuracy and make pretty // looking message transcriptions string w = ((JValue)word["word"]).Value.ToString(); transcript_text += w + " "; } } } } catch (Exception ex) { Trace.Write("transcript processing: " + ex.Message); } } else { Trace.WriteLine("Transcript " + "noname" + ": " + transcript_status); // TODO wait for transcript // figure out status code! // continue; } var vm = new VoiceMailMessage { ID = id, Time = GoogleUtils.UnixTimeToDateTime(start_time), Number = phone_number, CID = cid, MessageText = transcript_text, }; if (!SeenMessage(vm)) { DownloadMessage(vm.ID); Account.OnMessage_Internal(vm); } } } } catch (Exception ex) { Trace.WriteLine("GoogleVoice/Feed_SMS/Update *** " + ex); } }