📄 addfriendwindowcontroller.mm
字号:
[m_txtHint setStringValue:L(@"LQHintQuestionOpTimeout", @"AddFriend")]; } break; case kQQCommandAuthorize: AuthorizePacket* ap = (AuthorizePacket*)outPacket; if([ap QQ] == m_QQ) { m_operating = NO; [m_piBusy stopAnimation:self]; [m_btnOK setEnabled:YES]; [m_txtHint setStringValue:L(@"LQHintAuthorizeTimeout", @"AddFriend")]; } break; } return NO;}- (BOOL)handleAddFriendOK:(QQNotification*)event { AddFriendReplyPacket* packet = [event object]; if([packet QQ] == m_QQ) { // stop ui m_operating = NO; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintAdded", @"AddFriend")]; [m_btnOK setEnabled:YES]; [m_btnOK setHidden:YES]; [m_btnCancel setTitle:L(@"LQClose")]; [m_mainWindowController addAddFriendGroupMapping:m_QQ groupIndex:[m_cbGroup indexOfSelectedItem]]; [m_mainWindowController addFriend:m_QQ]; return YES; } return NO;}- (BOOL)handleAddFriendDenied:(QQNotification*)event { AddFriendReplyPacket* packet = [event object]; if([packet QQ] == m_QQ) { // stop ui m_operating = NO; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintDenied", @"AddFriend")]; [m_btnOK setEnabled:YES]; [m_btnOK setHidden:YES]; [m_btnCancel setTitle:L(@"LQClose")]; return YES; } return NO;}- (BOOL)handleAddFriendNeedAuth:(QQNotification*)event { AddFriendReplyPacket* packet = [event object]; if([packet QQ] == m_QQ) { // change phase m_secondPhase = YES; // save auth type and refresh UI m_authType = [packet authType]; [self showAuthUI]; // check auth type, if need question, continute if(m_authType == kQQAuthQuestion) { [m_txtHint setStringValue:L(@"LQHintGetQuestion", @"AddFriend")]; m_waitingSequence = [[m_mainWindowController client] getUserQuestion:m_QQ]; } else { // stop ui m_operating = NO; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintNeedAuth", @"AddFriend")]; [m_btnOK setEnabled:YES]; } return YES; } return NO;}- (BOOL)handleGetAuthInfoOK:(QQNotification*)event { AuthInfoOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // save auth info m_authInfo = [[packet authInfo] retain]; // add [m_txtHint setStringValue:L(@"LQHintAddFriend", @"AddFriend")]; [[m_mainWindowController client] addFriend:m_QQ]; // handled, so return YES return YES; } return NO;}- (BOOL)handleGetAuthInfoNeedVerifyCode:(QQNotification*)event { AuthInfoOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // save url [m_verifyCodeHelper setUrl:[packet url]]; // show verify code panel [self showView:m_verifyCodeView]; // start to get verify code image m_refreshing = NO; [self startGetVerifyCodeImage]; return YES; } return NO;}- (BOOL)handleGetAuthInfoByVerifyCodeOK:(QQNotification*)event { AuthInfoOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // save auth info m_authInfo = [[packet authInfo] retain]; // answer question or authorize if([m_questionView superview] == nil) { [m_txtHint setStringValue:L(@"LQHintAuthorize", @"AddFriend")]; [[m_mainWindowController client] authorize:m_QQ authInfo:m_authInfo message:[m_txtMessage string] allowAddMe:[m_chkAllowAddMe state] group:[m_cbGroup indexOfSelectedItem]]; } else { [m_txtHint setStringValue:L(@"LQHintAnswerQuestion", @"AddFriend")]; m_waitingSequence = [[m_mainWindowController client] answerQuestion:m_QQ answer:[m_txtAnswer stringValue]]; } return YES; } return NO;}- (BOOL)handleGetAuthInfoByVerifyCodeRetry:(QQNotification*)event { AuthInfoOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // stop ui m_operating = NO; [m_piBusy stopAnimation:self]; [m_btnOK setEnabled:YES]; [m_txtHint setStringValue:L(@"LQHintVerifyCodeRetry", @"AddFriend")]; return YES; } return NO;}- (BOOL)handleAnswerQuestionOK:(QQNotification*)event { AuthQuestionOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // save auth info m_questionAuthInfo = [[packet authInfo] retain]; // send authorize [m_txtHint setStringValue:L(@"LQHintAuthorize", @"AddFriend")]; [[m_mainWindowController client] authorize:m_QQ authInfo:m_authInfo questionAuthInfo:m_questionAuthInfo allowAddMe:[m_chkAllowAddMe state] group:[m_cbGroup indexOfSelectedItem]]; return YES; } return NO;}- (BOOL)handleAnswerQuestionFailed:(QQNotification*)event { AuthQuestionOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // stop ui m_operating = NO; [m_btnOK setEnabled:YES]; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintAnswerRetry", @"AddFriend")]; return YES; } return NO;}- (BOOL)handleGetUserQuestionOK:(QQNotification*)event { AuthQuestionOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // stop ui m_operating = NO; [m_btnOK setEnabled:YES]; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintNeedAnswer", @"AddFriend")]; // set question [m_txtQuestion setStringValue:[packet question]]; return YES; } return NO;}- (BOOL)handleGetUserQuestionFailed:(QQNotification*)event { AuthQuestionOpReplyPacket* packet = [event object]; if([packet sequence] == m_waitingSequence) { // stop ui m_operating = NO; [m_btnOK setEnabled:YES]; [m_btnOK setHidden:YES]; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintGetQuestionFailed", @"AddFriend")]; return YES; } return NO;}- (BOOL)handleAuthorizeOK:(QQNotification*)event { AuthorizeReplyPacket* packet = [event object]; if([packet QQ] == m_QQ) { // stop ui m_operating = NO; [m_btnOK setEnabled:YES]; [m_btnOK setHidden:YES]; [m_btnCancel setTitle:L(@"LQClose")]; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintAuthorizeOK", @"AddFriend")]; // cache destination group index [m_mainWindowController addAddFriendGroupMapping:m_QQ groupIndex:[m_cbGroup indexOfSelectedItem]]; return YES; } return NO;}- (BOOL)handleAuthorizeFailed:(QQNotification*)event { AuthorizeReplyPacket* packet = [event object]; if([packet QQ] == m_QQ) { // stop ui m_operating = NO; [m_btnOK setEnabled:YES]; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintAuthorizeFailed", @"AddFriend")]; return YES; } return NO;}#pragma mark -#pragma mark downloader delegate- (void)downloadDidFinish:(NSURLDownload *)download { // refresh ui [m_btnRefresh setEnabled:YES]; // set verify code image [m_ivVerifyCode setImage:[m_verifyCodeHelper image]]; // add friend if(m_refreshing) { m_operating = NO; [m_piBusy stopAnimation:self]; [m_txtHint setStringValue:L(@"LQHintVerifyCodeImageRefreshed", @"AddFriend")]; } else { [m_txtHint setStringValue:L(@"LQHintAddFriend", @"AddFriend")]; [[m_mainWindowController client] addFriend:m_QQ]; }}- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error { // refresh ui [m_btnRefresh setEnabled:YES];}- (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response { }#pragma mark -#pragma mark animation delegate- (void)animationDidEnd:(NSAnimation*)animation { [m_lastView setAutoresizingMask:NSViewMinYMargin];}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -