"];
76 | return description;
77 | }
78 |
79 | @end
80 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/GCDWebUploader.bundle/css/index.css:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | .row-file {
29 | height: 40px;
30 | }
31 |
32 | .column-icon {
33 | width: 40px;
34 | text-align: center;
35 | }
36 |
37 | .column-name {
38 | }
39 |
40 | .column-size {
41 | width: 100px;
42 | text-align: right;
43 | }
44 |
45 | .column-move {
46 | width: 40px;
47 | text-align: center;
48 | }
49 |
50 | .column-delete {
51 | width: 40px;
52 | text-align: center;
53 | }
54 |
55 | .column-path {
56 | }
57 |
58 | .column-progress {
59 | width: 200px;
60 | }
61 |
62 | .footer {
63 | color: #999;
64 | text-align: center;
65 | font-size: 0.9em;
66 | }
67 |
68 | #reload {
69 | float: right;
70 | }
71 |
72 | #create-input {
73 | width: 50%;
74 | height: 20px;
75 | }
76 |
77 | #move-input {
78 | width: 80%;
79 | height: 20px;
80 | }
81 |
82 | /* Bootstrap overrides */
83 |
84 | .btn:focus {
85 | outline: none; /* FIXME: Work around for Chrome only but still draws focus ring while button pressed */
86 | }
87 |
88 | .btn-toolbar {
89 | margin-top: 30px;
90 | margin-bottom: 20px;
91 | }
92 |
93 | .table .progress {
94 | margin-top: 0px;
95 | margin-bottom: 0px;
96 | height: 16px;
97 | }
98 |
99 | .panel-default > .panel-heading {
100 | color: #555;
101 | }
102 |
103 | .breadcrumb {
104 | background-color: transparent;
105 | border-radius: 0px;
106 | margin-bottom: 0px;
107 | padding: 0px;
108 | }
109 |
110 | .breadcrumb > .active {
111 | color: #555;
112 | }
113 |
114 | .breadcrumb > li + li:before {
115 | color: #999;
116 | }
117 |
118 | .table > tbody > tr > td {
119 | vertical-align: middle;
120 | }
121 |
122 | .table > tbody > tr > td > p {
123 | margin: 0px;
124 | }
125 |
126 | /* Initial state */
127 |
128 | .uploading {
129 | display: none;
130 | }
131 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerStreamedResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "GCDWebServerResponse.h"
29 |
30 | /**
31 | * The GCDWebServerStreamBlock is called to stream the data for the HTTP body.
32 | * The block must return either a chunk of data, an empty NSData when done, or
33 | * nil on error and set the "error" argument which is guaranteed to be non-NULL.
34 | */
35 | typedef NSData* (^GCDWebServerStreamBlock)(NSError** error);
36 |
37 | /**
38 | * The GCDWebServerAsyncStreamBlock works like the GCDWebServerStreamBlock
39 | * except the streamed data can be returned at a later time allowing for
40 | * truly asynchronous generation of the data.
41 | *
42 | * The block must call "completionBlock" passing the new chunk of data when ready,
43 | * an empty NSData when done, or nil on error and pass a NSError.
44 | *
45 | * The block cannot call "completionBlock" more than once per invocation.
46 | */
47 | typedef void (^GCDWebServerAsyncStreamBlock)(GCDWebServerBodyReaderCompletionBlock completionBlock);
48 |
49 | /**
50 | * The GCDWebServerStreamedResponse subclass of GCDWebServerResponse streams
51 | * the body of the HTTP response using a GCD block.
52 | */
53 | @interface GCDWebServerStreamedResponse : GCDWebServerResponse
54 |
55 | /**
56 | * Creates a response with streamed data and a given content type.
57 | */
58 | + (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block;
59 |
60 | /**
61 | * Creates a response with async streamed data and a given content type.
62 | */
63 | + (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block;
64 |
65 | /**
66 | * Initializes a response with streamed data and a given content type.
67 | */
68 | - (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block;
69 |
70 | /**
71 | * This method is the designated initializer for the class.
72 | */
73 | - (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block;
74 |
75 | @end
76 |
--------------------------------------------------------------------------------
/Insider.xcodeproj/xcshareddata/xcschemes/InsiderDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/docs/search.json:
--------------------------------------------------------------------------------
1 | {"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didReceiveRemoteMessage:":{"name":"insider(_:didReceiveRemote:)","abstract":"This method will be called on delegate for send command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:returnResponseMessageForRemoteMessage:":{"name":"insider(_:returnResponseMessageForRemote:)","abstract":"This method will be called on delegate for sendAndWaitForResponse command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didSendNotificationWithMessage:":{"name":"insider(_:didSendNotificationWith:)","abstract":"This method will be called on delegate for notification command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didReturnSystemInfo:":{"name":"insider(_:didReturn:)","abstract":"This method will be called on delegate for systemInfo command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didCreateDirectoryAtPath:":{"name":"insider(_:didCreateDirectoryAt:)","abstract":"This method is caled when a new directory is created in sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didDeleteItemAtPath:":{"name":"insider(_:didDeleteItemAt:)","abstract":"This method is called when an item is removed from sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didDownloadFileAtPath:":{"name":"insider(_:didDownloadFileAt:)","abstract":"This method is called when an item is downloaded from sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didMoveItemFromPath:toPath:":{"name":"insider(_:didMoveItem:to:)","abstract":"This method is called when an item is moved in sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didUploadFileAtPath:":{"name":"insider(_:didUploadFileAt:)","abstract":"This method is called when an item is uploaded to sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html":{"name":"InsiderDelegate","abstract":"The Insider delegate protocol.
"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(cpy)shared":{"name":"shared","abstract":"The shared instance.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(py)delegate":{"name":"delegate","abstract":"The Insider delegate.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(cpy)insiderNotificationKey":{"name":"insiderNotificationKey","abstract":"The Insider notification key.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)start":{"name":"start()","abstract":"Start the local web server which will listen for commands.","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)startWithDelegate:":{"name":"start(withDelegate:)","abstract":"
Start the local web server which will listen for commands, for given delegate.","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)startWithDelegate:port:":{"name":"start(withDelegate:port:)","abstract":"
Start the local web server which will listen for commands, for given delegate and port number.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)stop":{"name":"stop()","abstract":"Stop the local web server.
","parent_name":"Insider"},"Classes/Insider.html":{"name":"Insider","abstract":"The Insider API facade class.
"},"Classes.html":{"name":"Classes","abstract":"The following classes are available globally.
"},"Protocols.html":{"name":"Protocols","abstract":"The following protocols are available globally.
"}}
--------------------------------------------------------------------------------
/docs/docsets/Insider.docset/Contents/Resources/Documents/search.json:
--------------------------------------------------------------------------------
1 | {"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didReceiveRemoteMessage:":{"name":"insider(_:didReceiveRemote:)","abstract":"This method will be called on delegate for send command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:returnResponseMessageForRemoteMessage:":{"name":"insider(_:returnResponseMessageForRemote:)","abstract":"This method will be called on delegate for sendAndWaitForResponse command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didSendNotificationWithMessage:":{"name":"insider(_:didSendNotificationWith:)","abstract":"This method will be called on delegate for notification command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didReturnSystemInfo:":{"name":"insider(_:didReturn:)","abstract":"This method will be called on delegate for systemInfo command
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didCreateDirectoryAtPath:":{"name":"insider(_:didCreateDirectoryAt:)","abstract":"This method is caled when a new directory is created in sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didDeleteItemAtPath:":{"name":"insider(_:didDeleteItemAt:)","abstract":"This method is called when an item is removed from sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didDownloadFileAtPath:":{"name":"insider(_:didDownloadFileAt:)","abstract":"This method is called when an item is downloaded from sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didMoveItemFromPath:toPath:":{"name":"insider(_:didMoveItem:to:)","abstract":"This method is called when an item is moved in sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html#/c:@M@Insider@objc(pl)InsiderDelegate(im)insider:didUploadFileAtPath:":{"name":"insider(_:didUploadFileAt:)","abstract":"This method is called when an item is uploaded to sandbox
","parent_name":"InsiderDelegate"},"Protocols/InsiderDelegate.html":{"name":"InsiderDelegate","abstract":"The Insider delegate protocol.
"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(cpy)shared":{"name":"shared","abstract":"The shared instance.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(py)delegate":{"name":"delegate","abstract":"The Insider delegate.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(cpy)insiderNotificationKey":{"name":"insiderNotificationKey","abstract":"The Insider notification key.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)start":{"name":"start()","abstract":"Start the local web server which will listen for commands.","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)startWithDelegate:":{"name":"start(withDelegate:)","abstract":"
Start the local web server which will listen for commands, for given delegate.","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)startWithDelegate:port:":{"name":"start(withDelegate:port:)","abstract":"
Start the local web server which will listen for commands, for given delegate and port number.
","parent_name":"Insider"},"Classes/Insider.html#/c:@M@Insider@objc(cs)Insider(im)stop":{"name":"stop()","abstract":"Stop the local web server.
","parent_name":"Insider"},"Classes/Insider.html":{"name":"Insider","abstract":"The Insider API facade class.
"},"Classes.html":{"name":"Classes","abstract":"The following classes are available globally.
"},"Protocols.html":{"name":"Protocols","abstract":"The following protocols are available globally.
"}}
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Requests/GCDWebServerDataRequest.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !__has_feature(objc_arc)
29 | #error GCDWebServer requires ARC
30 | #endif
31 |
32 | #import "GCDWebServerPrivate.h"
33 |
34 | @interface GCDWebServerDataRequest () {
35 | @private
36 | NSMutableData* _data;
37 |
38 | NSString* _text;
39 | id _jsonObject;
40 | }
41 | @end
42 |
43 | @implementation GCDWebServerDataRequest
44 |
45 | @synthesize data=_data;
46 |
47 | - (BOOL)open:(NSError**)error {
48 | if (self.contentLength != NSUIntegerMax) {
49 | _data = [[NSMutableData alloc] initWithCapacity:self.contentLength];
50 | } else {
51 | _data = [[NSMutableData alloc] init];
52 | }
53 | if (_data == nil) {
54 | if (error) {
55 | *error = [NSError errorWithDomain:kGCDWebServerErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: @"Failed allocating memory"}];
56 | }
57 | return NO;
58 | }
59 | return YES;
60 | }
61 |
62 | - (BOOL)writeData:(NSData*)data error:(NSError**)error {
63 | [_data appendData:data];
64 | return YES;
65 | }
66 |
67 | - (BOOL)close:(NSError**)error {
68 | return YES;
69 | }
70 |
71 | - (NSString*)description {
72 | NSMutableString* description = [NSMutableString stringWithString:[super description]];
73 | if (_data) {
74 | [description appendString:@"\n\n"];
75 | [description appendString:GCDWebServerDescribeData(_data, self.contentType)];
76 | }
77 | return description;
78 | }
79 |
80 | @end
81 |
82 | @implementation GCDWebServerDataRequest (Extensions)
83 |
84 | - (NSString*)text {
85 | if (_text == nil) {
86 | if ([self.contentType hasPrefix:@"text/"]) {
87 | NSString* charset = GCDWebServerExtractHeaderValueParameter(self.contentType, @"charset");
88 | _text = [[NSString alloc] initWithData:self.data encoding:GCDWebServerStringEncodingFromCharset(charset)];
89 | } else {
90 | GWS_DNOT_REACHED();
91 | }
92 | }
93 | return _text;
94 | }
95 |
96 | - (id)jsonObject {
97 | if (_jsonObject == nil) {
98 | NSString* mimeType = GCDWebServerTruncateHeaderValue(self.contentType);
99 | if ([mimeType isEqualToString:@"application/json"] || [mimeType isEqualToString:@"text/json"] || [mimeType isEqualToString:@"text/javascript"]) {
100 | _jsonObject = [NSJSONSerialization JSONObjectWithData:_data options:0 error:NULL];
101 | } else {
102 | GWS_DNOT_REACHED();
103 | }
104 | }
105 | return _jsonObject;
106 | }
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Core/GCDWebServerFunctions.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import
29 |
30 | #ifdef __cplusplus
31 | extern "C" {
32 | #endif
33 |
34 | /**
35 | * Converts a file extension to the corresponding MIME type.
36 | * If there is no match, "application/octet-stream" is returned.
37 | */
38 | NSString* GCDWebServerGetMimeTypeForExtension(NSString* extension);
39 |
40 | /**
41 | * Add percent-escapes to a string so it can be used in a URL.
42 | * The legal characters ":@/?&=+" are also escaped to ensure compatibility
43 | * with URL encoded forms and URL queries.
44 | */
45 | NSString* GCDWebServerEscapeURLString(NSString* string);
46 |
47 | /**
48 | * Unescapes a URL percent-encoded string.
49 | */
50 | NSString* GCDWebServerUnescapeURLString(NSString* string);
51 |
52 | /**
53 | * Extracts the unescaped names and values from an
54 | * "application/x-www-form-urlencoded" form.
55 | * http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
56 | */
57 | NSDictionary* GCDWebServerParseURLEncodedForm(NSString* form);
58 |
59 | /**
60 | * On OS X, returns the IPv4 or IPv6 address as a string of the primary
61 | * connected service or nil if not available.
62 | *
63 | * On iOS, returns the IPv4 or IPv6 address as a string of the WiFi
64 | * interface if connected or nil otherwise.
65 | */
66 | NSString* GCDWebServerGetPrimaryIPAddress(BOOL useIPv6);
67 |
68 | /**
69 | * Converts a date into a string using RFC822 formatting.
70 | * https://tools.ietf.org/html/rfc822#section-5
71 | * https://tools.ietf.org/html/rfc1123#section-5.2.14
72 | */
73 | NSString* GCDWebServerFormatRFC822(NSDate* date);
74 |
75 | /**
76 | * Converts a RFC822 formatted string into a date.
77 | * https://tools.ietf.org/html/rfc822#section-5
78 | * https://tools.ietf.org/html/rfc1123#section-5.2.14
79 | *
80 | * @warning Timezones other than GMT are not supported by this function.
81 | */
82 | NSDate* GCDWebServerParseRFC822(NSString* string);
83 |
84 | /**
85 | * Converts a date into a string using IOS 8601 formatting.
86 | * http://tools.ietf.org/html/rfc3339#section-5.6
87 | */
88 | NSString* GCDWebServerFormatISO8601(NSDate* date);
89 |
90 | /**
91 | * Converts a ISO 8601 formatted string into a date.
92 | * http://tools.ietf.org/html/rfc3339#section-5.6
93 | *
94 | * @warning Only "calendar" variant is supported at this time and timezones
95 | * other than GMT are not supported either.
96 | */
97 | NSDate* GCDWebServerParseISO8601(NSString* string);
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerErrorResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "GCDWebServerDataResponse.h"
29 | #import "GCDWebServerHTTPStatusCodes.h"
30 |
31 | /**
32 | * The GCDWebServerDataResponse subclass of GCDWebServerDataResponse generates
33 | * an HTML body from an HTTP status code and an error message.
34 | */
35 | @interface GCDWebServerErrorResponse : GCDWebServerDataResponse
36 |
37 | /**
38 | * Creates a client error response with the corresponding HTTP status code.
39 | */
40 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
41 |
42 | /**
43 | * Creates a server error response with the corresponding HTTP status code.
44 | */
45 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
46 |
47 | /**
48 | * Creates a client error response with the corresponding HTTP status code
49 | * and an underlying NSError.
50 | */
51 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4);
52 |
53 | /**
54 | * Creates a server error response with the corresponding HTTP status code
55 | * and an underlying NSError.
56 | */
57 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4);
58 |
59 | /**
60 | * Initializes a client error response with the corresponding HTTP status code.
61 | */
62 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
63 |
64 | /**
65 | * Initializes a server error response with the corresponding HTTP status code.
66 | */
67 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... NS_FORMAT_FUNCTION(2,3);
68 |
69 | /**
70 | * Initializes a client error response with the corresponding HTTP status code
71 | * and an underlying NSError.
72 | */
73 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4);
74 |
75 | /**
76 | * Initializes a server error response with the corresponding HTTP status code
77 | * and an underlying NSError.
78 | */
79 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... NS_FORMAT_FUNCTION(3,4);
80 |
81 | @end
82 |
--------------------------------------------------------------------------------
/docs/Classes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Classes Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 | Insider Reference
23 |
24 | Classes Reference
25 |
26 |
27 |
28 |
48 |
49 |
50 |
51 | Classes
52 | The following classes are available globally.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | Insider
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
The Insider API facade class.
72 |
73 |
See more
74 |
75 |
76 |
Declaration
77 |
78 |
Swift
79 |
final public class Insider : NSObject
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerDataResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "GCDWebServerResponse.h"
29 |
30 | /**
31 | * The GCDWebServerDataResponse subclass of GCDWebServerResponse reads the body
32 | * of the HTTP response from memory.
33 | */
34 | @interface GCDWebServerDataResponse : GCDWebServerResponse
35 |
36 | /**
37 | * Creates a response with data in memory and a given content type.
38 | */
39 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type;
40 |
41 | /**
42 | * This method is the designated initializer for the class.
43 | */
44 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type;
45 |
46 | @end
47 |
48 | @interface GCDWebServerDataResponse (Extensions)
49 |
50 | /**
51 | * Creates a data response from text encoded using UTF-8.
52 | */
53 | + (instancetype)responseWithText:(NSString*)text;
54 |
55 | /**
56 | * Creates a data response from HTML encoded using UTF-8.
57 | */
58 | + (instancetype)responseWithHTML:(NSString*)html;
59 |
60 | /**
61 | * Creates a data response from an HTML template encoded using UTF-8.
62 | * See -initWithHTMLTemplate:variables: for details.
63 | */
64 | + (instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables;
65 |
66 | /**
67 | * Creates a data response from a serialized JSON object and the default
68 | * "application/json" content type.
69 | */
70 | + (instancetype)responseWithJSONObject:(id)object;
71 |
72 | /**
73 | * Creates a data response from a serialized JSON object and a custom
74 | * content type.
75 | */
76 | + (instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type;
77 |
78 | /**
79 | * Initializes a data response from text encoded using UTF-8.
80 | */
81 | - (instancetype)initWithText:(NSString*)text;
82 |
83 | /**
84 | * Initializes a data response from HTML encoded using UTF-8.
85 | */
86 | - (instancetype)initWithHTML:(NSString*)html;
87 |
88 | /**
89 | * Initializes a data response from an HTML template encoded using UTF-8.
90 | *
91 | * All occurences of "%variable%" within the HTML template are replaced with
92 | * their corresponding values.
93 | */
94 | - (instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables;
95 |
96 | /**
97 | * Initializes a data response from a serialized JSON object and the default
98 | * "application/json" content type.
99 | */
100 | - (instancetype)initWithJSONObject:(id)object;
101 |
102 | /**
103 | * Initializes a data response from a serialized JSON object and a custom
104 | * content type.
105 | */
106 | - (instancetype)initWithJSONObject:(id)object contentType:(NSString*)type;
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerFileResponse.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "GCDWebServerResponse.h"
29 |
30 | /**
31 | * The GCDWebServerFileResponse subclass of GCDWebServerResponse reads the body
32 | * of the HTTP response from a file on disk.
33 | *
34 | * It will automatically set the contentType, lastModifiedDate and eTag
35 | * properties of the GCDWebServerResponse according to the file extension and
36 | * metadata.
37 | */
38 | @interface GCDWebServerFileResponse : GCDWebServerResponse
39 |
40 | /**
41 | * Creates a response with the contents of a file.
42 | */
43 | + (instancetype)responseWithFile:(NSString*)path;
44 |
45 | /**
46 | * Creates a response like +responseWithFile: and sets the "Content-Disposition"
47 | * HTTP header for a download if the "attachment" argument is YES.
48 | */
49 | + (instancetype)responseWithFile:(NSString*)path isAttachment:(BOOL)attachment;
50 |
51 | /**
52 | * Creates a response like +responseWithFile: but restricts the file contents
53 | * to a specific byte range.
54 | *
55 | * See -initWithFile:byteRange: for details.
56 | */
57 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range;
58 |
59 | /**
60 | * Creates a response like +responseWithFile:byteRange: and sets the
61 | * "Content-Disposition" HTTP header for a download if the "attachment"
62 | * argument is YES.
63 | */
64 | + (instancetype)responseWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment;
65 |
66 | /**
67 | * Initializes a response with the contents of a file.
68 | */
69 | - (instancetype)initWithFile:(NSString*)path;
70 |
71 | /**
72 | * Initializes a response like +responseWithFile: and sets the
73 | * "Content-Disposition" HTTP header for a download if the "attachment"
74 | * argument is YES.
75 | */
76 | - (instancetype)initWithFile:(NSString*)path isAttachment:(BOOL)attachment;
77 |
78 | /**
79 | * Initializes a response like -initWithFile: but restricts the file contents
80 | * to a specific byte range. This range should be set to (NSUIntegerMax, 0) for
81 | * the full file, (offset, length) if expressed from the beginning of the file,
82 | * or (NSUIntegerMax, length) if expressed from the end of the file. The "offset"
83 | * and "length" values will be automatically adjusted to be compatible with the
84 | * actual size of the file.
85 | *
86 | * This argument would typically be set to the value of the byteRange property
87 | * of the current GCDWebServerRequest.
88 | */
89 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range;
90 |
91 | /**
92 | * This method is the designated initializer for the class.
93 | */
94 | - (instancetype)initWithFile:(NSString*)path byteRange:(NSRange)range isAttachment:(BOOL)attachment;
95 |
96 | @end
97 |
--------------------------------------------------------------------------------
/docs/Protocols.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Protocols Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 | Insider Reference
23 |
24 | Protocols Reference
25 |
26 |
27 |
28 |
48 |
49 |
50 |
51 | Protocols
52 | The following protocols are available globally.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
67 |
68 |
69 |
70 |
71 |
The Insider delegate protocol.
72 |
73 |
See more
74 |
75 |
76 |
Declaration
77 |
78 |
Swift
79 |
public protocol InsiderDelegate : AnyObject
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/GCDWebUploader.bundle/js/respond.min.js:
--------------------------------------------------------------------------------
1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
3 | * */
4 |
5 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b
2 |
3 |
4 | Classes Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 | Insider Reference
23 |
24 | Classes Reference
25 |
26 |
27 |
28 |
48 |
49 |
50 |
51 | Classes
52 | The following classes are available globally.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | Insider
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
The Insider API facade class.
72 |
73 |
See more
74 |
75 |
76 |
Declaration
77 |
78 |
Swift
79 |
final public class Insider : NSObject
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/docs/docsets/Insider.docset/Contents/Resources/Documents/Protocols.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Protocols Reference
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
21 |
22 | Insider Reference
23 |
24 | Protocols Reference
25 |
26 |
27 |
28 |
48 |
49 |
50 |
51 | Protocols
52 | The following protocols are available globally.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
67 |
68 |
69 |
70 |
71 |
The Insider delegate protocol.
72 |
73 |
See more
74 |
75 |
76 |
Declaration
77 |
78 |
Swift
79 |
public protocol InsiderDelegate : AnyObject
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Requests/GCDWebServerFileRequest.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !__has_feature(objc_arc)
29 | #error GCDWebServer requires ARC
30 | #endif
31 |
32 | #import "GCDWebServerPrivate.h"
33 |
34 | @interface GCDWebServerFileRequest () {
35 | @private
36 | NSString* _temporaryPath;
37 | int _file;
38 | }
39 | @end
40 |
41 | @implementation GCDWebServerFileRequest
42 |
43 | @synthesize temporaryPath=_temporaryPath;
44 |
45 | - (instancetype)initWithMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers path:(NSString*)path query:(NSDictionary*)query {
46 | if ((self = [super initWithMethod:method url:url headers:headers path:path query:query])) {
47 | _temporaryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]];
48 | }
49 | return self;
50 | }
51 |
52 | - (void)dealloc {
53 | unlink([_temporaryPath fileSystemRepresentation]);
54 | }
55 |
56 | - (BOOL)open:(NSError**)error {
57 | _file = open([_temporaryPath fileSystemRepresentation], O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
58 | if (_file <= 0) {
59 | if (error) {
60 | *error = GCDWebServerMakePosixError(errno);
61 | }
62 | return NO;
63 | }
64 | return YES;
65 | }
66 |
67 | - (BOOL)writeData:(NSData*)data error:(NSError**)error {
68 | if (write(_file, data.bytes, data.length) != (ssize_t)data.length) {
69 | if (error) {
70 | *error = GCDWebServerMakePosixError(errno);
71 | }
72 | return NO;
73 | }
74 | return YES;
75 | }
76 |
77 | - (BOOL)close:(NSError**)error {
78 | if (close(_file) < 0) {
79 | if (error) {
80 | *error = GCDWebServerMakePosixError(errno);
81 | }
82 | return NO;
83 | }
84 | #ifdef __GCDWEBSERVER_ENABLE_TESTING__
85 | NSString* creationDateHeader = [self.headers objectForKey:@"X-GCDWebServer-CreationDate"];
86 | if (creationDateHeader) {
87 | NSDate* date = GCDWebServerParseISO8601(creationDateHeader);
88 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileCreationDate: date} ofItemAtPath:_temporaryPath error:error]) {
89 | return NO;
90 | }
91 | }
92 | NSString* modifiedDateHeader = [self.headers objectForKey:@"X-GCDWebServer-ModifiedDate"];
93 | if (modifiedDateHeader) {
94 | NSDate* date = GCDWebServerParseRFC822(modifiedDateHeader);
95 | if (!date || ![[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate: date} ofItemAtPath:_temporaryPath error:error]) {
96 | return NO;
97 | }
98 | }
99 | #endif
100 | return YES;
101 | }
102 |
103 | - (NSString*)description {
104 | NSMutableString* description = [NSMutableString stringWithString:[super description]];
105 | [description appendFormat:@"\n\n{%@}", _temporaryPath];
106 | return description;
107 | }
108 |
109 | @end
110 |
--------------------------------------------------------------------------------
/Libs/System Services/Utilities/SSApplicationInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSApplicationInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSApplicationInfo.h"
10 |
11 | // UIKit
12 | #import
13 |
14 | // mach
15 | #import
16 |
17 | @implementation SSApplicationInfo
18 |
19 | // Application Information
20 |
21 | // Application Version
22 | + (NSString *)applicationVersion {
23 | // Get the Application Version Number
24 | @try {
25 |
26 | // Query the plist for the version
27 | NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
28 |
29 | // Validate the Version
30 | if (version == nil || version.length <= 0) {
31 | // Invalid Version number
32 | return nil;
33 | }
34 | // Successful
35 | return version;
36 | }
37 | @catch (NSException *exception) {
38 | // Error
39 | return nil;
40 | }
41 | }
42 |
43 | // Clipboard Content
44 | + (NSString *)clipboardContent {
45 | // Get the string content of the clipboard (copy, paste)
46 | @try {
47 | // Get the Pasteboard
48 | UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
49 | // Get the string value of the pasteboard
50 | NSString *clipboardContent = [pasteBoard string];
51 | // Check for validity
52 | if (clipboardContent == nil || clipboardContent.length <= 0) {
53 | // Error, invalid pasteboard
54 | return nil;
55 | }
56 | // Successful
57 | return clipboardContent;
58 | }
59 | @catch (NSException *exception) {
60 | // Error
61 | return nil;
62 | }
63 | }
64 |
65 | // Application CPU Usage
66 | + (float)cpuUsage {
67 | @try {
68 | kern_return_t kr;
69 | task_info_data_t tinfo;
70 | mach_msg_type_number_t task_info_count;
71 |
72 | task_info_count = TASK_INFO_MAX;
73 | kr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)tinfo, &task_info_count);
74 | if (kr != KERN_SUCCESS) {
75 | return -1;
76 | }
77 |
78 | task_basic_info_t basic_info;
79 | thread_array_t thread_list;
80 | mach_msg_type_number_t thread_count;
81 |
82 | thread_info_data_t thinfo;
83 | mach_msg_type_number_t thread_info_count;
84 |
85 | thread_basic_info_t basic_info_th;
86 | uint32_t stat_thread = 0; // Mach threads
87 |
88 | basic_info = (task_basic_info_t)tinfo;
89 |
90 | // get threads in the task
91 | kr = task_threads(mach_task_self(), &thread_list, &thread_count);
92 | if (kr != KERN_SUCCESS) {
93 | return -1;
94 | }
95 | if (thread_count > 0)
96 | stat_thread += thread_count;
97 |
98 | long tot_sec = 0;
99 | long tot_usec = 0;
100 | float tot_cpu = 0;
101 | int j;
102 |
103 | for (j = 0; j < thread_count; j++)
104 | {
105 | thread_info_count = THREAD_INFO_MAX;
106 | kr = thread_info(thread_list[j], THREAD_BASIC_INFO,
107 | (thread_info_t)thinfo, &thread_info_count);
108 | if (kr != KERN_SUCCESS) {
109 | return -1;
110 | }
111 |
112 | basic_info_th = (thread_basic_info_t)thinfo;
113 |
114 | if (!(basic_info_th->flags & TH_FLAGS_IDLE)) {
115 | tot_sec = tot_sec + basic_info_th->user_time.seconds + basic_info_th->system_time.seconds;
116 | tot_usec = tot_usec + basic_info_th->system_time.microseconds + basic_info_th->system_time.microseconds;
117 | tot_cpu = tot_cpu + basic_info_th->cpu_usage / (float)TH_USAGE_SCALE * 100.0;
118 | }
119 |
120 | } // for each thread
121 |
122 | kr = vm_deallocate(mach_task_self(), (vm_offset_t)thread_list, thread_count * sizeof(thread_t));
123 | assert(kr == KERN_SUCCESS);
124 |
125 | return tot_cpu;
126 | }
127 | @catch (NSException *exception) {
128 | // Error
129 | return -1;
130 | }
131 | }
132 |
133 | @end
134 |
--------------------------------------------------------------------------------
/Libs/System Services/Utilities/SSProcessorInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSProcessorInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSProcessorInfo.h"
10 |
11 | // Sysctl
12 | #import
13 |
14 | // Mach
15 | #include
16 |
17 | @implementation SSProcessorInfo
18 |
19 | // Processor Information
20 |
21 | // Number of processors
22 | + (NSInteger)numberProcessors {
23 | // See if the process info responds to selector
24 | if ([[NSProcessInfo processInfo] respondsToSelector:@selector(processorCount)]) {
25 | // Get the number of processors
26 | NSInteger processorCount = [[NSProcessInfo processInfo] processorCount];
27 | // Return the number of processors
28 | return processorCount;
29 | } else {
30 | // Return -1 (not found)
31 | return -1;
32 | }
33 | }
34 |
35 | // Number of Active Processors
36 | + (NSInteger)numberActiveProcessors {
37 | // See if the process info responds to selector
38 | if ([[NSProcessInfo processInfo] respondsToSelector:@selector(activeProcessorCount)]) {
39 | // Get the number of active processors
40 | NSInteger activeprocessorCount = [[NSProcessInfo processInfo] activeProcessorCount];
41 | // Return the number of active processors
42 | return activeprocessorCount;
43 | } else {
44 | // Return -1 (not found)
45 | return -1;
46 | }
47 | }
48 |
49 | // Get Processor Usage Information (i.e. ["0.2216801", "0.1009614"])
50 | + (NSArray *)processorsUsage {
51 |
52 | // Try to get Processor Usage Info
53 | @try {
54 | // Variables
55 | processor_info_array_t _cpuInfo, _prevCPUInfo = nil;
56 | mach_msg_type_number_t _numCPUInfo, _numPrevCPUInfo = 0;
57 | unsigned _numCPUs;
58 | NSLock *_cpuUsageLock;
59 |
60 | // Get the number of processors from sysctl
61 | int _mib[2U] = { CTL_HW, HW_NCPU };
62 | size_t _sizeOfNumCPUs = sizeof(_numCPUs);
63 | int _status = sysctl(_mib, 2U, &_numCPUs, &_sizeOfNumCPUs, NULL, 0U);
64 | if (_status)
65 | _numCPUs = 1;
66 |
67 | // Allocate the lock
68 | _cpuUsageLock = [[NSLock alloc] init];
69 |
70 | // Get the processor info
71 | natural_t _numCPUsU = 0U;
72 | kern_return_t err = host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &_numCPUsU, &_cpuInfo, &_numCPUInfo);
73 | if (err == KERN_SUCCESS) {
74 | [_cpuUsageLock lock];
75 |
76 | // Go through info for each processor
77 | NSMutableArray *processorInfo = [NSMutableArray new];
78 | for (unsigned i = 0U; i < _numCPUs; ++i) {
79 | Float32 _inUse, _total;
80 | if (_prevCPUInfo) {
81 | _inUse = (
82 | (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER])
83 | + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM])
84 | + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE])
85 | );
86 | _total = _inUse + (_cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE] - _prevCPUInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE]);
87 | } else {
88 | _inUse = _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_USER] + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_SYSTEM] + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_NICE];
89 | _total = _inUse + _cpuInfo[(CPU_STATE_MAX * i) + CPU_STATE_IDLE];
90 | }
91 | // Add to the processor usage info
92 | [processorInfo addObject:@(_inUse / _total)];
93 | }
94 |
95 | [_cpuUsageLock unlock];
96 | if (_prevCPUInfo) {
97 | size_t prevCpuInfoSize = sizeof(integer_t) * _numPrevCPUInfo;
98 | vm_deallocate(mach_task_self(), (vm_address_t)_prevCPUInfo, prevCpuInfoSize);
99 | }
100 | // Retrieved processor information
101 | return processorInfo;
102 | } else {
103 | // Unable to get processor information
104 | return nil;
105 | }
106 | } @catch (NSException *exception) {
107 | // Getting processor information failed
108 | return nil;
109 | }
110 | }
111 |
112 | @end
113 |
--------------------------------------------------------------------------------
/InsiderDemo/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // InsiderDemo
4 | //
5 | // Created by Alexandru Maimescu on 2/16/16.
6 | // Copyright © 2016 Alex Maimescu. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | NSString * kLogMessageNotificationKey = @"com.alexmx.notificationLogMessage";
12 |
13 | @import Insider;
14 |
15 | @interface AppDelegate ()
16 |
17 | @end
18 |
19 | @implementation AppDelegate
20 |
21 |
22 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
23 |
24 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(insiderNotification:) name:[Insider insiderNotificationKey] object:nil];
25 |
26 | [[Insider shared] startWithDelegate:self];
27 |
28 | return YES;
29 | }
30 |
31 | - (void)applicationWillResignActive:(UIApplication *)application {
32 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
33 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
34 | }
35 |
36 | - (void)applicationDidEnterBackground:(UIApplication *)application {
37 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
38 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
39 | }
40 |
41 | - (void)applicationWillEnterForeground:(UIApplication *)application {
42 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
43 | }
44 |
45 | - (void)applicationDidBecomeActive:(UIApplication *)application {
46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
47 | }
48 |
49 | - (void)applicationWillTerminate:(UIApplication *)application {
50 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
51 | }
52 |
53 | - (void)postLogNotificationWithObject:(id)object
54 | {
55 | [[NSNotificationCenter defaultCenter] postNotificationName:kLogMessageNotificationKey object:object];
56 | }
57 |
58 | #pragma mark - InsiderDelegate
59 |
60 | - (void)insider:(Insider *)insider didReceiveRemoteMessage:(NSDictionary * _Nullable)message
61 | {
62 | NSLog(@"Insider invoke object: %@", message);
63 | [self postLogNotificationWithObject:message];
64 | }
65 |
66 | - (NSDictionary *)insider:(Insider *)insider returnResponseMessageForRemoteMessage:(NSDictionary * _Nullable)message
67 | {
68 | [self postLogNotificationWithObject:message];
69 |
70 | return @{@"test": @YES};
71 | }
72 |
73 | - (void)insider:(Insider *)insider didSendNotificationWithMessage:(NSDictionary * _Nullable)message
74 | {
75 | [self postLogNotificationWithObject:message];
76 | }
77 |
78 | - (void)insider:(Insider *)insider didReturnSystemInfo:(NSDictionary * _Nullable)systemInfo
79 | {
80 | [self postLogNotificationWithObject:systemInfo];
81 | }
82 |
83 | - (void)insider:(Insider *)insider didCreateDirectoryAtPath:(NSString * _Nonnull)path
84 | {
85 | [self postLogNotificationWithObject:[NSString stringWithFormat:@"Did create path: %@", path]];
86 | }
87 |
88 | - (void)insider:(Insider *)insider didDeleteItemAtPath:(NSString * _Nonnull)path
89 | {
90 | [self postLogNotificationWithObject:[NSString stringWithFormat:@"Did delete item: %@", path]];
91 | }
92 |
93 | - (void)insider:(Insider *)insider didDownloadFileAtPath:(NSString * _Nonnull)path
94 | {
95 | [self postLogNotificationWithObject:[NSString stringWithFormat:@"Did download item: %@", path]];
96 | }
97 |
98 | - (void)insider:(Insider *)insider didMoveItemFromPath:(NSString * _Nonnull)fromPath toPath:(NSString * _Nonnull)path
99 | {
100 | [self postLogNotificationWithObject:[NSString stringWithFormat:@"Did move item from: %@ to: %@", fromPath, path]];
101 | }
102 |
103 | - (void)insider:(Insider *)insider didUploadFileAtPath:(NSString * _Nonnull)path
104 | {
105 | [self postLogNotificationWithObject:[NSString stringWithFormat:@"Did upload item: %@", path]];
106 | }
107 |
108 | #pragma mark - Notification
109 |
110 | - (void)insiderNotification:(NSNotification *)notification
111 | {
112 | NSLog(@"Did recieve notification with params: %@", notification.object);
113 | }
114 |
115 | @end
116 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Requests/GCDWebServerMultiPartFormRequest.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #import "GCDWebServerRequest.h"
29 |
30 | /**
31 | * The GCDWebServerMultiPart class is an abstract class that wraps the content
32 | * of a part.
33 | */
34 | @interface GCDWebServerMultiPart : NSObject
35 |
36 | /**
37 | * Returns the control name retrieved from the part headers.
38 | */
39 | @property(nonatomic, readonly) NSString* controlName;
40 |
41 | /**
42 | * Returns the content type retrieved from the part headers or "text/plain"
43 | * if not available (per HTTP specifications).
44 | */
45 | @property(nonatomic, readonly) NSString* contentType;
46 |
47 | /**
48 | * Returns the MIME type component of the content type for the part.
49 | */
50 | @property(nonatomic, readonly) NSString* mimeType;
51 |
52 | @end
53 |
54 | /**
55 | * The GCDWebServerMultiPartArgument subclass of GCDWebServerMultiPart wraps
56 | * the content of a part as data in memory.
57 | */
58 | @interface GCDWebServerMultiPartArgument : GCDWebServerMultiPart
59 |
60 | /**
61 | * Returns the data for the part.
62 | */
63 | @property(nonatomic, readonly) NSData* data;
64 |
65 | /**
66 | * Returns the data for the part interpreted as text. If the content
67 | * type of the part is not a text one, or if an error occurs, nil is returned.
68 | *
69 | * The text encoding used to interpret the data is extracted from the
70 | * "Content-Type" header or defaults to UTF-8.
71 | */
72 | @property(nonatomic, readonly) NSString* string;
73 |
74 | @end
75 |
76 | /**
77 | * The GCDWebServerMultiPartFile subclass of GCDWebServerMultiPart wraps
78 | * the content of a part as a file on disk.
79 | */
80 | @interface GCDWebServerMultiPartFile : GCDWebServerMultiPart
81 |
82 | /**
83 | * Returns the file name retrieved from the part headers.
84 | */
85 | @property(nonatomic, readonly) NSString* fileName;
86 |
87 | /**
88 | * Returns the path to the temporary file containing the part data.
89 | *
90 | * @warning This temporary file will be automatically deleted when the
91 | * GCDWebServerMultiPartFile is deallocated. If you want to preserve this file,
92 | * you must move it to a different location beforehand.
93 | */
94 | @property(nonatomic, readonly) NSString* temporaryPath;
95 |
96 | @end
97 |
98 | /**
99 | * The GCDWebServerMultiPartFormRequest subclass of GCDWebServerRequest
100 | * parses the body of the HTTP request as a multipart encoded form.
101 | */
102 | @interface GCDWebServerMultiPartFormRequest : GCDWebServerRequest
103 |
104 | /**
105 | * Returns the argument parts from the multipart encoded form as
106 | * name / GCDWebServerMultiPartArgument pairs.
107 | */
108 | @property(nonatomic, readonly) NSArray* arguments;
109 |
110 | /**
111 | * Returns the files parts from the multipart encoded form as
112 | * name / GCDWebServerMultiPartFile pairs.
113 | */
114 | @property(nonatomic, readonly) NSArray* files;
115 |
116 | /**
117 | * Returns the MIME type for multipart encoded forms
118 | * i.e. "multipart/form-data".
119 | */
120 | + (NSString*)mimeType;
121 |
122 | /**
123 | * Returns the first argument for a given control name or nil if not found.
124 | */
125 | - (GCDWebServerMultiPartArgument*)firstArgumentForControlName:(NSString*)name;
126 |
127 | /**
128 | * Returns the first file for a given control name or nil if not found.
129 | */
130 | - (GCDWebServerMultiPartFile*)firstFileForControlName:(NSString*)name;
131 |
132 | @end
133 |
--------------------------------------------------------------------------------
/Insider/LocalWebServer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // LocalWebServer.swift
3 | // Insider
4 | //
5 | // Created by Alexandru Maimescu on 2/19/16.
6 | // Copyright © 2016 Alex Maimescu. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | typealias LocalWebServerRequestHandler = (InsiderMessage?) -> (LocalWebServerResponse)
12 |
13 | enum LocalWebServerRequestMethod: String {
14 | case GET
15 | case POST
16 | case PUT
17 | case DELETE
18 | }
19 |
20 | protocol GCDWebServerDataResponseConvertible {
21 |
22 | func convertedToGCDWebServerDataResponse() -> GCDWebServerDataResponse
23 | }
24 |
25 | protocol LocalWebServerDelegate: class {
26 |
27 | func localWebServer(_ server: LocalWebServer, didCreateDirectoryAtPath path: String)
28 | func localWebServer(_ server: LocalWebServer, didDeleteItemAtPath path: String)
29 | func localWebServer(_ server: LocalWebServer, didDownloadFileAtPath path: String)
30 | func localWebServer(_ server: LocalWebServer, didMoveItemFromPath fromPath: String, toPath: String)
31 | func localWebServer(_ server: LocalWebServer, didUploadFileAtPath path: String)
32 | }
33 |
34 | extension LocalWebServerResponse: GCDWebServerDataResponseConvertible {
35 |
36 | func convertedToGCDWebServerDataResponse() -> GCDWebServerDataResponse {
37 |
38 | if let jsonObject = self.response {
39 | return GCDWebServerDataResponse(jsonObject: jsonObject)
40 | } else {
41 | return GCDWebServerDataResponse(statusCode: self.statusCode.rawValue)
42 | }
43 | }
44 | }
45 |
46 | final class LocalWebServer: NSObject {
47 |
48 | struct Constants {
49 | static let defaultPort: UInt = 8080
50 | }
51 |
52 | private let localWebServer = GCDWebUploader()
53 |
54 | weak var delegate: LocalWebServerDelegate?
55 |
56 | func start() {
57 | startWithPort(Constants.defaultPort)
58 | }
59 |
60 | func startWithPort(_ port: UInt) {
61 | localWebServer?.delegate = self
62 | localWebServer?.start(withPort: port, bonjourName: nil)
63 | }
64 |
65 | func stop() {
66 | localWebServer?.stop()
67 | }
68 |
69 | func addSandboxDirectory(_ path: String, endpoint: String) {
70 | localWebServer?.addDirectory(path, endpoint: endpoint)
71 | }
72 |
73 | func addHandlerForMethod(_ method: LocalWebServerRequestMethod, path: String, handler: @escaping LocalWebServerRequestHandler) {
74 |
75 | localWebServer?.addHandler(forMethod: method.rawValue,
76 | path: path,
77 | request: GCDWebServerURLEncodedFormRequest.self) { (request) -> GCDWebServerResponse! in
78 |
79 | let params = self.paramsForRequest(request as? GCDWebServerURLEncodedFormRequest)
80 | var response: LocalWebServerResponse?
81 | self.executeOnMainQueue {
82 | response = handler(params)
83 | }
84 |
85 | return response?.convertedToGCDWebServerDataResponse()
86 | }
87 | }
88 |
89 | private func executeOnMainQueue(_ closure: (() -> Void)?) {
90 | DispatchQueue.main.sync { closure?() }
91 | }
92 |
93 | private func paramsForRequest(_ request: GCDWebServerURLEncodedFormRequest?) -> InsiderMessage? {
94 | guard let request = request, LocalWebServerRequestMethod(rawValue: request.method) != .GET else {
95 | return nil
96 | }
97 |
98 | var params: InsiderMessage?
99 | let contentType = request.contentType
100 | let jsonTypes = ["application/json", "text/json", "text/javascript"]
101 | if jsonTypes.contains(contentType!) {
102 | if let json = request.jsonObject {
103 | params = json as? InsiderMessage
104 | }
105 | } else {
106 | if let encodedParams = request.arguments {
107 | params = encodedParams as InsiderMessage?
108 | }
109 | }
110 |
111 | return params
112 | }
113 | }
114 |
115 | extension LocalWebServer: GCDWebUploaderDelegate {
116 |
117 | func webUploader(_ uploader: GCDWebUploader!, didCreateDirectoryAtPath path: String!) {
118 | delegate?.localWebServer(self, didCreateDirectoryAtPath: path)
119 | }
120 |
121 | func webUploader(_ uploader: GCDWebUploader!, didDeleteItemAtPath path: String!) {
122 | delegate?.localWebServer(self, didDeleteItemAtPath: path)
123 | }
124 |
125 | func webUploader(_ uploader: GCDWebUploader!, didDownloadFileAtPath path: String!) {
126 | delegate?.localWebServer(self, didDownloadFileAtPath: path)
127 | }
128 |
129 | func webUploader(_ uploader: GCDWebUploader!, didMoveItemFromPath fromPath: String!, toPath: String!) {
130 | delegate?.localWebServer(self, didMoveItemFromPath: fromPath, toPath: toPath)
131 | }
132 |
133 | func webUploader(_ uploader: GCDWebUploader!, didUploadFileAtPath path: String!) {
134 | delegate?.localWebServer(self, didUploadFileAtPath: path)
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerDataResponse.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !__has_feature(objc_arc)
29 | #error GCDWebServer requires ARC
30 | #endif
31 |
32 | #import "GCDWebServerPrivate.h"
33 |
34 | @interface GCDWebServerDataResponse () {
35 | @private
36 | NSData* _data;
37 | BOOL _done;
38 | }
39 | @end
40 |
41 | @implementation GCDWebServerDataResponse
42 |
43 | + (instancetype)responseWithData:(NSData*)data contentType:(NSString*)type {
44 | return [[[self class] alloc] initWithData:data contentType:type];
45 | }
46 |
47 | - (instancetype)initWithData:(NSData*)data contentType:(NSString*)type {
48 | if (data == nil) {
49 | GWS_DNOT_REACHED();
50 | return nil;
51 | }
52 |
53 | if ((self = [super init])) {
54 | _data = data;
55 |
56 | self.contentType = type;
57 | self.contentLength = data.length;
58 | }
59 | return self;
60 | }
61 |
62 | - (NSData*)readData:(NSError**)error {
63 | NSData* data;
64 | if (_done) {
65 | data = [NSData data];
66 | } else {
67 | data = _data;
68 | _done = YES;
69 | }
70 | return data;
71 | }
72 |
73 | - (NSString*)description {
74 | NSMutableString* description = [NSMutableString stringWithString:[super description]];
75 | [description appendString:@"\n\n"];
76 | [description appendString:GCDWebServerDescribeData(_data, self.contentType)];
77 | return description;
78 | }
79 |
80 | @end
81 |
82 | @implementation GCDWebServerDataResponse (Extensions)
83 |
84 | + (instancetype)responseWithText:(NSString*)text {
85 | return [[self alloc] initWithText:text];
86 | }
87 |
88 | + (instancetype)responseWithHTML:(NSString*)html {
89 | return [[self alloc] initWithHTML:html];
90 | }
91 |
92 | + (instancetype)responseWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables {
93 | return [[self alloc] initWithHTMLTemplate:path variables:variables];
94 | }
95 |
96 | + (instancetype)responseWithJSONObject:(id)object {
97 | return [[self alloc] initWithJSONObject:object];
98 | }
99 |
100 | + (instancetype)responseWithJSONObject:(id)object contentType:(NSString*)type {
101 | return [[self alloc] initWithJSONObject:object contentType:type];
102 | }
103 |
104 | - (instancetype)initWithText:(NSString*)text {
105 | NSData* data = [text dataUsingEncoding:NSUTF8StringEncoding];
106 | if (data == nil) {
107 | GWS_DNOT_REACHED();
108 | return nil;
109 | }
110 | return [self initWithData:data contentType:@"text/plain; charset=utf-8"];
111 | }
112 |
113 | - (instancetype)initWithHTML:(NSString*)html {
114 | NSData* data = [html dataUsingEncoding:NSUTF8StringEncoding];
115 | if (data == nil) {
116 | GWS_DNOT_REACHED();
117 | return nil;
118 | }
119 | return [self initWithData:data contentType:@"text/html; charset=utf-8"];
120 | }
121 |
122 | - (instancetype)initWithHTMLTemplate:(NSString*)path variables:(NSDictionary*)variables {
123 | NSMutableString* html = [[NSMutableString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL];
124 | [variables enumerateKeysAndObjectsUsingBlock:^(NSString* key, NSString* value, BOOL* stop) {
125 | [html replaceOccurrencesOfString:[NSString stringWithFormat:@"%%%@%%", key] withString:value options:0 range:NSMakeRange(0, html.length)];
126 | }];
127 | id response = [self initWithHTML:html];
128 | return response;
129 | }
130 |
131 | - (instancetype)initWithJSONObject:(id)object {
132 | return [self initWithJSONObject:object contentType:@"application/json"];
133 | }
134 |
135 | - (instancetype)initWithJSONObject:(id)object contentType:(NSString*)type {
136 | NSData* data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL];
137 | if (data == nil) {
138 | return nil;
139 | }
140 | return [self initWithData:data contentType:type];
141 | }
142 |
143 | @end
144 |
--------------------------------------------------------------------------------
/docs/css/highlight.css:
--------------------------------------------------------------------------------
1 | /* Credit to https://gist.github.com/wataru420/2048287 */
2 | .highlight {
3 | /* Comment */
4 | /* Error */
5 | /* Keyword */
6 | /* Operator */
7 | /* Comment.Multiline */
8 | /* Comment.Preproc */
9 | /* Comment.Single */
10 | /* Comment.Special */
11 | /* Generic.Deleted */
12 | /* Generic.Deleted.Specific */
13 | /* Generic.Emph */
14 | /* Generic.Error */
15 | /* Generic.Heading */
16 | /* Generic.Inserted */
17 | /* Generic.Inserted.Specific */
18 | /* Generic.Output */
19 | /* Generic.Prompt */
20 | /* Generic.Strong */
21 | /* Generic.Subheading */
22 | /* Generic.Traceback */
23 | /* Keyword.Constant */
24 | /* Keyword.Declaration */
25 | /* Keyword.Pseudo */
26 | /* Keyword.Reserved */
27 | /* Keyword.Type */
28 | /* Literal.Number */
29 | /* Literal.String */
30 | /* Name.Attribute */
31 | /* Name.Builtin */
32 | /* Name.Class */
33 | /* Name.Constant */
34 | /* Name.Entity */
35 | /* Name.Exception */
36 | /* Name.Function */
37 | /* Name.Namespace */
38 | /* Name.Tag */
39 | /* Name.Variable */
40 | /* Operator.Word */
41 | /* Text.Whitespace */
42 | /* Literal.Number.Float */
43 | /* Literal.Number.Hex */
44 | /* Literal.Number.Integer */
45 | /* Literal.Number.Oct */
46 | /* Literal.String.Backtick */
47 | /* Literal.String.Char */
48 | /* Literal.String.Doc */
49 | /* Literal.String.Double */
50 | /* Literal.String.Escape */
51 | /* Literal.String.Heredoc */
52 | /* Literal.String.Interpol */
53 | /* Literal.String.Other */
54 | /* Literal.String.Regex */
55 | /* Literal.String.Single */
56 | /* Literal.String.Symbol */
57 | /* Name.Builtin.Pseudo */
58 | /* Name.Variable.Class */
59 | /* Name.Variable.Global */
60 | /* Name.Variable.Instance */
61 | /* Literal.Number.Integer.Long */ }
62 | .highlight .c {
63 | color: #999988;
64 | font-style: italic; }
65 | .highlight .err {
66 | color: #a61717;
67 | background-color: #e3d2d2; }
68 | .highlight .k {
69 | color: #000000;
70 | font-weight: bold; }
71 | .highlight .o {
72 | color: #000000;
73 | font-weight: bold; }
74 | .highlight .cm {
75 | color: #999988;
76 | font-style: italic; }
77 | .highlight .cp {
78 | color: #999999;
79 | font-weight: bold; }
80 | .highlight .c1 {
81 | color: #999988;
82 | font-style: italic; }
83 | .highlight .cs {
84 | color: #999999;
85 | font-weight: bold;
86 | font-style: italic; }
87 | .highlight .gd {
88 | color: #000000;
89 | background-color: #ffdddd; }
90 | .highlight .gd .x {
91 | color: #000000;
92 | background-color: #ffaaaa; }
93 | .highlight .ge {
94 | color: #000000;
95 | font-style: italic; }
96 | .highlight .gr {
97 | color: #aa0000; }
98 | .highlight .gh {
99 | color: #999999; }
100 | .highlight .gi {
101 | color: #000000;
102 | background-color: #ddffdd; }
103 | .highlight .gi .x {
104 | color: #000000;
105 | background-color: #aaffaa; }
106 | .highlight .go {
107 | color: #888888; }
108 | .highlight .gp {
109 | color: #555555; }
110 | .highlight .gs {
111 | font-weight: bold; }
112 | .highlight .gu {
113 | color: #aaaaaa; }
114 | .highlight .gt {
115 | color: #aa0000; }
116 | .highlight .kc {
117 | color: #000000;
118 | font-weight: bold; }
119 | .highlight .kd {
120 | color: #000000;
121 | font-weight: bold; }
122 | .highlight .kp {
123 | color: #000000;
124 | font-weight: bold; }
125 | .highlight .kr {
126 | color: #000000;
127 | font-weight: bold; }
128 | .highlight .kt {
129 | color: #445588; }
130 | .highlight .m {
131 | color: #009999; }
132 | .highlight .s {
133 | color: #d14; }
134 | .highlight .na {
135 | color: #008080; }
136 | .highlight .nb {
137 | color: #0086B3; }
138 | .highlight .nc {
139 | color: #445588;
140 | font-weight: bold; }
141 | .highlight .no {
142 | color: #008080; }
143 | .highlight .ni {
144 | color: #800080; }
145 | .highlight .ne {
146 | color: #990000;
147 | font-weight: bold; }
148 | .highlight .nf {
149 | color: #990000; }
150 | .highlight .nn {
151 | color: #555555; }
152 | .highlight .nt {
153 | color: #000080; }
154 | .highlight .nv {
155 | color: #008080; }
156 | .highlight .ow {
157 | color: #000000;
158 | font-weight: bold; }
159 | .highlight .w {
160 | color: #bbbbbb; }
161 | .highlight .mf {
162 | color: #009999; }
163 | .highlight .mh {
164 | color: #009999; }
165 | .highlight .mi {
166 | color: #009999; }
167 | .highlight .mo {
168 | color: #009999; }
169 | .highlight .sb {
170 | color: #d14; }
171 | .highlight .sc {
172 | color: #d14; }
173 | .highlight .sd {
174 | color: #d14; }
175 | .highlight .s2 {
176 | color: #d14; }
177 | .highlight .se {
178 | color: #d14; }
179 | .highlight .sh {
180 | color: #d14; }
181 | .highlight .si {
182 | color: #d14; }
183 | .highlight .sx {
184 | color: #d14; }
185 | .highlight .sr {
186 | color: #009926; }
187 | .highlight .s1 {
188 | color: #d14; }
189 | .highlight .ss {
190 | color: #990073; }
191 | .highlight .bp {
192 | color: #999999; }
193 | .highlight .vc {
194 | color: #008080; }
195 | .highlight .vg {
196 | color: #008080; }
197 | .highlight .vi {
198 | color: #008080; }
199 | .highlight .il {
200 | color: #009999; }
201 |
--------------------------------------------------------------------------------
/docs/docsets/Insider.docset/Contents/Resources/Documents/css/highlight.css:
--------------------------------------------------------------------------------
1 | /* Credit to https://gist.github.com/wataru420/2048287 */
2 | .highlight {
3 | /* Comment */
4 | /* Error */
5 | /* Keyword */
6 | /* Operator */
7 | /* Comment.Multiline */
8 | /* Comment.Preproc */
9 | /* Comment.Single */
10 | /* Comment.Special */
11 | /* Generic.Deleted */
12 | /* Generic.Deleted.Specific */
13 | /* Generic.Emph */
14 | /* Generic.Error */
15 | /* Generic.Heading */
16 | /* Generic.Inserted */
17 | /* Generic.Inserted.Specific */
18 | /* Generic.Output */
19 | /* Generic.Prompt */
20 | /* Generic.Strong */
21 | /* Generic.Subheading */
22 | /* Generic.Traceback */
23 | /* Keyword.Constant */
24 | /* Keyword.Declaration */
25 | /* Keyword.Pseudo */
26 | /* Keyword.Reserved */
27 | /* Keyword.Type */
28 | /* Literal.Number */
29 | /* Literal.String */
30 | /* Name.Attribute */
31 | /* Name.Builtin */
32 | /* Name.Class */
33 | /* Name.Constant */
34 | /* Name.Entity */
35 | /* Name.Exception */
36 | /* Name.Function */
37 | /* Name.Namespace */
38 | /* Name.Tag */
39 | /* Name.Variable */
40 | /* Operator.Word */
41 | /* Text.Whitespace */
42 | /* Literal.Number.Float */
43 | /* Literal.Number.Hex */
44 | /* Literal.Number.Integer */
45 | /* Literal.Number.Oct */
46 | /* Literal.String.Backtick */
47 | /* Literal.String.Char */
48 | /* Literal.String.Doc */
49 | /* Literal.String.Double */
50 | /* Literal.String.Escape */
51 | /* Literal.String.Heredoc */
52 | /* Literal.String.Interpol */
53 | /* Literal.String.Other */
54 | /* Literal.String.Regex */
55 | /* Literal.String.Single */
56 | /* Literal.String.Symbol */
57 | /* Name.Builtin.Pseudo */
58 | /* Name.Variable.Class */
59 | /* Name.Variable.Global */
60 | /* Name.Variable.Instance */
61 | /* Literal.Number.Integer.Long */ }
62 | .highlight .c {
63 | color: #999988;
64 | font-style: italic; }
65 | .highlight .err {
66 | color: #a61717;
67 | background-color: #e3d2d2; }
68 | .highlight .k {
69 | color: #000000;
70 | font-weight: bold; }
71 | .highlight .o {
72 | color: #000000;
73 | font-weight: bold; }
74 | .highlight .cm {
75 | color: #999988;
76 | font-style: italic; }
77 | .highlight .cp {
78 | color: #999999;
79 | font-weight: bold; }
80 | .highlight .c1 {
81 | color: #999988;
82 | font-style: italic; }
83 | .highlight .cs {
84 | color: #999999;
85 | font-weight: bold;
86 | font-style: italic; }
87 | .highlight .gd {
88 | color: #000000;
89 | background-color: #ffdddd; }
90 | .highlight .gd .x {
91 | color: #000000;
92 | background-color: #ffaaaa; }
93 | .highlight .ge {
94 | color: #000000;
95 | font-style: italic; }
96 | .highlight .gr {
97 | color: #aa0000; }
98 | .highlight .gh {
99 | color: #999999; }
100 | .highlight .gi {
101 | color: #000000;
102 | background-color: #ddffdd; }
103 | .highlight .gi .x {
104 | color: #000000;
105 | background-color: #aaffaa; }
106 | .highlight .go {
107 | color: #888888; }
108 | .highlight .gp {
109 | color: #555555; }
110 | .highlight .gs {
111 | font-weight: bold; }
112 | .highlight .gu {
113 | color: #aaaaaa; }
114 | .highlight .gt {
115 | color: #aa0000; }
116 | .highlight .kc {
117 | color: #000000;
118 | font-weight: bold; }
119 | .highlight .kd {
120 | color: #000000;
121 | font-weight: bold; }
122 | .highlight .kp {
123 | color: #000000;
124 | font-weight: bold; }
125 | .highlight .kr {
126 | color: #000000;
127 | font-weight: bold; }
128 | .highlight .kt {
129 | color: #445588; }
130 | .highlight .m {
131 | color: #009999; }
132 | .highlight .s {
133 | color: #d14; }
134 | .highlight .na {
135 | color: #008080; }
136 | .highlight .nb {
137 | color: #0086B3; }
138 | .highlight .nc {
139 | color: #445588;
140 | font-weight: bold; }
141 | .highlight .no {
142 | color: #008080; }
143 | .highlight .ni {
144 | color: #800080; }
145 | .highlight .ne {
146 | color: #990000;
147 | font-weight: bold; }
148 | .highlight .nf {
149 | color: #990000; }
150 | .highlight .nn {
151 | color: #555555; }
152 | .highlight .nt {
153 | color: #000080; }
154 | .highlight .nv {
155 | color: #008080; }
156 | .highlight .ow {
157 | color: #000000;
158 | font-weight: bold; }
159 | .highlight .w {
160 | color: #bbbbbb; }
161 | .highlight .mf {
162 | color: #009999; }
163 | .highlight .mh {
164 | color: #009999; }
165 | .highlight .mi {
166 | color: #009999; }
167 | .highlight .mo {
168 | color: #009999; }
169 | .highlight .sb {
170 | color: #d14; }
171 | .highlight .sc {
172 | color: #d14; }
173 | .highlight .sd {
174 | color: #d14; }
175 | .highlight .s2 {
176 | color: #d14; }
177 | .highlight .se {
178 | color: #d14; }
179 | .highlight .sh {
180 | color: #d14; }
181 | .highlight .si {
182 | color: #d14; }
183 | .highlight .sx {
184 | color: #d14; }
185 | .highlight .sr {
186 | color: #009926; }
187 | .highlight .s1 {
188 | color: #d14; }
189 | .highlight .ss {
190 | color: #990073; }
191 | .highlight .bp {
192 | color: #999999; }
193 | .highlight .vc {
194 | color: #008080; }
195 | .highlight .vg {
196 | color: #008080; }
197 | .highlight .vi {
198 | color: #008080; }
199 | .highlight .il {
200 | color: #009999; }
201 |
--------------------------------------------------------------------------------
/Libs/System Services/Utilities/SSCarrierInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSCarrierInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSCarrierInfo.h"
10 |
11 | // Core Telephony
12 | #import
13 | #import
14 |
15 | @implementation SSCarrierInfo
16 |
17 | // Carrier Information
18 |
19 | // Carrier Name
20 | + (NSString *)carrierName {
21 | // Get the carrier name
22 | @try {
23 | // Get the Telephony Network Info
24 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
25 | // Get the carrier
26 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
27 | // Get the carrier name
28 | NSString *carrierName = [carrier carrierName];
29 |
30 | // Check to make sure it's valid
31 | if (carrierName == nil || carrierName.length <= 0) {
32 | // Return unknown
33 | return nil;
34 | }
35 |
36 | // Return the name
37 | return carrierName;
38 | }
39 | @catch (NSException *exception) {
40 | // Error finding the name
41 | return nil;
42 | }
43 | }
44 |
45 | // Carrier Country
46 | + (NSString *)carrierCountry {
47 | // Get the country that the carrier is located in
48 | @try {
49 | // Get the locale
50 | NSLocale *currentCountry = [NSLocale currentLocale];
51 | // Get the country Code
52 | NSString *country = [currentCountry objectForKey:NSLocaleCountryCode];
53 | // Check if it returned anything
54 | if (country == nil || country.length <= 0) {
55 | // No country found
56 | return nil;
57 | }
58 | // Return the country
59 | return country;
60 | }
61 | @catch (NSException *exception) {
62 | // Failed, return nil
63 | return nil;
64 | }
65 | }
66 |
67 | // Carrier Mobile Country Code
68 | + (NSString *)carrierMobileCountryCode {
69 | // Get the carrier mobile country code
70 | @try {
71 | // Get the Telephony Network Info
72 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
73 | // Get the carrier
74 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
75 | // Get the carrier mobile country code
76 | NSString *carrierCode = [carrier mobileCountryCode];
77 |
78 | // Check to make sure it's valid
79 | if (carrierCode == nil || carrierCode.length <= 0) {
80 | // Return unknown
81 | return nil;
82 | }
83 |
84 | // Return the name
85 | return carrierCode;
86 | }
87 | @catch (NSException *exception) {
88 | // Error finding the name
89 | return nil;
90 | }
91 | }
92 |
93 | // Carrier ISO Country Code
94 | + (NSString *)carrierISOCountryCode {
95 | // Get the carrier ISO country code
96 | @try {
97 | // Get the Telephony Network Info
98 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
99 | // Get the carrier
100 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
101 | // Get the carrier ISO country code
102 | NSString *carrierCode = [carrier isoCountryCode];
103 |
104 | // Check to make sure it's valid
105 | if (carrierCode == nil || carrierCode.length <= 0) {
106 | // Return unknown
107 | return nil;
108 | }
109 |
110 | // Return the name
111 | return carrierCode;
112 | }
113 | @catch (NSException *exception) {
114 | // Error finding the name
115 | return nil;
116 | }
117 | }
118 |
119 | // Carrier Mobile Network Code
120 | + (NSString *)carrierMobileNetworkCode {
121 | // Get the carrier mobile network code
122 | @try {
123 | // Get the Telephony Network Info
124 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
125 | // Get the carrier
126 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
127 | // Get the carrier mobile network code
128 | NSString *carrierCode = [carrier mobileNetworkCode];
129 |
130 | // Check to make sure it's valid
131 | if (carrierCode == nil || carrierCode.length <= 0) {
132 | // Return unknown
133 | return nil;
134 | }
135 |
136 | // Return the name
137 | return carrierCode;
138 | }
139 | @catch (NSException *exception) {
140 | // Error finding the name
141 | return nil;
142 | }
143 | }
144 |
145 | // Carrier Allows VOIP
146 | + (BOOL)carrierAllowsVOIP {
147 | // Check if the carrier allows VOIP
148 | @try {
149 | // Get the Telephony Network Info
150 | CTTelephonyNetworkInfo *telephonyInfo = [[CTTelephonyNetworkInfo alloc] init];
151 | // Get the carrier
152 | CTCarrier *carrier = [telephonyInfo subscriberCellularProvider];
153 | // Get the carrier VOIP Status
154 | BOOL carrierVOIP = [carrier allowsVOIP];
155 |
156 | // Return the VOIP Status
157 | return carrierVOIP;
158 | }
159 | @catch (NSException *exception) {
160 | // Error finding the VOIP Status
161 | return false;
162 | }
163 | }
164 |
165 | @end
166 |
--------------------------------------------------------------------------------
/Libs/System Services/Utilities/SSAccessoryInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccessoryInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/17/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSAccessoryInfo.h"
10 |
11 | // Accessory Manager
12 | #import
13 |
14 | // AVFoundation
15 | #import
16 |
17 | @implementation SSAccessoryInfo
18 |
19 | // Accessory Information
20 |
21 | // Are any accessories attached?
22 | + (BOOL)accessoriesAttached {
23 | // Check if any accessories are connected
24 | @try {
25 | // Set up the accessory manger
26 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
27 | // Get the number of accessories connected
28 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
29 | // Check if there are any connected
30 | if (numberOfAccessoriesConnected > 0) {
31 | // There are accessories connected
32 | return true;
33 | } else {
34 | // There are no accessories connected
35 | return false;
36 | }
37 | }
38 | @catch (NSException *exception) {
39 | // Error, return false
40 | return false;
41 | }
42 | }
43 |
44 | // Are headphone attached?
45 | + (BOOL)headphonesAttached {
46 | // Check if the headphones are connected
47 | @try {
48 | // Get the audiosession route information
49 | AVAudioSessionRouteDescription *route = [[AVAudioSession sharedInstance] currentRoute];
50 |
51 | // Run through all the route outputs
52 | for (AVAudioSessionPortDescription *desc in [route outputs]) {
53 |
54 | // Check if any of the ports are equal to the string headphones
55 | if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones]) {
56 |
57 | // Return YES
58 | return YES;
59 | }
60 | }
61 |
62 | // No headphones attached
63 | return NO;
64 | }
65 | @catch (NSException *exception) {
66 | // Error, return false
67 | return false;
68 | }
69 | }
70 |
71 | // Number of attached accessories
72 | + (NSInteger)numberAttachedAccessories {
73 | // Get the number of attached accessories
74 | @try {
75 | // Set up the accessory manger
76 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
77 | // Get the number of accessories connected
78 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
79 | // Return how many accessories are attached
80 | return numberOfAccessoriesConnected;
81 | }
82 | @catch (NSException *exception) {
83 | // Error, return false
84 | return false;
85 | }
86 | }
87 |
88 | // Name of attached accessory/accessories (seperated by , comma's)
89 | + (NSString *)nameAttachedAccessories {
90 | // Get the name of the attached accessories
91 | @try {
92 | // Set up the accessory manger
93 | EAAccessoryManager *accessoryManager = [EAAccessoryManager sharedAccessoryManager];
94 | // Set up an accessory (for later use)
95 | EAAccessory *accessory;
96 | // Get the number of accessories connected
97 | int numberOfAccessoriesConnected = (int)[accessoryManager.connectedAccessories count];
98 |
99 | // Check to make sure there are accessories connected
100 | if (numberOfAccessoriesConnected > 0) {
101 | // Set up a string for all the accessory names
102 | NSString *allAccessoryNames = @"";
103 | // Set up a string for the accessory names
104 | NSString *accessoryName;
105 | // Get the accessories
106 | NSArray *accessoryArray = accessoryManager.connectedAccessories;
107 | // Run through all the accessories
108 | for (int x = 0; x < numberOfAccessoriesConnected; x++) {
109 | // Get the accessory at that index
110 | accessory = [accessoryArray objectAtIndex:x];
111 | // Get the name of it
112 | accessoryName = [accessory name];
113 | // Make sure there is a name
114 | if (accessoryName == nil || accessoryName.length == 0) {
115 | // If there isn't, try and get the manufacturer name
116 | accessoryName = [accessory manufacturer];
117 | }
118 | // Make sure there is a manufacturer name
119 | if (accessoryName == nil || accessoryName.length == 0) {
120 | // If there isn't a manufacturer name still
121 | accessoryName = @"Unknown";
122 | }
123 | // Format that name
124 | allAccessoryNames = [allAccessoryNames stringByAppendingFormat:@"%@", accessoryName];
125 | if (x < numberOfAccessoriesConnected - 1) {
126 | allAccessoryNames = [allAccessoryNames stringByAppendingFormat:@", "];
127 | }
128 | }
129 | // Return the name/s of the connected accessories
130 | return allAccessoryNames;
131 | } else {
132 | // No accessories connected
133 | return nil;
134 | }
135 | }
136 | @catch (NSException *exception) {
137 | // Error, return false
138 | return nil;
139 | }
140 | }
141 |
142 | @end
143 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Core/GCDWebServerHTTPStatusCodes.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | // http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
29 | // http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
30 |
31 | #import
32 |
33 | /**
34 | * Convenience constants for "informational" HTTP status codes.
35 | */
36 | typedef NS_ENUM(NSInteger, GCDWebServerInformationalHTTPStatusCode) {
37 | kGCDWebServerHTTPStatusCode_Continue = 100,
38 | kGCDWebServerHTTPStatusCode_SwitchingProtocols = 101,
39 | kGCDWebServerHTTPStatusCode_Processing = 102
40 | };
41 |
42 | /**
43 | * Convenience constants for "successful" HTTP status codes.
44 | */
45 | typedef NS_ENUM(NSInteger, GCDWebServerSuccessfulHTTPStatusCode) {
46 | kGCDWebServerHTTPStatusCode_OK = 200,
47 | kGCDWebServerHTTPStatusCode_Created = 201,
48 | kGCDWebServerHTTPStatusCode_Accepted = 202,
49 | kGCDWebServerHTTPStatusCode_NonAuthoritativeInformation = 203,
50 | kGCDWebServerHTTPStatusCode_NoContent = 204,
51 | kGCDWebServerHTTPStatusCode_ResetContent = 205,
52 | kGCDWebServerHTTPStatusCode_PartialContent = 206,
53 | kGCDWebServerHTTPStatusCode_MultiStatus = 207,
54 | kGCDWebServerHTTPStatusCode_AlreadyReported = 208
55 | };
56 |
57 | /**
58 | * Convenience constants for "redirection" HTTP status codes.
59 | */
60 | typedef NS_ENUM(NSInteger, GCDWebServerRedirectionHTTPStatusCode) {
61 | kGCDWebServerHTTPStatusCode_MultipleChoices = 300,
62 | kGCDWebServerHTTPStatusCode_MovedPermanently = 301,
63 | kGCDWebServerHTTPStatusCode_Found = 302,
64 | kGCDWebServerHTTPStatusCode_SeeOther = 303,
65 | kGCDWebServerHTTPStatusCode_NotModified = 304,
66 | kGCDWebServerHTTPStatusCode_UseProxy = 305,
67 | kGCDWebServerHTTPStatusCode_TemporaryRedirect = 307,
68 | kGCDWebServerHTTPStatusCode_PermanentRedirect = 308
69 | };
70 |
71 | /**
72 | * Convenience constants for "client error" HTTP status codes.
73 | */
74 | typedef NS_ENUM(NSInteger, GCDWebServerClientErrorHTTPStatusCode) {
75 | kGCDWebServerHTTPStatusCode_BadRequest = 400,
76 | kGCDWebServerHTTPStatusCode_Unauthorized = 401,
77 | kGCDWebServerHTTPStatusCode_PaymentRequired = 402,
78 | kGCDWebServerHTTPStatusCode_Forbidden = 403,
79 | kGCDWebServerHTTPStatusCode_NotFound = 404,
80 | kGCDWebServerHTTPStatusCode_MethodNotAllowed = 405,
81 | kGCDWebServerHTTPStatusCode_NotAcceptable = 406,
82 | kGCDWebServerHTTPStatusCode_ProxyAuthenticationRequired = 407,
83 | kGCDWebServerHTTPStatusCode_RequestTimeout = 408,
84 | kGCDWebServerHTTPStatusCode_Conflict = 409,
85 | kGCDWebServerHTTPStatusCode_Gone = 410,
86 | kGCDWebServerHTTPStatusCode_LengthRequired = 411,
87 | kGCDWebServerHTTPStatusCode_PreconditionFailed = 412,
88 | kGCDWebServerHTTPStatusCode_RequestEntityTooLarge = 413,
89 | kGCDWebServerHTTPStatusCode_RequestURITooLong = 414,
90 | kGCDWebServerHTTPStatusCode_UnsupportedMediaType = 415,
91 | kGCDWebServerHTTPStatusCode_RequestedRangeNotSatisfiable = 416,
92 | kGCDWebServerHTTPStatusCode_ExpectationFailed = 417,
93 | kGCDWebServerHTTPStatusCode_UnprocessableEntity = 422,
94 | kGCDWebServerHTTPStatusCode_Locked = 423,
95 | kGCDWebServerHTTPStatusCode_FailedDependency = 424,
96 | kGCDWebServerHTTPStatusCode_UpgradeRequired = 426,
97 | kGCDWebServerHTTPStatusCode_PreconditionRequired = 428,
98 | kGCDWebServerHTTPStatusCode_TooManyRequests = 429,
99 | kGCDWebServerHTTPStatusCode_RequestHeaderFieldsTooLarge = 431
100 | };
101 |
102 | /**
103 | * Convenience constants for "server error" HTTP status codes.
104 | */
105 | typedef NS_ENUM(NSInteger, GCDWebServerServerErrorHTTPStatusCode) {
106 | kGCDWebServerHTTPStatusCode_InternalServerError = 500,
107 | kGCDWebServerHTTPStatusCode_NotImplemented = 501,
108 | kGCDWebServerHTTPStatusCode_BadGateway = 502,
109 | kGCDWebServerHTTPStatusCode_ServiceUnavailable = 503,
110 | kGCDWebServerHTTPStatusCode_GatewayTimeout = 504,
111 | kGCDWebServerHTTPStatusCode_HTTPVersionNotSupported = 505,
112 | kGCDWebServerHTTPStatusCode_InsufficientStorage = 507,
113 | kGCDWebServerHTTPStatusCode_LoopDetected = 508,
114 | kGCDWebServerHTTPStatusCode_NotExtended = 510,
115 | kGCDWebServerHTTPStatusCode_NetworkAuthenticationRequired = 511
116 | };
117 |
--------------------------------------------------------------------------------
/InsiderDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/Libs/System Services/Utilities/SSAccelerometerInfo.m:
--------------------------------------------------------------------------------
1 | //
2 | // SSAccelerometerInfo.m
3 | // SystemServicesDemo
4 | //
5 | // Created by Shmoopi LLC on 9/20/12.
6 | // Copyright (c) 2012 Shmoopi LLC. All rights reserved.
7 | //
8 |
9 | #import "SSAccelerometerInfo.h"
10 |
11 | // Private
12 | @interface SSAccelerometerInfo ()
13 |
14 | /**
15 | * processMotion:withError:
16 | *
17 | * Appends the new motion data to the appropriate instance variable strings.
18 | */
19 | - (void)processMotion:(CMDeviceMotion*)motion withError:(NSError*)error;
20 |
21 | /**
22 | * processAccel:withError:
23 | *
24 | * Appends the new raw accleration data to the appropriate instance variable string.
25 | */
26 | - (void)processAccel:(CMAccelerometerData*)accelData withError:(NSError*)error;
27 |
28 | /**
29 | * processGyro:withError:
30 | *
31 | * Appends the new raw gyro data to the appropriate instance variable string.
32 | */
33 | - (void)processGyro:(CMGyroData*)gyroData withError:(NSError*)error;
34 |
35 | @end
36 |
37 | // Implementation
38 | @implementation SSAccelerometerInfo
39 |
40 | @synthesize attitudeString, gravityString, magneticFieldString, rotationRateString, userAccelerationString, rawGyroscopeString, rawAccelerometerString;
41 |
42 | // Accelerometer Information
43 |
44 | // Device Orientation
45 | + (UIInterfaceOrientation)deviceOrientation {
46 | // Get the device's current orientation
47 | @try {
48 | #if !(defined(__has_feature) && __has_feature(attribute_availability_app_extension))
49 | // Device orientation
50 | UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
51 |
52 | // Successful
53 | return orientation;
54 | #endif
55 | }
56 | @catch (NSException *exception) {
57 | return -1;
58 | }
59 | // Error
60 | return -1;
61 | }
62 |
63 | // Start logging motion data
64 | - (void)startLoggingMotionData {
65 | motionManager = [[CMMotionManager alloc] init];
66 | motionManager.deviceMotionUpdateInterval = 0.01; //100 Hz
67 | motionManager.accelerometerUpdateInterval = 0.01;
68 | motionManager.gyroUpdateInterval = 0.01;
69 |
70 | // Limiting the concurrent ops to 1 is a cheap way to avoid two handlers editing the same
71 | // string at the same time.
72 | deviceMotionQueue = [[NSOperationQueue alloc] init];
73 | [deviceMotionQueue setMaxConcurrentOperationCount:1];
74 |
75 | accelQueue = [[NSOperationQueue alloc] init];
76 | [accelQueue setMaxConcurrentOperationCount:1];
77 |
78 | gyroQueue = [[NSOperationQueue alloc] init];
79 | [gyroQueue setMaxConcurrentOperationCount:1];
80 |
81 | // Logging Motion Data
82 |
83 | CMDeviceMotionHandler motionHandler = ^(CMDeviceMotion *motion, NSError *error) {
84 | [self processMotion:motion withError:error];
85 | };
86 |
87 | CMGyroHandler gyroHandler = ^(CMGyroData *gyroData, NSError *error) {
88 | [self processGyro:gyroData withError:error];
89 | };
90 |
91 | CMAccelerometerHandler accelHandler = ^(CMAccelerometerData *accelerometerData, NSError *error) {
92 | [self processAccel:accelerometerData withError:error];
93 | };
94 |
95 | [motionManager startDeviceMotionUpdatesToQueue:deviceMotionQueue withHandler:motionHandler];
96 |
97 | [motionManager startGyroUpdatesToQueue:gyroQueue withHandler:gyroHandler];
98 |
99 | [motionManager startAccelerometerUpdatesToQueue:accelQueue withHandler:accelHandler];
100 | }
101 |
102 | // Stop logging motion data
103 | - (void)stopLoggingMotionData {
104 |
105 | // Stop everything
106 | [motionManager stopDeviceMotionUpdates];
107 | [deviceMotionQueue waitUntilAllOperationsAreFinished];
108 |
109 | [motionManager stopAccelerometerUpdates];
110 | [accelQueue waitUntilAllOperationsAreFinished];
111 |
112 | [motionManager stopGyroUpdates];
113 | [gyroQueue waitUntilAllOperationsAreFinished];
114 |
115 | }
116 |
117 | #pragma mark - Set Motion Variables when Updating (in background)
118 |
119 | - (void)processAccel:(CMAccelerometerData*)accelData withError:(NSError*)error {
120 | rawAccelerometerString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", accelData.timestamp,
121 | accelData.acceleration.x,
122 | accelData.acceleration.y,
123 | accelData.acceleration.z,
124 | nil];
125 | }
126 |
127 | - (void)processGyro:(CMGyroData*)gyroData withError:(NSError*)error {
128 |
129 | rawGyroscopeString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", gyroData.timestamp,
130 | gyroData.rotationRate.x,
131 | gyroData.rotationRate.y,
132 | gyroData.rotationRate.z,
133 | nil];
134 | }
135 |
136 | - (void)processMotion:(CMDeviceMotion*)motion withError:(NSError*)error {
137 |
138 | attitudeString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
139 | motion.attitude.roll,
140 | motion.attitude.pitch,
141 | motion.attitude.yaw,
142 | nil];
143 |
144 | gravityString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
145 | motion.gravity.x,
146 | motion.gravity.y,
147 | motion.gravity.z,
148 | nil];
149 |
150 | magneticFieldString = [NSString stringWithFormat:@"%f,%f,%f,%f,%d\n", motion.timestamp,
151 | motion.magneticField.field.x,
152 | motion.magneticField.field.y,
153 | motion.magneticField.field.z,
154 | (int)motion.magneticField.accuracy,
155 | nil];
156 |
157 | rotationRateString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
158 | motion.rotationRate.x,
159 | motion.rotationRate.y,
160 | motion.rotationRate.z,
161 | nil];
162 |
163 | userAccelerationString = [NSString stringWithFormat:@"%f,%f,%f,%f\n", motion.timestamp,
164 | motion.userAcceleration.x,
165 | motion.userAcceleration.y,
166 | motion.userAcceleration.z,
167 | nil];
168 |
169 | }
170 |
171 |
172 | @end
173 |
--------------------------------------------------------------------------------
/Libs/GCDWebServer/Responses/GCDWebServerErrorResponse.m:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012-2015, Pierre-Olivier Latour
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright
10 | notice, this list of conditions and the following disclaimer in the
11 | documentation and/or other materials provided with the distribution.
12 | * The name of Pierre-Olivier Latour may not be used to endorse
13 | or promote products derived from this software without specific
14 | prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | #if !__has_feature(objc_arc)
29 | #error GCDWebServer requires ARC
30 | #endif
31 |
32 | #import "GCDWebServerPrivate.h"
33 |
34 | @interface GCDWebServerErrorResponse ()
35 | - (instancetype)initWithStatusCode:(NSInteger)statusCode underlyingError:(NSError*)underlyingError messageFormat:(NSString*)format arguments:(va_list)arguments;
36 | @end
37 |
38 | @implementation GCDWebServerErrorResponse
39 |
40 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... {
41 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500));
42 | va_list arguments;
43 | va_start(arguments, format);
44 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments];
45 | va_end(arguments);
46 | return response;
47 | }
48 |
49 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... {
50 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600));
51 | va_list arguments;
52 | va_start(arguments, format);
53 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments];
54 | va_end(arguments);
55 | return response;
56 | }
57 |
58 | + (instancetype)responseWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... {
59 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500));
60 | va_list arguments;
61 | va_start(arguments, format);
62 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments];
63 | va_end(arguments);
64 | return response;
65 | }
66 |
67 | + (instancetype)responseWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... {
68 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600));
69 | va_list arguments;
70 | va_start(arguments, format);
71 | GCDWebServerErrorResponse* response = [[self alloc] initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments];
72 | va_end(arguments);
73 | return response;
74 | }
75 |
76 | static inline NSString* _EscapeHTMLString(NSString* string) {
77 | return [string stringByReplacingOccurrencesOfString:@"\"" withString:@"""];
78 | }
79 |
80 | - (instancetype)initWithStatusCode:(NSInteger)statusCode underlyingError:(NSError*)underlyingError messageFormat:(NSString*)format arguments:(va_list)arguments {
81 | NSString* message = [[NSString alloc] initWithFormat:format arguments:arguments];
82 | NSString* title = [NSString stringWithFormat:@"HTTP Error %i", (int)statusCode];
83 | NSString* error = underlyingError ? [NSString stringWithFormat:@"[%@] %@ (%li)", underlyingError.domain, _EscapeHTMLString(underlyingError.localizedDescription), (long)underlyingError.code] : @"";
84 | NSString* html = [NSString stringWithFormat:@"%@ %@: %@ %@ ",
85 | title, title, _EscapeHTMLString(message), error];
86 | if ((self = [self initWithHTML:html])) {
87 | self.statusCode = statusCode;
88 | }
89 | return self;
90 | }
91 |
92 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode message:(NSString*)format, ... {
93 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500));
94 | va_list arguments;
95 | va_start(arguments, format);
96 | self = [self initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments];
97 | va_end(arguments);
98 | return self;
99 | }
100 |
101 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode message:(NSString*)format, ... {
102 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600));
103 | va_list arguments;
104 | va_start(arguments, format);
105 | self = [self initWithStatusCode:errorCode underlyingError:nil messageFormat:format arguments:arguments];
106 | va_end(arguments);
107 | return self;
108 | }
109 |
110 | - (instancetype)initWithClientError:(GCDWebServerClientErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... {
111 | GWS_DCHECK(((NSInteger)errorCode >= 400) && ((NSInteger)errorCode < 500));
112 | va_list arguments;
113 | va_start(arguments, format);
114 | self = [self initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments];
115 | va_end(arguments);
116 | return self;
117 | }
118 |
119 | - (instancetype)initWithServerError:(GCDWebServerServerErrorHTTPStatusCode)errorCode underlyingError:(NSError*)underlyingError message:(NSString*)format, ... {
120 | GWS_DCHECK(((NSInteger)errorCode >= 500) && ((NSInteger)errorCode < 600));
121 | va_list arguments;
122 | va_start(arguments, format);
123 | self = [self initWithStatusCode:errorCode underlyingError:underlyingError messageFormat:format arguments:arguments];
124 | va_end(arguments);
125 | return self;
126 | }
127 |
128 | @end
129 |
--------------------------------------------------------------------------------