Esempio n. 1
0
        private void LoadManifests()
        {
            comboBox1.Items.Clear();
            string s = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            s = MyPath.Combine(s, "Apple Computer", "MobileSync", "Backup");
            try
            {
                DirectoryInfo d = new DirectoryInfo(s);
                foreach (DirectoryInfo sd in d.GetDirectories())
                {
                    comboBox1.Items.Add(LoadManifest(sd.FullName));
                }
            }
            catch (Exception)
            {
                MessageBox.Show("没有找到iTunes备份文件夹,可能需要手动选择。");
            }
            comboBox1.Items.Add("<选择其他备份文件夹...>");
        }
Esempio n. 2
0
        private void LoadManifests()
        {
            comboBox1.Items.Clear();

            List <string> dirs = new List <string>();
            string        s    = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            s = MyPath.Combine(s, "Apple Computer", "MobileSync", "Backup");
            dirs.Add(s);

            string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName;

            if (Environment.OSVersion.Version.Major >= 6)
            {
                path = Directory.GetParent(path).ToString();
            }
            path = MyPath.Combine(path, "Apple", "MobileSync", "Backup");
            dirs.Add(path);

            try
            {
                foreach (string dir in dirs)
                {
                    if (Directory.Exists(dir))
                    {
                        DirectoryInfo d = new DirectoryInfo(dir);

                        foreach (DirectoryInfo sd in d.GetDirectories())
                        {
                            comboBox1.Items.Add(LoadManifest(sd.FullName));
                        }
                    }
                }
            }
            catch (Exception)
            {
                //MessageBox.Show("没有找到iTunes备份文件夹,可能需要手动选择。");
            }

            comboBox1.Items.Add("<选择其他备份文件夹...>");
        }
Esempio n. 3
0
        private void LoadManifests()
        {
            comboBox1.Items.Clear();
            string s = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            s = MyPath.Combine(s, "Apple Computer", "MobileSync", "Backup");
            try
            {
                DirectoryInfo d = new DirectoryInfo(s);
                int           numberOfBackups = 0;
                foreach (DirectoryInfo sd in d.GetDirectories())
                {
                    IPhoneBackup backup = LoadManifest(sd.FullName);
                    if (backup != null)
                    {
                        comboBox1.Items.Add(backup);
                        ++numberOfBackups;
                    }
                }

                if (numberOfBackups == 0)
                {
                    System.Threading.Timer timer = null;
                    timer = new System.Threading.Timer((obj) =>
                    {
                        MessageBox.Show("没有找到iTunes备份文件夹,可能需要手动选择。", "提示");
                        timer.Dispose();
                    }, null, 100, System.Threading.Timeout.Infinite);
                }
            }
            catch (Exception ex)
            {
                listBox1.Items.Add(ex.ToString());
            }
            comboBox1.Items.Add("<选择其他备份文件夹...>");
        }
