⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseimcontainer.mm

📁 lumaqq
💻 MM
📖 第 1 页 / 共 3 页
字号:
/* * LumaQQ - Cross platform QQ client, special edition for Mac * * Copyright (C) 2007 luma <stubma@163.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 0 2111-1307 USA */#import "BaseIMContainer.h"#import "NSData-BytesOperation.h"#import "ByteTool.h"#import "MainWindowController.h"#import "AlertTool.h"#import "PreferenceCache.h"#import "Constants.h"#import "FontTool.h"#import "FaceSelectorDataSource.h"#import "FileTool.h"#import "ScreenscrapHelper.h"#import "TextTool.h"@implementation BaseIMContainer#pragma mark -#pragma mark IMContainer protocol- (NSString*)canSend {	// get picture count and screenscrap count	int count = [TextTool customFaceCount:[m_txtInput textStorage] type:kFaceTypeScreenscrap];	count += [TextTool customFaceCount:[m_txtInput textStorage] type:kFaceTypePicture];		// if count > 2, forbid sending	if(count > 1)		return L(@"LQWarningTooManyPicture", @"BaseIMContainer");	else		return nil;}- (IBAction)send:(id)sender {	if([[m_txtInput textStorage] length] == 0) {		// no more sheet hint now because it's a little boring		// if need it, uncomment them//		[AlertTool showWarning:[m_imView window]//					   message:L(@"LQWarningEmptyMessage", @"BaseIMContainer")];	} else {		// can send?		NSString* msg = [self canSend];		if(msg != nil) {			[AlertTool showWarning:[m_imView window]						   message:msg];			return;		}				// create SentIM		NSDate* date = [NSDate date];		SentIM* sentIM = [[[SentIM alloc] initWithTime:[date timeIntervalSince1970]											   message:[[[m_txtInput textStorage] copyWithZone:nil] autorelease]] autorelease];				// add to history		[m_history addSentIM:sentIM];				// add message to send queue		[m_sendQueue addObject:[sentIM message]];				// append hint		[self appendMessageHint:[[m_mainWindowController me] nick]						   date:date					 attributes:m_myHintAttributes];				// add to output		[[m_txtOutput textStorage] appendAttributedString:[sentIM message]];		[m_txtOutput scrollRangeToVisible:NSMakeRange([[m_txtOutput textStorage] length], 0)];				// clear input		[m_txtInput setString:kStringEmpty];				// send		if(!m_sending)			[self sendNextMessage];	}}- (id)initWithObject:(id)obj mainWindow:(MainWindowController*)mainWindowController {	self = [super init];	if(self) {		m_obj = [obj retain];		m_mainWindowController = [mainWindowController retain];		m_sendQueue = [[NSMutableArray array] retain];		m_sending = NO;		m_formatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:NO];		m_faceWaitingList = [[NSMutableDictionary dictionary] retain];		m_faceSendingList = [[NSMutableDictionary dictionary] retain];		m_objectController = [[NSObjectController alloc] initWithContent:self];				NSFont* font = [NSFont fontWithName:@"Helvetica" size:[NSFont systemFontSize]];		m_myHintAttributes = [[NSMutableDictionary dictionary] retain];		[m_myHintAttributes setObject:font forKey:NSFontAttributeName];		[m_myHintAttributes setObject:[NSColor colorWithCalibratedRed:0 green:0.51 blue:0.26 alpha:1.0] forKey:NSForegroundColorAttributeName];				m_otherHintAttributes = [[NSMutableDictionary dictionary] retain];		[m_otherHintAttributes setObject:font forKey:NSFontAttributeName];		[m_otherHintAttributes setObject:[NSColor blueColor] forKey:NSForegroundColorAttributeName];				m_errorHintAttributes = [[NSMutableDictionary dictionary] retain];		[m_errorHintAttributes setObject:font forKey:NSFontAttributeName];		[m_errorHintAttributes setObject:[NSColor grayColor] forKey:NSForegroundColorAttributeName];				// get history		m_history = [[[m_mainWindowController historyManager] getHistoryToday:[self owner]] retain];				// add observer		[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleWindowWillClose:)													 name:NSWindowWillCloseNotification												   object:nil];			[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleHistoryDidSelected:)													 name:kHistoryDidSelectedNotificationName												   object:nil];				[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleCustomFaceDidReceived:)													 name:kCustomFaceDidReceivedNotificationName												   object:nil];			[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleCustomFaceFailedToReceive:)													 name:kCustomFaceFailedToReceiveNotificationName												   object:nil];			[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleCustomFaceDidSent:)													 name:kCustomFaceDidSentNotificationName												   object:nil];		[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleCustomFaceListFailedToSend:)													 name:kCustomFaceListFailedToSendNotificationName												   object:nil];		[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleIMContainerAttachedToWindow:)													 name:kIMContainerAttachedToWindowNotificationName												   object:nil];		[[NSNotificationCenter defaultCenter] addObserver:self												 selector:@selector(handleModelMessageCountChanged:)													 name:kModelMessageCountChangedNotificationName												   object:nil];	}	return self;}- (id)windowKey {	NSException* e = [NSException exceptionWithName:@"Method Not Implemented"											 reason:@"Must Implement owner Method"										   userInfo:nil];	[e raise];	return nil;}- (id)model {	return m_obj;}- (int)pendingMessageCount {	return [m_sendQueue count];}- (NSString*)owner {	NSException* e = [NSException exceptionWithName:@"Method Not Implemented"											 reason:@"Must Implement owner Method"										   userInfo:nil];	[e raise];	return nil;}- (NSImage*)ownerImage {	NSException* e = [NSException exceptionWithName:@"Method Not Implemented"											 reason:@"Must Implement owner Method"										   userInfo:nil];	[e raise];	return nil;}- (void)refreshHeadControl:(HeadControl*)headControl {}- (IBAction)showOwnerInfo:(id)sender {	}- (BOOL)handleQQEvent:(QQNotification*)event {	return NO;}- (BOOL)accept:(InPacket*)packet {	return NO;}- (void)walkMessageQueue:(MessageQueue*)queue {}- (NSArray*)actionIds {	if(m_actionIds == nil) {		m_actionIds = [[NSArray arrayWithObjects:kToolbarItemFont, 			kToolbarItemColor, 			NSToolbarSeparatorItemIdentifier,			kToolbarItemSmiley,			NSToolbarSeparatorItemIdentifier,			kToolbarItemSendPicture,			kToolbarItemScreenscrap,			nil] retain];	}	return m_actionIds;}- (void)performAction:(NSString*)actionId {	if([actionId isEqualToString:kToolbarItemFont])		[self onFont:self];	else if([actionId isEqualToString:kToolbarItemColor])		[self onColor:self];	else if([actionId isEqualToString:kToolbarItemSmiley])		[self onSmiley:self];	else if([actionId isEqualToString:kToolbarItemSendPicture])		[self onSendPicture:self];	else if([actionId isEqualToString:kToolbarItemScreenscrap])		[self onScreenscrap:self];}- (NSImage*)actionImage:(NSString*)actionId {	if([actionId isEqualToString:kToolbarItemFont])		return [NSImage imageNamed:kImageFont];	else if([actionId isEqualToString:kToolbarItemColor])		return [NSImage imageNamed:kImageColor];	else if([actionId isEqualToString:kToolbarItemSmiley])		return [NSImage imageNamed:kImageSmiley];	else if([actionId isEqualToString:kToolbarItemSendPicture])		return [NSImage imageNamed:kImageSendPicture];	else if([actionId isEqualToString:kToolbarItemScreenscrap])		return [NSImage imageNamed:kImageScreenscrap];	else		return nil;}- (NSString*)actionTooltip:(NSString*)actionId {	if([actionId isEqualToString:kToolbarItemFont])		return L(@"LQTooltipFont", @"BaseIMContainer");	else if([actionId isEqualToString:kToolbarItemColor])		return L(@"LQTooltipColor", @"BaseIMContainer");	else if([actionId isEqualToString:kToolbarItemSmiley])		return L(@"LQTooltipFace", @"BaseIMContainer");	else if([actionId isEqualToString:kToolbarItemSendPicture])		return L(@"LQTooltipSendPicture", @"BaseIMContainer");	else if([actionId isEqualToString:kToolbarItemScreenscrap])		return L(@"LQTooltipScreenscrap", @"BaseIMContainer");	else		return kStringEmpty;}- (NSToolbarItem*)actionItem:(NSString*)actionId {	if([actionId isEqualToString:NSToolbarSeparatorItemIdentifier])		return nil;	else if(![m_actionIds containsObject:actionId])		return nil;	else {		NSToolbarItem* item = [[NSToolbarItem alloc] initWithItemIdentifier:actionId];		[item setImage:[self actionImage:actionId]];		[item setToolTip:[self actionTooltip:actionId]];		return [item autorelease];	}}- (BOOL)allowCustomFace {	return YES;}- (NSString*)shortDescription {	return kStringEmpty;}#pragma mark -#pragma mark PSMTabModel protocol- (BOOL)isProcessing {	return NO;}- (void)setIsProcessing:(BOOL)value {	}- (NSImage*)icon {	return nil;}- (void)setIcon:(NSImage*)icon {	}- (NSString*)iconName {	return kStringEmpty;}- (void)setIconName:(NSString*)iconName {	}- (int)objectCount {	return 0;}- (void)setObjectCount:(int)value {	}- (NSObjectController*)controller {	return m_objectController;}#pragma mark -#pragma mark initialization- (void) dealloc {	[[NSNotificationCenter defaultCenter] removeObserver:self													name:NSWindowWillCloseNotification 												  object:nil];		[[NSNotificationCenter defaultCenter] removeObserver:self

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -