private void exportConversation(Conversation c, String directory) { String fileName = directory + "\\" + (c.DisplayName + (c.getType() == 3?"-Broken Log":"")).Replace("\\", "-").Replace("/", "-").Replace(":", "-").Replace("*", "-") .Replace("\"", "-").Replace("|", "-").Replace(">", "-").Replace("<", "-").Replace("?", "-") + ".txt"; List <SkypeMessage> messages = getSkypeMessages(c); using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName)) { foreach (SkypeMessage message in messages) { file.WriteLine(this.formatMessage(message, c.DisplayName)); } } }
private void exportConversation(Conversation c, String directory) { String fileName = directory + "\\" + (c.DisplayName + (c.getType() == 3?"-Broken Log":"")).Replace("\\", "-").Replace("/", "-").Replace(":", "-").Replace("*", "-") .Replace("\"", "-").Replace("|", "-").Replace(">", "-").Replace("<", "-").Replace("?", "-") + ".txt"; List <SkypeMessage> messages = getSkypeMessages(c); using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName)) { foreach (SkypeMessage message in messages) { String format = (Properties.Settings.Default.Format != "") ? Properties.Settings.Default.Format : "[[Month]/[Day]/[Year] [Time]] [DisplayName]:"; file.WriteLine(this.formatMessage(message, format)); } } }
private void exportConversation(Conversation c, String directory) { String fileName = directory + "\\" + (c.DisplayName+(c.getType()==3?"-Broken Log":"")).Replace("\\", "-").Replace("/", "-").Replace(":", "-").Replace("*", "-") .Replace("\"", "-").Replace("|", "-").Replace(">", "-").Replace("<", "-").Replace("?", "-") +".txt"; List<SkypeMessage> messages = getSkypeMessages(c); using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName)) { foreach (SkypeMessage message in messages) { String format = (Properties.Settings.Default.Format != "") ? Properties.Settings.Default.Format : "[[Month]/[Day]/[Year] [Time]] [DisplayName]:"; file.WriteLine(this.formatMessage(message,format)); } } }
private List<SkypeMessage> getSkypeMessages(Conversation c) { List<SkypeMessage> messages = new List<SkypeMessage>(); //debugAdd("Loading messages for " + c.Identity); if (c.getType() == 2) { SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where chatname='" + c.Identity + "' order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { //debugAdd("Found message " + dataRead["body_xml"]); SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } else if(c.getType()==1) { if (c.chats.Length == 0) return messages; String wheres = ""; foreach (string name in c.chats) { wheres += "OR chatname='" + name + "' "; } SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where " + wheres.Substring(3) + " order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { //debugAdd("Found message " + dataRead["body_xml"]); SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } else if (c.getType() == 3) { String wheres = ""; if(c.chats!=null) foreach (string name in c.chats) { wheres += "OR dialog_partner='" + name + "' "; } SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where " + "ifnull(chatname, '') = '' and from_dispname='"+c.DisplayName+"'" + wheres + " order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } return messages; }
public void tryLoad() { listViewConversations.Items.Clear(); connection = new SQLiteConnection( "data source=" + this.textBoxDataBasePath.Text); if (true)//checkAndKilledSkype() { if (File.Exists(textBoxDataBasePath.Text)) { try { connection.Open(); debugAdd("connection opened"); Properties.Settings.Default.LastPath = textBoxDataBasePath.Text; Properties.Settings.Default.Save(); } catch { if(checkAndKilledSkype()) tryLoad(); } } else { MessageBox.Show("Error, file does not exist"); return; } } //file should be open SQLiteCommand cmd = connection.CreateCommand(); //last_activity_timestamp //consumption_horizon //inbox_timestamp cmd.CommandText = "select * from Conversations order by last_activity_timestamp desc"; SQLiteDataReader dataRead = cmd.ExecuteReader(); listViewConversations.Items.Clear(); while (dataRead.Read()) { Conversation tempConv = new Conversation( dataRead["displayname"].ToString(), dataRead["identity"].ToString(), dataRead["type"].ToString()); if (tempConv.DisplayName == "") continue; if (tempConv.getType()==1) { //we need the real name SQLiteCommand namecmd = connection.CreateCommand(); namecmd.CommandText = "select name from Chats WHERE dialog_partner ='" +dataRead["identity"]+"' order by timestamp"; SQLiteDataReader chatDataRead = namecmd.ExecuteReader(); List<String> chats = new List<String>(); while (chatDataRead.Read()) chats.Add(chatDataRead[0].ToString()); tempConv.chats = chats.ToArray(); if (tempConv.chats.Length <= 0) { //tempConv.setType(3); continue; } } if (tempConv.getType() < 3) { ListViewItem tempItem = new ListViewItem(tempConv.DisplayName); tempItem.Tag = tempConv; tempItem.ToolTipText = tempConv.DisplayName + "\r\n" + tempConv.Identity; tempItem.ImageIndex = tempItem.StateImageIndex = tempConv.getType() - 1; listViewConversations.Items.Add(tempItem); } debugAdd("Found: "+ dataRead["displayname"] + " at "+tempConv.Identity); } cmd.Dispose(); // find broken msn b.s. if (true) { SQLiteCommand brokenCmd = connection.CreateCommand(); brokenCmd.CommandText = "select DISTINCT author,from_dispname from Messages where ifnull(chatname, '') = '' and ifnull(dialog_partner, '') = '' order by timestamp desc"; SQLiteDataReader brokenDataRead = brokenCmd.ExecuteReader(); while (brokenDataRead.Read()) { debugAdd("found missing partner with id of " + brokenDataRead["from_dispname"]); Conversation tempConv = new Conversation( brokenDataRead["from_dispname"].ToString(), "", "3"); List<String> chats = new List<String>(); chats.Add(brokenDataRead["from_dispname"].ToString()); chats.Add(brokenDataRead["author"].ToString()); tempConv.chats = chats.ToArray(); ListViewItem tempItem = new ListViewItem(tempConv.DisplayName); tempItem.Tag = tempConv; tempItem.ToolTipText = tempConv.DisplayName + "\r\n" + tempConv.Identity; tempItem.ImageIndex = tempItem.StateImageIndex = tempConv.getType() - 1; listViewConversations.Items.Add(tempItem); } } }
private List <SkypeMessage> getSkypeMessages(Conversation c) { List <SkypeMessage> messages = new List <SkypeMessage>(); //debugAdd("Loading messages for " + c.Identity); if (c.getType() == 2) { SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where chatname='" + c.Identity + "' order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { //debugAdd("Found message " + dataRead["body_xml"]); SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } else if (c.getType() == 1) { if (c.chats.Length == 0) { return(messages); } SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where convo_id = " + c.ConvoId + " order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { //debugAdd("Found message " + dataRead["body_xml"]); SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } else if (c.getType() == 3) { String wheres = ""; if (c.chats != null) { foreach (string name in c.chats) { wheres += "OR dialog_partner='" + name + "' "; } } SQLiteCommand cmd = connection.CreateCommand(); cmd.CommandText = "select timestamp,from_dispname,author,body_xml from Messages where " + "ifnull(chatname, '') = '' and from_dispname='" + c.DisplayName + "'" + wheres + " order by timestamp"; SQLiteDataReader dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { SkypeMessage message = new SkypeMessage(); message.sender = dataRead["from_dispname"].ToString(); message.senderID = dataRead["author"].ToString(); message.setData(dataRead["body_xml"].ToString()); message.setDate(dataRead["timestamp"].ToString()); messages.Add(message); } } return(messages); }
public void tryLoad() { listViewConversations.Items.Clear(); connection = new SQLiteConnection( "data source=" + this.textBoxDataBasePath.Text); if (true)//checkAndKilledSkype() { if (File.Exists(textBoxDataBasePath.Text)) { try { connection.Open(); debugAdd("connection opened"); Properties.Settings.Default.LastPath = textBoxDataBasePath.Text; Properties.Settings.Default.Save(); } catch { if (checkAndKilledSkype()) { tryLoad(); } } } else { MessageBox.Show("Error, file does not exist"); return; } } //file should be open SQLiteCommand cmd = connection.CreateCommand(); //last_activity_timestamp //consumption_horizon //inbox_timestamp cmd.CommandText = "select * from Conversations order by last_activity_timestamp desc"; SQLiteDataReader dataRead = cmd.ExecuteReader(); listViewConversations.Items.Clear(); while (dataRead.Read()) { Conversation tempConv = new Conversation( dataRead["displayname"].ToString(), dataRead["identity"].ToString(), dataRead["type"].ToString(), dataRead["id"].ToString()); if (tempConv.DisplayName == "") { continue; } if (tempConv.getType() == 1) { //we need the real name SQLiteCommand namecmd = connection.CreateCommand(); namecmd.CommandText = "select name from Chats WHERE dialog_partner ='" + dataRead["identity"] + "' order by timestamp"; SQLiteDataReader chatDataRead = namecmd.ExecuteReader(); List <String> chats = new List <String>(); while (chatDataRead.Read()) { chats.Add(chatDataRead[0].ToString()); } tempConv.chats = chats.ToArray(); if (tempConv.chats.Length <= 0) { //tempConv.setType(3); continue; } } if (tempConv.getType() < 3) { ListViewItem tempItem = new ListViewItem(tempConv.DisplayName); tempItem.Tag = tempConv; tempItem.ToolTipText = tempConv.DisplayName + "\r\n" + tempConv.Identity; tempItem.ImageIndex = tempItem.StateImageIndex = tempConv.getType() - 1; listViewConversations.Items.Add(tempItem); } debugAdd("Found: " + dataRead["displayname"] + " at " + tempConv.Identity); } cmd.Dispose(); // find broken msn b.s. if (true) { SQLiteCommand brokenCmd = connection.CreateCommand(); brokenCmd.CommandText = "select DISTINCT author,from_dispname from Messages where ifnull(chatname, '') = '' and ifnull(dialog_partner, '') = '' order by timestamp desc"; SQLiteDataReader brokenDataRead = brokenCmd.ExecuteReader(); while (brokenDataRead.Read()) { debugAdd("found missing partner with id of " + brokenDataRead["from_dispname"]); Conversation tempConv = new Conversation( brokenDataRead["from_dispname"].ToString(), "", "3", "-1"); List <String> chats = new List <String>(); chats.Add(brokenDataRead["from_dispname"].ToString()); chats.Add(brokenDataRead["author"].ToString()); tempConv.chats = chats.ToArray(); ListViewItem tempItem = new ListViewItem(tempConv.DisplayName); tempItem.Tag = tempConv; tempItem.ToolTipText = tempConv.DisplayName + "\r\n" + tempConv.Identity; tempItem.ImageIndex = tempItem.StateImageIndex = tempConv.getType() - 1; listViewConversations.Items.Add(tempItem); } } }
private void exportConversation(Conversation c, String directory) { String fileName = directory + "\\" + (c.DisplayName+(c.getType()==3?"-Broken Log":"")).Replace("\\", "-").Replace("/", "-").Replace(":", "-").Replace("*", "-") .Replace("\"", "-").Replace("|", "-").Replace(">", "-").Replace("<", "-").Replace("?", "-") +".txt"; List<SkypeMessage> messages = getSkypeMessages(c); using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName)) { foreach (SkypeMessage message in messages) { file.WriteLine(this.formatMessage(message, c.DisplayName)); } } }