Beispiel #1
0
        private void MoveMessageReaderByPos(int id)
        {
            if (textToSpeech.IsSpeaking)
            {
                textToSpeech.Stop();
            }

            if (id <= maxPos - 1 && id >= 0)
            {
                if (id == maxPos - 1)
                {
                    var btnNext = FindViewById <Button>(Resource.Id.btnNextEmailReader);
                    btnNext.Enabled = false;
                }
                else
                {
                    var btnNext = FindViewById <Button>(Resource.Id.btnNextEmailReader);
                    btnNext.Enabled = true;
                }

                if (id >= 0)
                {
                    var btnPrev = FindViewById <Button>(Resource.Id.btnPrevEmailReader);
                    btnPrev.Enabled = true;
                }
                else
                {
                    var btnPrev = FindViewById <Button>(Resource.Id.btnPrevEmailReader);
                    btnPrev.Enabled = false;
                }

                //DBManagerHelper dbmgr = new DBManagerHelper(this);
                DatabaseUpdates    tblEmail   = new DatabaseUpdates();
                List <EmailObject> eListAdapt = tblEmail.EmailOBJ();
                EmailObject        emlObj     = eListAdapt[id];
                emlFrom    = emlObj.From;            //Intent.GetStringExtra("emlFrom") ?? "From Data not available";
                emlDate    = emlObj.date.ToString(); //Intent.GetStringExtra("emlDate") ?? "Date Data not available";
                emlCC      = emlObj.CC;              //Intent.GetStringExtra("emlCC") ?? "CC Data not available";
                emlSubject = emlObj.Subject;         //Intent.GetStringExtra("emlSubject") ?? "Subject Data not available";
                emlBody    = emlObj.Body;            //Intent.GetStringExtra("emlBody") ?? "Body Data not available";
                curPos     = id;                     //Intent.GetIntExtra("curPos", 0);

                var tvFrom = FindViewById <TextView>(Resource.Id.tvFromEmailReaer);
                tvFrom.Text = emlFrom;
                var tvCC = FindViewById <TextView>(Resource.Id.tvCCEmailReader);
                tvCC.Text = emlCC;
                var tvSubject = FindViewById <TextView>(Resource.Id.tvSubjectEmailReader);
                tvSubject.Text = emlSubject;
                var tvBody = FindViewById <TextView>(Resource.Id.tvBodyEmailReader);
                tvBody.Text = emlBody;
            }
        }
Beispiel #2
0
        private void RetrievePOP3Mail()
        {
            EmailsToRead = "";
            using (var client = new Pop3Client())
            {
                // accept all SSL certificates (in case the server supports STARTTLS)
                client.ServerCertificateValidationCallback = (s, c, h, e) => true;

                //Console.WriteLine("Connecting to MailServer" + GetString(Resource.String.GDSSEMailServerHost) +" port 995");
                //Toast.MakeText(this, "Email Sync: Authenticating to Server", ToastLength.Long).Show();
                client.Connect(GetString(Resource.String.GDSSEMailServerHost), int.Parse(GetString(Resource.String.GDSSEMailServerPort)), true);

                // Note: since we don't have an OAuth2 token, disable
                // the XOAUTH2 authentication mechanism.
                client.AuthenticationMechanisms.Remove("XOAUTH2");
                client.Authenticate(GetString(Resource.String.GDSSEMailAccount), GetString(Resource.String.GDSSEMailPwd));

                var             emails   = new List <EmailObject>();
                DBManagerHelper dbmgr    = new DBManagerHelper(this);
                DatabaseUpdates tblEmail = new DatabaseUpdates();
                //var tblEmail = new EmailEntity();
                //Toast.MakeText(this, "Email Sync: Downloading Emails", ToastLength.Long).Show();
                //for testing purpose only / clearing of table.
                if (int.Parse(GetString(Resource.String.TestDeleteEmailsOn)) == 1)
                {
                    tblEmail.ClearMail();
                }

                for (int i = client.Count - 1; i >= 0; i--)
                {
                    var message = new MimeMessage();

                    try
                    {
                        message = client.GetMessage(i);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Source + " || " + ex.Message);
                    }

                    if (!tblEmail.IsEmailExist(message.MessageId))
                    {
                        var curemail = new EmailObject(message.MessageId, message.From.ToString(), message.Subject, message.TextBody, message.Cc.ToString(), DateTime.Parse(message.Date.ToString()));

                        try
                        {
                            tblEmail.AddEmail(new EmailEntity
                            {
                                EmailID      = curemail.EmailID ?? "0",
                                EmailFrom    = curemail.From,
                                EmailCC      = curemail.CC,
                                EmailDate    = curemail.date,
                                EmailSubject = curemail.Subject,
                                EmailBody    = curemail.Body
                            });
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Source + "||" + ex.Message);
                        }
                    }
                }
                client.Disconnect(true);
                dbmgr.Close();
            }
        }
Beispiel #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EmailForm);
            // Create your application here

            isRecording = false;

            //initialize speech to text (input)
            InitSTTMethod();
            //initialize text to speech (read/speak)
            InitTTSMethod();

            var backButton = FindViewById <Button>(Resource.Id.btnBackEmailForm);

            backButton.Click += delegate { Finish(); };


            var btnGetEmails = FindViewById <Button>(Resource.Id.btnGetMailPOP3EmailForm);

            btnGetEmails.Click += delegate
            {
                var progressDialog = ProgressDialog.Show(this, "Please wait...", "Connecting to GDSS Mail Server", true);
                progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                new Thread(new ThreadStart(delegate
                {
                    //LOAD METHOD TO GET ACCOUNT INFO
                    RunOnUiThread(() => {
                        Toast.MakeText(this, "Email Sync: Connecting to Server", ToastLength.Long).Show();
                    });
                    //RetrievePOP3Mail();
                    RunOnUiThread(() => RetrievePOP3Mail());
                    RunOnUiThread(() => {
                        Toast.MakeText(this, "Email Sync: Successful", ToastLength.Long).Show();
                    });
                    RunOnUiThread(() => RetrieveDBMail());
                    //HIDE PROGRESS DIALOG
                    RunOnUiThread(() => progressDialog.Hide());
                })).Start();
            };

            var btnResetEmailForm = FindViewById <Button>(Resource.Id.btnResetEmailForm);

            btnResetEmailForm.Click += delegate
            {
                Finish();
                StartActivity(typeof(EmailActivity));
            };

            var lvEmail = FindViewById <ListView>(Resource.Id.lvEmailList);

            lvEmail.ItemClick += (sender, e) => {
                EmailListAdapter EmailList = ((EmailListAdapter)lvEmail.Adapter);
                EmailObject      item      = EmailList[e.Position];

                var actEmalReader = new Intent(this, typeof(EmailReaderActivity));
                actEmalReader.PutExtra("emlFrom", item.From);
                actEmalReader.PutExtra("emlCC", item.CC);
                actEmalReader.PutExtra("emlDate", item.date.ToString());
                actEmalReader.PutExtra("emlSubject", item.Subject);
                actEmalReader.PutExtra("emlBody", item.Body);
                actEmalReader.PutExtra("curPos", e.Position);
                actEmalReader.PutExtra("maxPos", EmailList.Count);
                actEmalReader.PutExtra("autoRead", 1);
                actEmalReader.SetFlags(ActivityFlags.ReorderToFront);
                StartActivity(actEmalReader);
            };

            ActivityStatus = "Created";

            RetrieveDBMail();
        }