Reid Ellis (clith) wrote in ijournal,
Reid Ellis
clith
ijournal

  • Mood:

Fix for "no port number" bug

I found that if no port number is specified in the lj server settings, login fails. Most people don't even know what a port number is, or if they do, perhaps they don't know what the default LJ port numer is. So if no value is specified, this patch uses the default value of "80".

Next on my todo list is fixing the hard-coded livejournal.com URLs used when you select the "Recent Entries" menu item. :-)

I hope this is the right place to submit patch diffs. I'll put the code after an lj cut..

Here's the diff, inside a <pre> block..

? port-fix-diff.txt
? LiveJournal.pbproj/rae.pbxuser
Index: LiveJournalController.m
===================================================================
RCS file: /cvsroot/ljosx/LiveJournal/LiveJournalController.m,v
retrieving revision 1.108
diff -u -r1.108 LiveJournalController.m
--- LiveJournalController.m	14 Apr 2002 03:06:13 -0000	1.108
+++ LiveJournalController.m	16 Apr 2002 17:47:42 -0000
@@ -843,6 +843,7 @@
 
     NSHost *host = [NSHost hostWithName:@"www.livejournal.com"];
     u_short port = 80;
+	u_short enteredPort = 0;
     int sock;
     struct sockaddr_in sin;
     NSEnumerator *addressEnm;
@@ -857,7 +858,11 @@
     // check for server setting
     if ([serverCheckBox state]) {
         host = [NSHost hostWithName: [ljServer stringValue]];
-        port = [ljPort intValue];
+        enteredPort = [ljPort intValue];
+		// make sure the port number is valid -- user may have left field empty
+		if(enteredPort != 0) {
+		    port = enteredPort;
+		}
         //NSLog(@"Different Server Selected: %@ port: %d", [ljServer stringValue], [ljPort intValue]);
     }
 
@@ -865,6 +870,11 @@
     if ([proxyCheckBox state]) {
         host = [NSHost hostWithName: [proxyServer stringValue]];
         port = [proxyPort intValue];
+        enteredPort = [proxyPort intValue];
+		// make sure the port number is valid -- user may have left field empty
+		if(enteredPort != 0) {
+		    port = enteredPort;
+		}
         //NSLog(@"Proxy Selected: %@ port: %d", [proxyServer stringValue], [proxyPort intValue]);
     }
 
@@ -2876,9 +2886,13 @@
 - (NSString *) journalServerURI
 {
     if ([serverCheckBox state]) {
-        return [NSString stringWithFormat: @"%@:%@", [ljServer stringValue], [ljPort stringValue]];
+	if([ljPort intValue]) {
+            return [NSString stringWithFormat: @"%@:%@", [ljServer stringValue], [ljPort stringValue]];
+        } else {
+            return [NSString stringWithFormat: @"%@:80", [ljServer stringValue]];
+        }
     } else {
         return @"www.livejournal.com";
     }
 }
-@end
\ No newline at end of file
+@end
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments