Exemple #1
0
 /// <summary>
 /// Disconnect sim card from reader
 /// </summary>
 private void SimDisconnect()
 {
     GlobalObj.CloseConnection();
     UpdateSimControls(false);
     lstSimContacts.Clear();
     MainClass.GtkWait();
 }
Exemple #2
0
 /// <summary>
 /// Set gui widgets after sim scan
 /// </summary>
 private void ScanSimAfter()
 {
     PBar.Visible         = false;
     MainMenu.Sensitive   = true;
     TopToolBar.Sensitive = true;
     FrameSim.Sensitive   = true;
     FrameFile.Sensitive  = true;
     MainClass.GtkWait();
 }
Exemple #3
0
        /// <summary>
        /// Perform sim card connection and contacts read.
        /// </summary>
        private void SimConnect()
        {
            MainClass.GtkWait();

            if (GlobalObj.IsPowered)
            {
                // Disconnect card if needed
                GlobalObj.CloseConnection();
            }

            // Connect to smartcard
            retStr = GlobalObj.AnswerToReset(ref ATR);

            // check for error
            if (retStr != "")
            {
                // error on answer to reset
                log.Error("MainWindowClass::SimConnect: " + retStr);
                MainClass.ShowMessage(MainWindow, "ERROR", retStr, MessageType.Error);
                return;
            }

            // read sim contacts and fill list
            retStr = GlobalObjUI.SelectSimContactsList();

            // check for error
            if (retStr != "")
            {
                if (retStr == GlobalObjUI.LMan.GetString("needpindisable"))
                {
                    // Pin1 enabled
                    MainClass.ShowMessage(MainWindow, "ERROR", retStr, MessageType.Error);
                    EnableSimPinControl();
                    return;
                }
                else
                {
                    // error on reading contacts list
                    GlobalObj.CloseConnection();
                    MainClass.ShowMessage(MainWindow, "ERROR", retStr, MessageType.Error);
                    return;
                }
            }

            ScanSimBefore();
            lstSimContacts.Clear();

            // Reset status values
            GlobalObjUI.SimADNStatus   = 1;
            GlobalObjUI.SimADNPosition = 0;
            GlobalObjUI.SimADNError    = "";

            // Start thread for reading process
            notify    = new ThreadNotify(new ReadyEvent(ReadingUpdate));
            simThread = new System.Threading.Thread(new System.Threading.ThreadStart(GlobalObjUI.ReadSimContactsList));
            simThread.Start();
        }
