Initial commit

This commit is contained in:
Tha_14
2024-02-22 21:43:11 +02:00
commit 1b96a031d2
1108 changed files with 157706 additions and 0 deletions

View File

@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@end

View File

@ -0,0 +1,34 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "AppDelegate.h"
#import "OCTMainWindowController.h"
#import "DDLog.h"
#import "DDASLLogger.h"
#import "DDTTYLogger.h"
@interface AppDelegate ()
@property (strong, nonatomic) IBOutlet OCTMainWindowController *window;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
self.window = [[OCTMainWindowController alloc] initWithWindowNibName:@"MainWindow"];
[self.window showWindow:self];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
// Insert code here to tear down your application
}
@end

View File

@ -0,0 +1,667 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="OSXDemo" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="OSXDemo" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About OSXDemo" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
<menuItem title="Services" id="NMo-om-nkz">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide OSXDemo" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
</connections>
</menuItem>
<menuItem title="Show All" id="Kd2-mp-pUS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit OSXDemo" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="File" id="dMs-cI-mzQ">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="File" id="bib-Uj-vzu">
<items>
<menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
<connections>
<action selector="newDocument:" target="-1" id="4Si-XN-c54"/>
</connections>
</menuItem>
<menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
<connections>
<action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/>
</connections>
</menuItem>
<menuItem title="Open Recent" id="tXI-mr-wws">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
<items>
<menuItem title="Clear Menu" id="vNY-rz-j42">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="clearRecentDocuments:" target="-1" id="Daa-9d-B3U"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
<menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
<connections>
<action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/>
</connections>
</menuItem>
<menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
<connections>
<action selector="saveDocument:" target="-1" id="teZ-XB-qJY"/>
</connections>
</menuItem>
<menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
<connections>
<action selector="saveDocumentAs:" target="-1" id="mDf-zr-I0C"/>
</connections>
</menuItem>
<menuItem title="Revert to Saved" id="KaW-ft-85H">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="revertDocumentToSaved:" target="-1" id="iJ3-Pv-kwq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
<menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
<connections>
<action selector="runPageLayout:" target="-1" id="Din-rz-gC5"/>
</connections>
</menuItem>
<menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
<connections>
<action selector="print:" target="-1" id="qaZ-4w-aoO"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Edit" id="5QF-Oa-p0T">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
<items>
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
<connections>
<action selector="undo:" target="-1" id="M6e-cu-g7V"/>
</connections>
</menuItem>
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
<connections>
<action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
<connections>
<action selector="cut:" target="-1" id="YJe-68-I9s"/>
</connections>
</menuItem>
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
<connections>
<action selector="copy:" target="-1" id="G1f-GL-Joy"/>
</connections>
</menuItem>
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
<connections>
<action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
</connections>
</menuItem>
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
</connections>
</menuItem>
<menuItem title="Delete" id="pa3-QI-u2k">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
</connections>
</menuItem>
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
<connections>
<action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
<menuItem title="Find" id="4EN-yA-p0u">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Find" id="1b7-l0-nxx">
<items>
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
<connections>
<action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
</connections>
</menuItem>
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
</connections>
</menuItem>
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
<connections>
<action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
</connections>
</menuItem>
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
<connections>
<action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
</connections>
</menuItem>
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
<connections>
<action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
</connections>
</menuItem>
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
<connections>
<action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
<items>
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
<connections>
<action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
</connections>
</menuItem>
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
<connections>
<action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
</connections>
</menuItem>
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
</connections>
</menuItem>
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Substitutions" id="9ic-FL-obx">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
<items>
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
</connections>
</menuItem>
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
</connections>
</menuItem>
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
</connections>
</menuItem>
<menuItem title="Smart Links" id="cwL-P1-jid">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
</connections>
</menuItem>
<menuItem title="Data Detectors" id="tRr-pd-1PS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
</connections>
</menuItem>
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Transformations" id="2oI-Rn-ZJC">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
<items>
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
</connections>
</menuItem>
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
</connections>
</menuItem>
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Speech" id="xrE-MZ-jX0">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
<items>
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
</connections>
</menuItem>
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Format" id="jxT-CU-nIS">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Format" id="GEO-Iw-cKr">
<items>
<menuItem title="Font" id="Gi5-1S-RQB">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
<items>
<menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq">
<connections>
<action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/>
</connections>
</menuItem>
<menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27">
<connections>
<action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/>
</connections>
</menuItem>
<menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq">
<connections>
<action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/>
</connections>
</menuItem>
<menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
<connections>
<action selector="underline:" target="-1" id="FYS-2b-JAY"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/>
<menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL">
<connections>
<action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/>
</connections>
</menuItem>
<menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST">
<connections>
<action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/>
<menuItem title="Kern" id="jBQ-r6-VK2">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Kern" id="tlD-Oa-oAM">
<items>
<menuItem title="Use Default" id="GUa-eO-cwY">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useStandardKerning:" target="-1" id="6dk-9l-Ckg"/>
</connections>
</menuItem>
<menuItem title="Use None" id="cDB-IK-hbR">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="turnOffKerning:" target="-1" id="U8a-gz-Maa"/>
</connections>
</menuItem>
<menuItem title="Tighten" id="46P-cB-AYj">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="tightenKerning:" target="-1" id="hr7-Nz-8ro"/>
</connections>
</menuItem>
<menuItem title="Loosen" id="ogc-rX-tC1">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="loosenKerning:" target="-1" id="8i4-f9-FKE"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Ligatures" id="o6e-r0-MWq">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
<items>
<menuItem title="Use Default" id="agt-UL-0e3">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useStandardLigatures:" target="-1" id="7uR-wd-Dx6"/>
</connections>
</menuItem>
<menuItem title="Use None" id="J7y-lM-qPV">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="turnOffLigatures:" target="-1" id="iX2-gA-Ilz"/>
</connections>
</menuItem>
<menuItem title="Use All" id="xQD-1f-W4t">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="useAllLigatures:" target="-1" id="KcB-kA-TuK"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Baseline" id="OaQ-X3-Vso">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Baseline" id="ijk-EB-dga">
<items>
<menuItem title="Use Default" id="3Om-Ey-2VK">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="unscript:" target="-1" id="0vZ-95-Ywn"/>
</connections>
</menuItem>
<menuItem title="Superscript" id="Rqc-34-cIF">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="superscript:" target="-1" id="3qV-fo-wpU"/>
</connections>
</menuItem>
<menuItem title="Subscript" id="I0S-gh-46l">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="subscript:" target="-1" id="Q6W-4W-IGz"/>
</connections>
</menuItem>
<menuItem title="Raise" id="2h7-ER-AoG">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="raiseBaseline:" target="-1" id="4sk-31-7Q9"/>
</connections>
</menuItem>
<menuItem title="Lower" id="1tx-W0-xDw">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="lowerBaseline:" target="-1" id="OF1-bc-KW4"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/>
<menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
<connections>
<action selector="orderFrontColorPanel:" target="-1" id="mSX-Xz-DV3"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/>
<menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="copyFont:" target="-1" id="GJO-xA-L4q"/>
</connections>
</menuItem>
<menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="pasteFont:" target="-1" id="JfD-CL-leO"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Text" id="Fal-I4-PZk">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Text" id="d9c-me-L2H">
<items>
<menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
<connections>
<action selector="alignLeft:" target="-1" id="zUv-R1-uAa"/>
</connections>
</menuItem>
<menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
<connections>
<action selector="alignCenter:" target="-1" id="spX-mk-kcS"/>
</connections>
</menuItem>
<menuItem title="Justify" id="J5U-5w-g23">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="alignJustified:" target="-1" id="ljL-7U-jND"/>
</connections>
</menuItem>
<menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
<connections>
<action selector="alignRight:" target="-1" id="r48-bG-YeY"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/>
<menuItem title="Writing Direction" id="H1b-Si-o9J">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
<items>
<menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem id="YGs-j5-SAR">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionNatural:" target="-1" id="qtV-5e-UBP"/>
</connections>
</menuItem>
<menuItem id="Lbh-J2-qVU">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionLeftToRight:" target="-1" id="S0X-9S-QSf"/>
</connections>
</menuItem>
<menuItem id="jFq-tB-4Kx">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeBaseWritingDirectionRightToLeft:" target="-1" id="5fk-qB-AqJ"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="swp-gr-a21"/>
<menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem id="Nop-cj-93Q">
<string key="title"> Default</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionNatural:" target="-1" id="lPI-Se-ZHp"/>
</connections>
</menuItem>
<menuItem id="BgM-ve-c93">
<string key="title"> Left to Right</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionLeftToRight:" target="-1" id="caW-Bv-w94"/>
</connections>
</menuItem>
<menuItem id="RB4-Sm-HuC">
<string key="title"> Right to Left</string>
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="makeTextWritingDirectionRightToLeft:" target="-1" id="EXD-6r-ZUu"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/>
<menuItem title="Show Ruler" id="vLm-3I-IUL">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleRuler:" target="-1" id="FOx-HJ-KwY"/>
</connections>
</menuItem>
<menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="copyRuler:" target="-1" id="71i-fW-3W2"/>
</connections>
</menuItem>
<menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="pasteRuler:" target="-1" id="cSh-wd-qM2"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="View" id="H8h-7b-M4v">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="HyV-fh-RgO">
<items>
<menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/>
</connections>
</menuItem>
<menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="aUF-d1-5bR">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
<connections>
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="R4o-n2-Eq4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="wpr-3q-Mcd">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
<items>
<menuItem title="OSXDemo Help" keyEquivalent="?" id="FKE-Sm-Kum">
<connections>
<action selector="showHelp:" target="-1" id="y7X-2Q-9no"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
</objects>
</document>

View File

