public void Overrides() { var extPlist = new PList <string, string>(_pList) { ["prop1"] = "overriden", ["propx"] = "valuex", ["prop5"] = null }; Assert.Equal(6, extPlist.Count); extPlist.Remove("prop2"); Assert.Equal(5, extPlist.Count); Assert.False(extPlist.ContainsKey("prop2")); Assert.Equal("overriden", extPlist["prop1"]); Assert.Equal("value1", extPlist.Prototype?["prop1"]); Assert.False(extPlist.TryGetValue("prop2", out _)); Assert.True(extPlist.Prototype?.TryGetValue("prop2", out _)); Assert.Equal("value2", extPlist.Prototype?["prop2"]); Assert.Equal("valuex", extPlist["propx"]); Assert.False(extPlist.Prototype?.TryGetValue("propx", out _)); Assert.Null(extPlist["prop5"]); Assert.NotNull(extPlist.Prototype?["prop5"]); Assert.Equal(5, extPlist.Count); Assert.All(extPlist.Keys, s => Assert.Contains(s, new [] { "prop1", "prop3", "prop4", "prop5", "propx" })); Assert.All(extPlist.Values, s => Assert.Contains(s, new[] { "overriden", "value3", "value4", null, "valuex" })); }
public void MoreOverrides() { var extPlist1 = new PList <string, string>(_pList); extPlist1.Remove("prop1"); var extPlist2 = new PList <string, string>(extPlist1); Assert.False(extPlist2.ContainsKey("prop1")); extPlist1["prop6"] = "value6"; extPlist1["prop7"] = "value7"; extPlist2["prop8"] = "value8"; Assert.Equal(7, extPlist2.Count); Assert.Equal(6, extPlist1.Count); extPlist1.Clear(); Assert.Equal("value1", extPlist2["prop1"]); Assert.False(extPlist1.ContainsKey("prop6")); Assert.Equal(6, extPlist2.Count); Assert.Equal(5, extPlist1.Count); }
public void LoadTheme(string themeName, string variantName) { if (this.ChatHandler == null) { throw new InvalidOperationException("Set ChatHandler first"); } string themeDirectory = System.IO.Path.Combine(ThemesDirectory, themeName) + ".AdiumMessageStyle"; if (!Directory.Exists(themeDirectory)) { throw new DirectoryNotFoundException(themeDirectory); } m_StylePath = Util.JoinPath(themeDirectory, "Contents", "Resources"); string plistPath = Util.JoinPath(themeDirectory, "Contents", "Info.plist"); // XXX: Add additional checks for other required files. if (!File.Exists(plistPath)) { throw new Exception("Missing required theme file: Info.plist"); } m_StyleInfo = new PList(plistPath); // Default Behavior m_AllowsCustomBackground = true; m_AllowsUserIcons = true; m_StyleVersion = m_StyleInfo.GetInt("MessageViewVersion"); // Pre-fetch our templates LoadTemplates(); // Style flags m_AllowsCustomBackground = !m_StyleInfo.Get<bool>("DisableCustomBackground"); m_TransparentDefaultBackground = m_StyleInfo.Get<bool>("DefaultBackgroundIsTransparent"); if (m_TransparentDefaultBackground) { // FIXME: Console.WriteLine("Transparent background not supported"); } m_CombineConsecutive = !m_StyleInfo.Get<bool>("DisableCombineConsecutive"); if (m_StyleInfo.ContainsKey("ShowsUserIcons")) { m_AllowsUserIcons = m_StyleInfo.Get<bool>("ShowsUserIcons"); } // User icon masking var maskName = m_StyleInfo.Get<string>("ImageMask"); if (!String.IsNullOrEmpty(maskName)) { // FIXME: Console.WriteLine("ImageMask not supported"); } m_AllowsColors = m_StyleInfo.Get<bool>("AllowTextColors"); if (!m_AllowsColors) { Console.WriteLine("AllowTextColors not supported"); } // FIXME: Need to selectively show certain actions depending on what's under the cursor. //this.AddAction(this.PageAction(QWebPage.WebAction.OpenLink)); //this.AddAction(this.PageAction(QWebPage.WebAction.CopyLinkToClipboard)); //this.AddAction(this.PageAction(QWebPage.WebAction.CopyImageToClipboard)); //this.AddSeparator(); QAction copyAction = this.PageAction(QWebPage.WebAction.Copy); copyAction.SetShortcuts(QKeySequence.StandardKey.Copy); this.AddAction(copyAction); this.AddAction(this.PageAction(QWebPage.WebAction.InspectElement)); // Create the base template string baseUri = "file://" + m_StylePath + "/"; string mainCssPath = "main.css"; string variantCssPath = PathForVariant(variantName); var formattedBaseTemplate = FormatBaseTemplate(baseUri, mainCssPath, variantCssPath); base.Page().MainFrame().SetHtml(formattedBaseTemplate, themeDirectory); QObject.Connect(this.Page().MainFrame(), Qt.SIGNAL("javaScriptWindowObjectCleared()"), HandleJavaScriptWindowObjectCleared); if (ConversationWidget.ThemesDirectory == null) { throw new Exception("Set ThemesDirectory first"); } this.ContextMenuPolicy = ContextMenuPolicy.ActionsContextMenu; this.Page().linkDelegationPolicy = QWebPage.LinkDelegationPolicy.DelegateAllLinks; QObject.Connect<QUrl>(this, Qt.SIGNAL("linkClicked(QUrl)"), HandleLinkClicked); m_ThemeLoaded = true; HandleJavaScriptWindowObjectCleared(); }
public void LoadTheme(string themeName, string variantName) { if (this.ChatHandler == null) { throw new InvalidOperationException("Set ChatHandler first"); } string themeDirectory = System.IO.Path.Combine(ThemesDirectory, themeName) + ".AdiumMessageStyle"; if (!Directory.Exists(themeDirectory)) { throw new DirectoryNotFoundException(themeDirectory); } m_StylePath = Util.JoinPath(themeDirectory, "Contents", "Resources"); string plistPath = Util.JoinPath(themeDirectory, "Contents", "Info.plist"); // XXX: Add additional checks for other required files. if (!File.Exists(plistPath)) { throw new Exception("Missing required theme file: Info.plist"); } m_StyleInfo = new PList(plistPath); // Default Behavior m_AllowsCustomBackground = true; m_AllowsUserIcons = true; m_StyleVersion = m_StyleInfo.GetInt("MessageViewVersion"); // Pre-fetch our templates LoadTemplates(); // Style flags m_AllowsCustomBackground = !m_StyleInfo.Get <bool>("DisableCustomBackground"); m_TransparentDefaultBackground = m_StyleInfo.Get <bool>("DefaultBackgroundIsTransparent"); if (m_TransparentDefaultBackground) { // FIXME: Console.WriteLine("Transparent background not supported"); } m_CombineConsecutive = !m_StyleInfo.Get <bool>("DisableCombineConsecutive"); if (m_StyleInfo.ContainsKey("ShowsUserIcons")) { m_AllowsUserIcons = m_StyleInfo.Get <bool>("ShowsUserIcons"); } // User icon masking var maskName = m_StyleInfo.Get <string>("ImageMask"); if (!String.IsNullOrEmpty(maskName)) { // FIXME: Console.WriteLine("ImageMask not supported"); } m_AllowsColors = m_StyleInfo.Get <bool>("AllowTextColors"); if (!m_AllowsColors) { Console.WriteLine("AllowTextColors not supported"); } // FIXME: Need to selectively show certain actions depending on what's under the cursor. //this.AddAction(this.PageAction(QWebPage.WebAction.OpenLink)); //this.AddAction(this.PageAction(QWebPage.WebAction.CopyLinkToClipboard)); //this.AddAction(this.PageAction(QWebPage.WebAction.CopyImageToClipboard)); //this.AddSeparator(); QAction copyAction = this.PageAction(QWebPage.WebAction.Copy); copyAction.SetShortcuts(QKeySequence.StandardKey.Copy); this.AddAction(copyAction); this.AddAction(this.PageAction(QWebPage.WebAction.InspectElement)); // Create the base template string baseUri = "file://" + m_StylePath + "/"; string mainCssPath = "main.css"; string variantCssPath = PathForVariant(variantName); var formattedBaseTemplate = FormatBaseTemplate(baseUri, mainCssPath, variantCssPath); base.Page().MainFrame().SetHtml(formattedBaseTemplate, themeDirectory); QObject.Connect(this.Page().MainFrame(), Qt.SIGNAL("javaScriptWindowObjectCleared()"), HandleJavaScriptWindowObjectCleared); if (ConversationWidget.ThemesDirectory == null) { throw new Exception("Set ThemesDirectory first"); } this.ContextMenuPolicy = ContextMenuPolicy.ActionsContextMenu; this.Page().linkDelegationPolicy = QWebPage.LinkDelegationPolicy.DelegateAllLinks; QObject.Connect <QUrl>(this, Qt.SIGNAL("linkClicked(QUrl)"), HandleLinkClicked); m_ThemeLoaded = true; HandleJavaScriptWindowObjectCleared(); }
public bool ConnectViaHouseArrest(string appId) { bool ret; IntPtr currDevice = this.iPhoneHandle; IntPtr ldService; IntPtr lockdownClient; Lockdown.LockdownError lockdownReturnCode = Lockdown.Start(currDevice, out lockdownClient, out ldService); IntPtr hHA; IntPtr hSvc; HouseArrest.house_arrest_error_t hea = HouseArrest.house_arrest_client_start_service(currDevice, out hHA, out hSvc); hea = HouseArrest.house_arrest_send_command(hHA, "VendDocuments", appId); IntPtr result; hea = HouseArrest.house_arrest_get_result(hHA, out result); XDocument har = LibiMobileDevice.PlistToXml(result); PList pl = new PList(har, true); if (pl.ContainsKey("Error")) { ret = false; } else { IntPtr HA_afc; HouseArrest.afc_error_t afce = HouseArrest.afc_client_new_from_house_arrest_client(hHA, out HA_afc); ret = afce == HouseArrest.afc_error_t.AFC_E_SUCCESS; if (ret) this.hAFC = HA_afc; } HouseArrest.house_arrest_client_free(hHA); Lockdown.FreeService(ldService); Lockdown.FreeClient(lockdownClient); return ret; }
public bool QueryDeveloperDisk() { bool ret = false; this.developer = false; IntPtr currDevice = this.iPhoneHandle; IntPtr ldService; IntPtr lockdownClient; Lockdown.LockdownError lockdownReturnCode = Lockdown.Start(currDevice, out lockdownClient, out ldService); if (!(lockdownReturnCode == Lockdown.LockdownError.LOCKDOWN_E_SUCCESS)) return false; IntPtr ddservice; IntPtr ddclient; Lockdown.LockdownError lde = Lockdown.lockdownd_start_service(lockdownClient, "com.apple.mobile.mobile_image_mounter", out ddservice); if (!(lde == Lockdown.LockdownError.LOCKDOWN_E_SUCCESS)) return false; ImageMounter.mobile_image_mounter_error_t dde = ImageMounter.mobile_image_mounter_new(currDevice, ddservice, out ddclient); if (!(dde == ImageMounter.mobile_image_mounter_error_t.MOBILE_IMAGE_MOUNTER_E_SUCCESS)) return false; string imageType = "Developer"; IntPtr resultPlist; dde = ImageMounter.mobile_image_mounter_lookup_image(ddclient, imageType, out resultPlist); if (!(dde == ImageMounter.mobile_image_mounter_error_t.MOBILE_IMAGE_MOUNTER_E_SUCCESS)) return false; ImageMounter.mobile_image_mounter_free(ddclient); Lockdown.FreeClient(lockdownClient); Lockdown.FreeService(ldService); XDocument xd = LibiMobileDevice.PlistToXml(resultPlist); PList pl = new PList(xd, true); this.developer = ret; ret = pl.ContainsKey("ImagePresent") && pl["ImagePresent"] == true; return ret; }