Browse Source

Wifi Server:display the access link with server hostname

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Pierre SAGASPE 11 years ago
parent
commit
92656f33c4

+ 1 - 0
Sources/VLCHTTPUploaderController.h

@@ -22,6 +22,7 @@
 
 - (BOOL)changeHTTPServerState:(BOOL)state;
 - (NSString *)currentIPAddress;
+- (NSString *)hostname;
 
 - (void)moveFileFrom:(NSString *)filepath;
 

+ 15 - 0
Sources/VLCHTTPUploaderController.m

@@ -147,6 +147,21 @@
     return address;
 }
 
+- (NSString *)hostname
+{
+    char baseHostName[256];
+    int success = gethostname(baseHostName, 255);
+    if (success != 0)
+        return nil;
+    baseHostName[255] = '\0';
+
+#if !TARGET_IPHONE_SIMULATOR
+    return [NSString stringWithFormat:@"%s.local", baseHostName];
+#else
+    return [NSString stringWithFormat:@"%s", baseHostName];
+#endif
+}
+
 - (void)moveFileFrom:(NSString *)filepath
 {
     NSString *fileName = [filepath lastPathComponent];

+ 3 - 2
Sources/VLCMenuTableViewController.m

@@ -280,10 +280,11 @@
 {
     HTTPServer *server = self.uploadController.httpServer;
     if (server.isRunning) {
+        _uploadLocationLabel.numberOfLines = 0;
         if (server.listeningPort != 80)
-            _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@:%i", [self.uploadController currentIPAddress], server.listeningPort];
+            _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@:%i\nhttp://%@:%i", [self.uploadController currentIPAddress], server.listeningPort, [self.uploadController hostname], server.listeningPort];
         else
-            _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@", [self.uploadController currentIPAddress]];
+            _uploadLocationLabel.text = [NSString stringWithFormat:@"http://%@\nhttp://%@", [self.uploadController currentIPAddress], [self.uploadController hostname]];
         [_uploadButton setImage:[UIImage imageNamed:@"WifiUpOn"] forState:UIControlStateNormal];
     } else {
         _uploadLocationLabel.text = NSLocalizedString(@"HTTP_UPLOAD_SERVER_OFF", nil);