@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
},
{
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>me.dvor.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 dvor. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTMainWindowController">
<connections>
<outlet property="mainView" destination="EiT-Mj-1SZ" id="s3w-x8-007"/>
<outlet property="tabView" destination="dee-pV-kUQ" id="jA8-zB-DNG"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="549" height="390"/>
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/>
<view key="contentView" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="549" height="390"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tabView initialItem="Vfd-vl-afF" translatesAutoresizingMaskIntoConstraints="NO" id="dee-pV-kUQ">
<rect key="frame" x="-7" y="-10" width="563" height="406"/>
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="User" identifier="1" id="Vfd-vl-afF">
<view key="view" id="sND-HD-MEq">
<rect key="frame" x="10" y="33" width="543" height="360"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Friends" identifier="2" id="bll-Ay-CiL">
<view key="view" id="ob7-g2-Mql">
<rect key="frame" x="10" y="33" width="543" height="360"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Chats" identifier="" id="R09-Ir-Pqw">
<view key="view" id="0G4-8E-wi5">
<rect key="frame" x="10" y="33" width="543" height="360"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Calls" identifier="" id="KGw-8l-4aK" userLabel="Calls">
<view key="view" id="gaG-RV-UfY">
<rect key="frame" x="10" y="33" width="543" height="360"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Files" identifier="" id="uxo-8a-TGl" userLabel="Files">
<view key="view" id="SkJ-nQ-fyf">
<rect key="frame" x="10" y="33" width="543" height="360"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
</tabViewItems>
</tabView>
</subviews>
<constraints>
<constraint firstItem="dee-pV-kUQ" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="BwN-kJ-2AQ"/>
<constraint firstItem="dee-pV-kUQ" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="Ege-PX-Ga5"/>
<constraint firstAttribute="trailing" secondItem="dee-pV-kUQ" secondAttribute="trailing" id="Fd3-L2-rxc"/>
<constraint firstAttribute="bottom" secondItem="dee-pV-kUQ" secondAttribute="bottom" id="NTS-88-QqR"/>
</constraints>
</view>
<point key="canvasLocation" x="407.5" y="432"/>
</window>
</objects>
</document>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTBootStrapViewController">
<connections>
<outlet property="ipv6Button" destination="pHg-S5-Bvi" id="P1y-y9-VKE"/>
<outlet property="udpButton" destination="tgf-jZ-bSu" id="oui-8A-BSH"/>
<outlet property="view" destination="c22-O7-iKe" id="oX2-SS-sBF"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="c22-O7-iKe">
<rect key="frame" x="0.0" y="0.0" width="589" height="380"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button translatesAutoresizingMaskIntoConstraints="NO" id="tgf-jZ-bSu">
<rect key="frame" x="531" y="163" width="50" height="55"/>
<buttonCell key="cell" type="check" title="UDP" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Y8J-fJ-dk3">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Scd-Yz-VvX">
<rect key="frame" x="245" y="43" width="100" height="32"/>
<constraints>
<constraint firstAttribute="width" secondItem="Scd-Yz-VvX" secondAttribute="height" multiplier="88:21" id="zNf-Kh-zgj"/>
</constraints>
<buttonCell key="cell" type="push" title="Bootstrap" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="88c-Ls-aPZ">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="bootstrapButtonTapped:" target="-2" id="M84-Km-pKN"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="pHg-S5-Bvi">
<rect key="frame" x="8" y="163" width="50" height="55"/>
<constraints>
<constraint firstAttribute="height" constant="51" id="kSA-WV-zDT"/>
</constraints>
<buttonCell key="cell" type="check" title="IPv6" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="WAk-kg-dbj">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="tgf-jZ-bSu" secondAttribute="trailing" constant="10" id="1KC-mq-a66"/>
<constraint firstItem="tgf-jZ-bSu" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="pHg-S5-Bvi" secondAttribute="trailing" constant="10" id="7x3-qU-zce"/>
<constraint firstItem="tgf-jZ-bSu" firstAttribute="centerY" secondItem="pHg-S5-Bvi" secondAttribute="centerY" id="IZ0-KA-OD8"/>
<constraint firstItem="tgf-jZ-bSu" firstAttribute="height" secondItem="pHg-S5-Bvi" secondAttribute="height" id="NHM-x7-RVG"/>
<constraint firstItem="pHg-S5-Bvi" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="aNF-4H-lCN"/>
<constraint firstAttribute="bottom" secondItem="Scd-Yz-VvX" secondAttribute="bottom" constant="50" id="d8e-bP-bK9"/>
<constraint firstItem="pHg-S5-Bvi" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" constant="10" id="e9Z-ez-yZu"/>
<constraint firstItem="tgf-jZ-bSu" firstAttribute="width" secondItem="pHg-S5-Bvi" secondAttribute="width" id="pbR-gn-uyZ"/>
<constraint firstItem="Scd-Yz-VvX" firstAttribute="centerX" secondItem="c22-O7-iKe" secondAttribute="centerX" id="yHM-IS-uNV"/>
</constraints>
<point key="canvasLocation" x="236.5" y="400"/>
</customView>
</objects>
</document>

View File

@ -0,0 +1,21 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
#import "OCTManagerConfiguration.h"
@class OCTBootStrapViewController;
@protocol OCTBootStrapViewDelegate <NSObject>
- (void)didBootStrap:(OCTBootStrapViewController *)controller;
@end
@interface OCTBootStrapViewController : NSViewController
@property (weak, nonatomic) id<OCTBootStrapViewDelegate> delegate;
- (instancetype)initWithConfiguration:(OCTManagerConfiguration *)configuration;
@end

View File

@ -0,0 +1,42 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTBootStrapViewController.h"
static NSString *const kNibName = @"OCTBootStrap";
@interface OCTBootStrapViewController ()
@property (strong, nonatomic) OCTManagerConfiguration *configuration;
@property (weak) IBOutlet NSButton *ipv6Button;
@property (weak) IBOutlet NSButton *udpButton;
@end
@implementation OCTBootStrapViewController
- (instancetype)initWithConfiguration:(OCTManagerConfiguration *)configuration
{
self = [super initWithNibName:kNibName bundle:nil];
if (! self) {
return nil;
}
_configuration = configuration;
return self;
}
#pragma mark - Private
- (IBAction)bootstrapButtonTapped:(NSButton *)sender
{
self.configuration.options.udpEnabled = self.udpButton.state;
self.configuration.options.ipv6Enabled = self.ipv6Button.state;
[self.delegate didBootStrap:self];
}
@end

View File

@ -0,0 +1,13 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
@protocol OCTManager;
@interface OCTCallsViewController : NSViewController
- (instancetype)initWithManager:(id<OCTManager>)manager;
@end

View File

@ -0,0 +1,203 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTCallsViewController.h"
#import "OCTSubmanagerCalls.h"
#import "OCTManager.h"
#import "OCTSubmanagerObjects.h"
#import "OCTCall.h"
#import "RLMCollectionChange+IndexSet.h"
static NSString *const kCellIdent = @"cellIdent";
@interface OCTCallsViewController () <NSTableViewDataSource, NSTableViewDelegate>
@property (weak, nonatomic) id<OCTManager> manager;
@property (strong, nonatomic) RLMResults<OCTCall *> *calls;
@property (strong, nonatomic) RLMNotificationToken *callsNotificationToken;
@property (weak) IBOutlet NSTableView *callsTableView;
@property (weak) IBOutlet NSView *videoContainerView;
@property (strong, nonatomic) NSView *videoView;
@end
@implementation OCTCallsViewController
- (instancetype)initWithManager:(id<OCTManager>)manager
{
self = [super init];
if (! self) {
return nil;
}
_manager = manager;
[manager.calls setupAndReturnError:nil];
_calls = [manager.objects objectsForType:OCTFetchRequestTypeCall predicate:nil];
return self;
}
- (void)dealloc
{
[self.callsNotificationToken invalidate];
}
- (void)viewDidLoad
{
[super viewDidLoad];
__weak typeof(self)weakSelf = self;
self.callsNotificationToken = [self.calls addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
if (error) {
NSLog(@"Failed to open Realm on background worker: %@", error);
return;
}
NSTableView *tableView = weakSelf.callsTableView;
// Initial run of the query will pass nil for the change information
if (! changes) {
[tableView reloadData];
return;
}
[tableView beginUpdates];
[tableView removeRowsAtIndexes:[changes deletionsSet] withAnimation:NSTableViewAnimationSlideLeft];
[tableView insertRowsAtIndexes:[changes insertionsSet] withAnimation:NSTableViewAnimationSlideRight];
[tableView reloadDataForRowIndexes:[changes modificationsSet] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[tableView endUpdates];
}];
}
- (void)setupVideoView
{
if (self.videoView == self.manager.calls.videoFeed) {
return;
}
if (self.videoView) {
[self.videoView removeFromSuperview];
self.videoView = nil;
}
self.videoView = self.manager.calls.videoFeed;
[self.videoContainerView addSubview:self.videoView];
NSLayoutConstraint *centerX = [NSLayoutConstraint constraintWithItem:self.videoView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.videoContainerView attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0];
NSLayoutConstraint *centerY = [NSLayoutConstraint constraintWithItem:self.videoView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.videoContainerView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0];
NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:self.videoView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.videoContainerView attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0.0];
NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:self.videoView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.videoContainerView attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.0];
self.videoView.translatesAutoresizingMaskIntoConstraints = NO;
[self.videoView setContentHuggingPriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationVertical];
[self.videoView setContentHuggingPriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
[self.videoContainerView addConstraints:@[centerX, centerY, widthConstraint, heightConstraint]];
}
#pragma mark - NSTableViewDelegate
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return self.calls.count;
}
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
return 300.0;
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
[self doSomeThingWithCallWithBlock:^(OCTCall *call) {
if (call.videoIsEnabled || call.friendSendingVideo) {
[self setupVideoView];
}
}];
}
#pragma mark - NSTableViewDataSource
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
OCTCall *call = self.calls[row];
NSTextField *textField = [self.callsTableView makeViewWithIdentifier:kCellIdent owner:nil];
if (! textField) {
textField = [NSTextField new];
textField.identifier = kCellIdent;
}
textField.stringValue = [NSString stringWithFormat:@"Friend name:%@\n"
@"Call\n"
@"Chat identifier %@\n"
@"call status: %ld\n"
@"callDuration: %f\n"
@"friend sending audio: %d\n"
@"friend receiving audio: %d\n"
@"friend sending video: %d\n"
@"friend receiving Video: %d\n",
call.caller.name,
call.chat.uniqueIdentifier, (long)call.status, call.callDuration, call.friendSendingAudio, call.friendAcceptingAudio,
call.friendSendingVideo, call.friendAcceptingVideo];
;
return textField;
}
#pragma mark - Actions
- (IBAction)callActionButtonPressed:(NSButton *)sender
{
[self doSomeThingWithCallWithBlock:^(OCTCall *call) {
[self.manager.calls answerCall:call enableAudio:YES enableVideo:YES error:nil];
}];
}
- (IBAction)sendCallControlSelected:(NSPopUpButton *)sender
{
[self doSomeThingWithCallWithBlock:^(OCTCall *call) {
OCTToxAVCallControl control = (OCTToxAVCallControl)[sender indexOfSelectedItem];
[self.manager.calls sendCallControl:control toCall:call error:nil];
}];
}
#pragma mark - Private
- (OCTCall *)callForCurrentlySelectedRow
{
NSInteger selectedRow = self.callsTableView.selectedRow;
if (selectedRow < 0) {
return nil;
}
OCTCall *call = self.calls[selectedRow];
return call;
}
- (BOOL)doSomeThingWithCallWithBlock:(void (^)(OCTCall *))block
{
NSInteger selectedRow = self.callsTableView.selectedRow;
if (selectedRow < 0) {
return NO;
}
OCTCall *call = self.calls[selectedRow];
block(call);
return YES;
}
@end

View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTCallsViewController">
<connections>
<outlet property="callsTableView" destination="dec-A7-CdC" id="XTP-2r-3Mb"/>
<outlet property="videoContainerView" destination="Uaa-qP-bom" id="eWY-Sh-LFb"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<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="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="64" horizontalPageScroll="10" verticalLineScroll="64" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yg6-pc-aSB">
<rect key="frame" x="0.0" y="177" width="480" height="95"/>
<clipView key="contentView" id="AvR-rZ-9tn">
<rect key="frame" x="1" y="0.0" width="478" height="94"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="62" rowSizeStyle="automatic" headerView="dEg-2y-3UD" viewBased="YES" id="dec-A7-CdC">
<rect key="frame" x="0.0" y="0.0" width="478" height="71"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="475" minWidth="40" maxWidth="1000" id="6du-JO-EPC">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="xgE-CY-kI5">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="J6c-lB-CSR">
<rect key="frame" x="1" y="1" width="475" height="62"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="d70-Wi-c46">
<rect key="frame" x="-2" y="0.0" width="479" height="62"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="oai-vF-3V6">
<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>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="d70-Wi-c46" secondAttribute="trailing" id="bob-U1-YG0"/>
<constraint firstAttribute="bottom" secondItem="d70-Wi-c46" secondAttribute="bottom" id="fWa-tL-5dN"/>
<constraint firstItem="d70-Wi-c46" firstAttribute="leading" secondItem="J6c-lB-CSR" secondAttribute="leading" id="frD-fa-sVP"/>
<constraint firstItem="d70-Wi-c46" firstAttribute="top" secondItem="J6c-lB-CSR" secondAttribute="top" id="wnf-TU-xx0"/>
</constraints>
<connections>
<outlet property="textField" destination="d70-Wi-c46" id="I1B-Qo-nRa"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="c9w-x3-cDh"/>
<outlet property="delegate" destination="-2" id="KiG-Ec-PLY"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="YSR-4A-87k">
<rect key="frame" x="1" y="79" width="478" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="KYl-Ot-neB">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="dEg-2y-3UD">
<rect key="frame" x="0.0" y="0.0" width="478" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="KGi-JU-EyX">
<rect key="frame" x="13" y="2" width="84" height="32"/>
<buttonCell key="cell" type="push" title="answer" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="uxj-HF-8S2">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="callActionButtonPressed:" target="-2" id="ieJ-qC-dyZ"/>
</connections>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ea1-xh-98s" userLabel="Call action popup button">
<rect key="frame" x="183" y="6" width="122" height="26"/>
<popUpButtonCell key="cell" type="push" title="Cancel call" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="lkl-J4-Kpd" id="CLZ-bA-Xix">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="S6H-Kd-jUO">
<items>
<menuItem title="Resume call" id="1OI-oa-uEb" userLabel="resume"/>
<menuItem title="Pause call" id="Jzn-qd-k5S" userLabel="pause"/>
<menuItem title="Cancel call" state="on" id="lkl-J4-Kpd" userLabel="cancel"/>
<menuItem title="Mute audio" id="rxS-WL-5xE" userLabel="mute audio"/>
<menuItem title="Unmute audio" id="IEj-mC-VFd" userLabel="unmute audio">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Hide video" id="nWZ-tO-BX9" userLabel="hide video">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
<menuItem title="Show video" id="S82-y9-HLX" userLabel="show video">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
<connections>
<action selector="sendCallControlSelected:" target="-2" id="WTK-ea-lKu"/>
</connections>
</popUpButton>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Uaa-qP-bom" userLabel="videoContainerView">
<rect key="frame" x="0.0" y="50" width="480" height="127"/>
</customView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="KGi-JU-EyX" secondAttribute="bottom" constant="9" id="6Ah-gJ-nGZ"/>
<constraint firstItem="Yg6-pc-aSB" firstAttribute="height" secondItem="Hz6-mo-xeY" secondAttribute="height" multiplier="0.35" id="9iP-U5-WZY"/>
<constraint firstItem="Yg6-pc-aSB" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="AFa-j0-7Dl"/>
<constraint firstItem="Yg6-pc-aSB" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="Jxm-sQ-HCx"/>
<constraint firstItem="Uaa-qP-bom" firstAttribute="top" secondItem="Yg6-pc-aSB" secondAttribute="bottom" id="L6l-T1-axj"/>
<constraint firstItem="Ea1-xh-98s" firstAttribute="leading" secondItem="KGi-JU-EyX" secondAttribute="trailing" constant="94" id="Pm5-MR-TwL"/>
<constraint firstAttribute="trailing" secondItem="Uaa-qP-bom" secondAttribute="trailing" id="QWD-GP-ZbW"/>
<constraint firstItem="Ea1-xh-98s" firstAttribute="top" secondItem="Uaa-qP-bom" secondAttribute="bottom" constant="20" id="Tpj-EY-apX"/>
<constraint firstItem="Yg6-pc-aSB" firstAttribute="width" secondItem="Hz6-mo-xeY" secondAttribute="width" id="Vbw-KR-EDS"/>
<constraint firstItem="KGi-JU-EyX" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="19" id="tOu-pj-Ayf"/>
<constraint firstItem="Uaa-qP-bom" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="uyQ-Ja-D4y"/>
<constraint firstItem="Ea1-xh-98s" firstAttribute="centerY" secondItem="KGi-JU-EyX" secondAttribute="centerY" id="zoV-sk-OcT"/>
</constraints>
</customView>
</objects>
</document>

View File

@ -0,0 +1,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
#import "OCTManager.h"
@interface OCTConversationViewController : NSViewController
- (instancetype)initWithManager:(id<OCTManager>)manager;
@end

View File

@ -0,0 +1,270 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTConversationViewController.h"
#import "OCTSubmanagerObjects.h"
#import "OCTSubmanagerChats.h"
#import "OCTFriend.h"
#import "OCTChat.h"
#import "OCTMessageAbstract.h"
#import "OCTSubmanagerUser.h"
#import "OCTSubmanagerCalls.h"
#import "OCTSubmanagerFiles.h"
#import "OCTMessageText.h"
#import "RLMCollectionChange+IndexSet.h"
static NSString *const kCellIdent = @"cellIdent";
@interface OCTConversationViewController () <NSTableViewDataSource,
NSTableViewDelegate,
NSTextFieldDelegate>
@property (weak) IBOutlet NSTableView *chatsViewController;
@property (weak, nonatomic) id<OCTManager> manager;
@property (strong, nonatomic) RLMResults<OCTChat *> *allChats;
@property (strong, nonatomic) RLMNotificationToken *allChatsNotificationToken;
@property (strong, nonatomic) RLMResults<OCTMessageAbstract *> *conversationMessages;
@property (strong, nonatomic) RLMNotificationToken *conversationMessagesNotificationToken;
@property (weak) IBOutlet NSTableView *chatsTableView;
@property (weak) IBOutlet NSTableView *conversationTableView;
@end
@implementation OCTConversationViewController
- (instancetype)initWithManager:(id<OCTManager>)manager
{
self = [super init];
if (! self) {
return nil;
}
_manager = manager;
_allChats = [self.manager.objects objectsForType:OCTFetchRequestTypeChat predicate:nil];
_conversationMessages = nil;
return self;
}
- (void)dealloc
{
[self.allChatsNotificationToken invalidate];
[self.conversationMessagesNotificationToken invalidate];
}
- (void)viewDidLoad
{
[super viewDidLoad];
__weak typeof(self)weakSelf = self;
self.allChatsNotificationToken = [self.allChats addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
if (error) {
NSLog(@"Failed to open Realm on background worker: %@", error);
return;
}
NSTableView *tableView = weakSelf.chatsTableView;
// Initial run of the query will pass nil for the change information
if (! changes) {
[tableView reloadData];
return;
}
[tableView beginUpdates];
[tableView removeRowsAtIndexes:[changes deletionsSet] withAnimation:NSTableViewAnimationSlideLeft];
[tableView insertRowsAtIndexes:[changes insertionsSet] withAnimation:NSTableViewAnimationSlideRight];
[tableView reloadDataForRowIndexes:[changes modificationsSet] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[tableView endUpdates];
}];
}
#pragma mark - Actions
- (IBAction)deleteChatButtonPressed:(NSButton *)sender
{
NSInteger selectedRow = self.chatsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTChat *chat = self.allChats[selectedRow];
[self.manager.chats removeAllMessagesInChat:chat removeChat:YES];
}
- (IBAction)callUserButtonPressed:(NSButton *)sender
{
NSInteger selectedRow = self.chatsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTChat *chat = self.allChats[selectedRow];
[self.manager.calls callToChat:chat enableAudio:YES enableVideo:YES error:nil];
}
- (IBAction)sendFileButtonPressed:(id)sender
{
NSInteger selectedRow = self.chatsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTChat *chat = self.allChats[selectedRow];
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel runModal];
NSString *path = [panel.URL path];
[self.manager.files sendFileAtPath:path moveToUploads:NO toChat:chat failureBlock:nil];
}
#pragma mark - NSTextFieldDelegate
- (IBAction)chatTextFieldEntered:(NSTextField *)sender
{
NSInteger selectedRow = self.chatsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTChat *chat = self.allChats[selectedRow];
[self.manager.chats sendMessageToChat:chat
text:sender.stringValue
type:OCTToxMessageTypeNormal
successBlock:nil
failureBlock:nil];
sender.stringValue = @"";
}
#pragma mark - NSTableViewDelegate
- (NSView *) tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
{
NSTextField *field = [tableView
makeViewWithIdentifier:kCellIdent
owner:self];
if (! field) {
field = [NSTextField new];
field.identifier = kCellIdent;
}
field.selectable = YES;
field.editable = NO;
if (tableView == self.chatsTableView) {
OCTChat *chat = self.allChats[row];
OCTFriend *friend = [chat.friends firstObject];
field.stringValue = (friend.isConnected) ? ([NSString stringWithFormat:@"%@ : Online", friend.nickname]) : friend.nickname;
}
else {
OCTMessageAbstract *messageAbstract = self.conversationMessages[row];
if (messageAbstract.messageText) {
if ([messageAbstract isOutgoing]) {
field.stringValue = [NSString stringWithFormat:@"%@: %@", self.manager.user.userName, messageAbstract.messageText.text];
}
else {
OCTFriend *friend = (OCTFriend *)[self.manager.objects objectWithUniqueIdentifier:messageAbstract.senderUniqueIdentifier
forType:OCTFetchRequestTypeFriend];
field.stringValue = [NSString stringWithFormat:@"%@: %@", friend.nickname, messageAbstract.messageText.text];
}
}
}
return field;
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
if (notification.object != self.chatsTableView) {
return;
}
NSInteger selectedRow = self.chatsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTChat *chat = self.allChats[selectedRow];
[self updateConversationControllerForChat:chat];
[self.conversationTableView reloadData];
}
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
return 50.0;
}
#pragma mark - NSTableViewDataSource
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
if (tableView == self.chatsTableView) {
return self.allChats.count;
}
else {
return self.conversationMessages.count;
}
return 0;
}
#pragma mark - Private
- (void)updateConversationControllerForChat:(OCTChat *)chat
{
[self.conversationMessagesNotificationToken invalidate];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"chatUniqueIdentifier == %@", chat.uniqueIdentifier];
self.conversationMessages = [self.manager.objects objectsForType:OCTFetchRequestTypeMessageAbstract predicate:predicate];
__weak typeof(self)weakSelf = self;
self.conversationMessagesNotificationToken = [self.conversationMessages addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
if (error) {
NSLog(@"Failed to open Realm on background worker: %@", error);
return;
}
NSTableView *tableView = weakSelf.conversationTableView;
// Initial run of the query will pass nil for the change information
if (! changes) {
[tableView reloadData];
return;
}
[tableView beginUpdates];
[tableView removeRowsAtIndexes:[changes deletionsSet] withAnimation:NSTableViewAnimationSlideLeft];
[tableView insertRowsAtIndexes:[changes insertionsSet] withAnimation:NSTableViewAnimationSlideRight];
[tableView reloadDataForRowIndexes:[changes modificationsSet] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[tableView endUpdates];
}];
}
@end

