[zephyrchat-cvs] zchat/zChat ZCChatWindowController.mm,1.22,1.23
Status: Alpha
Brought to you by:
akosut
|
From: <ak...@us...> - 2003-04-03 18:08:38
|
Update of /cvsroot/zephyrchat/zchat/zChat
In directory sc8-pr-cvs1:/tmp/cvs-serv1867
Modified Files:
ZCChatWindowController.mm
Log Message:
Show instance when appropriate.
Correctly invite users chosen from pop-up menu.
Index: ZCChatWindowController.mm
===================================================================
RCS file: /cvsroot/zephyrchat/zchat/zChat/ZCChatWindowController.mm,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- ZCChatWindowController.mm 3 Apr 2003 17:21:21 -0000 1.22
+++ ZCChatWindowController.mm 3 Apr 2003 18:08:20 -0000 1.23
@@ -328,6 +328,7 @@
[self removeMyPing];
_myDisplayedPing = [self appendMessage:[self pingMessageWithColor:[ZChatApp textColorForMe]]
from:[ZChatApp mySignature]
+ instance:nil
color:[ZChatApp colorForMe]
textColor:[ZChatApp textColorForMe]
alignment:NSNaturalTextAlignment];
@@ -367,7 +368,7 @@
* for the next input.
*/
[self removeMyPing];
- [self appendMessage:[_input attributedStringValue] from:[ZChatApp mySignature]
+ [self appendMessage:[_input attributedStringValue] from:[ZChatApp mySignature] instance:nil
color:[ZChatApp colorForMe]
textColor:[ZChatApp textColorForMe]
alignment:NSNaturalTextAlignment];
@@ -463,6 +464,7 @@
[self removePingFrom:senderString];
NSRange pingRange = [self appendMessage:[self pingMessageWithColor:[ZChatApp textColorFor:senderString]]
from:[self displayNameFor:senderString]
+ instance:nil
color:[ZChatApp colorFor:senderString]
textColor:[ZChatApp textColorFor:senderString]
alignment:NSNaturalTextAlignment];
@@ -515,9 +517,21 @@
@selector(invitationSheetDidEnd:returnCode:contextInfo:), nil, invitation,
NSLocalizedString(@"INVITATION_MESSAGE", nil), displayName,
[ZChatSubscription titleForSub:invitation->dest]);
- } else {
+ } else {
+ NSString *instance;
+
+ if ((_chatWith->dest.instance == "*" || _chatWith->dest.instance == "")
+ && !strcaseequal(message.GetInstance(), "personal") && !strcaseequal(message.GetInstance(), "urgent")
+ && !strcaseequal(message.GetInstance(), "message") && message.GetInstance() != "*"
+ && message.GetInstance() != "") {
+ instance = [NSString stringWithSTLString:message.GetInstance()];
+ } else {
+ instance = nil;
+ }
+
[self appendMessage:formattedMessage
from:displayName
+ instance:instance
color:[ZChatApp colorFor:sender]
textColor:textColor
alignment:NSNaturalTextAlignment];
@@ -549,8 +563,8 @@
return _sentMessages->find(message.GetPacket().GetUID()) != _sentMessages->end();
}
-- (NSRange)appendMessage:(NSAttributedString *)message from:(NSString *)sender color:(NSColor *)bgColor
- textColor:(NSColor *)fgColor alignment:(NSTextAlignment)alignment {
+- (NSRange)appendMessage:(NSAttributedString *)message from:(NSString *)sender instance:(NSString *)instance
+ color:(NSColor *)bgColor textColor:(NSColor *)fgColor alignment:(NSTextAlignment)alignment {
NSTextStorage *text = [_output textStorage];
bool shouldScroll = [[[_output enclosingScrollView] verticalScroller] floatValue] == 1.0;
@@ -590,7 +604,7 @@
[text appendString:sender attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont boldSystemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName,
fgColor, NSForegroundColorAttributeName, nil]];
-
+
/* Add some space: If the message is multi-line, add a newline, otherwise just a space */
NSRange lineRange = [[message string] lineRangeForRange:NSMakeRange(0, 0)];
if (NSMaxRange(lineRange) != [message length]) {
@@ -598,7 +612,16 @@
} else {
[text appendString:@" " attributes:nil];
}
-
+
+ /* Add the instance (if present) */
+ if (instance != nil) {
+ [text appendString:[NSString stringWithFormat:NSLocalizedString(@"INSTANCE_DISPLAY_FORMAT", nil),
+ instance]
+ attributes:[NSDictionary dictionaryWithObjectsAndKeys:
+ [NSFont systemFontOfSize:[NSFont systemFontSize]], NSFontAttributeName,
+ fgColor, NSForegroundColorAttributeName, nil]];
+ }
+
/* Add the message */
[text appendAttributedString:message];
@@ -678,6 +701,12 @@
NSString *message;
NSAssert([user length] > 0, @"User must not be blank");
+
+ /* Use only the first word */
+ NSRange ws = [user rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]];
+ if (ws.location != NSNotFound) {
+ user = [user substringToIndex:ws.location];
+ }
if ([ZephyrUtils::RemoveRealm(user) rangeOfString:@"@"].location != NSNotFound) {
NSBeginAlertSheet(NSLocalizedString(@"INVITE_GALAXY_ERR_TITLE", nil), nil, nil, nil, [self window],
|