Esempio n. 1
0
        private void cmbRadio_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedInterfaceId = radios[cmbRadio.SelectedIndex].InterfaceID;
            InitializeEventHandlers();
            uint age = 0;

            lvNetwork.Items.Clear();
            try
            {
                lastScannedNetworks = (MBN_PROVIDER[])m_MbnInterface.GetVisibleProviders(out age);
                PopulateNetworks(lastScannedNetworks);
                lblLastScan.Text = DateTime.Now.AddSeconds(-1 * age).ToShortTimeString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Networks not found.  Please scan to find networks.");
                lblLastScan.Text = "Unknown";
            }

            //Fill In the registration stuff
            IMbnRegistration registrationInterface = m_MbnInterface as IMbnRegistration;

            updateRegistration(registrationInterface);

            //Fill in the IMSI
            try
            {
                string IMSI = m_MbnInterfaceManager.GetInterface(selectedInterfaceId).GetSubscriberInformation().SubscriberID;
                lblIMSI.Text = IMSI;
            } catch (Exception ex)
            {
                lblIMSI.Text = "Unknown";
            }

            //Check if connected
            try
            {
                IMbnConnection       connection = ((IMbnConnection[])m_MbnConnectionManager.GetConnections())[0];
                MBN_ACTIVATION_STATE activationState;
                string profileName;
                connection.GetConnectionState(out activationState, out profileName);
                if (activationState == MBN_ACTIVATION_STATE.MBN_ACTIVATION_STATE_ACTIVATED)
                {
                    btnPcConnect.Enabled = false;
                }
                else
                {
                    btnPcDisconnect.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                btnPcDisconnect.Enabled = false;
            }
        }
Esempio n. 2
0
        private void ProcessOnScanNetworkComplete(IMbnInterface newInterface, uint requestID, int status)
        {
            LogMessage("Scanning Complete");
            uint age;

            try
            {
                MBN_PROVIDER[] lastScannedNetworks = (MBN_PROVIDER[])newInterface.GetVisibleProviders(out age);
                this.Invoke((MethodInvoker) delegate()
                {
                    PopulateNetworks(lastScannedNetworks);
                    lblLastScan.Text = DateTime.Now.AddSeconds(-1 * age).ToShortTimeString();
                    btnScan.Enabled  = true;
                });
            } catch (Exception ex)
            {
                this.Invoke((MethodInvoker) delegate()
                {
                    LogMessage("No Networks found");
                    lblLastScan.Text = DateTime.Now.ToShortTimeString();
                });
            }
        }
Esempio n. 3
0
        public void Test()
        {
            IMbnInterfaceManager      interfaceManager = null;
            IMbnInterface             inf        = null;
            IMbnSubscriberInformation subscriber = null;

            try
            {
                interfaceManager = (IMbnInterfaceManager) new MbnInterfaceManager();
                inf        = interfaceManager.GetInterface(InterfaceID);
                subscriber = inf.GetSubscriberInformation();

                uint outCode = 0;
                inf.ScanNetwork(out outCode);

                uint age   = 0;
                var  array = inf.GetVisibleProviders(out age);

                var provider = inf.GetHomeProvider();

                //inf.SetPreferredProviders(new MBN_PROVIDER[] { plusProvider }, out outCode);

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(mobileProfileTemplate);

                xml["MBNProfile"]["SubscriberID"].InnerText = subscriber.SubscriberID;
                xml["MBNProfile"]["SimIccID"].InnerText     = subscriber.SimIccID;

                //Console.WriteLine("Profile: " + xml.OuterXml);

                IMbnConnection conn = null;

                try
                {
                    conn = inf.GetConnection();

                    //MBN_ACTIVATION_STATE state;
                    //string profile;
                    //conn.GetConnectionState(out state, out profile);

                    uint requestId;
                }
                finally
                {
                    if (conn != null)
                    {
                        Marshal.FinalReleaseComObject(conn);
                    }
                }
            }
            finally
            {
                if (subscriber != null)
                {
                    Marshal.FinalReleaseComObject(subscriber);
                }
                if (inf != null)
                {
                    Marshal.FinalReleaseComObject(inf);
                }
                if (interfaceManager != null)
                {
                    Marshal.FinalReleaseComObject(interfaceManager);
                }
            }
        }