View File

@ -0,0 +1,230 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTConversationViewController">
<connections>
<outlet property="chatsTableView" destination="PwP-zX-WIB" id="h7Z-az-i3b"/>
<outlet property="chatsViewController" destination="PwP-zX-WIB" id="dKQ-NA-YA6"/>
<outlet property="conversationTableView" destination="d4g-VC-zIT" id="t9h-nG-SQ5"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<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="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="29" horizontalPageScroll="10" verticalLineScroll="29" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LtX-5e-me2">
<rect key="frame" x="0.0" y="41" width="239" height="231"/>
<clipView key="contentView" drawsBackground="NO" id="k81-ad-n1w">
<rect key="frame" x="1" y="0.0" width="237" height="230"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="27" rowSizeStyle="automatic" headerView="mzu-O4-OBb" viewBased="YES" id="PwP-zX-WIB">
<rect key="frame" x="0.0" y="0.0" width="237" height="207"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="234" minWidth="40" maxWidth="1000" id="K5L-L6-3yD">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Chats">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" selectable="YES" title="Text Cell" id="aMw-lS-UMD">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="vyZ-eB-mdi">
<rect key="frame" x="1" y="1" width="234" height="27"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ndp-hY-Dej">
<rect key="frame" x="0.0" y="3" width="223" height="24"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Table View Cell" id="4QX-Vz-hmE">
<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>
</subviews>
<connections>
<outlet property="textField" destination="Ndp-hY-Dej" id="Blx-xS-keR"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="Adq-0g-D2q"/>
<outlet property="delegate" destination="-2" id="Zdr-QT-wJK"/>
</connections>
</tableView>
</subviews>
<nil key="backgroundColor"/>
</clipView>
<constraints>
<constraint firstAttribute="width" constant="239" id="KRf-yr-vtK"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="6cD-U0-s2V">
<rect key="frame" x="1" y="215" width="237" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Nsl-pH-TFj">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="mzu-O4-OBb">
<rect key="frame" x="0.0" y="0.0" width="237" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="l4O-Ce-roz">
<rect key="frame" x="4" y="3" width="112" height="32"/>
<buttonCell key="cell" type="push" title="Delete Chat" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="YQ5-VB-gcm">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="deleteChatButtonPressed:" target="-2" id="HWv-Rg-jEq"/>
</connections>
</button>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qAJ-48-2Vl">
<rect key="frame" x="239" y="99" width="241" height="173"/>
<clipView key="contentView" id="uC1-jK-RYF">
<rect key="frame" x="1" y="0.0" width="239" height="172"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="17q-XH-pFx" viewBased="YES" id="d4g-VC-zIT">
<rect key="frame" x="0.0" y="0.0" width="239" height="149"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="236" minWidth="40" maxWidth="1000" id="Ats-sY-DiE">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" selectable="YES" title="Text Cell" id="SCB-p3-duz">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="AdV-yU-BJh">
<rect key="frame" x="1" y="1" width="236" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="wr1-4F-gCW">
<rect key="frame" x="-2" y="0.0" width="240" height="17"/>
<textFieldCell key="cell" selectable="YES" sendsActionOnEndEditing="YES" alignment="left" title="Table View Cell" id="nWj-Mh-nt0">
<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>
</subviews>
<constraints>
<constraint firstItem="wr1-4F-gCW" firstAttribute="leading" secondItem="AdV-yU-BJh" secondAttribute="leading" id="7MB-cz-0wl"/>
<constraint firstAttribute="trailing" secondItem="wr1-4F-gCW" secondAttribute="trailing" id="F19-i8-8g7"/>
<constraint firstItem="wr1-4F-gCW" firstAttribute="top" secondItem="AdV-yU-BJh" secondAttribute="top" id="Xee-rx-RP4"/>
</constraints>
<connections>
<outlet property="textField" destination="wr1-4F-gCW" id="yb0-kX-GIO"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="0bE-og-FBu"/>
<outlet property="delegate" destination="-2" id="WJj-Nm-xem"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="eiW-Dm-IZ0">
<rect key="frame" x="1" y="157" width="239" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Ucm-qy-FdE">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="17q-XH-pFx">
<rect key="frame" x="0.0" y="0.0" width="239" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<textField horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="zLC-bT-7fG">
<rect key="frame" x="239" y="41" width="241" height="58"/>
<textFieldCell key="cell" selectable="YES" editable="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="Rev-lk-sNt">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="chatTextFieldEntered:" target="-2" id="bXA-t9-zdi"/>
<outlet property="delegate" destination="-2" id="Cgq-PV-Yhi"/>
</connections>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5DZ-38-1cv">
<rect key="frame" x="162" y="3" width="93" height="32"/>
<buttonCell key="cell" type="push" title="Call user" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="HBA-rc-hH3">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="callUserButtonPressed:" target="-2" id="0fg-kO-gc1"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="mLZ-GO-ldp">
<rect key="frame" x="291" y="3" width="93" height="32"/>
<buttonCell key="cell" type="push" title="Send file" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="4AP-wz-wf0">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="sendFileButtonPressed:" target="-2" id="Fbj-Ad-MoV"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="zLC-bT-7fG" secondAttribute="trailing" id="1ZD-Fp-tLh"/>
<constraint firstItem="LtX-5e-me2" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="3o0-ex-7Yz"/>
<constraint firstItem="mLZ-GO-ldp" firstAttribute="leading" secondItem="5DZ-38-1cv" secondAttribute="trailing" constant="48" id="7EI-PM-Fka"/>
<constraint firstAttribute="bottom" secondItem="mLZ-GO-ldp" secondAttribute="bottom" constant="10" id="E3t-bN-wgf"/>
<constraint firstAttribute="bottom" secondItem="l4O-Ce-roz" secondAttribute="bottom" constant="10" id="EXT-aC-ip0"/>
<constraint firstItem="qAJ-48-2Vl" firstAttribute="height" secondItem="LtX-5e-me2" secondAttribute="height" multiplier="0.75" id="Hx8-LR-mpr"/>
<constraint firstItem="qAJ-48-2Vl" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="Ocm-gh-ocf"/>
<constraint firstItem="5DZ-38-1cv" firstAttribute="trailing" secondItem="LtX-5e-me2" secondAttribute="trailing" constant="10" id="OeG-a0-kg4"/>
<constraint firstItem="5DZ-38-1cv" firstAttribute="centerY" secondItem="l4O-Ce-roz" secondAttribute="centerY" id="VHD-Mz-1zF"/>
<constraint firstItem="qAJ-48-2Vl" firstAttribute="leading" secondItem="LtX-5e-me2" secondAttribute="trailing" id="VM8-N3-D4Z"/>
<constraint firstAttribute="trailing" secondItem="qAJ-48-2Vl" secondAttribute="trailing" id="Vdz-DI-2av"/>
<constraint firstItem="LtX-5e-me2" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="bl3-3C-KbC"/>
<constraint firstItem="l4O-Ce-roz" firstAttribute="top" secondItem="LtX-5e-me2" secondAttribute="bottom" constant="10" id="cNY-6x-4aP"/>
<constraint firstItem="5DZ-38-1cv" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="l4O-Ce-roz" secondAttribute="trailing" constant="10" id="gwy-r5-V6J"/>
<constraint firstItem="zLC-bT-7fG" firstAttribute="bottom" secondItem="LtX-5e-me2" secondAttribute="bottom" id="kMv-dH-TTU"/>
<constraint firstItem="l4O-Ce-roz" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="10" id="l1l-xC-0gf"/>
<constraint firstItem="zLC-bT-7fG" firstAttribute="leading" secondItem="LtX-5e-me2" secondAttribute="trailing" id="uAp-xu-yJL"/>
<constraint firstItem="zLC-bT-7fG" firstAttribute="top" secondItem="qAJ-48-2Vl" secondAttribute="bottom" id="wDI-aX-9Qh"/>
</constraints>
</customView>
</objects>
</document>

View File

@ -0,0 +1,13 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
@protocol OCTManager;
@interface OCTFilesViewController : NSViewController
- (instancetype)initWithManager:(id<OCTManager>)manager;
@end

View File

