Skip to content

Commit

Permalink
Add local listening socket
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Nov 10, 2013
1 parent 6c0fdba commit b9440b8
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "Submodules/libplist"]
path = Submodules/libplist
url = git@github.com:libimobiledevice/libplist.git
[submodule "Submodules/CocoaAsyncSocket"]
path = Submodules/CocoaAsyncSocket
url = git@github.com:robbiehanson/CocoaAsyncSocket.git
1 change: 1 addition & 0 deletions Submodules/CocoaAsyncSocket
Submodule CocoaAsyncSocket added at 52b6e3
32 changes: 30 additions & 2 deletions Tether.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
D90E32DF182F663A00A6F642 /* node_iterator.c in Sources */ = {isa = PBXBuildFile; fileRef = D90E32DA182F663A00A6F642 /* node_iterator.c */; };
D90E32E0182F663A00A6F642 /* node_list.c in Sources */ = {isa = PBXBuildFile; fileRef = D90E32DB182F663A00A6F642 /* node_list.c */; };
D90E32E1182F663A00A6F642 /* node.c in Sources */ = {isa = PBXBuildFile; fileRef = D90E32DC182F663A00A6F642 /* node.c */; };
D931A60D1830126D00593FF9 /* GCDAsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = D931A60C1830126D00593FF9 /* GCDAsyncSocket.m */; };
D931A611183012D600593FF9 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D931A610183012D600593FF9 /* Security.framework */; };
D9D810FD182F6794003DCCBB /* collection.c in Sources */ = {isa = PBXBuildFile; fileRef = D9D810F8182F6794003DCCBB /* collection.c */; };
D9D810FE182F6794003DCCBB /* collection.h in Headers */ = {isa = PBXBuildFile; fileRef = D9D810F9182F6794003DCCBB /* collection.h */; };
D9D810FF182F6794003DCCBB /* libusbmuxd.c in Sources */ = {isa = PBXBuildFile; fileRef = D9D810FA182F6794003DCCBB /* libusbmuxd.c */; };
Expand Down Expand Up @@ -112,6 +114,9 @@
D90E32DA182F663A00A6F642 /* node_iterator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = node_iterator.c; path = Submodules/libplist/libcnary/node_iterator.c; sourceTree = "<group>"; };
D90E32DB182F663A00A6F642 /* node_list.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = node_list.c; path = Submodules/libplist/libcnary/node_list.c; sourceTree = "<group>"; };
D90E32DC182F663A00A6F642 /* node.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = node.c; path = Submodules/libplist/libcnary/node.c; sourceTree = "<group>"; };
D931A60B1830126D00593FF9 /* GCDAsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GCDAsyncSocket.h; path = Submodules/CocoaAsyncSocket/GCD/GCDAsyncSocket.h; sourceTree = "<group>"; };
D931A60C1830126D00593FF9 /* GCDAsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GCDAsyncSocket.m; path = Submodules/CocoaAsyncSocket/GCD/GCDAsyncSocket.m; sourceTree = "<group>"; };
D931A610183012D600593FF9 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
D9D810F8182F6794003DCCBB /* collection.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = collection.c; path = Submodules/libusbmuxd/src/collection.c; sourceTree = "<group>"; };
D9D810F9182F6794003DCCBB /* collection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = collection.h; path = Submodules/libusbmuxd/src/collection.h; sourceTree = "<group>"; };
D9D810FA182F6794003DCCBB /* libusbmuxd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = libusbmuxd.c; path = Submodules/libusbmuxd/src/libusbmuxd.c; sourceTree = "<group>"; };
Expand All @@ -128,6 +133,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D931A611183012D600593FF9 /* Security.framework in Frameworks */,
D9D81107182F83DD003DCCBB /* libxml2.dylib in Frameworks */,
D9D81106182F83D2003DCCBB /* liblibplist.a in Frameworks */,
D9D81105182F83CF003DCCBB /* liblibcnary.a in Frameworks */,
Expand Down Expand Up @@ -164,8 +170,7 @@
D90E324C182F07DC00A6F642 = {
isa = PBXGroup;
children = (
D90E32E4182F676200A6F642 /* libusbmuxd */,
D90E32CC182F638D00A6F642 /* libplist */,
D931A60F1830128000593FF9 /* Submodules */,
D90E325E182F07DC00A6F642 /* Tether */,
D90E3257182F07DC00A6F642 /* Frameworks */,
D90E3256182F07DC00A6F642 /* Products */,
Expand All @@ -186,6 +191,7 @@
D90E3257182F07DC00A6F642 /* Frameworks */ = {
isa = PBXGroup;
children = (
D931A610183012D600593FF9 /* Security.framework */,
D90E32CD182F653300A6F642 /* libxml2.dylib */,
D90E3258182F07DC00A6F642 /* Cocoa.framework */,
D90E3277182F07DC00A6F642 /* XCTest.framework */,
Expand Down Expand Up @@ -280,6 +286,25 @@
name = libusbmuxd;
sourceTree = "<group>";
};
D931A60E1830127400593FF9 /* CocoaAsyncSocket */ = {
isa = PBXGroup;
children = (
D931A60B1830126D00593FF9 /* GCDAsyncSocket.h */,
D931A60C1830126D00593FF9 /* GCDAsyncSocket.m */,
);
name = CocoaAsyncSocket;
sourceTree = "<group>";
};
D931A60F1830128000593FF9 /* Submodules */ = {
isa = PBXGroup;
children = (
D931A60E1830127400593FF9 /* CocoaAsyncSocket */,
D90E32E4182F676200A6F642 /* libusbmuxd */,
D90E32CC182F638D00A6F642 /* libplist */,
);
name = Submodules;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -438,6 +463,7 @@
buildActionMask = 2147483647;
files = (
D90E3265182F07DC00A6F642 /* main.m in Sources */,
D931A60D1830126D00593FF9 /* GCDAsyncSocket.m in Sources */,
D90E326C182F07DC00A6F642 /* CBAppDelegate.m in Sources */,
D90E3297182F18CC00A6F642 /* CBDeviceWindowController.m in Sources */,
D9D8110A182F8B80003DCCBB /* USBMuxClient.m in Sources */,
Expand Down Expand Up @@ -607,6 +633,7 @@
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/Submodules/libusbmuxd/include",
"$(SRCROOT)/Submodules/CocoaAsyncSocket/GCD",
);
INFOPLIST_FILE = "Tether/Tether-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -625,6 +652,7 @@
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/Submodules/libusbmuxd/include",
"$(SRCROOT)/Submodules/CocoaAsyncSocket/GCD",
);
INFOPLIST_FILE = "Tether/Tether-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
2 changes: 2 additions & 0 deletions Tether/CBDeviceWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

#import <Cocoa/Cocoa.h>
#import "USBMuxClient.h"
#import "GCDAsyncSocket.h"

@interface CBDeviceWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate, USBMuxClientDelegate>

@property (strong) IBOutlet NSTableView *deviceTableView;
@property (nonatomic, strong) NSMutableOrderedSet *devices;
@property (strong) IBOutlet NSButton *connectButton;
@property (strong) IBOutlet NSButton *refreshButton;
@property (nonatomic, strong) GCDAsyncSocket *socket;

- (IBAction)connectButtonPressed:(id)sender;
- (IBAction)refreshButtonPressed:(id)sender;
Expand Down
9 changes: 8 additions & 1 deletion Tether/CBDeviceWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ @interface CBDeviceWindowController ()
@end

@implementation CBDeviceWindowController
@synthesize devices, deviceTableView;
@synthesize devices, deviceTableView, socket;


- (void) device:(USBMuxDevice *)device statusDidChange:(USBDeviceStatus)deviceStatus {
Expand Down Expand Up @@ -92,6 +92,13 @@ - (IBAction)connectButtonPressed:(id)sender {
[USBMuxClient connectDevice:device port:port completionCallback:^(BOOL success, NSError *error) {
NSLog(@"connecting %@ on port %lu", device.udid, (unsigned long)port);
}];
self.socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSError *error = nil;
uint16_t portNumber = 8000;
[socket acceptOnPort:portNumber error:&error];
if (error) {
NSLog(@"Error listening on port %d", portNumber);
}
}

- (IBAction)refreshButtonPressed:(id)sender {
Expand Down
40 changes: 40 additions & 0 deletions Tether/CBDeviceWindowController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,52 @@
<action selector="refreshButtonPressed:" target="-2" id="nIX-fL-R1u"/>
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZXH-Mq-bEb">
<rect key="frame" x="98" y="9" width="70" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="70" id="1nB-yY-4rv"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Local Port" drawsBackground="YES" id="DLV-Zo-zSC">
<numberFormatter key="formatter" formatterBehavior="default10_4" positiveFormat="#,##0.###" negativeFormat="#,##0.###" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="309" minimumFractionDigits="0" maximumFractionDigits="3" id="CCU-xj-aGA">
<real key="roundingIncrement" value="0.0"/>
<metadata>
<bool key="localizesFormat" value="YES"/>
</metadata>
</numberFormatter>
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oUG-u6-zx0">
<rect key="frame" x="176" y="9" width="86" height="22"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="86" id="0dm-cS-kDd"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Remote Port" drawsBackground="YES" id="XdH-Rr-36G">
<numberFormatter key="formatter" formatterBehavior="default10_4" positiveFormat="#,##0.###" negativeFormat="#,##0.###" numberStyle="decimal" minimumIntegerDigits="1" maximumIntegerDigits="309" minimumFractionDigits="0" maximumFractionDigits="3" id="tcq-YS-yxJ">
<real key="roundingIncrement" value="0.0"/>
<metadata>
<bool key="localizesFormat" value="YES"/>
</metadata>
</numberFormatter>
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="sue-YU-LfJ" secondAttribute="trailing" constant="10" id="81p-rh-BfH"/>
<constraint firstItem="OsL-u8-g7s" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="10" id="Gbg-dv-Vqa"/>
<constraint firstItem="sue-YU-LfJ" firstAttribute="baseline" secondItem="OsL-u8-g7s" secondAttribute="baseline" id="Ins-WT-elu"/>
<constraint firstItem="oUG-u6-zx0" firstAttribute="leading" secondItem="ZXH-Mq-bEb" secondAttribute="trailing" constant="8" symbolic="YES" id="LrO-Ak-Azn"/>
<constraint firstItem="ZXH-Mq-bEb" firstAttribute="top" secondItem="OsL-u8-g7s" secondAttribute="top" id="ROw-Sx-KqU"/>
<constraint firstAttribute="bottom" secondItem="OsL-u8-g7s" secondAttribute="bottom" constant="10" id="Ulh-c1-6xT"/>
<constraint firstItem="ZXH-Mq-bEb" firstAttribute="baseline" secondItem="oUG-u6-zx0" secondAttribute="baseline" id="UvH-Xd-X98"/>
<constraint firstItem="ZXH-Mq-bEb" firstAttribute="leading" secondItem="OsL-u8-g7s" secondAttribute="trailing" constant="8" symbolic="YES" id="X4b-Ze-zGY"/>
<constraint firstItem="Cej-YJ-dtF" firstAttribute="top" secondItem="2" secondAttribute="top" constant="-1" id="jGF-P8-91b"/>
<constraint firstAttribute="trailing" secondItem="Cej-YJ-dtF" secondAttribute="trailing" constant="-1" id="jwC-6k-K9y"/>
<constraint firstItem="OsL-u8-g7s" firstAttribute="top" secondItem="Cej-YJ-dtF" secondAttribute="bottom" constant="10" id="nQV-9a-icg"/>
Expand Down

0 comments on commit b9440b8

Please sign in to comment.