Changeset 594


Ignore:
Timestamp:
Jul 15, 2006, 11:13:21 PM (16 years ago)
Author:
livings124
Message:

Use Growl framework rather than applescript.

Location:
trunk
Files:
15 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r593 r594  
    110110                A25FCDEF0A3769A6002BCBBE /* PauseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDD0A37695F002BCBBE /* PauseSelected.png */; };
    111111                A25FCDF00A3769AC002BCBBE /* ResumeSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */; };
     112                A261F1DC0A69A1610002815A /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A261F1DB0A69A1610002815A /* Growl.framework */; };
     113                A261F1E40A69A1B10002815A /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A261F1DB0A69A1610002815A /* Growl.framework */; };
    112114                A26D450B0A0503AC00A10BB3 /* peermessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A309DEC0430047D688 /* peermessages.h */; };
    113115                A27431DB0A68538400FA780A /* BarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A27431D90A68538400FA780A /* BarButton.m */; };
     
    152154                        dstSubfolderSpec = 10;
    153155                        files = (
     156                                A261F1E40A69A1B10002815A /* Growl.framework in CopyFiles */,
    154157                                A24F19210A3A796800C9C145 /* Sparkle.framework in CopyFiles */,
    155158                        );
     
    250253                4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TorrentCell.m; path = macosx/TorrentCell.m; sourceTree = "<group>"; };
    251254                4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TorrentCell.h; path = macosx/TorrentCell.h; sourceTree = "<group>"; };
    252                 4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
     255                4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
    253256                4DDBB71B09E16BF100284745 /* transmissioncli.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = transmissioncli.c; path = cli/transmissioncli.c; sourceTree = "<group>"; };
    254257                4DDFDD20099A5D8E00189D81 /* DownloadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownloadBadge.png; path = macosx/Images/DownloadBadge.png; sourceTree = "<group>"; };
     
    306309                A25FCDDD0A37695F002BCBBE /* PauseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = PauseSelected.png; path = macosx/Images/PauseSelected.png; sourceTree = "<group>"; };
    307310                A25FCDDE0A37695F002BCBBE /* ResumeSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ResumeSelected.png; path = macosx/Images/ResumeSelected.png; sourceTree = "<group>"; };
     311                A261F1DB0A69A1610002815A /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Growl.framework; sourceTree = "<group>"; };
    308312                A27431D80A68538400FA780A /* BarButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = BarButton.h; path = macosx/BarButton.h; sourceTree = "<group>"; };
    309313                A27431D90A68538400FA780A /* BarButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = BarButton.m; path = macosx/BarButton.m; sourceTree = "<group>"; };
     
    352356                                4D4B7F6109E055660053C1EB /* libcrypto.0.9.dylib in Frameworks */,
    353357                                A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */,
     358                                A261F1DC0A69A1610002815A /* Growl.framework in Frameworks */,
    354359                        );
    355360                        runOnlyForDeploymentPostprocessing = 0;
     
    568573                        isa = PBXGroup;
    569574                        children = (
     575                                A261F1DB0A69A1610002815A /* Growl.framework */,
    570576                                A24F19070A3A790800C9C145 /* Sparkle.framework */,
    571577                        );
     
    896902                                        "$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
    897903                                        "$(FRAMEWORK_SEARCH_PATHS_QUOTED_2)",
     904                                        "$(FRAMEWORK_SEARCH_PATHS_QUOTED_3)",
    898905                                );
    899906                                FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\"";
    900907                                FRAMEWORK_SEARCH_PATHS_QUOTED_2 = "\"$(SRCROOT)\"";
     908                                FRAMEWORK_SEARCH_PATHS_QUOTED_3 = "\"$(SRCROOT)\"";
    901909                                GCC_PRECOMPILE_PREFIX_HEADER = YES;
    902910                                GCC_PREFIX_HEADER = macosx/Transmission_Prefix.pch;
  • trunk/macosx/Controller.h

    r581 r594  
    8484    NSMutableArray              * fAutoImportedNames;
    8585   
    86     BOOL                        fHasGrowl, fUpdateInProgress;
     86    BOOL                        fUpdateInProgress;
    8787    Badger                      * fBadger;
    8888}
    8989
    9090- (void) openShowSheet:   (id) sender;
    91 - (void) openSheetClosed: (NSOpenPanel *) s returnCode: (int) code
    92                         contextInfo: (void *) info;
     91- (void) openSheetClosed: (NSOpenPanel *) s returnCode: (int) code contextInfo: (void *) info;
    9392
    94 - (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode
    95                             contextInfo: (void *) contextInfo;
     93- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
    9694
    9795- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet;
     
    162160- (void) autoImportChange: (NSNotification *) notification;
    163161
    164 - (void) sleepCallBack: (natural_t) messageType argument:
    165                         (void *) messageArgument;
     162- (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument;
    166163
    167164- (void) toggleSmallView: (id) sender;
     
    178175- (void) linkForums:        (id) sender;
    179176
    180 - (void) notifyGrowl: (NSString *) title message: (NSString *) message identifier: (NSString *) ident;
    181 - (void) growlRegister;
    182 
    183177- (void) checkUpdate:       (id) sender;
    184178- (void) prepareForUpdate:  (NSNotification *) notification;
  • trunk/macosx/Controller.m

    r587 r594  
    3232
    3333#import <Sparkle/Sparkle.h>
     34#import <Growl/GrowlApplicationBridge.h>
    3435
    3536#define TOOLBAR_OPEN            @"Toolbar Open"
     
    4950#define FORUM_URL   @"http://transmission.m0k.org/forum/"
    5051
    51 #define GROWL_PATH  @"/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app"
    52 
    5352static void sleepCallBack(void * controller, io_service_t y,
    5453        natural_t messageType, void * messageArgument)
     
    7574        fBadger = [[Badger alloc] init];
    7675       
    77         //check and register Growl if it is installed for this user or all users
    78         NSFileManager * manager = [NSFileManager defaultManager];
    79         fHasGrowl = [manager fileExistsAtPath: GROWL_PATH]
    80             || [manager fileExistsAtPath: [NSHomeDirectory() stringByAppendingPathComponent: GROWL_PATH]];
    81         [self growlRegister];
     76        [GrowlApplicationBridge setGrowlDelegate: self];
    8277    }
    8378    return self;
     
    833828            [self checkToStartWaiting: torrent];
    834829       
    835             //notifications
    836             [self notifyGrowl: @"Download Complete" message: [[torrent name] stringByAppendingString:
    837                                             @" finished downloading"] identifier: @"Download Complete"];
     830            [GrowlApplicationBridge notifyWithTitle: @"Download Complete"
     831                description: [torrent name] notificationName: @"Download Complete" iconData: nil
     832                priority: 0 isSticky: NO clickContext: nil];
     833
    838834            if (![fWindow isKeyWindow])
    839835                fCompleted++;
     
    12231219    [fInfoController updateInfoStatsAndSettings];
    12241220   
    1225     [self notifyGrowl: @"Seeding Complete" message: [[[notification object] name] stringByAppendingString:
    1226                                                         @" finished seeding"] identifier: @"Seeding Complete"];
     1221    [GrowlApplicationBridge notifyWithTitle: @"Seeding Complete"
     1222                description: [[notification object] name] notificationName: @"Seeding Complete"
     1223                iconData: nil priority: 0 isSticky: NO clickContext: nil];
    12271224}
    12281225
     
    13311328            //import only actually happened if the torrent array is larger
    13321329            if (oldCount < [fTorrents count])
    1333                 [self notifyGrowl: @"Torrent File Auto Added" message: [file stringByAppendingString:
    1334                                                     @" added to Transmission"] identifier: @"Torrent Auto Added"];
     1330                [GrowlApplicationBridge notifyWithTitle: @"Torrent File Auto Added"
     1331                    description: file notificationName: @"Torrent Auto Added" iconData: nil
     1332                    priority: 0 isSticky: NO clickContext: nil];
    13351333        }
    13361334}
     
    19911989}
    19921990
    1993 - (void) notifyGrowl: (NSString *) title message: (NSString *) message identifier: (NSString *) ident
    1994 {
    1995     if (!fHasGrowl)
    1996         return;
    1997 
    1998     NSString * growlScript = [NSString stringWithFormat:
    1999         @"tell application \"System Events\"\n"
    2000          "  if exists application process \"GrowlHelperApp\" then\n"
    2001          "    tell application \"GrowlHelperApp\"\n "
    2002          "      notify with name \"%@\""
    2003          "        title \"%@\""
    2004          "        description \"%@\""
    2005          "        application name \"Transmission\"\n"
    2006          "    end tell\n"
    2007          "  end if\n"
    2008          "end tell", ident, title, message];
    2009    
    2010     NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
    2011     NSDictionary * error;
    2012     if (![appleScript executeAndReturnError: & error])
    2013         NSLog(@"Growl notify failed");
    2014     [appleScript release];
    2015 }
    2016 
    2017 - (void) growlRegister
    2018 {
    2019     if (!fHasGrowl)
    2020         return;
    2021 
    2022     NSString * growlScript = @"tell application \"System Events\"\n"
    2023          "  if exists application process \"GrowlHelperApp\" then\n"
    2024          "    tell application \"GrowlHelperApp\"\n"
    2025          "      register as application \"Transmission\" "
    2026          "        all notifications {\"Download Complete\", \"Seeding Complete\", \"Torrent Auto Added\"}"
    2027          "        default notifications {\"Download Complete\", \"Seeding Complete\", \"Torrent Auto Added\"}"
    2028          "        icon of application \"Transmission\"\n"
    2029          "    end tell\n"
    2030          "  end if\n"
    2031          "end tell";
    2032 
    2033     NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
    2034     NSDictionary * error;
    2035     if (![appleScript executeAndReturnError: & error])
    2036         NSLog(@"Growl registration failed");
    2037     [appleScript release];
    2038 }
    2039 
    20401991- (void) checkUpdate: (id) sender
    20411992{
     
    20481999}
    20492000
     2001- (NSDictionary *) registrationDictionaryForGrowl
     2002{
     2003    NSArray * notifications = [NSArray arrayWithObjects: @"Download Complete",
     2004                                @"Seeding Complete", @"Torrent Auto Added", nil];
     2005    return [NSDictionary dictionaryWithObjectsAndKeys: notifications, GROWL_NOTIFICATIONS_ALL,
     2006                                notifications, GROWL_NOTIFICATIONS_DEFAULT, nil];
     2007}
     2008
    20502009@end
Note: See TracChangeset for help on using the changeset viewer.