@ -0,0 +1,236 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTFilesViewController.h"
#import "OCTManager.h"
#import "OCTSubmanagerObjects.h"
#import "OCTSubmanagerFiles.h"
#import "OCTSubmanagerFilesProgressSubscriber.h"
#import "OCTMessageAbstract.h"
#import "OCTMessageFile.h"
static NSString *const kCellIdentifier = @"fileCell";
@interface OCTFilesViewController () <NSTableViewDataSource, NSTableViewDelegate, OCTSubmanagerFilesProgressSubscriber>
@property (weak, nonatomic) id<OCTManager> manager;
@property (weak) IBOutlet NSTableView *tableView;
@property (strong, nonatomic) RLMResults<OCTMessageAbstract *> *fileMessages;
@property (strong, nonatomic) RLMNotificationToken *fileMessagesNotificationToken;
@end
@implementation OCTFilesViewController
#pragma mark - Lifecycle
- (instancetype)initWithManager:(id<OCTManager>)manager
{
self = [super init];
if (! self) {
return nil;
}
_manager = manager;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"messageFile != nil"];
_fileMessages = [manager.objects objectsForType:OCTFetchRequestTypeMessageAbstract predicate:predicate];
return self;
}
- (void)dealloc
{
[self.fileMessagesNotificationToken invalidate];
}
- (void)viewDidLoad
{
[super viewDidLoad];
__weak typeof(self)weakSelf = self;
self.fileMessagesNotificationToken = [self.fileMessages addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
[weakSelf.tableView reloadData];
}];
}
- (IBAction)receiveButtonPressed:(id)sender
{
OCTMessageAbstract *message = [self messageForCurrentlySelectedRow];
if (! message) {
return;
}
[self.manager.files acceptFileTransfer:message failureBlock:nil];
[self.manager.files addProgressSubscriber:self forFileTransfer:message error:nil];
}
- (IBAction)declineButtonPressed:(id)sender
{
OCTMessageAbstract *message = [self messageForCurrentlySelectedRow];
if (! message) {
return;
}
[self.manager.files cancelFileTransfer:message error:nil];
}
- (IBAction)pauseButtonPressed:(id)sender
{
OCTMessageAbstract *message = [self messageForCurrentlySelectedRow];
if (! message) {
return;
}
[self.manager.files pauseFileTransfer:YES message:message error:nil];
}
- (IBAction)resumeButtonPressed:(id)sender
{
OCTMessageAbstract *message = [self messageForCurrentlySelectedRow];
if (! message) {
return;
}
[self.manager.files pauseFileTransfer:NO message:message error:nil];
}
#pragma mark - NSTableViewDelegate
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return self.fileMessages.count;
}
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row
{
return 150.0;
}
#pragma mark - NSTableViewDataSource
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
OCTMessageAbstract *message = self.fileMessages[row];
NSTextField *textField = [self.tableView makeViewWithIdentifier:kCellIdentifier owner:nil];
if (! textField) {
textField = [NSTextField new];
textField.identifier = kCellIdentifier;
}
if ([tableColumn.identifier isEqualToString:@"AutomaticTableColumnIdentifier.0"]) {
textField.stringValue = [NSString stringWithFormat:
@"fileType = %@\n"
@"pausedBy = %@\n"
@"fileSize = %lld\n"
@"fileName = %@\n"
@"filePath = %@\n"
@"fileUTI = %@\n"
@"fileNumber = %d\n"
@"senderUniqueIdentifier = %@",
[self stringFromFileType:message.messageFile.fileType],
[self stringFromPausedBy:message.messageFile.pausedBy],
message.messageFile.fileSize,
message.messageFile.fileName,
message.messageFile.filePath,
message.messageFile.fileUTI,
message.messageFile.internalFileNumber,
message.senderUniqueIdentifier];
}
else if ([tableColumn.identifier isEqualToString:@"AutomaticTableColumnIdentifier.1"]) {
textField.stringValue = @"";
}
return textField;
}
#pragma mark - OCTSubmanagerFilesProgressSubscriber
- (void)submanagerFilesOnProgressUpdate:(float)progress message:(nonnull OCTMessageAbstract *)message
{}
- (void)submanagerFilesOnEtaUpdate:(CFTimeInterval)eta
bytesPerSecond:(OCTToxFileSize)bytesPerSecond
message:(nonnull OCTMessageAbstract *)message
{
NSUInteger index = [self.fileMessages indexOfObject:message];
if (index == NSNotFound) {
[self.manager.files removeProgressSubscriber:self forFileTransfer:message error:nil];
return;
}
NSTextField *textField = [self.tableView viewAtColumn:1 row:index makeIfNecessary:NO];
if (! textField) {
return;
}
textField.stringValue = [NSString stringWithFormat:
@"bytesPerSecond = %lld\n"
@"eta = %g",
bytesPerSecond,
eta];
}
#pragma mark - Private
- (NSString *)stringFromFileType:(OCTMessageFileType)type
{
switch (type) {
case OCTMessageFileTypeWaitingConfirmation:
return @"Waiting confirmaion";
case OCTMessageFileTypeLoading:
return @"Loading";
case OCTMessageFileTypePaused:
return @"Paused";
case OCTMessageFileTypeCanceled:
return @"Canceled";
case OCTMessageFileTypeReady:
return @"Ready";
}
}
- (NSString *)stringFromPausedBy:(OCTMessageFilePausedBy)pausedBy
{
if (pausedBy == OCTMessageFilePausedByNone) {
return @"None";
}
NSString *string = @"";
if (pausedBy & OCTMessageFilePausedByUser) {
string = [string stringByAppendingString:@" user"];
}
if (pausedBy & OCTMessageFilePausedByFriend) {
string = [string stringByAppendingString:@" friend"];
}
return string;
}
- (OCTMessageAbstract *)messageForCurrentlySelectedRow
{
NSInteger selectedRow = self.tableView.selectedRow;
if (selectedRow < 0) {
return nil;
}
OCTMessageAbstract *message = self.fileMessages[selectedRow];
return message;
}
@end

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTFilesViewController">
<connections>
<outlet property="tableView" destination="shY-H6-tes" id="z4Z-Iz-Qz4"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<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="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Gn-mW-Fx9">
<rect key="frame" x="0.0" y="40" width="480" height="232"/>
<clipView key="contentView" id="TyA-XD-Mii">
<rect key="frame" x="1" y="0.0" width="478" height="231"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="hkF-wS-k9D" viewBased="YES" id="shY-H6-tes">
<rect key="frame" x="0.0" y="0.0" width="478" height="208"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="337" minWidth="40" maxWidth="1000" id="OEa-8a-QPb">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="bFp-hJ-dZ4">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="U6Y-0h-h57">
<rect key="frame" x="1" y="1" width="337" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eDa-Sl-H5v">
<rect key="frame" x="0.0" y="0.0" width="100" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="FrO-1M-mwn">
<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>
</subviews>
<connections>
<outlet property="textField" destination="eDa-Sl-H5v" id="5eI-df-0R1"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="" width="135" minWidth="10" maxWidth="3.4028234663852886e+38" id="VGF-3j-UwG">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="T48-MB-Rky">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="oAq-Ef-rAb">
<rect key="frame" x="341" y="1" width="136" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tOw-vd-pWJ">
<rect key="frame" x="0.0" y="0.0" width="100" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="aHU-VX-hdi">
<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>
</subviews>
<connections>
<outlet property="textField" destination="tOw-vd-pWJ" id="NyD-I9-6X2"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="ccT-3h-lvY"/>
<outlet property="delegate" destination="-2" id="x1a-nb-e5r"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="aV4-SX-bZ0">
<rect key="frame" x="1" y="255" width="478" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="asx-4P-8R5">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="hkF-wS-k9D">
<rect key="frame" x="0.0" y="0.0" width="479" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NHP-k7-ZQ9">
<rect key="frame" x="5" y="3" width="88" height="32"/>
<buttonCell key="cell" type="push" title="Receive" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5Fs-cK-LT2">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="receiveButtonPressed:" target="-2" id="4bj-47-Fk3"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="zHn-bO-wq3">
<rect key="frame" x="113" y="3" width="86" height="32"/>
<buttonCell key="cell" type="push" title="Decline" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Fzm-3E-gNO">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="declineButtonPressed:" target="-2" id="hwj-vU-yPG"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ec3-3z-kAr">
<rect key="frame" x="222" y="3" width="77" height="32"/>
<buttonCell key="cell" type="push" title="Pause" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="BXs-lv-HMx">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="pauseButtonPressed:" target="-2" id="kP8-y1-PsC"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SIh-QM-kli">
<rect key="frame" x="321" y="3" width="89" height="32"/>
<buttonCell key="cell" type="push" title="Resume" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="iln-xZ-OWK">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="resumeButtonPressed:" target="-2" id="jhX-td-seF"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="NHP-k7-ZQ9" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="11" id="7kF-kf-4fo"/>
<constraint firstItem="ec3-3z-kAr" firstAttribute="centerY" secondItem="zHn-bO-wq3" secondAttribute="centerY" id="ANX-TX-Rws"/>
<constraint firstItem="ec3-3z-kAr" firstAttribute="leading" secondItem="zHn-bO-wq3" secondAttribute="trailing" constant="35" id="HkJ-yQ-Vvm"/>
<constraint firstItem="zHn-bO-wq3" firstAttribute="leading" secondItem="NHP-k7-ZQ9" secondAttribute="trailing" constant="32" id="JgK-Hy-PYP"/>
<constraint firstAttribute="bottom" secondItem="NHP-k7-ZQ9" secondAttribute="bottom" constant="10" id="P3C-VZ-khz"/>
<constraint firstItem="SIh-QM-kli" firstAttribute="centerY" secondItem="ec3-3z-kAr" secondAttribute="centerY" id="RAp-LZ-jU6"/>
<constraint firstItem="2Gn-mW-Fx9" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="VWz-eX-UnV"/>
<constraint firstAttribute="trailing" secondItem="2Gn-mW-Fx9" secondAttribute="trailing" id="ZSx-Mi-aca"/>
<constraint firstItem="NHP-k7-ZQ9" firstAttribute="centerY" secondItem="zHn-bO-wq3" secondAttribute="centerY" id="cpX-Rh-82X"/>
<constraint firstItem="SIh-QM-kli" firstAttribute="leading" secondItem="ec3-3z-kAr" secondAttribute="trailing" constant="34" id="q5p-lJ-vP1"/>
<constraint firstItem="2Gn-mW-Fx9" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="tuH-hd-2K3"/>
<constraint firstItem="NHP-k7-ZQ9" firstAttribute="top" secondItem="2Gn-mW-Fx9" secondAttribute="bottom" constant="9" id="uYB-od-6pq"/>
</constraints>
</customView>
</objects>
</document>

View File

@ -0,0 +1,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
#import "OCTManager.h"
@interface OCTFriendsViewController : NSViewController
- (instancetype)initWithManager:(id<OCTManager>)manager;
@end

View File

