private void DoGetVerify(string reason, ProcActionFuture future) { if (future.IsCanceled) { return; } var account = Context.Account; var login = Context.GetModule <LoginModule>(QQModuleType.LOGIN); login.GetCaptcha(account.Uin, (sender, Event) => { if (Event.Type == QQActionEventType.EVT_OK) { var verify = new QQNotifyEventArgs.ImageVerify { Type = QQNotifyEventArgs.ImageVerify.VerifyType.LOGIN, Image = (Image)Event.Target, Reason = reason, Future = future }; Context.FireNotify(new QQNotifyEvent(QQNotifyEventType.CAPACHA_VERIFY, verify)); } else if (Event.Type == QQActionEventType.EVT_ERROR) { future.NotifyActionEvent(QQActionEventType.EVT_ERROR, Event.Target); } }); }
private void doGetVerify(String reason, AbstractActionFuture future) { QQAccount account = (QQAccount)(getContext().getAccount()); LoginModule login = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN); login.getCaptcha(account.getUin(), delegate(QQActionEvent evt) { if (evt.getType() == QQActionEvent.Type.EVT_OK) { QQNotifyEventArgs.ImageVerify verify = new QQNotifyEventArgs.ImageVerify(); verify.type = QQNotifyEventArgs.ImageVerify.VerifyType.LOGIN; verify.image = (BitmapImage)evt.getTarget(); verify.reason = reason; verify.future = future; getContext().fireNotify(new QQNotifyEvent(QQNotifyEvent.Type.CAPACHA_VERIFY, verify)); } else if (evt.getType() == QQActionEvent.Type.EVT_ERROR) { future.notifyActionEvent( QQActionEvent.Type.EVT_ERROR, (QQException)evt.getTarget()); } }); }
/** * {@inheritDoc} * * 提交验证码 */ public void submitVerify(String code, QQNotifyEvent verifyEvent) { QQNotifyEventArgs.ImageVerify verify = (QQNotifyEventArgs.ImageVerify)verifyEvent.getTarget(); if (verify.type == QQWpfApplication1.bean.QQNotifyEventArgs.ImageVerify.VerifyType.LOGIN) { ProcModule mod = (ProcModule)getModule(AbstractModule.Type.PROC); mod.loginWithVerify(code, (AbstractActionFuture)verify.future); } }
/** * 需要验证码通知 * * @throws IOException */ public void processVerify(QQNotifyEvent evt) { QQNotifyEventArgs.ImageVerify verify = (QQNotifyEventArgs.ImageVerify)evt.getTarget(); BufferedStream stream = new BufferedStream(verify.image.StreamSource); FileStream file = File.Create("C:\\Users\\leegean\\Desktop"); int read = -1; while ((read = stream.ReadByte()) != -1) { file.WriteByte((byte)read); } file.Dispose(); Console.WriteLine(verify.reason); Console.WriteLine("请输入在项目根目录下verify.png图片里面的验证码:"); String code = Console.ReadLine(); client.submitVerify(code, evt); }