Changeset 1139

Show
Ignore:
Timestamp:
05/06/04 00:08:09 (5 years ago)
Author:
morris
Message:

mvoe timestamp from timer to just checking when chat comes in

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCChat.h

    r1120 r1139  
    1 /* $Id: WCChat.h,v 1.6 2004/04/01 12:18:59 morris Exp $ */ 
     1/* $Id: WCChat.h,v 1.7 2004/05/05 22:08:09 morris Exp $ */ 
    22 
    33/* 
     
    7474        unsigned int                                    _cid; 
    7575         
    76         NSTimer                                                 *_timestampTimer; 
    77         NSDate                                                  *_lastChat; 
     76        NSDate                                                  *_timestamp; 
    7877} 
    7978 
  • WiredClient/trunk/WCChat.m

    r1136 r1139  
    1 /* $Id: WCChat.m,v 1.26 2004/05/05 21:06:20 morris Exp $ */ 
     1/* $Id: WCChat.m,v 1.27 2004/05/05 22:08:09 morris Exp $ */ 
    22 
    33/* 
     
    6464        _sortedUsers    = [[NSArray alloc] init]; 
    6565         
     66        // --- initiate timestamp date 
     67        _timestamp              = [[NSDate dateWithTimeIntervalSinceNow:0] retain]; 
     68         
    6669        // --- subscribe to these 
    6770        [[NSNotificationCenter defaultCenter] 
     
    143146                object:NULL]; 
    144147         
    145         // --- ping at intervals 
    146         _timestampTimer = [NSTimer scheduledTimerWithTimeInterval:[[WCSettings objectForKey:WCTimestampChatInterval] doubleValue] 
    147                                                                                                            target:self 
    148                                                                                                          selector:@selector(timestampTimer:) 
    149                                                                                                          userInfo:NULL 
    150                                                                                                           repeats:YES]; 
    151         [_timestampTimer retain]; 
    152  
    153148        return self; 
    154149} 
     
    165160        [_commandHistory release]; 
    166161 
    167         [_timestampTimer release]; 
    168         [_lastChat release]; 
     162        [_timestamp release]; 
    169163         
    170164        [super dealloc]; 
     
    554548        WCConnection            *connection; 
    555549        WCUser                          *user; 
     550        NSDate                          *date; 
    556551        NSRange                         range; 
     552        double                          interval; 
    557553        int                                     i, length, offset; 
     554         
    558555         
    559556        // --- get objects 
     
    579576        if([user ignore]) 
    580577                return; 
     578         
     579        // --- insert a timestamp 
     580        interval = [[WCSettings objectForKey:WCTimestampChatInterval] doubleValue]; 
     581        date = [NSDate dateWithTimeIntervalSinceNow:0 - interval]; 
     582         
     583        if([date compare:_timestamp] == NSOrderedDescending) { 
     584                [self printEvent:[[NSDate date] localizedDateWithFormat:NSShortTimeDateFormatString]]; 
     585                 
     586                [_timestamp release]; 
     587                _timestamp = [NSDate date]; 
     588                [_timestamp retain]; 
     589        } 
    581590         
    582591        // --- lower the prepend offset a bit when using timestamps 
     
    653662        if([(NSString *) [WCSettings objectForKey:WCChatEventSound] length] > 0) 
    654663                [[NSSound soundNamed:[WCSettings objectForKey:WCChatEventSound]] play]; 
    655          
    656         // --- update timestamp 
    657         [_lastChat release]; 
    658         _lastChat = [[NSDate date] retain]; 
    659664} 
    660665 
     
    667672        NSMutableString         *format; 
    668673        NSRange                         range; 
     674        NSDate                          *date; 
    669675        WCConnection            *connection; 
    670676        WCUser                          *user; 
     677        double                          interval; 
    671678         
    672679        // --- get objects 
     
    692699        if([user ignore]) 
    693700                return; 
     701         
     702        // --- insert a timestamp 
     703        interval = [[WCSettings objectForKey:WCTimestampChatInterval] doubleValue]; 
     704        date = [NSDate dateWithTimeIntervalSinceNow:0 - interval]; 
     705         
     706        if([date compare:_timestamp] == NSOrderedDescending) { 
     707                [self printEvent:[[NSDate date] localizedDateWithFormat:NSShortTimeDateFormatString]]; 
     708                 
     709                [_timestamp release]; 
     710                _timestamp = [NSDate date]; 
     711                [_timestamp retain]; 
     712        } 
    694713         
    695714        // --- get nick 
     
    751770        if([(NSString *) [WCSettings objectForKey:WCChatEventSound] length] > 0) 
    752771                [[NSSound soundNamed:[WCSettings objectForKey:WCChatEventSound]] play]; 
    753          
    754         // --- update timestamp 
    755         [_lastChat release]; 
    756         _lastChat = [[NSDate date] retain]; 
    757772} 
    758773 
     
    13241339 
    13251340 
    1326 - (void)timestampTimer:(NSTimer *)timer { 
    1327         NSDate          *date; 
    1328         double          interval; 
    1329          
    1330         // --- get interval 
    1331         interval = [[WCSettings objectForKey:WCTimestampChatInterval] doubleValue]; 
    1332         date = [NSDate dateWithTimeIntervalSinceNow:0 - interval]; 
    1333          
    1334         // --- print a timed timestamp 
    1335         if([[WCSettings objectForKey:WCTimestampChat] boolValue]) { 
    1336                 if([date  compare:_lastChat] == NSOrderedAscending) 
    1337                         [self printEvent:[[NSDate date] localizedDateWithFormat:NSShortTimeDateFormatString]]; 
    1338         } 
    1339          
    1340         // --- re-schedule timer 
    1341         [timer setFireDate:[NSDate dateWithTimeIntervalSinceNow:interval]]; 
    1342 } 
    1343  
    1344  
    1345  
    13461341- (void)saveChatToURL:(NSURL *)url { 
    13471342        NSData          *data; 
  • WiredClient/trunk/WCPrivateChat.m

    r1120 r1139  
    1 /* $Id: WCPrivateChat.m,v 1.8 2004/04/01 12:18:59 morris Exp $ */ 
     1/* $Id: WCPrivateChat.m,v 1.9 2004/05/05 22:08:09 morris Exp $ */ 
    22 
    33/* 
     
    122122                @"%u", _cid]]; 
    123123         
    124         [_timestampTimer invalidate]; 
    125  
    126124        [_userListTableView setDataSource:NULL]; 
    127125 
  • WiredClient/trunk/WCPublicChat.m

    r1135 r1139  
    1 /* $Id: WCPublicChat.m,v 1.19 2004/05/05 16:46:14 morris Exp $ */ 
     1/* $Id: WCPublicChat.m,v 1.20 2004/05/05 22:08:09 morris Exp $ */ 
    22 
    33/* 
     
    190190                return; 
    191191                 
    192         [_timestampTimer invalidate]; 
    193  
    194192        [_userListTableView setDataSource:NULL]; 
    195193