public bool Equals(PString s, bool ignoreCase) { byte *pStr1 = _address; byte *pStr2 = s._address; byte b1, b2; do { b1 = *pStr1++; b2 = *pStr2++; if (b1 != b2) { if (ignoreCase) { if ((b1 >= 0x41) && (b1 <= 0x5A)) { if (b1 + 0x20 == b2) { continue; } } else if ((b1 >= 0x61) && (b1 <= 0x7A)) { if (b1 - 0x20 == b2) { continue; } } } return(false); } }while (b1 != 0); return(true); }
PString MergeEntitlementString(PString pstr, MobileProvision profile) { string TeamIdentifierPrefix; string AppIdentifierPrefix; if (string.IsNullOrEmpty (pstr.Value)) return (PString) pstr.Clone (); if (profile == null) { if (!warnedTeamIdentifierPrefix && pstr.Value.Contains ("$(TeamIdentifierPrefix)")) { Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "Cannot expand $(TeamIdentifierPrefix) in Entitlements.plist without a provisioning profile."); warnedTeamIdentifierPrefix = true; } if (!warnedAppIdentifierPrefix && pstr.Value.Contains ("$(AppIdentifierPrefix)")) { Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "Cannot expand $(AppIdentifierPrefix) in Entitlements.plist without a provisioning profile."); warnedAppIdentifierPrefix = true; } } if (profile != null && profile.ApplicationIdentifierPrefix.Count > 0) AppIdentifierPrefix = profile.ApplicationIdentifierPrefix[0] + "."; else AppIdentifierPrefix = string.Empty; if (profile != null && profile.TeamIdentifierPrefix.Count > 0) TeamIdentifierPrefix = profile.TeamIdentifierPrefix[0] + "."; else TeamIdentifierPrefix = AppIdentifierPrefix; var customTags = new Dictionary<string, string> (StringComparer.OrdinalIgnoreCase) { { "TeamIdentifierPrefix", TeamIdentifierPrefix }, { "AppIdentifierPrefix", AppIdentifierPrefix }, { "CFBundleIdentifier", BundleIdentifier }, }; var expanded = StringParserService.Parse (pstr.Value, customTags); if (expanded.IndexOf ('*') != -1) { int asterisk = expanded.IndexOf ('*'); string prefix; if (expanded.StartsWith (TeamIdentifierPrefix, StringComparison.Ordinal)) prefix = TeamIdentifierPrefix; else if (expanded.StartsWith (AppIdentifierPrefix, StringComparison.Ordinal)) prefix = AppIdentifierPrefix; else prefix = string.Empty; var baseBundleIdentifier = expanded.Substring (prefix.Length, asterisk - prefix.Length); if (!BundleIdentifier.StartsWith (baseBundleIdentifier, StringComparison.Ordinal)) expanded = expanded.Replace ("*", BundleIdentifier); else expanded = prefix + BundleIdentifier; } return new PString (expanded); }
protected virtual PDictionary GetCompiledEntitlements(MobileProvision profile, PDictionary template) { var entitlements = new PDictionary (); if (profile != null && MergeProfileEntitlements) { // start off with the settings from the provisioning profile foreach (var item in profile.Entitlements) { if (!AllowedProvisioningKeys.Contains (item.Key)) continue; var value = item.Value; if (item.Key == "com.apple.developer.icloud-container-environment") value = new PString ("Development"); else if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) value = MergeEntitlementString ((PString) value, profile); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else value = value.Clone (); if (value != null) entitlements.Add (item.Key, value); } } // merge in the user's values foreach (var item in template) { var value = item.Value; if (item.Key == "com.apple.developer.ubiquity-container-identifiers" || item.Key == "com.apple.developer.icloud-container-identifiers" || item.Key == "com.apple.developer.icloud-container-environment" || item.Key == "com.apple.developer.icloud-services") { if (profile == null) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "iCloud entitlements such as '" + item.Key + "' require a Provisioning Profile."); else if (!profile.Entitlements.ContainsKey (item.Key)) Log.LogWarning (null, null, null, Entitlements, 0, 0, 0, 0, "The iCloud entitlement '" + item.Key + "' is not supported by the Provisioning Profile."); } else if (item.Key == ApplicationIdentifierKey) { var str = value as PString; // Ignore ONLY if it is empty, otherwise take the user's value if (str == null || string.IsNullOrEmpty (str.Value)) continue; } if (value is PDictionary) value = MergeEntitlementDictionary ((PDictionary) value, profile); else if (value is PString) value = MergeEntitlementString ((PString) value, profile); else if (value is PArray) value = MergeEntitlementArray ((PArray) value, profile); else value = value.Clone (); if (value != null) entitlements[item.Key] = value; } return entitlements; }
public CustomPropertiesWidget (PListScheme scheme) { this.scheme = scheme = scheme ?? PListScheme.Empty; treeview = new PopupTreeView (this); treeview.HeadersClickable = true; this.PackStart (treeview, true, true, 0); ShowAll (); var keyRenderer = new CellRendererCombo (); keyRenderer.Editable = true; keyRenderer.Model = keyStore; keyRenderer.Mode = CellRendererMode.Editable; keyRenderer.TextColumn = 0; keyRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter selIter; if (!treeStore.GetIterFromString (out selIter, args.Path)) return; if (args.NewText == (string)treeStore.GetValue (selIter, 0)) return; var obj = (PObject)treeStore.GetValue (selIter, 1); var dict = obj.Parent as PDictionary; if (dict == null) return; var key = scheme.Keys.FirstOrDefault (k => k.Identifier == args.NewText || k.Description == args.NewText); var newKey = key != null ? key.Identifier : args.NewText; dict.ChangeKey (obj, newKey, key == null || obj.TypeString == key.Type ? null : CreateNewObject (key.Type)); }; var col = new TreeViewColumn (); col.Resizable = true; col.Title = GettextCatalog.GetString ("Property"); col.PackStart (keyRenderer, true); col.SetCellDataFunc (keyRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; string id = (string)tree_model.GetValue (iter, 0) ?? ""; var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Text = id; renderer.Editable = false; renderer.Sensitive = false; return; } var key = scheme.GetKey (id); renderer.Editable = !(obj.Parent is PArray); renderer.Sensitive = true; renderer.Text = key != null && ShowDescriptions ? GettextCatalog.GetString (key.Description) : id; }); treeview.AppendColumn (col); var iconSize = IconSize.Menu; col = new TreeViewColumn { MinWidth = 25, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize }; var removeRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-remove", IconSize.Menu)); removeRenderer.Clicked += delegate { TreeIter iter; bool hasSelection = treeview.Selection.GetSelected (out iter); PObject obj = null; if (hasSelection) { obj = (PObject)treeStore.GetValue (iter, 1); obj.Remove (); } }; col.PackEnd (removeRenderer, false); col.SetCellDataFunc (removeRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { removeRenderer.Visible = treeview.Selection.IterIsSelected (iter) && !AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); var addRenderer = new CellRendererButton (ImageService.GetPixbuf ("gtk-add", IconSize.Menu)); addRenderer.Clicked += delegate { Gtk.TreeIter iter = Gtk.TreeIter.Zero; if (!treeview.Selection.GetSelected (out iter)) return; PObject obj = null; if (treeStore.IterParent (out iter, iter)) obj = (PObject) treeStore.GetValue (iter, 1); obj = obj ?? nsDictionary; var newObj = new PString (""); if (obj is PArray) { var arr = (PArray) obj; arr.Add (newObj); } else if (obj is PDictionary) { string name = "newNode"; var dict = (PDictionary) obj; while (dict.ContainsKey (name)) name += "_"; dict.Add (name ,newObj); } else { return; } }; col.PackEnd (addRenderer, false); col.SetCellDataFunc (addRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { addRenderer.Visible = treeview.Selection.IterIsSelected (iter) && AddKeyNode.Equals (treeStore.GetValue (iter, 0)); }); treeview.AppendColumn (col); treeview.RowExpanded += delegate(object o, RowExpandedArgs args) { var obj = (PObject)treeStore.GetValue (args.Iter, 1); expandedObjects.Add (obj); }; treeview.RowCollapsed += delegate(object o, RowCollapsedArgs args) { var obj = (PObject)treeStore.GetValue (args.Iter, 1); expandedObjects.Remove (obj); }; var comboRenderer = new CellRendererCombo (); var typeModel = new ListStore (typeof (string)); typeModel.AppendValues ("Array"); typeModel.AppendValues ("Dictionary"); typeModel.AppendValues ("Boolean"); typeModel.AppendValues ("Data"); typeModel.AppendValues ("Date"); typeModel.AppendValues ("Number"); typeModel.AppendValues ("String"); comboRenderer.Model = typeModel; comboRenderer.Mode = CellRendererMode.Editable; comboRenderer.HasEntry = false; comboRenderer.TextColumn = 0; comboRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter selIter; if (!treeStore.GetIterFromString (out selIter, args.Path)) return; PObject oldObj = (PObject)treeStore.GetValue (selIter, 1); if (oldObj != null && oldObj.TypeString != args.NewText) oldObj.Replace (CreateNewObject (args.NewText)); }; treeview.AppendColumn (GettextCatalog.GetString ("Type"), comboRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; string id = (string)tree_model.GetValue (iter, 0) ?? ""; var key = scheme.GetKey (id); var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Editable = false; renderer.Text = ""; return; } renderer.Editable = key == null; renderer.ForegroundGdk = Style.Text (renderer.Editable ? StateType.Normal : StateType.Insensitive); renderer.Text = obj.TypeString; }); var propRenderer = new CellRendererCombo (); propRenderer.Model = valueStore; propRenderer.Mode = CellRendererMode.Editable; propRenderer.TextColumn = 0; propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) { valueStore.Clear (); if (Scheme == null) return; TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; var pObject = (PObject)treeStore.GetValue (iter, 1); if (pObject == null) return; var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null; if (key != null) { var descr = new List<string> (key.Values.Select (v => v.Description)); descr.Sort (); foreach (var val in descr) { valueStore.AppendValues (val); } } }; propRenderer.Edited += delegate(object o, EditedArgs args) { TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; var pObject = (PObject)treeStore.GetValue (iter, 1); if (pObject == null) return; string newText = args.NewText; var key = Parent != null? Scheme.GetKey (pObject.Parent.Key) : null; if (key != null) { foreach (var val in key.Values) { if (newText == val.Description) { newText = val.Identifier; break; } } } pObject.SetValue (newText); }; /* propRenderer.EditingStarted += delegate(object o, EditingStartedArgs args) { TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; PObject obj = (PObject)treeStore.GetValue (iter, 1); if (obj is PBoolean) { ((PBoolean)obj).Value = !((PBoolean)obj).Value; propRenderer.StopEditing (false); } };*/ treeview.AppendColumn (GettextCatalog.GetString ("Value"), propRenderer, delegate(TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var renderer = (CellRendererCombo)cell; var obj = (PObject)tree_model.GetValue (iter, 1); if (obj == null) { renderer.Editable = false; renderer.Text = ""; return; } renderer.Editable = !(obj is PArray || obj is PDictionary || obj is PData); obj.RenderValue (this, renderer); }); treeview.EnableGridLines = TreeViewGridLines.Horizontal; treeview.Model = treeStore; }
void ShowPopup (Gdk.EventButton evnt) { Gtk.TreeIter iter; bool hasSelection = Selection.GetSelected (out iter); PObject obj = null; if (hasSelection) { obj = (PObject)widget.treeStore.GetValue (iter, 1); } else { return; } var menu = new Gtk.Menu (); var newKey = new Gtk.MenuItem (GettextCatalog.GetString ("New key")); menu.Append (newKey); newKey.Activated += delegate(object sender, EventArgs e) { var newObj = new PString (""); PObject parent; if (obj != null) { parent = obj.Parent; } else { Gtk.TreeIter parentIter; if (widget.treeStore.IterParent (out parentIter, iter)) parent = (PObject)widget.treeStore.GetValue (parentIter, 1); else parent = widget.nsDictionary; } if (parent is PArray) { var arr = (PArray)parent; arr.Add (newObj); return; } var dict = parent as PDictionary; if (dict == null) return; string name = "newNode"; while (dict.ContainsKey (name)) name += "_"; dict[name] = newObj; }; if (hasSelection && obj != null) { var removeKey = new Gtk.MenuItem (GettextCatalog.GetString ("Remove key")); menu.Append (removeKey); removeKey.Activated += delegate(object sender, EventArgs e) { //the change event handler removes it from the store obj.Remove (); }; } if (widget.scheme != null) { menu.Append (new Gtk.SeparatorMenuItem ()); var showDescItem = new Gtk.CheckMenuItem (GettextCatalog.GetString ("Show descriptions")); showDescItem.Active = widget.ShowDescriptions; showDescItem.Activated += delegate { widget.ShowDescriptions = !widget.ShowDescriptions; }; menu.Append (showDescItem); } menu.ShowAll (); IdeApp.CommandService.ShowContextMenu (this, evnt, menu, this); }
public static bool Equals(PString s1, String s2, bool ignoreCase) { return(s1.Equals(s2, ignoreCase)); }
public StringListWidget () { treeview = new Gtk.TreeView (); treeview.HeadersVisible = false; PackStart (treeview, true, true, 0); ShowAll (); var col = new TreeViewColumn { MinWidth = CellRendererAddRemove.MinWidth, Resizable = true, Sizing = Gtk.TreeViewColumnSizing.Autosize }; var addRemoveRenderer = new CellRendererAddRemove (); col.PackStart (addRemoveRenderer, false); col.SetCellDataFunc (addRemoveRenderer, delegate (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { if (treeStore.GetValue (iter, (int) ListColumn.Object) != null) addRemoveRenderer.Action = CellRendererAddRemove.AddRemoveAction.Remove; else addRemoveRenderer.Action = CellRendererAddRemove.AddRemoveAction.Add; }); addRemoveRenderer.RemoveClicked += delegate { TreeIter iter; bool hasSelection = treeview.Selection.GetSelected (out iter); PObject obj = null; if (hasSelection) { obj = (PObject) treeStore.GetValue (iter, (int) ListColumn.Object); treeStore.Remove (ref iter); editing = true; obj.Remove (); editing = false; } }; addRemoveRenderer.AddClicked += delegate { PObject obj = new PString (string.Empty); TreeIter iter; bool hasSelection = treeview.Selection.GetSelected (out iter); if (hasSelection) { treeStore.SetValues (iter, string.Empty, obj); AppendCreateNewEntry (); editing = true; array.Add (obj); editing = false; } }; treeview.AppendColumn (col); var valueRenderer = new CellRendererCombo (); valueRenderer.Mode = CellRendererMode.Editable; valueRenderer.TextColumn = (int) ListColumn.DisplayValue; valueRenderer.Edited += delegate (object o, EditedArgs args) { TreeIter iter; if (!treeStore.GetIterFromString (out iter, args.Path)) return; var pObject = (PObject) treeStore.GetValue (iter, (int) ListColumn.Object); if (pObject == null) return; string newValue = !string.IsNullOrEmpty (ValuePrefix) ? ValuePrefix + args.NewText : args.NewText; pObject.SetValue (newValue); }; treeview.AppendColumn (GettextCatalog.GetString ("Value"), valueRenderer, delegate (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter) { var text = (string) tree_model.GetValue (iter, (int) ListColumn.DisplayValue); var obj = (PObject) tree_model.GetValue (iter, (int) ListColumn.Object); var renderer = (CellRendererCombo) cell; renderer.Sensitive = obj != null; renderer.Editable = obj != null; renderer.Text = text; }); treeview.EnableGridLines = TreeViewGridLines.Horizontal; treeview.Model = treeStore; }
public bool Equals(PString s, bool ignoreCase) { byte* pStr1 = _address; byte* pStr2 = s._address; byte b1, b2; do { b1 = *pStr1++; b2 = *pStr2++; if (b1 != b2) { if (ignoreCase) { if ((b1 >= 0x41) && (b1 <= 0x5A)) { if (b1 + 0x20 == b2) continue; } else if ((b1 >= 0x61) && (b1 <= 0x7A)) { if (b1 - 0x20 == b2) continue; } } return false; } } while (b1 != 0); return true; }
public static bool Equals(PString s1, String s2, bool ignoreCase) { return s1.Equals(s2, ignoreCase); }