# HG changeset patch # User Jens Alfke # Date 1208206728 25200 # Node ID 64823cdde6a50ba36265afbc8f31b1435c596c33 # Parent 8fad19466c59db99aa2c06d39cce13a5a75fa22a Minor improvements. diff -r 8fad19466c59 -r 64823cdde6a5 CollectionUtils.h --- a/CollectionUtils.h Sun Apr 06 19:13:27 2008 -0700 +++ b/CollectionUtils.h Mon Apr 14 13:58:48 2008 -0700 @@ -29,9 +29,9 @@ #define $sprintf(FORMAT, ARGS... ) [NSString stringWithFormat: (FORMAT), ARGS] -#define $cast(CLASSNAME,OBJ) (CLASSNAME*)(_cast([CLASSNAME class],(OBJ))) -#define $castNotNil(CLASSNAME,OBJ) (CLASSNAME*)(_castNotNil([CLASSNAME class],(OBJ))) -#define $castIf(CLASSNAME,OBJ) (CLASSNAME*)(_castIf([CLASSNAME class],(OBJ))) +#define $cast(CLASSNAME,OBJ) ((CLASSNAME*)(_cast([CLASSNAME class],(OBJ)))) +#define $castNotNil(CLASSNAME,OBJ) ((CLASSNAME*)(_castNotNil([CLASSNAME class],(OBJ)))) +#define $castIf(CLASSNAME,OBJ) ((CLASSNAME*)(_castIf([CLASSNAME class],(OBJ)))) #define $castArrayOf(ITEMCLASSNAME,OBJ) _castArrayOf([ITEMCLASSNAME class],(OBJ))) void setObj( id *var, id value ); diff -r 8fad19466c59 -r 64823cdde6a5 DateUtils.h --- a/DateUtils.h Sun Apr 06 19:13:27 2008 -0700 +++ b/DateUtils.h Mon Apr 14 13:58:48 2008 -0700 @@ -11,9 +11,16 @@ #ifdef __cplusplus extern "C" { #endif + + + /** Absolute time (since 'reference date') to NSDate. 0.0 -> nil. */ + NSDate* $date( CFAbsoluteTime ); + + /** NSDate to absolute time (since 'reference date'). nil -> 0.0 */ + CFAbsoluteTime $time( NSDate* ); -NSTimeInterval TimeIntervalSinceBoot(void); + NSTimeInterval TimeIntervalSinceBoot(void); #ifdef __cplusplus diff -r 8fad19466c59 -r 64823cdde6a5 DateUtils.m --- a/DateUtils.m Sun Apr 06 19:13:27 2008 -0700 +++ b/DateUtils.m Mon Apr 14 13:58:48 2008 -0700 @@ -15,6 +15,22 @@ #include +/** Absolute time (since 'reference date') to NSDate. 0.0 -> nil. */ +NSDate* $date( CFAbsoluteTime time ) +{ + CAssert(time>=0.0 && time < 1.0e15, @"Bogus timestamp %g",time); + return time ?[NSDate dateWithTimeIntervalSinceReferenceDate: time] :nil; +} + + +/** NSDate to absolute time (since 'reference date'). nil -> 0.0 */ +CFAbsoluteTime $time( NSDate* date ) +{ + return date ?[date timeIntervalSinceReferenceDate] :0.0; +} + + + NSTimeInterval TimeIntervalSinceBoot(void) { // From http://developer.apple.com/qa/qa2004/qa1398.html diff -r 8fad19466c59 -r 64823cdde6a5 IChatUtils.m --- a/IChatUtils.m Sun Apr 06 19:13:27 2008 -0700 +++ b/IChatUtils.m Mon Apr 14 13:58:48 2008 -0700 @@ -36,19 +36,21 @@ if( chats.count==0 ) return nil; iChatTextChat *chat = [chats objectAtIndex: 0]; - if( ! chat.active ) - return nil; + /*if( ! chat.active ) // somehow this returns NO for Bonjour chats + return nil;*/ return chat; } + (NSString*) activeChatPartner { iChatTextChat *chat = [self activeChat]; + Log(@"Active chat = %@",chat); if( ! chat ) return nil; NSMutableArray *names = $marray(); for( iChatBuddy *b in [chat participants] ) [names addObject: (b.fullName ?: b.name)]; + Log(@"Particpants = %@",names); return [names componentsJoinedByString: @", "]; }