Changeset 2662

Show
Ignore:
Timestamp:
05/07/05 14:01:47 (3 years ago)
Author:
timothy
Message:

The rest of Thomas's transcript browser patch.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Colloquy.pch

    r2656 r2662  
    1515 
    1616#endif 
     17 
     18#ifdef MAC_OS_X_VERSION_10_4 
     19#include <sys/xattr.h> 
     20#endif 
     21 
     22// define these here so they weak link for Panther letting the binary be backwards compatible 
     23extern int fsetxattr(int fd, const char *name, const void *value, size_t size, u_int32_t position, int options) __attribute__((weak_import)); 
     24extern ssize_t fgetxattr(int fd, const char *name, void *value, size_t size, u_int32_t position, int options) __attribute__((weak_import)); 
  • trunk/Colloquy.xcode/project.pbxproj

    r2661 r2662  
    10801080                        sourceTree = "<group>"; 
    10811081                }; 
    1082                 1C3972DD082D30D200DCF3CF = { 
    1083                         fileRef = 1C3972DB082D30D200DCF3CF; 
    1084                         isa = PBXBuildFile; 
    1085                         settings = { 
    1086                         }; 
    1087                 }; 
    10881082                1C3972DE082D30D200DCF3CF = { 
    10891083                        fileRef = 1C3972DC082D30D200DCF3CF; 
     1084                        isa = PBXBuildFile; 
     1085                        settings = { 
     1086                        }; 
     1087                }; 
     1088                1C397368082D3ED000DCF3CF = { 
     1089                        children = ( 
     1090                                1C397369082D3ED000DCF3CF, 
     1091                        ); 
     1092                        isa = PBXVariantGroup; 
     1093                        name = JVChatTranscriptBrowserPanel.nib; 
     1094                        path = ""; 
     1095                        refType = 4; 
     1096                        sourceTree = "<group>"; 
     1097                }; 
     1098                1C397369082D3ED000DCF3CF = { 
     1099                        isa = PBXFileReference; 
     1100                        lastKnownFileType = wrapper.nib; 
     1101                        name = English; 
     1102                        path = Languages/English.lproj/JVChatTranscriptBrowserPanel.nib; 
     1103                        refType = 4; 
     1104                        sourceTree = "<group>"; 
     1105                }; 
     1106                1C39736A082D3ED000DCF3CF = { 
     1107                        fileRef = 1C397368082D3ED000DCF3CF; 
    10901108                        isa = PBXBuildFile; 
    10911109                        settings = { 
     
    25232541                                0AA8117B0826E08000A3BF2D, 
    25242542                                1C05F4560828727D006FCB72, 
     2543                                1C39736A082D3ED000DCF3CF, 
    25252544                        ); 
    25262545                        isa = PBXResourcesBuildPhase; 
     
    31953214                                1CB2CD86052DDC560094AAA4, 
    31963215                                1CF5F8DD07D537F70019DC13, 
    3197                                 1C3972DD082D30D200DCF3CF, 
    31983216                        ); 
    31993217                        isa = PBXCopyFilesBuildPhase; 
     
    55835601                                1CBECE3A0508D58F000001C8, 
    55845602                                1CBECE380508D58F000001C8, 
     5603                                1C397368082D3ED000DCF3CF, 
    55855604                                1C0A4C980799BDAF0093B702, 
    55865605                                1C0A4C9A0799BDAF0093B702, 
  • trunk/JVChatTranscript.h

    r2629 r2662  
    33@class JVChatEvent; 
    44@class JVChatSession; 
     5 
     6extern NSString *JVChatTranscriptUpdatedNotification; 
    57 
    68@protocol JVChatTranscriptElement 
  • trunk/JVChatTranscript.m

    r2629 r2662  
    1212#import <libxml/xinclude.h> 
    1313 
    14 #ifdef MAC_OS_X_VERSION_10_4 
    15 #include <sys/xattr.h> 
    16 #endif 
    17  
    18 // define this here so they weak link for Panther letting the binary will load 
    19 extern int fsetxattr(int fd, const char *name, const void *value, size_t size, u_int32_t position, int options) __attribute__((weak_import)); 
     14NSString *JVChatTranscriptUpdatedNotification = @"JVChatTranscriptUpdatedNotification"; 
    2015 
    2116#pragma mark - 
     
    946941        [self _changeFileAttributesAtPath:path]; 
    947942 
     943        [[NSNotificationCenter defaultCenter] postNotificationName:JVChatTranscriptUpdatedNotification object:self]; 
     944 
    948945        return ret; 
    949946} 
     
    963960                [xmlData release]; 
    964961 
    965                 if( [url isFileURL] ) [self _changeFileAttributesAtPath:[url path]]; 
     962                if( [url isFileURL] ) { 
     963                        [self _changeFileAttributesAtPath:[url path]]; 
     964                        [[NSNotificationCenter defaultCenter] postNotificationName:JVChatTranscriptUpdatedNotification object:self]; 
     965                } 
    966966        } 
    967967 
     
    11381138        [_logFile writeData:[@"</log>" dataUsingEncoding:NSUTF8StringEncoding]]; 
    11391139 
     1140        [[NSNotificationCenter defaultCenter] postNotificationName:JVChatTranscriptUpdatedNotification object:self]; 
     1141 
    11401142        xmlBufferFree( buf ); 
    11411143} 
  • trunk/JVChatTranscriptBrowserPanel.m

    r2661 r2662  
    2828-(NSString *)indexPath 
    2929{ 
    30         return [[self logsPath] stringByAppendingPathComponent:@"Logs Index"]; 
     30        return [[@"~/Library/Application Support/Colloquy" stringByExpandingTildeInPath] stringByAppendingPathComponent:@"Transcript Search Index"]; 
    3131} 
    3232 
    3333-(NSString *)dirtyPath 
    3434{ 
    35         return [[self logsPath] stringByAppendingPathComponent:@"Dirty Logs"]; 
     35        return [[@"~/Library/Application Support/Colloquy" stringByExpandingTildeInPath] stringByAppendingPathComponent:@"Dirty Transcripts"]; 
    3636} 
    3737 
     
    9696                                 
    9797#ifdef MAC_OS_X_VERSION_10_4 
    98                                 if (NSAppKitVersionNumber > NSAppKitVersionNumber10_3_5) 
    99                                 { 
     98                                if( floor( NSAppKitVersionNumber ) == NSAppKitVersionNumber10_3 ) { 
    10099                                        FILE* logsFile = fopen([path fileSystemRepresentation],"r"); 
    101100                                        if (logsFile) 
     
    106105                                                ssize_t size; 
    107106                                                 
    108                                                 if ((size=fgetxattr(fd,"server",buffer,1023,0,NULL))>0) 
     107                                                if ((size=fgetxattr(fd,"server",buffer,1023,0,0))>0) 
    109108                                                { 
    110109                                                        buffer[size]=0; 
     
    112111                                                } 
    113112                                                 
    114                                                 if ((size=fgetxattr(fd,"target",buffer,1023,0,NULL))>0) 
     113                                                if ((size=fgetxattr(fd,"target",buffer,1023,0,0))>0) 
    115114                                                { 
    116115                                                        buffer[size]=0; 
     
    118117                                                } 
    119118                                                 
    120                                                 if ((size=fgetxattr(fd,"dateBegan",buffer,1023,0,NULL))>0) 
     119                                                if ((size=fgetxattr(fd,"dateBegan",buffer,1023,0,0))>0) 
    121120                                                { 
    122121                                                        buffer[size]=0; 
     
    274273                        CFRange         resultRange = CFRangeMake(0, resultCount); 
    275274                         
    276                         //Read the results in LOG_RESULT_CLUMP_SIZE at a time 
    277275                        SKSearchResultsGetInfoInRange(results,resultRange,outDocumentsArray,NULL,outScoresArray); 
    278276                        int i; 
  • trunk/Languages/English.lproj/Colloquy.nib/classes.nib

    r2609 r2662  
    4343                showConnectionManager = id;  
    4444                showPreferences = id;  
     45                showTranscriptBrowser = id;  
    4546                showTransferManager = id;  
    4647            };  
  • trunk/Languages/English.lproj/Colloquy.nib/info.nib

    r2595 r2662  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>38 66 356 240 0 0 1024 746 </string> 
     6        <string>245 320 356 240 0 0 1280 832 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
    99                <key>29</key> 
    10                 <string>21 533 383 44 0 0 1024 746 </string> 
     10                <string>68 774 383 44 0 0 1280 832 </string> 
    1111        </dict> 
    1212        <key>IBFramework Version</key> 
     
    1414        <key>IBOldestOS</key> 
    1515        <integer>3</integer> 
     16        <key>IBOpenObjects</key> 
     17        <array> 
     18                <integer>29</integer> 
     19        </array> 
    1620        <key>IBSystem Version</key> 
    1721        <string>8A428</string> 
  • trunk/MVApplicationController.h

    r2602 r2662  
    11extern NSString *JVChatStyleInstalledNotification; 
    22extern NSString *JVChatEmoticonSetInstalledNotification; 
     3extern NSString *JVMachineBecameIdleNotification; 
     4extern NSString *JVMachineStoppedIdlingNotification; 
    35 
    4 @interface MVApplicationController : NSObject {} 
     6@class JVChatTranscriptBrowserPanel; 
     7 
     8@interface MVApplicationController : NSObject { 
     9        io_registry_entry_t _hidEntry; 
     10        NSTimer *_idleCheck; 
     11        NSTimeInterval _lastIdle; 
     12        BOOL _isIdle; 
     13
     14 
    515- (IBAction) checkForUpdate:(id) sender; 
    616- (IBAction) connectToSupportRoom:(id) sender; 
     
    1020- (IBAction) showPreferences:(id) sender; 
    1121- (IBAction) showTransferManager:(id) sender; 
     22- (IBAction) showTranscriptBrowser:(id) sender; 
    1223- (IBAction) showConnectionManager:(id) sender; 
    1324- (IBAction) showBuddyList:(id) sender; 
     
    1829 
    1930+ (BOOL) isTerminating; 
     31 
     32- (NSTimeInterval) idleTime; 
    2033@end 
    2134 
  • trunk/MVApplicationController.m

    r2655 r2662  
    2727#import "JVGetCommand.h" 
    2828#import "JVDirectChatPanel.h" 
     29#import "JVChatTranscriptBrowserPanel.h" 
    2930 
    3031#import <Foundation/NSDebug.h> 
     
    3839NSString *JVChatStyleInstalledNotification = @"JVChatStyleInstalledNotification"; 
    3940NSString *JVChatEmoticonSetInstalledNotification = @"JVChatEmoticonSetInstalledNotification"; 
     41NSString *JVMachineBecameIdleNotification = @"JVMachineBecameIdleNotification"; 
     42NSString *JVMachineStoppedIdlingNotification = @"JVMachineStoppedIdlingNotification"; 
     43 
    4044static BOOL applicationIsTerminating = NO; 
    4145 
    4246@implementation MVApplicationController 
     47- (id) init { 
     48        if( ( self = [super init] ) ) { 
     49                mach_port_t masterPort = 0; 
     50                kern_return_t err = IOMasterPort( MACH_PORT_NULL, &masterPort ); 
     51 
     52                io_iterator_t hidIter = 0; 
     53                err = IOServiceGetMatchingServices( masterPort, IOServiceMatching( "IOHIDSystem" ), &hidIter ); 
     54 
     55                _hidEntry = IOIteratorNext( hidIter ); 
     56                IOObjectRelease( hidIter ); 
     57 
     58                _isIdle = NO; 
     59                _lastIdle = 0.; 
     60                _idleCheck = [[NSTimer scheduledTimerWithTimeInterval:30. target:self selector:@selector( checkIdle: ) userInfo:nil repeats:YES] retain]; 
     61        } 
     62 
     63        return self; 
     64} 
     65 
     66- (void) dealloc { 
     67        if( _hidEntry ) { 
     68                IOObjectRelease( _hidEntry ); 
     69                _hidEntry = nil; 
     70        } 
     71 
     72        [super dealloc]; 
     73} 
     74 
     75#pragma mark - 
     76 
    4377+ (BOOL) isTerminating { 
    4478        extern BOOL applicationIsTerminating; 
    4579        return applicationIsTerminating; 
     80} 
     81 
     82#pragma mark - 
     83 
     84// idle stuff adapted from a post by Jonathan 'Wolf' Rentzsch on the cocoa-dev mailing list. 
     85 
     86- (NSTimeInterval) idleTime { 
     87        NSMutableDictionary *hidProperties = nil; 
     88        kern_return_t err = IORegistryEntryCreateCFProperties( _hidEntry, (CFMutableDictionaryRef *) &hidProperties, kCFAllocatorDefault, 0 ); 
     89 
     90        id hidIdleTimeObj = [hidProperties objectForKey:@"HIDIdleTime"]; 
     91        unsigned long long result; 
     92 
     93        if( [hidIdleTimeObj isKindOfClass:[NSData class]] ) [hidIdleTimeObj getBytes:&result]; 
     94        else result = [hidIdleTimeObj longLongValue]; 
     95 
     96        [hidProperties release]; 
     97 
     98        return ( result / 1000000000. ); 
     99} 
     100 
     101- (void) checkIdle:(id) sender { 
     102        NSTimeInterval idle = [self idleTime]; 
     103 
     104        if( _isIdle ) { 
     105                if( idle < _lastIdle ) { 
     106                        // no longer idle 
     107 
     108                        _isIdle = NO; 
     109                        [[NSNotificationCenter defaultCenter] postNotificationName:JVMachineStoppedIdlingNotification object:self userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:idle] forKey:@"idleTime"]]; 
     110 
     111                        // reschedule the timer, to check for idle every 30 seconds 
     112                        [_idleCheck invalidate]; 
     113                        [_idleCheck autorelease]; 
     114 
     115                        _idleCheck = [[NSTimer scheduledTimerWithTimeInterval:30. target:self selector:@selector( checkIdle: ) userInfo:nil repeats:YES] retain]; 
     116                } 
     117        } else { 
     118                if( idle > [[NSUserDefaults standardUserDefaults] integerForKey:@"JVIdleTime"] ) { 
     119                        // we're now idle 
     120 
     121                        _isIdle = YES; 
     122                        [[NSNotificationCenter defaultCenter] postNotificationName:JVMachineBecameIdleNotification object:self userInfo:[NSDictionary dictionaryWithObject:[NSNumber numberWithDouble:idle] forKey:@"idleTime"]]; 
     123 
     124                        // reschedule the timer, we will check every second to catch the user's return quickly 
     125                        [_idleCheck invalidate]; 
     126                        [_idleCheck autorelease]; 
     127 
     128                        _idleCheck = [[NSTimer scheduledTimerWithTimeInterval:1. target:self selector:@selector( checkIdle: ) userInfo:nil repeats:YES] retain]; 
     129                } 
     130        } 
     131 
     132        _lastIdle = idle; 
    46133} 
    47134 
     
    86173                [[MVConnectionsController defaultController] hideConnectionManager:nil]; 
    87174        else [[MVConnectionsController defaultController] showConnectionManager:nil]; 
     175} 
     176 
     177- (IBAction) showTranscriptBrowser:(id) sender { 
     178        [[JVChatTranscriptBrowserPanel sharedBrowser] showBrowser:self]; 
    88179} 
    89180 
     
    347438        [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[[NSBundle mainBundle] bundleIdentifier] ofType:@"plist"]]]; 
    348439        [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector( handleURLEvent:withReplyEvent: ) forEventClass:kInternetEventClass andEventID:kAEGetURL]; 
    349          
    350440#ifdef DEBUG 
    351441        NSDebugEnabled = YES; 
     
    396486        [MVFileTransferController defaultController]; 
    397487        [MVBuddyListController sharedBuddyList]; 
     488        [JVChatTranscriptBrowserPanel sharedBrowser]; 
    398489 
    399490        [[[[[[NSApplication sharedApplication] mainMenu] itemAtIndex:1] submenu] itemWithTag:20] setSubmenu:[MVConnectionsController favoritesMenu]]; 
  • trunk/Resources/cc.javelin.colloquy.plist

    r2435 r2662  
    6767        <key>MVChatNaturalActions</key> 
    6868        <false/> 
     69        <key>JVIdleTime</key> 
     70        <integer>300</integer> 
    6971        <key>JVChatServers</key> 
    7072        <array>