@ -0,0 +1,255 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTFriendsViewController.h"
#import "OCTFriend.h"
#import "OCTFriendRequest.h"
#import "OCTSubmanagerObjects.h"
#import "OCTSubmanagerFriends.h"
#import "OCTSubmanagerChats.h"
#import "RLMCollectionChange+IndexSet.h"
static NSString *const kNibName = @"OCTFriendsViewController";
static NSString *const kCellIdent = @"cellIdent";
@interface OCTFriendsViewController () <NSTableViewDataSource, NSTableViewDelegate>
@property (weak, nonatomic) id<OCTManager> manager;
@property (strong, nonatomic) RLMResults<OCTFriend *> *friends;
@property (strong, nonatomic) RLMNotificationToken *friendsNotificationToken;
@property (strong, nonatomic) RLMResults<OCTFriendRequest *> *friendRequests;
@property (strong, nonatomic) RLMNotificationToken *friendRequestsNotificationToken;
@property (weak) IBOutlet NSButton *acceptButton;
@property (weak) IBOutlet NSButton *rejectButton;
@property (unsafe_unretained) IBOutlet NSTextView *friendInfoTextField;
@property (weak) IBOutlet NSTableView *friendsTableView;
@property (weak) IBOutlet NSTableView *requestsTableView;
@property (weak) IBOutlet NSImageView *avatarImageView;
@end
@implementation OCTFriendsViewController
- (instancetype)initWithManager:(id<OCTManager>)manager
{
self = [super initWithNibName:kNibName bundle:nil];
if (! self) {
return nil;
}
_manager = manager;
_friends = [self.manager.objects objectsForType:OCTFetchRequestTypeFriend predicate:nil];
_friendRequests = [self.manager.objects objectsForType:OCTFetchRequestTypeFriendRequest predicate:nil];
return self;
}
- (void)dealloc
{
[self.friendsNotificationToken invalidate];
[self.friendRequestsNotificationToken invalidate];
}
- (void)viewDidLoad
{
[super viewDidLoad];
__weak typeof(self)weakSelf = self;
self.friendsNotificationToken = [self.friends addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
[weakSelf realmWasUpdated:changes tableView:weakSelf.friendsTableView error:error];
}];
self.friendRequestsNotificationToken = [self.friendRequests addNotificationBlock:^(RLMResults *results, RLMCollectionChange *changes, NSError *error) {
[weakSelf realmWasUpdated:changes tableView:weakSelf.requestsTableView error:error];
}];
}
#pragma mark - NSTableViewDataSource
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
if (tableView == self.friendsTableView) {
return self.friends.count;
}
else if (tableView == self.requestsTableView) {
return self.friendRequests.count;
}
return 0;
}
#pragma mark - NSTableViewDelegate
- (NSView *) tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
{
NSTextField *field = [tableView
makeViewWithIdentifier:kCellIdent
owner:self];
if (! field) {
field = [NSTextField new];
field.identifier = kCellIdent;
}
field.selectable = YES;
field.editable = NO;
if (tableView == self.friendsTableView) {
OCTFriend *friend = self.friends[row];
field.stringValue = (friend.isConnected) ? ([NSString stringWithFormat:@"%@ : Online", friend.nickname]) : friend.nickname;
}
else if (tableView == self.requestsTableView) {
OCTFriendRequest *request = self.friendRequests[row];
field.stringValue = request.publicKey;
}
return field;
}
- (void)tableViewSelectionDidChange:(NSNotification *)notification
{
if (notification.object == self.friendsTableView) {
OCTFriend *friend = self.friends[self.friendsTableView.selectedRow];
self.avatarImageView.image = [[NSImage alloc] initWithData:friend.avatarData];
self.friendInfoTextField.string = [NSString stringWithFormat:
@"friendNumber %u\n"
@"publicKey %@\n"
@"name %@\n"
@"nickname %@\n"
@"statusMessage %@\n"
@"status %@\n"
@"isConnected %d\n"
@"connectionStatus %@\n"
@"lastSeenOnline %@\n"
@"isTyping %d",
friend.friendNumber,
friend.publicKey,
friend.name,
friend.nickname,
friend.statusMessage,
[self stringFromUserStatus:friend.status],
friend.isConnected,
[self stringFromConnectionStatus:friend.connectionStatus],
friend.lastSeenOnline,
friend.isTyping];
}
}
#pragma mark - Actions
- (IBAction)addFriendReturn:(NSTextField *)sender
{
[self.manager.friends
sendFriendRequestToAddress:sender.stringValue
message:@"Friend request from objcTox Mac OSX Demo"
error:nil];
}
- (IBAction)removeFriendButtonPressed:(NSButton *)sender
{
NSInteger selectedRow = self.friendsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTFriend *friend = self.friends[selectedRow];
[self.manager.friends removeFriend:friend error:nil];
}
- (IBAction)createChatButtonPressed:(NSButton *)sender
{
NSInteger selectedRow = self.friendsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTFriend *friend = self.friends[selectedRow];
[self.manager.chats getOrCreateChatWithFriend:friend];
}
- (IBAction)proceedWithFriendRequest:(NSButton *)sender
{
NSInteger selectedRow = self.requestsTableView.selectedRow;
if (selectedRow < 0) {
return;
}
OCTFriendRequest *request = self.friendRequests[selectedRow];
if (sender == self.acceptButton) {
[self.manager.friends approveFriendRequest:request error:nil];
}
else {
[self.manager.friends removeFriendRequest:request];
}
dispatch_async(dispatch_get_main_queue(), ^{
[self.requestsTableView reloadData];
});
}
#pragma mark - Private
- (NSString *)stringFromUserStatus:(OCTToxUserStatus)status
{
switch (status) {
case OCTToxUserStatusNone:
return @"None";
case OCTToxUserStatusAway:
return @"Away";
case OCTToxUserStatusBusy:
return @"Busy";
}
}
- (NSString *)stringFromConnectionStatus:(OCTToxConnectionStatus)status
{
switch (status) {
case OCTToxConnectionStatusNone:
return @"None";
case OCTToxConnectionStatusTCP:
return @"TCP";
case OCTToxConnectionStatusUDP:
return @"UDP";
}
}
- (void)realmWasUpdated:(RLMCollectionChange *)changes tableView:(NSTableView *)tableView error:(NSError *)error
{
if (error) {
NSLog(@"Failed to open Realm on background worker: %@", error);
return;
}
// Initial run of the query will pass nil for the change information
if (! changes) {
[tableView reloadData];
return;
}
[tableView beginUpdates];
[tableView removeRowsAtIndexes:[changes deletionsSet] withAnimation:NSTableViewAnimationSlideLeft];
[tableView insertRowsAtIndexes:[changes insertionsSet] withAnimation:NSTableViewAnimationSlideRight];
[tableView reloadDataForRowIndexes:[changes modificationsSet] columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[tableView endUpdates];
}
@end

View File

@ -0,0 +1,295 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTFriendsViewController">
<connections>
<outlet property="acceptButton" destination="9Vs-Kt-TIN" id="JpX-Jp-nEt"/>
<outlet property="avatarImageView" destination="vTj-O0-Vzm" id="xtN-Cb-NxB"/>
<outlet property="friendInfoTextField" destination="sxe-3t-ZJw" id="J6k-wW-fnB"/>
<outlet property="friendsTableView" destination="ESn-Kc-Dww" id="pgH-Bb-Cjo"/>
<outlet property="rejectButton" destination="o0o-3n-uC8" id="6za-Q1-V9J"/>
<outlet property="requestsTableView" destination="RSW-Mi-6sH" id="Ffd-m4-9gC"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<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="661" height="456"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="29" horizontalPageScroll="10" verticalLineScroll="29" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z8l-tP-yyv" userLabel="friendsBorderScrollView">
<rect key="frame" x="0.0" y="228" width="397" height="228"/>
<clipView key="contentView" id="K5d-3V-F85">
<rect key="frame" x="1" y="0.0" width="395" height="227"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="27" rowSizeStyle="automatic" headerView="Qxe-g4-fZV" viewBased="YES" id="ESn-Kc-Dww">
<rect key="frame" x="0.0" y="0.0" width="395" height="204"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="392" minWidth="40" maxWidth="1000" id="DRx-o9-HTF">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Friends">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="gwC-Z5-YV1">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="l6h-QX-s9g">
<rect key="frame" x="1" y="1" width="392" height="27"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mfN-hO-fpZ">
<rect key="frame" x="0.0" y="10" width="222" height="23"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="Table View Cell" id="hBB-Wl-doc">
<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>
</subviews>
<connections>
<outlet property="textField" destination="mfN-hO-fpZ" id="IBJ-F3-aWz"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="A32-H4-aeh"/>
<outlet property="delegate" destination="-2" id="YAf-tK-Id4"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="S0z-Ra-5dY">
<rect key="frame" x="1" y="212" width="395" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Npz-qZ-jct">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="Qxe-g4-fZV">
<rect key="frame" x="0.0" y="0.0" width="395" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<scrollView autohidesScrollers="YES" horizontalLineScroll="29" horizontalPageScroll="10" verticalLineScroll="29" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jg4-lw-sFa" userLabel="requestBorderScrollView">
<rect key="frame" x="0.0" y="0.0" width="397" height="228"/>
<clipView key="contentView" id="Z7i-Nu-GMr">
<rect key="frame" x="1" y="0.0" width="395" height="227"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" rowHeight="27" rowSizeStyle="automatic" headerView="AlV-5p-8oe" viewBased="YES" id="RSW-Mi-6sH">
<rect key="frame" x="0.0" y="0.0" width="395" height="204"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="392" minWidth="40" maxWidth="1000" id="SEQ-ui-00x" userLabel="Requests">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Requests">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="TI1-Xi-GDW">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="EF5-0F-eeX">
<rect key="frame" x="1" y="1" width="392" height="27"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2Lt-uD-sev">
<rect key="frame" x="0.0" y="10" width="222" height="23"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" title="Table View Cell" id="Fzg-Ig-ucR">
<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>
</subviews>
<connections>
<outlet property="textField" destination="2Lt-uD-sev" id="e7V-1N-WWD"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="J3W-NL-dFp"/>
<outlet property="delegate" destination="-2" id="AxQ-zw-Yeb"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="ahG-Mq-14A">
<rect key="frame" x="1" y="212" width="395" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="YPz-FR-Tol">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="AlV-5p-8oe">
<rect key="frame" x="0.0" y="0.0" width="395" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" verticalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="9Vs-Kt-TIN" userLabel="acceptButton">
<rect key="frame" x="411" y="63" width="236" height="32"/>
<buttonCell key="cell" type="push" title="Accept" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="vxU-DE-ybo">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="proceedWithFriendRequest:" target="-2" id="AkD-0D-685"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="o0o-3n-uC8" userLabel="rejectButton">
<rect key="frame" x="410" y="22" width="237" height="32"/>
<buttonCell key="cell" type="push" title="Reject" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="dh0-bo-xh7">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="proceedWithFriendRequest:" target="-2" id="f5k-EF-Ube"/>
</connections>
</button>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="36g-42-IRz">
<rect key="frame" x="397" y="228" width="264" height="228"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="iTV-0E-fau">
<rect key="frame" x="4" y="3" width="128" height="32"/>
<buttonCell key="cell" type="push" title="Remove friend" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="FwX-AA-flk">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="removeFriendButtonPressed:" target="-2" id="gSY-dA-NDk"/>
</connections>
</button>
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Hxk-L9-rxu" userLabel="friendInfoView">
<rect key="frame" x="0.0" y="41" width="264" height="137"/>
<clipView key="contentView" id="QkX-iq-Jsn">
<rect key="frame" x="1" y="1" width="262" height="135"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView editable="NO" importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" smartInsertDelete="YES" id="sxe-3t-ZJw">
<rect key="frame" x="0.0" y="0.0" width="262" height="135"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<size key="minSize" width="262" height="135"/>
<size key="maxSize" width="463" height="10000000"/>
<color key="insertionPointColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<size key="minSize" width="262" height="135"/>
<size key="maxSize" width="463" height="10000000"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="58C-9n-sHX">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="0kP-1A-VQQ">
<rect key="frame" x="247" y="1" width="16" height="135"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="37h-6U-FC5" userLabel="createChat">
<rect key="frame" x="132" y="3" width="128" height="32"/>
<buttonCell key="cell" type="push" title="Create chat" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="VgA-0v-apv">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="createChatButtonPressed:" target="-2" id="M4S-Od-F4R"/>
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vTj-O0-Vzm">
<rect key="frame" x="109" y="180" width="48" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="aRb-Vn-bz2"/>
<constraint firstAttribute="width" constant="48" id="ghn-Kr-esy"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="KTf-jx-Ayh"/>
</imageView>
</subviews>
<constraints>
<constraint firstItem="Hxk-L9-rxu" firstAttribute="top" secondItem="vTj-O0-Vzm" secondAttribute="bottom" constant="2" id="03m-Ja-Qd8"/>
<constraint firstItem="vTj-O0-Vzm" firstAttribute="top" secondItem="36g-42-IRz" secondAttribute="top" id="4ds-eB-M5o"/>
<constraint firstItem="37h-6U-FC5" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="iTV-0E-fau" secondAttribute="trailing" constant="10" id="6pX-QM-g2t"/>
<constraint firstItem="iTV-0E-fau" firstAttribute="leading" secondItem="36g-42-IRz" secondAttribute="leading" constant="10" id="7qO-T4-28w"/>
<constraint firstItem="iTV-0E-fau" firstAttribute="top" secondItem="Hxk-L9-rxu" secondAttribute="bottom" constant="10" id="BAH-yo-hGN"/>
<constraint firstItem="37h-6U-FC5" firstAttribute="width" secondItem="iTV-0E-fau" secondAttribute="width" id="F8k-J2-R0s"/>
<constraint firstItem="Hxk-L9-rxu" firstAttribute="leading" secondItem="36g-42-IRz" secondAttribute="leading" id="MEA-UR-jqW"/>
<constraint firstItem="vTj-O0-Vzm" firstAttribute="centerX" secondItem="36g-42-IRz" secondAttribute="centerX" id="N1p-42-mx4"/>
<constraint firstAttribute="trailing" secondItem="Hxk-L9-rxu" secondAttribute="trailing" id="a4U-bh-fuR"/>
<constraint firstAttribute="bottom" secondItem="37h-6U-FC5" secondAttribute="bottom" constant="10" id="gad-s0-eVd"/>
<constraint firstAttribute="bottom" secondItem="iTV-0E-fau" secondAttribute="bottom" constant="10" id="kG1-PE-oNe"/>
<constraint firstItem="37h-6U-FC5" firstAttribute="top" secondItem="Hxk-L9-rxu" secondAttribute="bottom" constant="10" id="rM4-nR-Bjh"/>
<constraint firstAttribute="trailing" secondItem="37h-6U-FC5" secondAttribute="trailing" constant="10" id="zu0-o5-FPq"/>
</constraints>
</customView>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="34D-L0-nbV">
<rect key="frame" x="417" y="111" width="224" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" state="on" borderStyle="bezel" placeholderString="add friend" drawsBackground="YES" id="rnC-rt-okl">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<action selector="addFriendReturn:" target="-2" id="CTO-Pa-pgL"/>
</connections>
</textField>
</subviews>
<constraints>
<constraint firstItem="9Vs-Kt-TIN" firstAttribute="top" secondItem="34D-L0-nbV" secondAttribute="bottom" constant="20" id="1Wa-eX-pQA"/>
<constraint firstAttribute="bottom" secondItem="o0o-3n-uC8" secondAttribute="bottom" constant="29" id="2aL-At-VgW"/>
<constraint firstAttribute="trailing" secondItem="o0o-3n-uC8" secondAttribute="trailing" constant="20" id="3jF-Si-tSi"/>
<constraint firstItem="o0o-3n-uC8" firstAttribute="top" secondItem="9Vs-Kt-TIN" secondAttribute="bottom" constant="20" id="5VJ-gZ-gIh"/>
<constraint firstItem="z8l-tP-yyv" firstAttribute="height" secondItem="Hz6-mo-xeY" secondAttribute="height" multiplier="0.5" id="IpA-Fe-XWI"/>
<constraint firstAttribute="bottom" secondItem="jg4-lw-sFa" secondAttribute="bottom" id="Kmb-dW-oIW"/>
<constraint firstItem="34D-L0-nbV" firstAttribute="width" secondItem="9Vs-Kt-TIN" secondAttribute="width" id="Sy7-Z1-LOx"/>
<constraint firstItem="9Vs-Kt-TIN" firstAttribute="centerX" secondItem="36g-42-IRz" secondAttribute="centerX" id="aS2-Eo-DcH"/>
<constraint firstItem="34D-L0-nbV" firstAttribute="top" relation="greaterThanOrEqual" secondItem="36g-42-IRz" secondAttribute="bottom" constant="30" id="bMC-7i-U7K"/>
<constraint firstItem="36g-42-IRz" firstAttribute="width" secondItem="Hz6-mo-xeY" secondAttribute="width" multiplier="0.4" id="cpE-9w-cP3"/>
<constraint firstItem="jg4-lw-sFa" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="d2W-n5-6RM"/>
<constraint firstItem="36g-42-IRz" firstAttribute="height" secondItem="z8l-tP-yyv" secondAttribute="height" id="eL9-K5-NVI"/>
<constraint firstItem="36g-42-IRz" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="eOf-FC-NDO"/>
<constraint firstAttribute="trailing" secondItem="9Vs-Kt-TIN" secondAttribute="trailing" constant="20" id="nVG-xw-65b"/>
<constraint firstAttribute="trailing" secondItem="36g-42-IRz" secondAttribute="trailing" id="pVE-bQ-6xN"/>
<constraint firstItem="34D-L0-nbV" firstAttribute="centerX" secondItem="9Vs-Kt-TIN" secondAttribute="centerX" id="rXg-jG-qid"/>
<constraint firstItem="36g-42-IRz" firstAttribute="leading" secondItem="z8l-tP-yyv" secondAttribute="trailing" id="rzi-u5-Pb6"/>
<constraint firstItem="z8l-tP-yyv" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="sTw-Qt-iyq"/>
<constraint firstItem="z8l-tP-yyv" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="sqj-fI-lg7"/>
<constraint firstItem="jg4-lw-sFa" firstAttribute="width" secondItem="z8l-tP-yyv" secondAttribute="width" id="tf2-qg-wYG"/>
<constraint firstItem="o0o-3n-uC8" firstAttribute="centerX" secondItem="36g-42-IRz" secondAttribute="centerX" id="u7B-Uv-bfm"/>
<constraint firstItem="jg4-lw-sFa" firstAttribute="top" secondItem="z8l-tP-yyv" secondAttribute="bottom" id="vag-SQ-aCM"/>
</constraints>
<point key="canvasLocation" x="295.5" y="350"/>
</customView>
</objects>
</document>

View File

@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
@interface OCTMainWindowController : NSWindowController
@end

View File

@ -0,0 +1,100 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTMainWindowController.h"
#import "OCTBootStrapViewController.h"
#import "OCTManagerConfiguration.h"
#import "OCTManager.h"
#import "OCTManagerFactory.h"
#import "OCTSubmanagerBootstrap.h"
#import "OCTUserViewController.h"
#import "OCTFriendsViewController.h"
#import "OCTConversationViewController.h"
#import "OCTCallsViewController.h"
#import "OCTFilesViewController.h"
@interface OCTMainWindowController () <OCTBootStrapViewDelegate>
@property (weak) IBOutlet NSView *mainView;
@property (strong, nonatomic) NSViewController *currentViewController;
@property (strong, nonatomic) NSViewController *userViewController;
@property (strong, nonatomic) NSViewController *friendUserViewController;
@property (strong, nonatomic) NSViewController *conversationViewController;
@property (strong, nonatomic) NSViewController *callsViewController;
@property (strong, nonatomic) NSViewController *filesViewController;
@property (strong, nonatomic) OCTManagerConfiguration *configuration;
@property (strong, nonatomic) id<OCTManager> manager;
@property (weak) IBOutlet NSTabView *tabView;
@end
@implementation OCTMainWindowController
- (void)windowDidLoad
{
[super windowDidLoad];
self.configuration = [OCTManagerConfiguration defaultConfiguration];
self.tabView.hidden = YES;
[self setupBootstrapViewController];
}
- (void)setupBootstrapViewController
{
OCTBootStrapViewController *bootstrapVC = [[OCTBootStrapViewController alloc]
initWithConfiguration:self.configuration];
bootstrapVC.delegate = self;
self.currentViewController = bootstrapVC;
[self.mainView addSubview:self.currentViewController.view];
[self.currentViewController.view setFrame:self.mainView.bounds];
}
#pragma mark - Bootstrap delegate
- (void)didBootStrap:(OCTBootStrapViewController *)controller
{
[self.currentViewController.view removeFromSuperview];
self.currentViewController = nil;
__weak OCTMainWindowController *weakSelf = self;
[OCTManagerFactory managerWithConfiguration:self.configuration encryptPassword:@"123" successBlock:^(id < OCTManager > manager) {
weakSelf.manager = manager;
[weakSelf.manager.bootstrap addPredefinedNodes];
[weakSelf.manager.bootstrap bootstrap];
weakSelf.tabView.hidden = NO;
[weakSelf setupTabControllers];
} failureBlock:nil];
}
#pragma mark - Private
- (void)setupTabControllers
{
NSTabViewItem *userViewItem = [self.tabView tabViewItemAtIndex:0];
self.userViewController = [[OCTUserViewController alloc] initWithManager:self.manager.user];
userViewItem.view = self.userViewController.view;
NSTabViewItem *friendViewItem = [self.tabView tabViewItemAtIndex:1];
self.friendUserViewController = [[OCTFriendsViewController alloc] initWithManager:self.manager];
friendViewItem.view = self.friendUserViewController.view;
NSTabViewItem *conversationViewItem = [self.tabView tabViewItemAtIndex:2];
self.conversationViewController = [[OCTConversationViewController alloc] initWithManager:self.manager];
conversationViewItem.view = self.conversationViewController.view;
NSTabViewItem *callViewItem = [self.tabView tabViewItemAtIndex:3];
self.callsViewController = [[OCTCallsViewController alloc] initWithManager:self.manager];
callViewItem.view = self.callsViewController.view;
NSTabViewItem *fileViewItem = [self.tabView tabViewItemAtIndex:4];
self.filesViewController = [[OCTFilesViewController alloc] initWithManager:self.manager];
fileViewItem.view = self.filesViewController.view;
}
@end

View File

@ -0,0 +1,12 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
#import "OCTSubmanagerUser.h"
@interface OCTUserViewController : NSViewController
- (instancetype)initWithManager:(id<OCTSubmanagerUser>)userManager;
@end

View File

@ -0,0 +1,268 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "OCTUserViewController.h"
#import "OCTSubmanagerUser.h"
typedef NS_ENUM(NSUInteger, Row) {
RowConnectionStatus,
RowAddress,
RowPublicKey,
RowNospam,
RowStatus,
RowName,
RowStatusMessage,
};
static NSString *const kNibName = @"OCTUserViewController";
static NSString *const kTableViewIdentifier = @"userTableViewIdent";
@interface OCTUserViewController () <NSTableViewDataSource,
NSTableViewDelegate,
NSTextFieldDelegate,
OCTSubmanagerUserDelegate>
@property (weak, nonatomic) id<OCTSubmanagerUser> userManager;
@property (weak) IBOutlet NSTableView *userTableView;
@property (strong, nonatomic) NSArray *userData;
@property (weak) IBOutlet NSTableColumn *firstColumn;
@property (weak) IBOutlet NSTableColumn *secondColumn;
@property (weak) IBOutlet NSImageView *avatarImageView;
@end
@implementation OCTUserViewController
- (instancetype)initWithManager:(id<OCTSubmanagerUser>)userManager
{
self = [super initWithNibName:kNibName bundle:nil];
if (! self) {
return nil;
}
_userData = @[
@(RowConnectionStatus),
@(RowAddress),
@(RowPublicKey),
@(RowNospam),
@(RowStatus),
@(RowName),
@(RowStatusMessage),
];
_userManager = userManager;
userManager.delegate = self;
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self updateAvatarImageView];
}
#pragma mark - NSTableViewDataSource
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return self.userData.count;
}
#pragma mark - NSTableViewDelegate
- (NSView *) tableView:(NSTableView *)tableView
viewForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
{
NSTextField *textField = [tableView makeViewWithIdentifier:kTableViewIdentifier owner:self];
if (! textField) {
textField = [NSTextField new];
textField.identifier = kTableViewIdentifier;
}
if (tableColumn == self.firstColumn) {
textField.stringValue = [self nameLabelForRow:row];
textField.editable = NO;
}
if (tableColumn == self.secondColumn) {
if (row == RowStatus) {
NSPopUpButton *popUpButton = [NSPopUpButton new];
popUpButton.tag = row;
[popUpButton addItemsWithTitles:@[@"None", @"Away", @"Busy"]];
[popUpButton selectItemAtIndex:self.userManager.userStatus];
popUpButton.action = @selector(selectionMadeForUserStatus:);
popUpButton.target = self;
return popUpButton;
}
textField.stringValue = [self descriptionLabelForRow:row];
textField.delegate = self;
textField.selectable = (row < 3);
textField.editable = (row >= 3);
}
return textField;
}
#pragma mark - NSButtonTargetAction
- (void)selectionMadeForUserStatus:(NSPopUpButton *)sender
{
self.userManager.userStatus = sender.indexOfSelectedItem;
}
- (IBAction)avatarButtonPressed:(id)sender
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel runModal];
NSString *path = [panel.URL path];
NSData *data = [NSData dataWithContentsOfFile:path];
[self.userManager setUserAvatar:data error:nil];
[self updateAvatarImageView];
}
- (IBAction)removeAvatarButtonPressed:(id)sender
{
[self.userManager setUserAvatar:nil error:nil];
[self updateAvatarImageView];
}
#pragma mark - NSTextFieldDelegate
- (void)controlTextDidEndEditing:(NSNotification *)obj
{
NSTextField *field = obj.object;
NSInteger row = [self.userTableView rowForView:field];
NSString *string = field.stringValue;
switch (row) {
case RowNospam:
self.userManager.nospam = (OCTToxNoSpam)[string integerValue];
break;
case RowName:
[self.userManager setUserName:string error:nil];
break;
case RowStatusMessage:
[self.userManager setUserStatusMessage:string error:nil];
break;
default:
break;
}
}
#pragma mark - OCTSubmanagerUserDelegate
- (void)submanagerUser:(nonnull id<OCTSubmanagerUser>)submanager connectionStatusUpdate:(OCTToxConnectionStatus)connectionStatus
{
[self.userTableView reloadData];
}
#pragma mark - Private
- (NSString *)nameLabelForRow:(NSInteger)row
{
NSString *label;
switch (row) {
case RowConnectionStatus:
label = @"connectionStatus";
break;
case RowAddress:
label = @"userAddress";
break;
case RowPublicKey:
label = @"publicKey";
break;
case RowNospam:
label = @"nospam";
break;
case RowStatus:
label = @"user status";
break;
case RowName:
label = @"userName";
break;
case RowStatusMessage:
label = @"userStatusMessage";
break;
default:
break;
}
return label;
}
- (NSString *)descriptionLabelForRow:(NSInteger)row
{
NSString *label;
switch (row) {
case RowConnectionStatus:
label = [self stringFromConnectionStatus:self.userManager.connectionStatus];
break;
case RowAddress:
label = self.userManager.userAddress;
break;
case RowPublicKey:
label = self.userManager.publicKey;
break;
case RowNospam:
label = [NSString stringWithFormat:@"%u", self.userManager.nospam];
break;
case RowStatus:
label = [self stringFromUserStatus:self.userManager.userStatus];
break;
case RowName:
label = (self.userManager.userName) ? self.userManager.userName : @"";
break;
case RowStatusMessage:
label = (self.userManager.userStatusMessage) ? self.userManager
.userStatusMessage : @"";
break;
default:
break;
}
return label;
}
- (NSString *)stringFromConnectionStatus:(OCTToxConnectionStatus)status
{
switch (status) {
case OCTToxConnectionStatusNone:
return @"None";
case OCTToxConnectionStatusTCP:
return @"TCP";
case OCTToxConnectionStatusUDP:
return @"UDP";
}
}
- (NSString *)stringFromUserStatus:(OCTToxUserStatus)status
{
switch (status) {
case OCTToxUserStatusNone:
return @"None";
case OCTToxUserStatusAway:
return @"Away";
case OCTToxUserStatusBusy:
return @"Busy";
}
}
- (void)updateAvatarImageView
{
self.avatarImageView.image = [[NSImage alloc] initWithData:self.userManager.userAvatar];
}
@end

