Changeset 4775

Show
Ignore:
Timestamp:
05/19/07 17:13:28 (2 years ago)
Author:
morris
Message:

Bring back partially written messages/broadcasts/news posts after hiding and unhiding a connection

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCAccountEditor.m

    r4439 r4775  
    308308- (void)connectionWillTerminate:(NSNotification *)notification { 
    309309        [self close]; 
     310         
     311        [super connectionWillTerminate:notification]; 
    310312} 
    311313 
  • WiredClient/trunk/WCAccounts.m

    r4439 r4775  
    273273        [self close]; 
    274274        [self autorelease]; 
     275         
     276        [super connectionWillTerminate:notification]; 
    275277} 
    276278 
  • WiredClient/trunk/WCConnectionController.h

    r4466 r4775  
    4444- (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate; 
    4545- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate; 
     46- (void)connectionWillTerminate:(NSNotification *)notification; 
     47- (void)connectionDidTerminate:(NSNotification *)notification; 
     48- (void)serverConnectionShouldHide:(NSNotification *)notification; 
     49- (void)serverConnectionShouldUnhide:(NSNotification *)notification; 
    4650 
    4751- (void)setName:(NSString *)name; 
  • WiredClient/trunk/WCConnectionController.m

    r4466 r4775  
    116116 
    117117 
    118 - (void)_connectionWillTerminate:(NSNotification *)notification { 
    119         [self _saveWindowTemplate]; 
    120 } 
    121  
    122  
    123  
    124 - (void)_connectionDidTerminate:(NSNotification *)notification { 
    125         [_connection removeObserver:self]; 
    126         _connection = NULL; 
    127 } 
    128  
    129  
    130  
    131 - (void)_serverConnectionShouldHide:(NSNotification *)notification { 
    132         NSWindow        *sheet; 
    133                  
    134         _wasVisible = [[self window] isVisible]; 
    135         _hidden = YES; 
    136          
    137         if(_wasVisible) { 
    138                 sheet = [[self window] attachedSheet]; 
    139                  
    140                 if(sheet) 
    141                         [NSApp endSheet:sheet returnCode:NSAlertAlternateReturn]; 
    142                  
    143                 [[self window] orderOut:self]; 
    144         } 
    145 } 
    146  
    147  
    148  
    149 - (void)_serverConnectionShouldUnhide:(NSNotification *)notification { 
    150         if(_wasVisible) 
    151                 [[self window] orderFront:self]; 
    152                  
    153         _hidden = NO; 
    154 } 
    155  
    156  
    157  
    158118 
    159119- (void)_disconnectSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
     
    185145 
    186146        [_connection addObserver:self 
     147                                        selector:@selector(connectionWillTerminate:) 
     148                                                name:WCConnectionWillTerminate]; 
     149 
     150        [_connection addObserver:self 
     151                                        selector:@selector(connectionDidTerminate:) 
     152                                                name:WCConnectionDidTerminate]; 
     153 
     154        [_connection addObserver:self 
     155                                        selector:@selector(serverConnectionShouldHide:) 
     156                                                name:WCServerConnectionShouldHide]; 
     157         
     158        [_connection addObserver:self 
     159                                        selector:@selector(serverConnectionShouldUnhide:) 
     160                                                name:WCServerConnectionShouldUnhide]; 
     161 
     162        [_connection addObserver:self 
    187163                                        selector:@selector(_serverConnectionShouldLoadWindowTemplate:) 
    188164                                                name:WCServerConnectionShouldLoadWindowTemplate]; 
     
    192168                                                name:WCServerConnectionShouldSaveWindowTemplate]; 
    193169 
    194         [_connection addObserver:self 
    195                                         selector:@selector(_connectionWillTerminate:) 
    196                                                 name:WCConnectionWillTerminate]; 
    197  
    198         [_connection addObserver:self 
    199                                         selector:@selector(_connectionDidTerminate:) 
    200                                                 name:WCConnectionDidTerminate]; 
    201  
    202         [_connection addObserver:self 
    203                                         selector:@selector(_serverConnectionShouldHide:) 
    204                                                 name:WCServerConnectionShouldHide]; 
    205          
    206         [_connection addObserver:self 
    207                                         selector:@selector(_serverConnectionShouldUnhide:) 
    208                                                 name:WCServerConnectionShouldUnhide]; 
    209  
    210170        if([self respondsToSelector:@selector(connectionDidConnect:)]) { 
    211171                [_connection addObserver:self 
     
    218178                                                selector:@selector(connectionDidClose:) 
    219179                                                        name:WCConnectionDidClose]; 
    220         } 
    221  
    222         if([self respondsToSelector:@selector(connectionWillTerminate:)]) { 
    223                 [_connection addObserver:self 
    224                                                 selector:@selector(connectionWillTerminate:) 
    225                                                         name:WCConnectionWillTerminate]; 
    226         } 
    227          
    228         if([self respondsToSelector:@selector(connectionDidTerminate:)]) { 
    229                 [_connection addObserver:self 
    230                                                 selector:@selector(connectionDidTerminate:) 
    231                                                         name:WCConnectionDidTerminate]; 
    232180        } 
    233181         
     
    299247 
    300248- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate { 
     249} 
     250 
     251 
     252 
     253- (void)connectionWillTerminate:(NSNotification *)notification { 
     254        [self _saveWindowTemplate]; 
     255} 
     256 
     257 
     258 
     259- (void)connectionDidTerminate:(NSNotification *)notification { 
     260        [_connection removeObserver:self]; 
     261        _connection = NULL; 
     262} 
     263 
     264 
     265 
     266- (void)serverConnectionShouldHide:(NSNotification *)notification { 
     267        NSWindow        *sheet; 
     268                 
     269        _wasVisible = [[self window] isVisible]; 
     270        _hidden = YES; 
     271         
     272        if(_wasVisible) { 
     273                sheet = [[self window] attachedSheet]; 
     274                 
     275                if(sheet) 
     276                        [NSApp endSheet:sheet returnCode:NSAlertAlternateReturn]; 
     277                 
     278                [[self window] orderOut:self]; 
     279        } 
     280} 
     281 
     282 
     283 
     284- (void)serverConnectionShouldUnhide:(NSNotification *)notification { 
     285        if(_wasVisible) 
     286                [[self window] orderFront:self]; 
     287                 
     288        _hidden = NO; 
    301289} 
    302290 
  • WiredClient/trunk/WCConsole.m

    r4439 r4775  
    150150        [self close]; 
    151151        [self autorelease]; 
     152         
     153        [super connectionWillTerminate:notification]; 
    152154} 
    153155 
  • WiredClient/trunk/WCDock.m

    r4751 r4775  
    329329        selector = [item action]; 
    330330         
    331         if(selector == @selector(hideConnection:) || 
    332            selector == @selector(nextConnection:) || 
    333            selector == @selector(previousConnection:)) 
     331        if(selector == @selector(hideConnection:)) 
     332                return [[[NSApp keyWindow] windowController] isKindOfClass:[WCConnectionController class]]; 
     333        else if(selector == @selector(nextConnection:) || 
     334                        selector == @selector(previousConnection:)) 
    334335                return ([_shownConnections count] > 0); 
    335336        else if(selector == @selector(disconnect:)) 
  • WiredClient/trunk/WCFileInfo.m

    r4481 r4775  
    214214- (void)connectionWillTerminate:(NSNotification *)notification { 
    215215        [self close]; 
     216         
     217        [super connectionWillTerminate:notification]; 
    216218} 
    217219 
  • WiredClient/trunk/WCFiles.m

    r4466 r4775  
    473473- (void)connectionWillTerminate:(NSNotification *)notification { 
    474474        [self close]; 
     475         
     476        [super connectionWillTerminate:notification]; 
    475477} 
    476478 
  • WiredClient/trunk/WCMessages.h

    r4481 r4775  
    6666        unsigned int                                            _unread; 
    6767         
     68        WCUser                                                          *_messageUser; 
     69         
    6870        WIDateFormatter                                         *_tableDateFormatter; 
    6971        WIDateFormatter                                         *_dialogDateFormatter; 
     72         
     73        NSString                                                        *_hiddenMessage; 
     74        NSString                                                        *_hiddenBroadcast; 
    7075} 
    7176 
     
    7883 
    7984- (void)showPrivateMessageToUser:(WCUser *)user; 
     85- (void)showPrivateMessageToUser:(WCUser *)user message:(NSString *)message; 
     86- (void)showBroadcast:(NSString *)broadcast; 
    8087- (unsigned int)numberOfUnreadMessages; 
    8188 
  • WiredClient/trunk/WCMessages.m

    r4751 r4775  
    569569        [self close]; 
    570570        [self autorelease]; 
     571         
     572        [super connectionWillTerminate:notification]; 
    571573} 
    572574 
     
    583585 
    584586        [self _validate]; 
     587} 
     588 
     589 
     590 
     591- (void)serverConnectionShouldHide:(NSNotification *)notification { 
     592        NSWindow        *sheet; 
     593         
     594        sheet = [[self window] attachedSheet]; 
     595         
     596        if(sheet == _replyPanel) 
     597                _hiddenMessage = [[_replyTextView string] copy]; 
     598        else if(sheet == _broadcastPanel) 
     599                _hiddenBroadcast = [[_broadcastTextView string] copy]; 
     600         
     601        [super serverConnectionShouldHide:notification]; 
     602} 
     603 
     604 
     605 
     606- (void)serverConnectionShouldUnhide:(NSNotification *)notification { 
     607        [super serverConnectionShouldUnhide:notification]; 
     608         
     609        if(_hiddenMessage) { 
     610                [self showPrivateMessageToUser:_messageUser message:_hiddenMessage]; 
     611                 
     612                [_hiddenMessage release]; 
     613                _hiddenMessage = NULL; 
     614        } 
     615        else if(_hiddenBroadcast) { 
     616                [self showBroadcast:_hiddenBroadcast]; 
     617                 
     618                [_hiddenBroadcast release]; 
     619                _hiddenBroadcast = NULL; 
     620        } 
    585621} 
    586622 
     
    804840 
    805841- (void)showPrivateMessageToUser:(WCUser *)user { 
    806         [_userTextField setStringValue:[user nick]]; 
     842        [self showPrivateMessageToUser:user message:@""]; 
     843
     844 
     845 
     846 
     847- (void)showPrivateMessageToUser:(WCUser *)user message:(NSString *)message { 
     848        [user retain]; 
     849        [_messageUser release]; 
     850        _messageUser = user; 
     851         
     852        [_userTextField setStringValue:[_messageUser nick]]; 
     853 
     854        [_replyTextView setString:message]; 
    807855         
    808856        [self showWindow:self]; 
     
    812860                modalDelegate:self 
    813861           didEndSelector:@selector(replySheetDidEnd:returnCode:contextInfo:) 
    814                   contextInfo:[user retain]]; 
    815 
    816  
    817  
    818  
    819 - (void)showPrivateMessageReply { 
    820         if([_replyButton isEnabled]) 
    821                 [self reply:self]; 
    822 
    823  
    824  
    825  
    826 - (unsigned int)numberOfUnreadMessages { 
    827         return _unread; 
    828 
    829  
    830  
    831  
    832 #pragma mark - 
    833  
    834 - (IBAction)broadcast:(id)sender { 
     862                  contextInfo:NULL]; 
     863
     864 
     865 
     866 
     867- (void)showBroadcast:(NSString *)broadcast { 
    835868        [self showWindow:self]; 
     869 
     870        [_broadcastTextView setString:broadcast]; 
    836871         
    837872        [NSApp beginSheet:_broadcastPanel 
     
    844879 
    845880 
     881- (unsigned int)numberOfUnreadMessages { 
     882        return _unread; 
     883} 
     884 
     885 
     886 
     887#pragma mark - 
     888 
     889- (IBAction)broadcast:(id)sender { 
     890        [self showBroadcast:@""]; 
     891} 
     892 
     893 
     894 
    846895- (void)broadcastSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    847896        if(returnCode == NSAlertDefaultReturn) 
     
    862911                return; 
    863912         
    864         [_userTextField setStringValue:[[message user] nick]]; 
    865          
    866         [NSApp beginSheet:_replyPanel 
    867            modalForWindow:[self window] 
    868                 modalDelegate:self 
    869            didEndSelector:@selector(replySheetDidEnd:returnCode:contextInfo:) 
    870                   contextInfo:[[message user] retain]]; 
     913        [self showPrivateMessageToUser:[message user]]; 
    871914} 
    872915 
     
    874917 
    875918- (void)replySheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { 
    876         WCUser                  *user = (WCUser *) contextInfo; 
    877919        WCMessage               *message; 
    878920        WCConversation  *conversation; 
    879921         
    880922        if(returnCode == NSAlertDefaultReturn) { 
    881                 message = [WCMessage messageToUser:user string:[[[_replyTextView string] copy] autorelease]]; 
     923                message = [WCMessage messageToUser:_messageUser string:[[[_replyTextView string] copy] autorelease]]; 
    882924                [_allMessages addObject:message]; 
    883925                 
    884                 conversation = [WCConversation messageConversationWithUser:user]; 
     926                conversation = [WCConversation messageConversationWithUser:_messageUser]; 
    885927 
    886928                if(![_conversations containsObject:conversation]) 
     
    899941        [_replyPanel close]; 
    900942        [_replyTextView setString:@""]; 
     943         
     944        [_messageUser release]; 
    901945} 
    902946 
  • WiredClient/trunk/WCNews.h

    r4481 r4775  
    4343        WIDateFormatter                                 *_dateFormatter; 
    4444        unsigned int                                    _unread; 
     45         
     46        NSString                                                *_hiddenNews; 
    4547} 
    4648 
     
    5254+ (id)newsWithConnection:(WCServerConnection *)connection; 
    5355 
     56- (void)showPost:(NSString *)post; 
    5457- (unsigned int)numberOfUnreadPosts; 
    5558 
  • WiredClient/trunk/WCNews.m

    r4751 r4775  
    226226        [self close]; 
    227227        [self autorelease]; 
     228         
     229        [super connectionWillTerminate:notification]; 
    228230} 
    229231 
     
    247249- (void)serverConnectionPrivilegesDidChange:(NSNotification *)notification { 
    248250        [self _validate]; 
     251} 
     252 
     253 
     254 
     255- (void)serverConnectionShouldHide:(NSNotification *)notification { 
     256        NSWindow        *sheet; 
     257         
     258        sheet = [[self window] attachedSheet]; 
     259         
     260        if(sheet == _postPanel) 
     261                _hiddenNews = [[_postTextView string] copy]; 
     262         
     263        [super serverConnectionShouldHide:notification]; 
     264} 
     265 
     266 
     267 
     268- (void)serverConnectionShouldUnhide:(NSNotification *)notification { 
     269        [super serverConnectionShouldUnhide:notification]; 
     270         
     271        if(_hiddenNews) { 
     272                [self showPost:_hiddenNews]; 
     273                 
     274                [_hiddenNews release]; 
     275                _hiddenNews = NULL; 
     276        } 
    249277} 
    250278 
     
    336364#pragma mark - 
    337365 
    338 - (unsigned int)numberOfUnreadPosts { 
    339         return _unread; 
    340 
    341  
    342  
    343  
    344 #pragma mark - 
    345  
    346 - (IBAction)postNews:(id)sender { 
     366- (void)showPost:(NSString *)post { 
    347367        [self showWindow:self]; 
     368         
     369        [_postTextView setString:post]; 
    348370 
    349371        [NSApp beginSheet:_postPanel 
     
    352374           didEndSelector:@selector(postSheetDidEnd:returnCode:contextInfo:) 
    353375                  contextInfo:NULL]; 
     376} 
     377 
     378 
     379 
     380- (unsigned int)numberOfUnreadPosts { 
     381        return _unread; 
     382} 
     383 
     384 
     385 
     386#pragma mark - 
     387 
     388- (IBAction)postNews:(id)sender { 
     389        [self showPost:@""]; 
    354390} 
    355391 
  • WiredClient/trunk/WCPreview.m

    r4439 r4775  
    409409- (void)connectionWillTerminate:(NSNotification *)notification { 
    410410        [self close]; 
     411         
     412        [super connectionWillTerminate:notification]; 
    411413} 
    412414 
  • WiredClient/trunk/WCPrivateChat.m

    r4439 r4775  
    122122- (void)connectionWillTerminate:(NSNotification *)notification { 
    123123        [self close]; 
     124         
     125        [super connectionWillTerminate:notification]; 
    124126} 
    125127 
  • WiredClient/trunk/WCPublicChat.m

    r4751 r4775  
    331331 
    332332        [self autorelease]; 
     333         
     334        [super connectionWillTerminate:notification]; 
    333335} 
    334336 
  • WiredClient/trunk/WCSearch.m

    r4439 r4775  
    171171        [self close]; 
    172172        [self autorelease]; 
     173         
     174        [super connectionWillTerminate:notification]; 
    173175} 
    174176 
  • WiredClient/trunk/WCServerConnection.m

    r4752 r4775  
    927927 
    928928- (void)triggerEvent:(int)tag info1:(id)info1 info2:(id)info2 { 
    929         NSDictionary            *event, *userInfo; 
     929        NSMutableDictionary     *userInfo; 
     930        NSDictionary            *event; 
    930931         
    931932        event = [WCSettings eventForTag:tag]; 
    932         userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 
    933                 self,   WCServerConnectionEventConnectionKey, 
    934                 info1,  WCServerConnectionEventInfo1Key, 
    935                 info2,  WCServerConnectionEventInfo2Key, 
    936                 NULL]; 
     933        userInfo = [NSMutableDictionary dictionaryWithObject:self forKey:WCServerConnectionEventConnectionKey]; 
     934         
     935        if(info1) 
     936                [userInfo setObject:info1 forKey:WCServerConnectionEventInfo1Key]; 
     937         
     938        if(info2) 
     939                [userInfo setObject:info2 forKey:WCServerConnectionEventInfo2Key]; 
    937940         
    938941        [self postNotificationName:WCServerConnectionTriggeredEvent object:event userInfo:userInfo]; 
  • WiredClient/trunk/WCServerInfo.m

    r4481 r4775  
    230230         
    231231        [self autorelease]; 
     232         
     233        [super connectionWillTerminate:notification]; 
    232234} 
    233235 
  • WiredClient/trunk/WCTransfers.m

    r4756 r4775  
    11571157        [self close]; 
    11581158        [self autorelease]; 
     1159         
     1160        [super connectionWillTerminate:notification]; 
    11591161} 
    11601162 
  • WiredClient/trunk/WCUserInfo.m

    r4481 r4775  
    247247- (void)connectionWillTerminate:(NSNotification *)notification { 
    248248        [self close]; 
     249         
     250        [super connectionWillTerminate:notification]; 
    249251} 
    250252