public static iPhoneApps ReadXmlStream(Stream inStream) { iPhoneApps appList = new iPhoneApps(); NodeCounts nodes = new NodeCounts(); XmlTextReader textReader = null; textReader = new XmlTextReader(inStream); textReader.Normalization = true; textReader.MoveToContent(); Boolean inDict = false; while (textReader.Read()) { XmlNodeType nType = textReader.NodeType; String type = nType.ToString(); String name = textReader.Name; String value = textReader.Value.ToString(); nodes.Inc(nType); switch (nType) { case XmlNodeType.Element: //Console.WriteLine(nType.ToString() + ": " + textReader.Name.ToString()); switch (name) { case "dict": if (!inDict) { appList.Add(); inDict = true; } break; case "key": appList.Last = PListNodeType.PLKey; break; case "string": appList.Last = PListNodeType.PLString; break; } break; case XmlNodeType.Text: //Console.WriteLine(nType.ToString() + ": " + textReader.Value.ToString()); switch (appList.Last) { case PListNodeType.PLKey: appList.Key = value; break; case PListNodeType.PLString: appList.Value = value; appList.ApplyKey(); break; } break; case XmlNodeType.EndElement: switch (name) { case "dict": inDict = false; break; case "key": //appList.ApplyKey(); break; } break; case XmlNodeType.Whitespace: break; default: //Console.WriteLine(nType.ToString() + ": " + textReader.Name.ToString()); break; } } for (Int32 i = 0; i < nodes.Count; i++ ) { NodeCount node = nodes.Nodes[i]; Console.WriteLine(node.ToString() + ": " + node.Count.ToString()); } return appList; }
private void ShowApplicationsNull() { this.statusMain.Text = "Loading Application List"; if (localApps == null) { String installedAppPath = "//private/var/root/Library/Installer/LocalPackages.plist"; if (myPhone.Exists(installedAppPath)) { using (Stream inStream = iPhoneFile.OpenRead(myPhone, installedAppPath)) { localApps = AppList.ReadXmlStream(inStream); } } CreateAppListGroups(localApps); listApps.Items.Clear(); for (Int32 i = 0; i < localApps.Applications.Length; i++) { iPhoneApp app = localApps.Applications[i]; ListViewItem item = new ListViewItem(); item.Name = app.Name; item.Text = app.Name; item.ToolTipText = app.Name + Environment.NewLine + app.Description; ListViewItem.ListViewSubItem version = new ListViewItem.ListViewSubItem(); version.Name = "Version"; version.Text = app.Version; item.SubItems.Add(version); ListViewItem.ListViewSubItem desc = new ListViewItem.ListViewSubItem(); desc.Name = "Description"; desc.Text = app.Description; item.SubItems.Add(desc); ListViewItem.ListViewSubItem pub = new ListViewItem.ListViewSubItem(); pub.Name = "Publisher"; pub.Text = app.Source; item.SubItems.Add(pub); item.Group = listApps.Groups[app.Category]; listApps.Items.Add(item); } } listApps.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); listApps.Visible = true; listFiles.Visible = false; SetStatus(); }
public static iPhoneApps ReadXmlStream(Stream inStream) { iPhoneApps appList = new iPhoneApps(); NodeCounts nodes = new NodeCounts(); XmlTextReader textReader = null; textReader = new XmlTextReader(inStream); textReader.Normalization = true; textReader.MoveToContent(); Boolean inDict = false; while (textReader.Read()) { XmlNodeType nType = textReader.NodeType; String type = nType.ToString(); String name = textReader.Name; String value = textReader.Value.ToString(); nodes.Inc(nType); switch (nType) { case XmlNodeType.Element: //Console.WriteLine(nType.ToString() + ": " + textReader.Name.ToString()); switch (name) { case "dict": if (!inDict) { appList.Add(); inDict = true; } break; case "key": appList.Last = PListNodeType.PLKey; break; case "string": appList.Last = PListNodeType.PLString; break; } break; case XmlNodeType.Text: //Console.WriteLine(nType.ToString() + ": " + textReader.Value.ToString()); switch (appList.Last) { case PListNodeType.PLKey: appList.Key = value; break; case PListNodeType.PLString: appList.Value = value; appList.ApplyKey(); break; } break; case XmlNodeType.EndElement: switch (name) { case "dict": inDict = false; break; case "key": //appList.ApplyKey(); break; } break; case XmlNodeType.Whitespace: break; default: //Console.WriteLine(nType.ToString() + ": " + textReader.Name.ToString()); break; } } for (Int32 i = 0; i < nodes.Count; i++) { NodeCount node = nodes.Nodes[i]; Console.WriteLine(node.ToString() + ": " + node.Count.ToString()); } return(appList); }
private void CreateAppListGroups(iPhoneApps Applications) { iPhoneAppCategories appCats = Applications.Categories; listApps.Groups.Clear(); for ( Int32 i = 0; i < appCats.Items.Length; i++ ) { ListViewGroup group = new ListViewGroup(); group.Name = appCats.Items[i].Name; group.Header = appCats.Items[i].Name + " Files"; listApps.Groups.Add(group); } }