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

📄 mainqqlistener.mm

📁 lumaqq
💻 MM
📖 第 1 页 / 共 5 页
字号:
						case kQQClusterMessageAcceptNoPrompt:							
							// add to history
							[history addPacket:packet];
							break;
						case kQQClusterMessageAccept:
							[[m_main messageQueue] enqueue:packet];
							enqueued = YES;
							
							// add to history
							[history addPacket:packet];
							
							// increase message count
							[cluster increaseMessageCount];
							[[TimerTaskManager sharedManager] addTask:[ModelEffectTask taskWithMainWindow:m_main object:cluster]];
							
							// sound
							if([cache isEnableSound])
								[[SoundHelper shared] playSound:kLQSoundClusterMessage QQ:[m_me QQ]];
								
							// growl
							User* u = [m_groupManager user:[[packet clusterIM] sender]];
							if(u == nil)
								u = [[[User alloc] initWithQQ:[[packet clusterIM] sender] domain:m_main] autorelease];
							[[GrowlApplicationBridge growlDelegate] clusterIM:cluster
																		 user:u
																	   packet:packet
																   mainWindow:m_main];
							break;
						case kQQClusterMessageBlock:
							// play sound
							if([cache isEnableSound])
								[[SoundHelper shared] playSound:kLQSoundMessageBlocked QQ:[m_me QQ]];
							break;
					}	
				}
			}
			break;
		case kQQIMTypeRequestJoinCluster:
			if(![m_main shouldBlockRequest:[[packet clusterNotification] sourceQQ]]) {				
				// get history, add it to history
				History* history = [[m_main historyManager] getHistoryToday:@"10000"];
				[history addPacket:packet];
				
				// add to queue
				[[m_main messageQueue] enqueue:packet];
				enqueued = YES;
				
				// play sound
				if([cache isEnableSound])
					[[SoundHelper shared] playSound:kLQSoundSystemMessage QQ:[m_me QQ]];
				
				// growl
				[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			}
			break;
		case kQQIMTypeApprovedJoinCluster:			
			// get history, add it to history
			history = [[m_main historyManager] getHistoryToday:@"10000"];
			[history addPacket:packet];
			
			// add to queue
			[[m_main messageQueue] enqueue:packet];
			enqueued = YES;
			cluster = [m_groupManager cluster:[header sender]];
			if(cluster == nil) {
				cluster = [[Cluster alloc] initWithInternalId:[header sender] domain:m_main];
				[cluster setExternalId:[[packet clusterNotification] externalId]];
				[m_groupManager addCluster:cluster];
				[[m_main clusterOutline] reloadData];
				[[m_main client] getClusterInfo:[cluster internalId]];
				[cluster release];
			}
				
			// play sound
			if([cache isEnableSound])
				[[SoundHelper shared] playSound:kLQSoundGoodSystemMessage QQ:[m_me QQ]];
				
			// growl
			[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			break;
		case kQQIMTypeClusterCreated:			
			// get history, add it to history
			history = [[m_main historyManager] getHistoryToday:@"10000"];
			[history addPacket:packet];
			
			// add to queue
			[[m_main messageQueue] enqueue:packet];
			enqueued = YES;
			cluster = [m_groupManager cluster:[header sender]];
			if(cluster == nil) {
				cluster = [[Cluster alloc] initWithInternalId:[header sender] domain:m_main];
				[cluster setExternalId:[[packet clusterNotification] externalId]];
				[m_groupManager addCluster:cluster];
				[[m_main clusterOutline] reloadData];
				[[m_main client] getClusterInfo:[cluster internalId]];
				[cluster release];
			}
				
			// play sound
			if([cache isEnableSound])
				[[SoundHelper shared] playSound:kLQSoundSystemMessage QQ:[m_me QQ]];
				
			// growl
			[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			break;
		case kQQIMTypeRejectedJoinCluster:			
			// get history, add it to history
			history = [[m_main historyManager] getHistoryToday:@"10000"];
			[history addPacket:packet];
			
			// add to queue
			[[m_main messageQueue] enqueue:packet];
			enqueued = YES;
			
			// play sound
			if([cache isEnableSound])
				[[SoundHelper shared] playSound:kLQSoundBadSystemMessage QQ:[m_me QQ]];
			
			// growl
			[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			break;
		case kQQIMTypeJoinedCluster:			
			// get history, add it to history
			history = [[m_main historyManager] getHistoryToday:@"10000"];
			[history addPacket:packet];
			
			// add to queue
			[[m_main messageQueue] enqueue:packet];
			enqueued = YES;
			
			// ensure we have this cluster object
			ClusterNotification* n = [packet clusterNotification];
			if([n sourceQQ] == [m_me QQ]) {
				cluster = [m_groupManager cluster:[header sender]];
				if(cluster == nil) {
					cluster = [[Cluster alloc] initWithInternalId:[header sender] domain:m_main];
					[cluster setExternalId:[[packet clusterNotification] externalId]];
					[m_groupManager addCluster:cluster];
					[[m_main clusterOutline] reloadData];
					[[m_main client] getClusterInfo:[cluster internalId]];
					[cluster release];
				}
			}
				
			// play sound
			if([cache isEnableSound])
				[[SoundHelper shared] playSound:kLQSoundSystemMessage QQ:[m_me QQ]];
				
			// growl
			[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			break;
		case kQQIMTypeExitedCluster:			
			// get history, add it to history
			history = [[m_main historyManager] getHistoryToday:@"10000"];
			[history addPacket:packet];
			
			// add to queue
			[[m_main messageQueue] enqueue:packet];
			enqueued = YES;
			n = [packet clusterNotification];
			if([n sourceQQ] == [m_me QQ]) {
				cluster = [m_groupManager cluster:[header sender]];
				if(cluster) {
					[m_groupManager removeCluster:cluster];
					[[m_main clusterOutline] reloadData];
				}
			}
				
			// play sound
			if([cache isEnableSound])
				[[SoundHelper shared] playSound:kLQSoundSystemMessage QQ:[m_me QQ]];
				
			// growl
			[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
			break;
		case kQQIMTypeSystem:
			SystemIM* systemIM = [packet systemIM];
			switch([systemIM type]) {
				case kQQSystemIMTypeKickOut:
					// growl
					[[GrowlApplicationBridge growlDelegate] kickedOut:m_me];
					
					// restore from auto hide
					[m_main onRestoreFromAutoHide:self];
					
					// show alert
					[AlertTool showWarning:[m_main window]
									 title:L(@"LQWarning")
								   message:L(@"LQWarningKickedOut", @"MainWindow")
								  delegate:m_main
							didEndSelector:@selector(kickedOutAlertDidEnd:returnCode:contextInfo:)];
					
					// play sound
					if([cache isEnableSound])
						[[SoundHelper shared] playSound:kLQSoundKickedOut QQ:[m_me QQ]];
					break;
			}
			break;
		case kQQIMTypeSignatureChangedNotification:
			SignatureChangedNotification* scn = [packet signatureNotification];
			user = [m_groupManager user:[scn QQ]];
			if(user) {
				[user copyWithSignatureChangedNotification:scn];
				[[m_main userOutline] reloadItem:user];
			}
			break;
		case kQQIMTypeCustomHeadChangedNotification:
			// set custom head
			NSArray* heads = [packet customHeads];
			NSEnumerator* e = [heads objectEnumerator];
			while(CustomHead* head = [e nextObject]) {
				user = [m_groupManager user:[head QQ]];
				if(user)
					[user setCustomHead:head];
			}
				
			// start job
			if(![[m_main jobController] hasJob:kJobGetCustomHeadData])
				[[m_main jobController] startJob:[[[GetCustomHeadDataJob alloc] initWithCustomHeads:heads] autorelease]];
			break;
	}
	
	// check jump icon option
	if(enqueued) {		
		// jump icon if necessary
		if(jumpIcon && [cache jumpIconWhenReceivedIM])
			[NSApp requestUserAttention:NSCriticalRequest];
		
		// refresh dock icon as well as side widow
		[m_main refreshDockIcon];
		
		// show animation if necessary
		if(![cache disableDockIconAnimation])
			[[TimerTaskManager sharedManager] addTask:[MessageWingTask taskWithMainWindow:m_main]];
		
		// if system message count became 1, start blink task
		if(oldSystemMessageCount == 0 && [[m_main messageQueue] systemMessageCount] == 1)
			[[TimerTaskManager sharedManager] addTask:[SystemMessageBlinkTask taskWithMainWindow:m_main]];
	}
	
	return YES;
}

- (BOOL)handleReceivedSystemNotification:(QQNotification*)event {
	// if hot key is not enabled, the friend list is not populated, so cache the event
	// until the main UI is ready
	if(![m_main hotKeyEnabled]) {
		[[m_main postponedEventCache] addObject:event];
		return YES;
	}
	
	// system message, bad, good or neutral? on means good, off means bad, mix means...
	NSCellStateValue state = NSMixedState;
	
	// get old system message count
	int oldSystemMessageCount = [[m_main messageQueue] systemMessageCount];
	
	SystemNotificationPacket* packet = [event object];
	switch([packet subCommand]) {
		case kQQSubCommandOtherRequestAddMeEx:
			if(![m_main shouldBlockRequest:[packet sourceQQ]])
				[[m_main messageQueue] enqueue:packet];
			break;
		case kQQSubCommandOtherApproveMyRequest:
		case kQQSubCommandOtherApproveMyRequestAndAddMe:
			// add user in my friend list
			state = NSOnState;
			[m_main addFriend:[packet sourceQQ]];
			[[m_main messageQueue] enqueue:packet];
			break;
		case kQQSubCommandOtherAddMeEx:
			// add to stranger
			User* user = [m_groupManager user:[packet sourceQQ]];
			if(user == nil) {
				user = [[User alloc] initWithQQ:[packet sourceQQ] domain:m_main];
				[m_groupManager addUser:user groupIndex:[m_groupManager strangerGroupIndex]];
				[[m_main userOutline] reloadItem:[m_groupManager strangerGroup] reloadChildren:YES];
				[[m_main client] getUserInfo:[user QQ]];
				[user release];
			} 
			[[m_main messageQueue] enqueue:packet];
			break;
		case kQQSubCommandOtherRejectMyRequest:
			state = NSOffState;
			[[m_main messageQueue] enqueue:packet];
			break;
		default:
			return YES;
	}
	
	// add to history
	History* history = [[m_main historyManager] getHistoryToday:@"10000"];
	[history addPacket:packet];
	
	// check jump icon option
	PreferenceCache* cache = [PreferenceCache cache:[m_me QQ]];
	if([cache jumpIconWhenReceivedIM])
		[NSApp requestUserAttention:NSCriticalRequest];
	if(![cache disableDockIconAnimation])
		[[TimerTaskManager sharedManager] addTask:[MessageWingTask taskWithMainWindow:m_main]];
	else
		[m_main refreshDockIcon];
	
	// if system message count became 1, start blink task
	if(oldSystemMessageCount == 0 && [[m_main messageQueue] systemMessageCount] == 1)
		[[TimerTaskManager sharedManager] addTask:[SystemMessageBlinkTask taskWithMainWindow:m_main]];
	
	// play sound
	if([cache isEnableSound]) {
		if(state == NSMixedState)
			[[SoundHelper shared] playSound:kLQSoundSystemMessage QQ:[m_me QQ]];
		else if(state == NSOnState)
			[[SoundHelper shared] playSound:kLQSoundGoodSystemMessage QQ:[m_me QQ]];
		else
			[[SoundHelper shared] playSound:kLQSoundBadSystemMessage QQ:[m_me QQ]];
	}
	
	// growl
	[[GrowlApplicationBridge growlDelegate] systemIM:packet mainWindow:m_main];
	
	return YES;
}

- (BOOL)handleUploadGroupNameOK:(QQNotification*)event {
	// set hint
	[m_main setProgressWindowHint:L(@"LQHintUploadFriendGroup", @"MainWindow")];	
	
	// get mapping
	m_friendGroupMapping = [[m_groupManager friendGroupMapping] retain];
	m_nextUploadPage = 0;
	
	if(m_allUserQQs)
		[m_allUserQQs release];
	m_allUserQQs = [[m_friendGroupMapping allKeys] retain];
	[self uploadFriendGroups];
	return YES;
}

- (BOOL)handleUploadGroupNameFailed:(QQNotification*)event {
	[m_main showProgressWindow:NO];
	return YES;
}

- (BOOL)handleUploadGroupNameTimeout:(QQNotification*)event {
	[m_main showProgressWindow:NO];
	return YES;
}

- (BOOL)handleUploadFriendGroupOK:(QQNotification*)event {
	m_nextUploadPage++;
	if(m_nextUploadPage * kQQMaxUploadGroupFriendCount >= [m_friendGroupMapping count])
		[m_main showProgressWindow:NO];
	else
		[self uploadFriendGroups];
	return YES;
}

- (BOOL)handleUploadFriendGroupFailed:(QQNotification*)event {
	[m_main showProgressWindow:NO];
	return YES;
}

#pragma mark -
#pragma mark url connection delegate

-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
	[connection autorelease];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
	[connection autorelease];
}

#pragma mark -
#pragma mark getter and setter

- (UInt32)onlineUserCount {
	return m_onlineUserCount;
}

@end

⌨️ 快捷键说明

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