View File

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="OCTUserViewController">
<connections>
<outlet property="avatarImageView" destination="wj9-zk-Hyf" id="Lr7-Y2-AUj"/>
<outlet property="firstColumn" destination="eXS-dI-x4N" id="YZt-Pr-ctx"/>
<outlet property="secondColumn" destination="4Ty-KF-k9F" id="a30-93-mfY"/>
<outlet property="userTableView" destination="Qi4-Vc-Kq8" id="dP8-18-mL6"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<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="480" height="272"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="24" horizontalPageScroll="10" verticalLineScroll="24" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gva-6h-Bvw">
<rect key="frame" x="67" y="0.0" width="413" height="272"/>
<clipView key="contentView" id="5d5-Sb-fFR">
<rect key="frame" x="1" y="0.0" width="411" height="271"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="22" rowSizeStyle="automatic" headerView="PvT-sM-IAX" viewBased="YES" id="Qi4-Vc-Kq8">
<rect key="frame" x="0.0" y="0.0" width="411" height="248"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn width="154.6796875" minWidth="40" maxWidth="1000" id="eXS-dI-x4N">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="w4U-lp-AQb">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="ksE-uF-PCl">
<rect key="frame" x="1" y="1" width="154.5" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="b78-pK-trf">
<rect key="frame" x="0.0" y="5" width="100" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="rRH-2N-s70">
<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>
</subviews>
<connections>
<outlet property="textField" destination="b78-pK-trf" id="DZy-MY-VUv"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn width="250.5" minWidth="40" maxWidth="1000" id="4Ty-KF-k9F">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="3Ds-Jl-o7I">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="NKB-e2-AB0">
<rect key="frame" x="158.5" y="1" width="250.5" height="22"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mmU-R9-xQG">
<rect key="frame" x="0.0" y="5" width="100" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="vha-TB-4Lv">
<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>
</subviews>
<connections>
<outlet property="textField" destination="mmU-R9-xQG" id="uo3-aa-k6n"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="-2" id="d0G-zz-PKq"/>
<outlet property="delegate" destination="-2" id="3M8-nx-RhJ"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="0.5" horizontal="YES" id="JY9-Ok-UrT">
<rect key="frame" x="1" y="256" width="478" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="gqJ-XS-uFa">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="PvT-sM-IAX">
<rect key="frame" x="0.0" y="0.0" width="411" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="wj9-zk-Hyf">
<rect key="frame" x="0.0" y="224" width="48" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="hC7-Z2-UXd"/>
<constraint firstAttribute="height" constant="48" id="v98-xA-qYI"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="PRR-4f-kif"/>
</imageView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FS6-lb-SP5">
<rect key="frame" x="-6" y="183" width="79" height="32"/>
<buttonCell key="cell" type="push" title="Avatar" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5wg-L4-EwW">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="avatarButtonPressed:" target="-2" id="xeB-wl-gh8"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HAP-3P-xt2">
<rect key="frame" x="-10" y="150" width="89" height="32"/>
<buttonCell key="cell" type="push" title="Remove" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="EZO-AH-b9q">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="removeAvatarButtonPressed:" target="-2" id="W5t-yU-yvP"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="Gva-6h-Bvw" secondAttribute="trailing" id="4Sz-TO-rnE"/>
<constraint firstItem="FS6-lb-SP5" firstAttribute="top" secondItem="wj9-zk-Hyf" secondAttribute="bottom" constant="13" id="SIU-QA-58w"/>
<constraint firstAttribute="bottom" secondItem="Gva-6h-Bvw" secondAttribute="bottom" id="V3N-3H-5HF"/>
<constraint firstItem="Gva-6h-Bvw" firstAttribute="leading" secondItem="FS6-lb-SP5" secondAttribute="trailing" id="b7A-jS-dTv"/>
<constraint firstItem="wj9-zk-Hyf" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="qqE-x8-EVR"/>
<constraint firstItem="wj9-zk-Hyf" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="uKb-GX-th3"/>
<constraint firstItem="Gva-6h-Bvw" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="vxp-RB-744"/>
<constraint firstItem="FS6-lb-SP5" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="weo-LB-hlG"/>
</constraints>
</customView>
</objects>
</document>

View File

@ -0,0 +1,14 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Foundation/Foundation.h>
#import <Realm/Realm.h>
@interface RLMCollectionChange (IndexSet)
- (NSIndexSet *)deletionsSet;
- (NSIndexSet *)insertionsSet;
- (NSIndexSet *)modificationsSet;
@end

View File

@ -0,0 +1,39 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import "RLMCollectionChange+IndexSet.h"
@implementation RLMCollectionChange (IndexSet)
#pragma mark - Public
- (NSIndexSet *)deletionsSet
{
return [self indexSetFromNumbersArray:[self deletions]];
}
- (NSIndexSet *)insertionsSet
{
return [self indexSetFromNumbersArray:[self insertions]];
}
- (NSIndexSet *)modificationsSet
{
return [self indexSetFromNumbersArray:[self modifications]];
}
#pragma mark - Private
- (NSIndexSet *)indexSetFromNumbersArray:(NSArray<NSNumber *> *)numbersArray
{
NSMutableIndexSet *set = [NSMutableIndexSet new];
for (NSNumber *number in numbersArray) {
[set addIndex:number.integerValue];
}
return [set copy];
}
@end

View File

@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#import <Cocoa/Cocoa.h>
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, argv);
}