Exemple #1
0
        private async Task <bool> ZFetchToStream(cUID pUID, cSection pSection, eDecodingRequired pDecoding, string pTitle, Stream pStream)
        {
            frmProgress lProgress = null;

            try
            {
                lProgress = new frmProgress(pTitle);
                ZChildAdd(lProgress);
                await mClient.SelectedMailbox.UIDFetchAsync(pUID, pSection, pDecoding, pStream, new cBodyFetchConfiguration(lProgress.CancellationToken, lProgress.Increment));

                return(true);
            }
            catch (OperationCanceledException) { }
            catch (Exception ex)
            {
                if (!IsDisposed)
                {
                    MessageBox.Show(this, $"problem when fetching\n{ex}");
                }
            }
            finally
            {
                if (lProgress != null)
                {
                    lProgress.Complete();
                }
            }

            return(false);
        }
Exemple #2
0
        public frmMessageData(cUID pUID, cSection pSection, eDecodingRequired pDecoding, string pData)
        {
            mUID      = pUID;
            mSection  = pSection;
            mDecoding = pDecoding;
            mData     = pData;

            InitializeComponent();
        }
Exemple #3
0
        private string ZDownloadFileName(cSection pSection)
        {
            string lFileName = mMessage.UID.UID.ToString();

            if (pSection.Part != null)
            {
                lFileName += "." + pSection.Part;
            }
            if (pSection.TextPart != eSectionTextPart.all)
            {
                lFileName += "." + pSection.TextPart;
            }
            return(lFileName);
        }
Exemple #4
0
        private async void ZDownloadRaw(cSection pSection, int pSize)
        {
            var lSaveFileDialog = new SaveFileDialog();

            lSaveFileDialog.FileName = ZDownloadFileName(pSection) + ".txt";
            if (lSaveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            frmProgress lProgress = null;

            try
            {
                lProgress = new frmProgress("saving " + lSaveFileDialog.FileName, pSize);
                ZDownloadAdd(lProgress);

                using (FileStream lStream = new FileStream(lSaveFileDialog.FileName, FileMode.Create))
                {
                    await mMessage.FetchAsync(pSection, eDecodingRequired.none, lStream, new cBodyFetchConfiguration(lProgress.CancellationToken, lProgress.Increment));
                }
            }
            catch (OperationCanceledException) { }
            catch (Exception ex)
            {
                if (!IsDisposed)
                {
                    MessageBox.Show(this, $"problem when saving '{lSaveFileDialog.FileName}'\n{ex}");
                }
            }
            finally
            {
                if (lProgress != null)
                {
                    lProgress.Complete();
                }
            }
        }
Exemple #5
0
        private void ZValTextBoxIsPart(object sender, CancelEventArgs e)
        {
            if (!(sender is TextBox lSender))
            {
                return;
            }

            string lPart = lSender.Text.Trim();

            if (string.IsNullOrWhiteSpace(lPart))
            {
                return;
            }

            try
            {
                cSection lSection = new cSection(lPart);
            }
            catch
            {
                e.Cancel = true;
                erp.SetError(lSender, "part should be a list of dot separated non-zero integers");
            }
        }
Exemple #6
0
        private void ZQueryBodyStructureAddSection(TreeNode pParent, string pText, cSection pSection, int pApproximateSizeInBytes)
        {
            var lNode = pParent.Nodes.Add(pText);

            lNode.Tag = new cNodeTag(pSection, pApproximateSizeInBytes);
        }
Exemple #7
0
        private bool ZFetchParameters(out cUID rUID, out cSection rSection, out eDecodingRequired rDecoding)
        {
            rUID      = null;
            rSection  = null;
            rDecoding = eDecodingRequired.other;

            if (!ValidateChildren(ValidationConstraints.Enabled))
            {
                MessageBox.Show(this, "there are issues with the data entered");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(txtUID.Text))
            {
                MessageBox.Show(this, "you must enter a UID");
                return(false);
            }

            try
            {
                rUID = new cUID(uint.Parse(txtUIDValidity.Text), uint.Parse(txtUID.Text));

                string lPart;
                if (string.IsNullOrWhiteSpace(txtPart.Text))
                {
                    lPart = null;
                }
                else
                {
                    lPart = txtPart.Text.Trim();
                }

                eSectionTextPart lTextPart;

                if (rdoAll.Checked)
                {
                    lTextPart = eSectionTextPart.all;
                }
                else if (rdoHeader.Checked)
                {
                    lTextPart = eSectionTextPart.header;
                }
                else if (rdoFields.Checked)
                {
                    lTextPart = eSectionTextPart.headerfields;
                }
                else if (rdoFieldsNot.Checked)
                {
                    lTextPart = eSectionTextPart.headerfieldsnot;
                }
                else if (rdoText.Checked)
                {
                    lTextPart = eSectionTextPart.text;
                }
                else
                {
                    lTextPart = eSectionTextPart.mime;
                }

                if (lTextPart == eSectionTextPart.headerfields || lTextPart == eSectionTextPart.headerfieldsnot)
                {
                    if (string.IsNullOrWhiteSpace(txtFieldNames.Text))
                    {
                        MessageBox.Show(this, "must enter some field names");
                        return(false);
                    }

                    if (!ZTryParseHeaderFieldNames(txtFieldNames.Text, out var lNames))
                    {
                        MessageBox.Show(this, "must enter valid field names");
                        return(false);
                    }

                    rSection = new cSection(lPart, lNames, rdoFieldsNot.Checked);
                }
                else
                {
                    rSection = new cSection(lPart, lTextPart);
                }

                if (rdoNone.Checked)
                {
                    rDecoding = eDecodingRequired.none;
                }
                else if (rdoQuotedPrintable.Checked)
                {
                    rDecoding = eDecodingRequired.quotedprintable;
                }
                else if (rdoQuotedPrintable.Checked)
                {
                    rDecoding = eDecodingRequired.base64;
                }

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(this, $"there are issues with the data entered:\n{e.ToString()}");
                return(false);
            }
        }