Exemple #4
0
        /// <summary>
        /// Updates during sim contacts reading
        /// </summary>
        private void ReadingUpdate()
        {
            PBar.Adjustment.Value = (double)GlobalObjUI.SimADNPosition;
            StatusBar.Push(1, GlobalObjUI.LMan.GetString("readcontact") +
                           GlobalObjUI.SimADNPosition.ToString("d3"));
            MainClass.GtkWait();


            if (GlobalObjUI.SimADNStatus == 3)
            {
                // End with errors
                MainClass.ShowMessage(MainWindow, "ERROR", GlobalObjUI.SimADNError, MessageType.Error);

                // Update gui widgets properties
                ScanSimAfter();

                // update gui widgets with results
                UpdateSimControls(false);
            }

            if (GlobalObjUI.SimADNStatus == 2)
            {
                // Extract contacts from records
                retStr = GlobalObjUI.FromRecordsToContacts();

                if (retStr != "")
                {
                    // error detected
                    MainClass.ShowMessage(MainWindow, "ERROR", retStr, MessageType.Error);

                    // Update gui widgets properties
                    ScanSimAfter();

                    // update gui widgets with results
                    UpdateSimControls(false);
                }
                else
                {
                    // update ListView
                    foreach (Contact cnt in GlobalObjUI.SimContacts.SimContacts)
                    {
                        lstSimContacts.AppendValues(new string[] { cnt.Description, cnt.PhoneNumber });
                    }

                    // Update gui widgets properties
                    ScanSimAfter();

                    // update gui widgets with results
                    UpdateSimControls(true);
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Set gui widgets before sim scan
 /// </summary>
 private void ScanSimBefore()
 {
     // Setup ProgressBar
     PBar.Fraction         = 0;
     PBar.Adjustment.Lower = 0;
     PBar.Adjustment.Upper = GlobalObjUI.SimADNRecordCount;
     PBar.Adjustment.Value = 0;
     PBar.Visible          = true;
     MainMenu.Sensitive    = false;
     TopToolBar.Sensitive  = false;
     FrameSim.Sensitive    = false;
     FrameFile.Sensitive   = false;
     MainClass.GtkWait();
 }
Exemple #6
0
        /// <summary>
        /// Updates during sim contacts writing
        /// </summary>
        private void WritingUpdate()
        {
            PBar.Adjustment.Value = (double)GlobalObjUI.SimADNPosition;
            StatusBar.Push(1, GlobalObjUI.LMan.GetString("writecontact") +
                           GlobalObjUI.SimADNPosition.ToString("d3"));
            MainClass.GtkWait();


            if (GlobalObjUI.SimADNStatus == 3)
            {
                // End with errors
                MainClass.ShowMessage(MainWindow, "ERROR", GlobalObjUI.SimADNError, MessageType.Error);
                //ScanSimAfter();
                SimConnect();
            }

            // check for sim write ended
            if (GlobalObjUI.SimADNStatus != 1)
            {
                // Update gui widgets properties
                //ScanSimAfter();
                SimConnect();
            }
        }
Exemple #7
0
        private void OpenContactsFile()
        {
            GlobalObjUI.ContactsFilePath = "";

            // New dialog for select contacts file
            Gtk.FileChooserDialog FileBox = new Gtk.FileChooserDialog(GlobalObjUI.LMan.GetString("openfileact"),
                                                                      MainWindow,
                                                                      FileChooserAction.Open,
                                                                      GlobalObjUI.LMan.GetString("cancellbl"), Gtk.ResponseType.Cancel,
                                                                      GlobalObjUI.LMan.GetString("openlbl"), Gtk.ResponseType.Accept);

            // Filter for using only monosim files
            Gtk.FileFilter myFilter = new Gtk.FileFilter();
            myFilter.AddPattern("*.monosim");
            myFilter.Name = "monosim files";
            FileBox.AddFilter(myFilter);

            // Manage result of dialog box
            FileBox.Icon = Gdk.Pixbuf.LoadFromResource("monosim.png");
            int retFileBox = FileBox.Run();

            if ((ResponseType)retFileBox == Gtk.ResponseType.Accept)
            {
                // path of a right file returned
                GlobalObjUI.ContactsFilePath = FileBox.Filename;

                FileBox.Destroy();
                FileBox.Dispose();
            }
            else
            {
                // nothing returned
                FileBox.Destroy();
                FileBox.Dispose();
                return;
            }


            // Update gui
            UpdateFileControls(false);
            lstFileContacts.Clear();
            MainClass.GtkWait();

            try
            {
                GlobalObjUI.FileContacts = new Contacts();
                StreamReader sr       = new StreamReader(GlobalObjUI.ContactsFilePath);
                string       descRow  = sr.ReadLine();
                string       phoneRow = "";
                while (!sr.EndOfStream)
                {
                    phoneRow = sr.ReadLine();
                    // check for right values
                    if (descRow.Trim() != "" && phoneRow.Trim() != "")
                    {
                        GlobalObjUI.FileContacts.SimContacts.Add(new Contact(descRow, phoneRow));
                    }

                    // read new contact description
                    descRow = sr.ReadLine();
                }
                sr.Close();
                sr.Dispose();
                sr = null;
            }
            catch (Exception Ex)
            {
                log.Error("MainWindowClass::OpenContactsFile: " + Ex.Message + "\r\n" + Ex.StackTrace);
                MainClass.ShowMessage(MainWindow, "ERROR", Ex.Message, MessageType.Error);
                return;
            }

            // loop to append data readed from file
            foreach (Contact cnt in GlobalObjUI.FileContacts.SimContacts)
            {
                lstFileContacts.AppendValues(new string[] { cnt.Description, cnt.PhoneNumber });
            }

            UpdateFileControls(true);
        }