private void sendUsernameUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineGetLineUnit sendUsernameUnit = (AsciiSendLineGetLineUnit)unit; if (sendUsernameUnit.LineSent) { _responseLine = sendUsernameUnit.ResponseLine; if (_responseLine != null) { if (_responseLine.StartsWith("381")) // password required { AsciiSendLineGetLineUnit sendPasswordUnit = new AsciiSendLineGetLineUnit("authinfo pass " + _password); sendPasswordUnit.Finished += new AsciiProtocolUnitDelegate(sendPasswordUnit_Finished); StartUnit(sendPasswordUnit, _connection); return; } if (_responseLine.StartsWith("281")) // password not required (wonder if this can occur) { _succeeded = true; } } } FireFinished(); }
protected override void Start(AsciiTcpConnection connection) { _connection = connection; AsciiSendLineGetLineUnit setGroupUnit = new AsciiSendLineGetLineUnit("group " + _group.Name); setGroupUnit.Finished += new AsciiProtocolUnitDelegate(setGroupUnit_Finished); StartUnit(setGroupUnit, connection); }
protected override void Start(AsciiTcpConnection connection) { _connection = connection; AsciiSendLineGetLineUnit sendUsernameUnit = new AsciiSendLineGetLineUnit("authinfo user " + _username); sendUsernameUnit.Finished += new AsciiProtocolUnitDelegate(sendUsernameUnit_Finished); StartUnit(sendUsernameUnit, connection); }
private void sendPasswordUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineGetLineUnit sendPasswordUnit = (AsciiSendLineGetLineUnit)unit; if (sendPasswordUnit.LineSent) { _responseLine = sendPasswordUnit.ResponseLine; if (_responseLine != null && _responseLine.StartsWith("281")) { _succeeded = true; } } FireFinished(); }
private void postUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineGetLineUnit postUnit = (AsciiSendLineGetLineUnit)unit; string response = postUnit.ResponseLine; if (!postUnit.LineSent || response == null || !response.StartsWith("240")) { ExtractError(response); FireFinished(); } else { _error = null; FireFinished(); } }
private void initPostUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineGetLineUnit initPostUnit = (AsciiSendLineGetLineUnit)unit; string response = initPostUnit.ResponseLine; if (!initPostUnit.LineSent || (response != null && !response.StartsWith("340"))) { ExtractError(response); FireFinished(); } else { AsciiSendLineGetLineUnit postUnit = new AsciiSendLineGetLineUnit(_nntpBody); postUnit.Finished += new AsciiProtocolUnitDelegate(postUnit_Finished); StartUnit(postUnit, _connection); } }
private void PreparePosting() { if (NewsFolders.IsInFolder(_draftArticle, NewsFolders.SentItems)) { Core.NetworkAP.QueueJob( JobPriority.Immediate, "Finish posting", new MethodInvoker(FireFinished)); } else { NewsFolders.PlaceResourceToFolder(_draftArticle, NewsFolders.Outbox); _nntpBody = _draftArticle.GetPropText(NntpPlugin._propNntpText); if (!_draftArticle.HasProp(NntpPlugin._propArticleId)) { StringBuilder builder = new StringBuilder(_nntpBody.Length + 64); builder.Append("Date: "); DateTime postTime = DateTime.UtcNow; builder.Append(_daysOfTheWeek[(int)postTime.DayOfWeek]); builder.Append(", "); builder.Append(postTime.Day); builder.Append(' '); builder.Append(_months[postTime.Month - 1]); builder.Append(' '); builder.Append(postTime.Year); builder.Append(' '); builder.Append(postTime.Hour.ToString().PadLeft(2, '0')); builder.Append(':'); builder.Append(postTime.Minute.ToString().PadLeft(2, '0')); builder.Append(':'); builder.Append(postTime.Second.ToString().PadLeft(2, '0')); builder.Append(" +0000 (UTC)"); builder.Append("\r\nMessage-ID: "); string message_id = ParseTools.GenerateArticleId(_draftArticle, _server.Name); builder.Append(message_id); builder.Append("\r\n"); builder.Append(_nntpBody); _nntpBody = builder.ToString(); _draftArticle.SetProp(NntpPlugin._propArticleId, message_id); } AsciiSendLineGetLineUnit initPostUnit = new AsciiSendLineGetLineUnit("post"); initPostUnit.Finished += new AsciiProtocolUnitDelegate(initPostUnit_Finished); Core.NetworkAP.QueueJob(JobPriority.Immediate, "Posting articles", new StartUnitDelegate(StartUnit), initPostUnit, _connection); } }
private void setGroupUnit_Finished(AsciiProtocolUnit unit) { AsciiSendLineGetLineUnit setGroupUnit = (AsciiSendLineGetLineUnit)unit; _responseLine = setGroupUnit.ResponseLine; string error = null; if (_responseLine == null) { if (_connection.LastSocketException != null) { error = _connection.LastSocketException.Message; } else { error = "Newsgroup could not be processed"; } } else if (!_responseLine.StartsWith("211")) { if (_responseLine.Length > 4) { error = _responseLine.Substring(4); } else { error = "Newsgroup could not be processed"; } } ResourceProxy proxy = new ResourceProxy(_group.Resource); if (error != null) { proxy.SetPropAsync(Core.Props.LastError, error); } else { proxy.DeletePropAsync(Core.Props.LastError); } FireFinished(); }