Esempio n. 4
0
        public bool SaveHtmlRecord(SQLiteConnection conn, string userBase, string path, string displayname, string id, Friend myself, string table, Friend friend, Dictionary <string, Friend> friends, out int count, out HashSet <DownloadTask> emojidown)
        {
            bool succ = false;

            emojidown = new HashSet <DownloadTask>();
            count     = 0;
            try
            {
                Dictionary <string, string> chatremark = new Dictionary <string, string>();
                if (id.EndsWith("@chatroom") && friend != null && friend.dbContactChatRoom != null)
                {
                    chatremark = ReadChatRoomRemark(friend.dbContactChatRoom);
                }
                using (var cmd = new SQLiteCommand(conn))
                {
                    cmd.CommandText = "SELECT CreateTime,Message,Des,Type,MesLocalID FROM Chat_" + table;
                    using (var reader = cmd.ExecuteReader())
                    {
                        var assetsdir = Path.Combine(path, id + "_files");
                        Directory.CreateDirectory(assetsdir);
                        using (var sw = new StreamWriter(Path.Combine(path, id + ".html")))
                        {
                            sw.WriteLine(@"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">");
                            sw.WriteLine(@"<html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" /><title>" + displayname + " - 微信聊天记录</title></head>");
                            sw.WriteLine(@"<body><table width=""600"" border=""0"" style=""font-size:12px;border-collapse:separate;border-spacing:0px 20px;word-break:break-all;table-layout:fixed;word-wrap:break-word;"" align=""center"">");
                            while (reader.Read())
                            {
                                try
                                {
                                    var unixtime = reader.GetInt32(0);
                                    var message  = reader.GetString(1);
                                    var des      = reader.GetInt32(2);
                                    var type     = reader.GetInt32(3);
                                    var msgid    = reader.GetInt32(4);
                                    if (type == 10000)
                                    {
                                        sw.WriteLine(@"<tr><td width=""80"">&nbsp;</td><td width=""100"">&nbsp;</td><td>系统消息: " + message + @"</td></tr>");
                                        continue;
                                    }
                                    var ts = "";
                                    if (id.EndsWith("@chatroom"))
                                    {
                                        if (des == 0)
                                        {
                                            var txtsender = myself.DisplayName();
                                            if (chatremark.ContainsKeySafe(myself.UsrName))
                                            {
                                                txtsender = chatremark[myself.UsrName];
                                            }
                                            else if (chatremark.ContainsKeySafe(myself.alias))
                                            {
                                                txtsender = chatremark[myself.alias];
                                            }
                                            ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/" + myself.FindPortrait() + @""" width=""50"" height=""50"" /><br />" + txtsender + @"</td>";
                                        }
                                        else
                                        {
                                            var enter = message.IndexOf(":\n");
                                            if (enter > 0 && enter + 2 < message.Length)
                                            {
                                                var txtsender = message.Substring(0, enter);
                                                var senderid  = txtsender;
                                                message = message.Substring(enter + 2);
                                                if (chatremark.ContainsKeySafe(txtsender))
                                                {
                                                    txtsender = chatremark[txtsender];
                                                }
                                                else if (friends.ContainsKeySafe(txtsender))
                                                {
                                                    txtsender = friends[txtsender].DisplayName();
                                                }
                                                if (friends.ContainsKeySafe(senderid))
                                                {
                                                    ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/" + friends[senderid].FindPortrait() + @""" width=""50"" height=""50"" /><br />" + txtsender + @"</td>";
                                                }
                                                else
                                                {
                                                    ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/[email protected]"" width=""50"" height=""50"" /><br />" + txtsender + @"</td>";
                                                }
                                            }
                                            else
                                            {
                                                ts += @"<tr><td width=""80"" align=""center"">&nbsp;</td>";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (des == 0)
                                        {
                                            ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/" + myself.FindPortrait() + @""" width=""50"" height=""50"" /><br />" + myself.DisplayName() + @"</td>";
                                        }
                                        else if (friend != null)
                                        {
                                            ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/" + friend.FindPortrait() + @""" width=""50"" height=""50"" /><br />" + friend.DisplayName() + @"</td>";
                                        }
                                        else
                                        {
                                            ts += @"<tr><td width=""80"" align=""center""><img src=""Portrait/[email protected]"" width=""50"" height=""50"" /><br />" + displayname + @"</td>";
                                        }
                                    }
                                    if (type == 34)
                                    {
                                        var voicelen = -1;
                                        var match    = Regex.Match(message, @"voicelength=""(\d+?)""");
                                        if (match.Success)
                                        {
                                            voicelen = int.Parse(match.Groups[1].Value);
                                        }
                                        var audiosrc = GetBackupFilePath(MyPath.Combine(userBase, "Audio", table, msgid + ".aud"));
                                        if (audiosrc == null)
                                        {
                                            message = voicelen == -1 ? "[语音]" : "[语音 " + DisplayTime(voicelen) + "]";
                                        }
                                        else
                                        {
                                            ShellWait("silk_v3_decoder.exe", "\"" + audiosrc + "\" 1.pcm");
                                            ShellWait("lame.exe", "-r -s 24000 --preset voice 1.pcm \"" + Path.Combine(assetsdir, msgid + ".mp3") + "\"");
                                            message = "<audio controls><source src=\"" + id + "_files/" + msgid + ".mp3\" type=\"audio/mpeg\"><a href=\"" + id + "_files/" + msgid + ".mp3\">播放</a></audio>";
                                        }
                                    }
                                    else if (type == 47)
                                    {
                                        var match = Regex.Match(message, @"cdnurl ?= ?""(.+?)""");
                                        if (match.Success)
                                        {
                                            var localfile = RemoveCdata(match.Groups[1].Value);
                                            var match2    = Regex.Match(localfile, @"\/(\w+?)\/\w*$");
                                            if (!match2.Success)
                                            {
                                                localfile = RandomString(10);
                                            }
                                            else
                                            {
                                                localfile = match2.Groups[1].Value;
                                            }
                                            emojidown.Add(new DownloadTask()
                                            {
                                                url = match.Groups[1].Value, filename = localfile + ".gif"
                                            });
                                            message = "<img src=\"Emoji/" + localfile + ".gif\" style=\"max-width:100px;max-height:60px\" />";
                                        }
                                        else
                                        {
                                            message = "[表情]";
                                        }
                                    }
                                    else if (type == 62)
                                    {
                                        var hasthum = RequireResource(MyPath.Combine(userBase, "Video", table, msgid + ".video_thum"), Path.Combine(assetsdir, msgid + "_thum.jpg"));
                                        var hasvid  = RequireResource(MyPath.Combine(userBase, "Video", table, msgid + ".mp4"), Path.Combine(assetsdir, msgid + ".mp4"));
                                        if (hasthum && hasvid)
                                        {
                                            message = "<video controls poster=\"" + id + "_files/" + msgid + "_thum.jpg\"><source src=\"" + id + "_files/" + msgid + ".mp4\" type=\"video/mp4\"><a href=\"" + id + "_files/" + msgid + ".mp4\">播放</a></video>";
                                        }
                                        else if (hasthum)
                                        {
                                            message = "<img src=\"" + id + "_files/" + msgid + "_thum.jpg\" /> (视频丢失)";
                                        }
                                        else if (hasvid)
                                        {
                                            message = "<video controls><source src=\"" + id + "_files/" + msgid + ".mp4\" type=\"video/mp4\"><a href=\"" + id + "_files/" + msgid + ".mp4\">播放</a></video>";
                                        }
                                        else
                                        {
                                            message = "[视频]";
                                        }
                                    }
                                    else if (type == 50)
                                    {
                                        message = "[视频/语音通话]";
                                    }
                                    else if (type == 3)
                                    {
                                        var hasthum = RequireResource(MyPath.Combine(userBase, "Img", table, msgid + ".pic_thum"), Path.Combine(assetsdir, msgid + "_thum.jpg"));
                                        var haspic  = RequireResource(MyPath.Combine(userBase, "Img", table, msgid + ".pic"), Path.Combine(assetsdir, msgid + ".jpg"));
                                        if (hasthum && haspic)
                                        {
                                            message = "<a href=\"" + id + "_files/" + msgid + ".jpg\"><img src=\"" + id + "_files/" + msgid + "_thum.jpg\" style=\"max-width:100px;max-height:60px\" /></a>";
                                        }
                                        else if (hasthum)
                                        {
                                            message = "<img src=\"" + id + "_files/" + msgid + "_thum.jpg\" style=\"max-width:100px;max-height:60px\" />";
                                        }
                                        else if (haspic)
                                        {
                                            message = "<img src=\"" + id + "_files/" + msgid + ".jpg\" style=\"max-width:100px;max-height:60px\" />";
                                        }
                                        else
                                        {
                                            message = "[图片]";
                                        }
                                    }
                                    else if (type == 48)
                                    {
                                        var match1 = Regex.Match(message, @"x ?= ?""(.+?)""");
                                        var match2 = Regex.Match(message, @"y ?= ?""(.+?)""");
                                        var match3 = Regex.Match(message, @"label ?= ?""(.+?)""");
                                        if (match1.Success && match2.Success && match3.Success)
                                        {
                                            message = "[位置 (" + RemoveCdata(match2.Groups[1].Value) + "," + RemoveCdata(match1.Groups[1].Value) + ") " + RemoveCdata(match3.Groups[1].Value) + "]";
                                        }
                                        else
                                        {
                                            message = "[位置]";
                                        }
                                    }
                                    else if (type == 49)
                                    {
                                        if (message.Contains("<type>2001<"))
                                        {
                                            message = "[红包]";
                                        }
                                        else if (message.Contains("<type>2000<"))
                                        {
                                            message = "[转账]";
                                        }
                                        else if (message.Contains("<type>17<"))
                                        {
                                            message = "[实时位置共享]";
                                        }
                                        else if (message.Contains("<type>6<"))
                                        {
                                            message = "[文件]";
                                        }
                                        else
                                        {
                                            var match1 = Regex.Match(message, @"<title>(.+?)<\/title>");
                                            var match2 = Regex.Match(message, @"<des>(.*?)<\/des>");
                                            var match3 = Regex.Match(message, @"<url>(.+?)<\/url>");
                                            var match4 = Regex.Match(message, @"<thumburl>(.+?)<\/thumburl>");
                                            if (match1.Success && match3.Success)
                                            {
                                                message = "";
                                                if (match4.Success)
                                                {
                                                    message += "<img src=\"" + RemoveCdata(match4.Groups[1].Value) + "\" style=\"float:left;max-width:100px;max-height:60px\" />";
                                                }
                                                message += "<a href=\"" + RemoveCdata(match3.Groups[1].Value) + "\"><b>" + RemoveCdata(match1.Groups[1].Value) + "</b></a>";
                                                if (match2.Success)
                                                {
                                                    message += "<br />" + RemoveCdata(match2.Groups[1].Value);
                                                }
                                            }
                                            else
                                            {
                                                message = "[链接]";
                                            }
                                        }
                                    }
                                    else if (type == 42)
                                    {
                                        var match1 = Regex.Match(message, "nickname ?= ?\"(.+?)\"");
                                        var match2 = Regex.Match(message, "smallheadimgurl ?= ?\"(.+?)\"");
                                        if (match1.Success)
                                        {
                                            message = "";
                                            if (match2.Success)
                                            {
                                                message += "<img src=\"" + RemoveCdata(match2.Groups[1].Value) + "\" style=\"float:left;max-width:100px;max-height:60px\" />";
                                            }
                                            message += "[名片] " + RemoveCdata(match1.Groups[1].Value);
                                        }
                                        else
                                        {
                                            message = "[名片]";
                                        }
                                    }
                                    else
                                    {
                                        message = SafeHTML(message);
                                    }

                                    ts += @"<td width=""100"" align=""center"">" + FromUnixTime(unixtime).ToLocalTime().ToString().Replace(" ", "<br />") + "</td>";
                                    ts += @"<td>" + message + @"</td></tr>";
                                    sw.WriteLine(ts);
                                    count++;
                                }
                                catch (Exception) { }
                            }
                            sw.WriteLine(@"</body></html>");
                        }
                    }
                }
                succ = true;
            }
            catch (Exception) { }
            return(succ);
        }
Esempio n. 5
0
 public static string Combine(string a, string b, string c, string d)
 {
     return(Path.Combine(MyPath.Combine(a, b, c), d));
 }