Changeset 10073


Ignore:
Timestamp:
Feb 2, 2010, 1:47:22 AM (12 years ago)
Author:
livings124
Message:

#2720 When adding a duplicate magnet link, display an appropriate error message instead of a generic message

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r9844 r10073  
    128128- (void) invalidOpenMagnetAlert: (NSString *) address;
    129129- (void) duplicateOpenAlert: (NSString *) name;
     130- (void) duplicateOpenMagnetAlert: (NSString *) address transferName: (NSString *) name;
    130131
    131132- (void) openURL:               (NSString *) urlString;
  • trunk/macosx/Controller.m

    r10008 r10073  
    946946- (void) openMagnet: (NSString *) address
    947947{
     948    tr_torrent * duplicateTorrent;
     949    if ((duplicateTorrent = tr_torrentFindFromMagnetLink(fLib, [address UTF8String])))
     950    {
     951        const tr_info * info = tr_torrentInfo(duplicateTorrent);
     952        NSString * name = (info != NULL && info->name != NULL) ? [NSString stringWithUTF8String: info->name] : nil;
     953        [self duplicateOpenMagnetAlert: address transferName: name];
     954        return;
     955    }
     956   
    948957    Torrent * torrent;
    949958    if (!(torrent = [[Torrent alloc] initWithMagnetAddress: address location: nil lib: fLib]))
     
    10841093   
    10851094    NSAlert * alert = [[NSAlert alloc] init];
    1086     [alert setMessageText: NSLocalizedString(@"Adding magnetized transfer failed", "Magnet link failed -> title")];
     1095    [alert setMessageText: NSLocalizedString(@"Adding magnetized transfer failed.", "Magnet link failed -> title")];
    10871096    [alert setInformativeText: [NSString stringWithFormat: NSLocalizedString(@"There was an error when adding the magnet link \"%@\"."
    10881097                                " The transfer will not occur.", "Magnet link failed -> message"), address]];
     
    11091118    [alert setAlertStyle: NSWarningAlertStyle];
    11101119    [alert addButtonWithTitle: NSLocalizedString(@"OK", "Open duplicate alert -> button")];
     1120    [alert setShowsSuppressionButton: YES];
     1121   
     1122    [alert runModal];
     1123    if ([[alert suppressionButton] state])
     1124        [fDefaults setBool: NO forKey: @"WarningDuplicate"];
     1125    [alert release];
     1126}
     1127
     1128- (void) duplicateOpenMagnetAlert: (NSString *) address transferName: (NSString *) name
     1129{
     1130    if (![fDefaults boolForKey: @"WarningDuplicate"])
     1131        return;
     1132   
     1133    NSAlert * alert = [[NSAlert alloc] init];
     1134    if (name)
     1135        [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"A transfer of \"%@\" already exists.",
     1136                                "Open duplicate magnet alert -> title"), name]];
     1137    else
     1138        [alert setMessageText: NSLocalizedString(@"Magnet link is a duplicate of an existing transfer.",
     1139                                "Open duplicate magnet alert -> title")];
     1140    [alert setInformativeText: [NSString stringWithFormat:
     1141            NSLocalizedString(@"The magnet link  \"%@\" cannot be added because it is a duplicate of an already existing transfer.",
     1142                            "Open duplicate magnet alert -> message"), address]];
     1143    [alert setAlertStyle: NSWarningAlertStyle];
     1144    [alert addButtonWithTitle: NSLocalizedString(@"OK", "Open duplicate magnet alert -> button")];
    11111145    [alert setShowsSuppressionButton: YES];
    11121146   
Note: See TracChangeset for help on using the changeset viewer.