ring account: add incoming call permissions

This commit adds the three options for dht calls.
If "Allow Unknown" is checked then Allow Contacts and History are greyed out,
since their value won't be used anyway.

I've simplified a bit the loadAccount method in AccRingVC.mm

Issue: #78241
Change-Id: Ie95b54d11bb979bb369db2344158f37a3320ec88
diff --git a/ui/AccRing.xib b/ui/AccRing.xib
index 82eebdb..dba5cfc 100644
--- a/ui/AccRing.xib
+++ b/ui/AccRing.xib
@@ -1,12 +1,15 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
     </dependencies>
     <objects>
         <customObject id="-2" userLabel="File's Owner" customClass="AccRingVC">
             <connections>
                 <outlet property="aliasTextField" destination="D7f-4A-xXM" id="i9Y-jZ-iWM"/>
+                <outlet property="allowContacts" destination="Zpn-KI-Jfm" id="Kni-5a-nbF"/>
+                <outlet property="allowHistory" destination="c6K-nF-ezL" id="d4A-JI-MHb"/>
+                <outlet property="allowUnknown" destination="reK-M8-Eie" id="cVi-aY-v2K"/>
                 <outlet property="autoAnswerButton" destination="6uh-UC-6i9" id="6e1-1I-OY3"/>
                 <outlet property="bootstrapField" destination="phb-wW-DQS" id="kcY-7z-bjM"/>
                 <outlet property="hashField" destination="c6M-WV-uVk" id="Jhb-0k-sBc"/>
@@ -20,11 +23,11 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="481" height="430"/>
+            <rect key="frame" x="0.0" y="-5" width="590" height="464"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c6M-WV-uVk">
-                    <rect key="frame" x="42" y="219" width="419" height="30"/>
+                    <rect key="frame" x="42" y="263" width="528" height="30"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" sendsActionOnEndEditing="YES" borderStyle="border" alignment="center" title="hash" id="cf0-xD-2WZ">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -32,15 +35,15 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FlW-Vd-Eem">
-                    <rect key="frame" x="40" y="186" width="112" height="17"/>
-                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bootstrap servers" id="B6b-iB-REZ">
+                    <rect key="frame" x="40" y="236" width="112" height="17"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Bootstrap server" id="B6b-iB-REZ">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
                 <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4QL-FW-Kjb">
-                    <rect key="frame" x="40" y="257" width="377" height="34"/>
+                    <rect key="frame" x="40" y="301" width="532" height="24"/>
                     <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="This is the hash you need to communicate to pass calls with a RING account" id="bca-Wv-Xul">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -48,16 +51,24 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="P8b-Ru-H5G">
-                    <rect key="frame" x="18" y="298" width="77" height="17"/>
+                    <rect key="frame" x="18" y="332" width="77" height="17"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Hash DHT" id="dPO-b1-o58">
                         <font key="font" metaFont="systemBold"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DUI-3g-gHb">
+                    <rect key="frame" x="18" y="102" width="85" height="17"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Permissions" id="EDd-FX-wcz">
+                        <font key="font" metaFont="systemBold"/>
+                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="D7f-4A-xXM">
-                    <rect key="frame" x="80" y="365" width="150" height="22"/>
-                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="HN3-i9-zmw">
+                    <rect key="frame" x="80" y="397" width="154" height="22"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Name or nickname..." drawsBackground="YES" id="HN3-i9-zmw">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -67,7 +78,7 @@
                     </connections>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="iSd-2v-I3h">
-                    <rect key="frame" x="18" y="393" width="56" height="17"/>
+                    <rect key="frame" x="18" y="427" width="56" height="17"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Account" id="1Sx-Et-CDM">
                         <font key="font" metaFont="systemBold"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -75,7 +86,7 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PJq-0f-wMN">
-                    <rect key="frame" x="42" y="336" width="38" height="17"/>
+                    <rect key="frame" x="42" y="368" width="38" height="17"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Type:" id="ubB-AZ-nAm">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -83,7 +94,7 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="idQ-yZ-XB3">
-                    <rect key="frame" x="40" y="368" width="34" height="17"/>
+                    <rect key="frame" x="40" y="400" width="34" height="17"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Alias" id="Wzq-V2-YLU">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -91,7 +102,7 @@
                     </textFieldCell>
                 </textField>
                 <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vov-vT-UPq">
-                    <rect key="frame" x="78" y="336" width="35" height="17"/>
+                    <rect key="frame" x="78" y="368" width="35" height="17"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="TYPE" id="Bqr-Gq-OgA">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@@ -99,7 +110,7 @@
                     </textFieldCell>
                 </textField>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="phb-wW-DQS">
-                    <rect key="frame" x="158" y="183" width="303" height="22"/>
+                    <rect key="frame" x="158" y="233" width="303" height="22"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="WQz-3X-MeC">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@@ -110,7 +121,7 @@
                     </connections>
                 </textField>
                 <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6uh-UC-6i9">
-                    <rect key="frame" x="18" y="115" width="135" height="18"/>
+                    <rect key="frame" x="40" y="165" width="135" height="18"/>
                     <buttonCell key="cell" type="check" title="Auto-answer calls" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="OeY-na-0YT">
                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                         <font key="font" metaFont="system"/>
@@ -120,7 +131,7 @@
                     </connections>
                 </button>
                 <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="e6G-kW-opo">
-                    <rect key="frame" x="18" y="84" width="168" height="18"/>
+                    <rect key="frame" x="40" y="134" width="168" height="18"/>
                     <buttonCell key="cell" type="check" title="Use custom user-agent" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="ddk-1G-0jU">
                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                         <font key="font" metaFont="system"/>
@@ -130,7 +141,7 @@
                     </connections>
                 </button>
                 <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fJM-4J-mvZ">
-                    <rect key="frame" x="192" y="82" width="269" height="22"/>
+                    <rect key="frame" x="214" y="132" width="269" height="22"/>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Rs0-jZ-NYs">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@@ -141,7 +152,7 @@
                     </connections>
                 </textField>
                 <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eaR-8q-smW">
-                    <rect key="frame" x="18" y="145" width="110" height="18"/>
+                    <rect key="frame" x="40" y="195" width="110" height="18"/>
                     <buttonCell key="cell" type="check" title="Upnp enabled" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="lHI-bz-ddQ">
                         <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
                         <font key="font" metaFont="system"/>
@@ -150,8 +161,47 @@
                         <action selector="toggleUpnp:" target="-2" id="Ptl-25-3Xz"/>
                     </connections>
                 </button>
+                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="EVi-Oa-N9k">
+                    <rect key="frame" x="240" y="400" width="243" height="17"/>
+                    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="left" title="This will be displayed to unknow peers" id="0Yt-xC-OWa">
+                        <font key="font" metaFont="smallSystem"/>
+                        <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                        <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+                    </textFieldCell>
+                </textField>
+                <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="c6K-nF-ezL">
+                    <rect key="frame" x="40" y="44" width="274" height="18"/>
+                    <buttonCell key="cell" type="check" title="Allow calls from peers in your call history" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="PaC-xE-SHA">
+                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <action selector="toggleAllowFromHistory:" target="-2" id="nl2-H4-ARL"/>
+                    </connections>
+                </button>
+                <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="reK-M8-Eie">
+                    <rect key="frame" x="40" y="71" width="218" height="18"/>
+                    <buttonCell key="cell" type="check" title="Allow calls from unknown peers" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="kmI-jb-aal">
+                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <action selector="toggleAllowFromUnknown:" target="-2" id="St8-jV-rUj"/>
+                    </connections>
+                </button>
+                <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zpn-KI-Jfm">
+                    <rect key="frame" x="40" y="18" width="276" height="18"/>
+                    <buttonCell key="cell" type="check" title="Allow calls from peers in your contact list" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="fX7-9W-XFl">
+                        <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+                        <font key="font" metaFont="system"/>
+                    </buttonCell>
+                    <connections>
+                        <action selector="toggleAllowFromContacts:" target="-2" id="s1A-th-o6G"/>
+                    </connections>
+                </button>
             </subviews>
-            <point key="canvasLocation" x="139.5" y="233"/>
+            <point key="canvasLocation" x="194" y="250"/>
         </customView>
+        <userDefaultsController representsSharedInstance="YES" id="OEq-Ja-Vda"/>
     </objects>
 </document>