Changeset 13483


Ignore:
Timestamp:
Sep 9, 2012, 5:19:10 AM (9 years ago)
Author:
livings124
Message:

#5036 Bonjour Service Name Maximum Length Bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BonjourController.m

    r13253 r13483  
    2525#import "BonjourController.h"
    2626
     27#define BONJOUR_SERVICE_NAME_MAX_LENGTH 63
     28
    2729@implementation BonjourController
    2830
     
    4850    [self stop];
    4951   
    50     NSString * serviceName = [NSString stringWithFormat: @"Transmission Web Interface (%@ - %@)", NSUserName(), [[NSHost currentHost] localizedName]];
     52    //Attempt full length service name
     53    #warning localize?
     54    NSString * mainName = @"Transmission Web Interface";
     55    NSString * details = [NSString stringWithFormat: @"%@ - %@", NSUserName(), [[NSHost currentHost] localizedName]];
     56    NSString * serviceName = [NSString stringWithFormat: @"%@ (%@)", mainName, details];
     57   
     58    if ([serviceName length] > BONJOUR_SERVICE_NAME_MAX_LENGTH) {
     59        //Remove Web Interface to shorten name
     60        mainName = @"Transmission";
     61        serviceName = [NSString stringWithFormat: @"%@ (%@)", mainName, details];
     62       
     63        if ([serviceName length] > BONJOUR_SERVICE_NAME_MAX_LENGTH) {
     64            //Last resort is to truncate the user name and computer name
     65            serviceName = [serviceName substringToIndex: BONJOUR_SERVICE_NAME_MAX_LENGTH];
     66        }
     67    }NSLog(@"%@", serviceName);
    5168   
    5269    fService = [[NSNetService alloc] initWithDomain: @"" type: @"_http._tcp." name: serviceName port: port];
Note: See TracChangeset for help on using the changeset viewer.