Changeset 13804


Ignore:
Timestamp:
Jan 19, 2013, 5:03:00 AM (8 years ago)
Author:
livings124
Message:

#5223 Use VDKQueue for watching for torrent files

Location:
trunk
Files:
4 added
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r13338 r13804  
    5353  The Growl Development Team for Growl. <http://growl.info/>
    5454  Andy Matuschak for Sparkle. <http://sparkle.andymatuschak.org/>
    55   Christian Hammond for SexyIconEntry. <http://www.chipx86.com/wiki/Libsexy> 
    56   M. Uli Kusterer for UKKQueue.
     55  Christian Hammond for SexyIconEntry. <http://www.chipx86.com/wiki/Libsexy>
     56  Bryan D K Jones for VDKQueue. <https://github.com/bdkjones/VDKQueue>
  • trunk/Transmission.xcodeproj/project.pbxproj

    r13789 r13804  
    250250                A29E653613F1603100048D71 /* evutil_rand.c in Sources */ = {isa = PBXBuildFile; fileRef = A29E653513F1603100048D71 /* evutil_rand.c */; };
    251251                A2A1CB7A0BF29D5500AE959F /* PeerProgressIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */; };
    252                 A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306540AAD24A80049E2AC /* UKFileWatcher.m */; };
    253                 A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */; };
    254                 A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A306580AAD24A80049E2AC /* UKKQueue.m */; };
    255                 A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */; };
    256252                A2A4E9210DE0F7E9000CE197 /* web.h in Headers */ = {isa = PBXBuildFile; fileRef = A29EBE530DC01FC9006CEE80 /* web.h */; };
    257253                A2A4E9220DE0F7EB000CE197 /* web.c in Sources */ = {isa = PBXBuildFile; fileRef = A29EBE520DC01FC9006CEE80 /* web.c */; };
     
    270266                A2AAB6650DE0D08B00E04DDA /* blocklist.h in Headers */ = {isa = PBXBuildFile; fileRef = A2D307930D9EC4860051FD27 /* blocklist.h */; };
    271267                A2AB76EA15D8130B009EFC95 /* libcurl.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A2290D2D1442B23200B95A09 /* libcurl.4.dylib */; };
     268                A2AB883E16A399A6008FAD50 /* VDKQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AB883C16A399A6008FAD50 /* VDKQueue.m */; };
    272269                A2AF1C390A3D0F6200F1575D /* FileOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = A2AF1C370A3D0F6200F1575D /* FileOutlineView.m */; };
    273270                A2B3FB460E5901E700FF78FB /* cli.c in Sources */ = {isa = PBXBuildFile; fileRef = A2B3FB450E5901E700FF78FB /* cli.c */; };
     
    953950                A2A1CB770BF29D5500AE959F /* PeerProgressIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PeerProgressIndicatorCell.h; path = macosx/PeerProgressIndicatorCell.h; sourceTree = "<group>"; };
    954951                A2A1CB780BF29D5500AE959F /* PeerProgressIndicatorCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PeerProgressIndicatorCell.m; path = macosx/PeerProgressIndicatorCell.m; sourceTree = "<group>"; };
    955                 A2A306530AAD24A80049E2AC /* UKFileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = UKFileWatcher.h; path = macosx/UKKQueue/UKFileWatcher.h; sourceTree = "<group>"; };
    956                 A2A306540AAD24A80049E2AC /* UKFileWatcher.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = UKFileWatcher.m; path = macosx/UKKQueue/UKFileWatcher.m; sourceTree = "<group>"; };
    957                 A2A306550AAD24A80049E2AC /* UKFNSubscribeFileWatcher.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = UKFNSubscribeFileWatcher.h; path = macosx/UKKQueue/UKFNSubscribeFileWatcher.h; sourceTree = "<group>"; };
    958                 A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = UKFNSubscribeFileWatcher.m; path = macosx/UKKQueue/UKFNSubscribeFileWatcher.m; sourceTree = "<group>"; };
    959                 A2A306570AAD24A80049E2AC /* UKKQueue.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = UKKQueue.h; path = macosx/UKKQueue/UKKQueue.h; sourceTree = "<group>"; };
    960                 A2A306580AAD24A80049E2AC /* UKKQueue.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = UKKQueue.m; path = macosx/UKKQueue/UKKQueue.m; sourceTree = "<group>"; };
    961                 A2A306590AAD24A80049E2AC /* UKMainThreadProxy.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = UKMainThreadProxy.h; path = macosx/UKKQueue/UKMainThreadProxy.h; sourceTree = "<group>"; };
    962                 A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = UKMainThreadProxy.m; path = macosx/UKKQueue/UKMainThreadProxy.m; sourceTree = "<group>"; };
    963952                A2A4EA0A0DE106E8000CE197 /* ConvertUTF.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ConvertUTF.c; path = libtransmission/ConvertUTF.c; sourceTree = "<group>"; };
    964953                A2A4EA0B0DE106E8000CE197 /* ConvertUTF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ConvertUTF.h; path = libtransmission/ConvertUTF.h; sourceTree = "<group>"; };
     
    976965                A2AAB65A0DE0CF6200E04DDA /* rpc-server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "rpc-server.h"; path = "libtransmission/rpc-server.h"; sourceTree = "<group>"; };
    977966                A2AAB65B0DE0CF6200E04DDA /* rpcimpl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rpcimpl.c; path = libtransmission/rpcimpl.c; sourceTree = "<group>"; };
     967                A2AB883B16A399A6008FAD50 /* VDKQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VDKQueue.h; sourceTree = "<group>"; };
     968                A2AB883C16A399A6008FAD50 /* VDKQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VDKQueue.m; sourceTree = "<group>"; };
    978969                A2AC81D60D987E2D00A2878C /* nl */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nl; path = macosx/nl.lproj/AddWindow.xib; sourceTree = "<group>"; };
    979970                A2AF1C360A3D0F6200F1575D /* FileOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = FileOutlineView.h; path = macosx/FileOutlineView.h; sourceTree = "<group>"; };
     
    13641355                                E1B6FBFD0C0D72430015FE4D /* Prefs Window */,
    13651356                                E1B6FC000C0D72A00015FE4D /* Overlay Window */,
    1366                                 E1B6FBEB0C0D70AC0015FE4D /* UKKQueue */,
    13671357                                E138A9750C04D88F00C5426C /* ProgressGradients.h */,
    13681358                                E138A9760C04D88F00C5426C /* ProgressGradients.m */,
     
    13951385                                A222EA790E6C32C4009FB003 /* BlocklistScheduler.h */,
    13961386                                A222EA7A0E6C32C4009FB003 /* BlocklistScheduler.m */,
     1387                                A2AB883916A399A6008FAD50 /* VDKQueue */,
    13971388                        );
    13981389                        name = Sources;
     
    18051796                        sourceTree = "<group>";
    18061797                };
     1798                A2AB883916A399A6008FAD50 /* VDKQueue */ = {
     1799                        isa = PBXGroup;
     1800                        children = (
     1801                                A2AB883B16A399A6008FAD50 /* VDKQueue.h */,
     1802                                A2AB883C16A399A6008FAD50 /* VDKQueue.m */,
     1803                        );
     1804                        name = VDKQueue;
     1805                        path = macosx/VDKQueue;
     1806                        sourceTree = "<group>";
     1807                };
    18071808                A2E384BF130DFA49001F501B /* libutp */ = {
    18081809                        isa = PBXGroup;
     
    19271928                        );
    19281929                        name = daemon;
    1929                         sourceTree = "<group>";
    1930                 };
    1931                 E1B6FBEB0C0D70AC0015FE4D /* UKKQueue */ = {
    1932                         isa = PBXGroup;
    1933                         children = (
    1934                                 A2A306570AAD24A80049E2AC /* UKKQueue.h */,
    1935                                 A2A306580AAD24A80049E2AC /* UKKQueue.m */,
    1936                                 A2A306530AAD24A80049E2AC /* UKFileWatcher.h */,
    1937                                 A2A306540AAD24A80049E2AC /* UKFileWatcher.m */,
    1938                                 A2A306550AAD24A80049E2AC /* UKFNSubscribeFileWatcher.h */,
    1939                                 A2A306560AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m */,
    1940                                 A2A306590AAD24A80049E2AC /* UKMainThreadProxy.h */,
    1941                                 A2A3065A0AAD24A80049E2AC /* UKMainThreadProxy.m */,
    1942                         );
    1943                         name = UKKQueue;
    19441930                        sourceTree = "<group>";
    19451931                };
     
    27102696                                A2710E770A86796000CE4F7D /* PrefsWindow.m in Sources */,
    27112697                                A256588D0A9A695400E8A03B /* MessageWindowController.m in Sources */,
    2712                                 A2A3065C0AAD24A80049E2AC /* UKFileWatcher.m in Sources */,
    2713                                 A2A3065E0AAD24A80049E2AC /* UKFNSubscribeFileWatcher.m in Sources */,
    2714                                 A2A306600AAD24A80049E2AC /* UKKQueue.m in Sources */,
    2715                                 A2A306620AAD24A80049E2AC /* UKMainThreadProxy.m in Sources */,
    27162698                                A29C8B370ACC6EB3000ED9F9 /* PortChecker.m in Sources */,
    27172699                                A2AA579D0ADFCAB400CA59F6 /* PiecesView.m in Sources */,
     
    27672749                                A2966E8713DAF74C007B52DF /* GlobalOptionsPopoverViewController.m in Sources */,
    27682750                                A234EA541453563B000F3E97 /* NSImageAdditions.m in Sources */,
     2751                                A2AB883E16A399A6008FAD50 /* VDKQueue.m in Sources */,
    27692752                        );
    27702753                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/Controller.h

    r13414 r13804  
    2727#import <Quartz/Quartz.h>
    2828#import <Growl/Growl.h>
     29#import "VDKQueue.h"
    2930
    3031@class AddMagnetWindowController;
     
    5051} addType;
    5152
    52 @interface Controller : NSObject <GrowlApplicationBridgeDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate>
     53@interface Controller : NSObject <GrowlApplicationBridgeDelegate, NSURLDownloadDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate>
    5354{
    5455    tr_session                      * fLib;
     
    233234
    234235- (void) sleepCallback: (natural_t) messageType argument: (void *) messageArgument;
     236
     237@property (retain, readonly) VDKQueue * fileWatcherQueue;
    235238
    236239- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification;
  • trunk/macosx/Controller.m

    r13684 r13804  
    6161#import "variant.h"
    6262
    63 #import "UKKQueue.h"
     63#import "VDKQueue.h"
    6464#import <Sparkle/Sparkle.h>
    6565
     
    161161@synthesize prefsController = fPrefsController;
    162162@synthesize messageWindowController = fMessageController;
     163@synthesize fileWatcherQueue = fFileWatcherQueue;
    163164
    164165+ (void) initialize
     
    372373        fInfoController = [[InfoWindowController alloc] init];
    373374       
     375        //needs to be done before init-ing the prefs controller
     376        fFileWatcherQueue = [[[VDKQueue alloc] init] autorelease];
     377        [fFileWatcherQueue setDelegate: self];
     378       
    374379        fPrefsController = [[PrefsController alloc] initWithHandle: fLib];
    375380       
     
    385390       
    386391        [GrowlApplicationBridge setGrowlDelegate: self];
    387        
    388         [[UKKQueue sharedFileWatcher] setDelegate: self];
    389392       
    390393        [[SUUpdater sharedUpdater] setDelegate: self];
     
    777780   
    778781    [fConfigDirectory release];
     782   
     783    [fFileWatcherQueue release];
    779784   
    780785    //complete cleanup
     
    29302935}
    29312936
    2932 - (void) watcher: (id<UKFileWatcher>) watcher receivedNotification: (NSString *) notification forPath: (NSString *) path
    2933 {
    2934     if ([notification isEqualToString: UKFileWatcherWriteNotification])
    2935     {
    2936         if (![fDefaults boolForKey: @"AutoImport"] || ![fDefaults stringForKey: @"AutoImportDirectory"])
    2937             return;
    2938        
    2939         if (fAutoImportTimer)
    2940         {
    2941             if ([fAutoImportTimer isValid])
    2942                 [fAutoImportTimer invalidate];
    2943             [fAutoImportTimer release];
    2944             fAutoImportTimer = nil;
    2945         }
    2946        
    2947         //check again in 10 seconds in case torrent file wasn't complete
    2948         fAutoImportTimer = [[NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
    2949             selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO] retain];
    2950        
    2951         [self checkAutoImportDirectory];
    2952     }
     2937-(void) VDKQueue: (VDKQueue *) queue receivedNotification: (NSString*) notification forPath: (NSString*) fpath
     2938{
     2939    NSParameterAssert([notification isEqualToString:VDKQueueWriteNotification]);NSLog(@"%@",notification);
     2940   
     2941    if (![fDefaults boolForKey: @"AutoImport"] || ![fDefaults stringForKey: @"AutoImportDirectory"])
     2942        return;
     2943   
     2944    if (fAutoImportTimer)
     2945    {
     2946        if ([fAutoImportTimer isValid])
     2947            [fAutoImportTimer invalidate];
     2948        [fAutoImportTimer release];
     2949        fAutoImportTimer = nil;
     2950    }
     2951   
     2952    //check again in 10 seconds in case torrent file wasn't complete
     2953    fAutoImportTimer = [[NSTimer scheduledTimerWithTimeInterval: 10.0 target: self
     2954        selector: @selector(checkAutoImportDirectory) userInfo: nil repeats: NO] retain];
     2955   
     2956    [self checkAutoImportDirectory];
    29532957}
    29542958
  • trunk/macosx/PrefsController.m

    r13492 r13804  
    3131#import "NSApplicationAdditions.h"
    3232#import "NSStringAdditions.h"
    33 #import "UKKQueue.h"
     33#import "VDKQueue.h"
    3434
    3535#import "transmission.h"
     
    109109        NSString * autoPath;
    110110        if ([fDefaults boolForKey: @"AutoImport"] && (autoPath = [fDefaults stringForKey: @"AutoImportDirectory"]))
    111             [[UKKQueue sharedFileWatcher] addPath: [autoPath stringByExpandingTildeInPath]];
     111            [[(Controller *)[NSApp delegate] fileWatcherQueue] addPath: [autoPath stringByExpandingTildeInPath] notifyingAbout: VDKQueueNotifyAboutWrite];
    112112       
    113113        //set blocklist scheduler
     
    925925    if ((path = [fDefaults stringForKey: @"AutoImportDirectory"]))
    926926    {
    927         path = [path stringByExpandingTildeInPath];
     927        VDKQueue * watcherQueue = [(Controller *)[NSApp delegate] fileWatcherQueue];
    928928        if ([fDefaults boolForKey: @"AutoImport"])
    929             [[UKKQueue sharedFileWatcher] addPath: path];
     929        {
     930            path = [path stringByExpandingTildeInPath];
     931            [watcherQueue addPath: path notifyingAbout: VDKQueueNotifyAboutWrite];
     932        }
    930933        else
    931             [[UKKQueue sharedFileWatcher] removePathFromQueue: path];
     934            [watcherQueue removeAllPaths];
    932935       
    933936        [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
     
    948951
    949952    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
    950         NSString * path = [fDefaults stringForKey: @"AutoImportDirectory"];
    951953        if (result == NSFileHandlingPanelOKButton)
    952954        {
    953             UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
    954             if (path)
    955                 [sharedQueue removePathFromQueue: [path stringByExpandingTildeInPath]];
     955            VDKQueue * watcherQueue = [(Controller *)[NSApp delegate] fileWatcherQueue];
     956            [watcherQueue removeAllPaths];
    956957           
    957             path = [[[panel URLs] objectAtIndex: 0] path];
     958            NSString * path = [[[panel URLs] objectAtIndex: 0] path];
    958959            [fDefaults setObject: path forKey: @"AutoImportDirectory"];
    959             [sharedQueue addPath: [path stringByExpandingTildeInPath]];
     960            [watcherQueue addPath: [path stringByExpandingTildeInPath] notifyingAbout: VDKQueueNotifyAboutWrite];
    960961           
    961962            [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
    962963        }
    963         else if (!path)
    964             [fDefaults setBool: NO forKey: @"AutoImport"];
     964        else
     965        {
     966            NSString * path = [fDefaults stringForKey: @"AutoImportDirectory"];
     967            if (!path)
     968                [fDefaults setBool: NO forKey: @"AutoImport"];
     969        }
    965970       
    966971        [fImportFolderPopUp selectItemAtIndex: 0];
Note: See TracChangeset for help on using the changeset viewer.