Example #1
0
        private void Connect()
        {
            IPAddress ipAddress = new IPAddress(ipAddressControl1.GetAddressBytes());
            if (PingServer(ipAddress))
            {
                NFSClient.NFSVersion ver = NFSClient.NFSVersion.v2;
                if (cboxVer.SelectedItem.ToString() == "V3")
                    ver = NFSClient.NFSVersion.v3;

                mNFS = new NFSClient(ver);
                int UserId = int.Parse(tbUserId.Text);
                int GroupId = int.Parse(tbGroupId.Text);
                Encoding encoding = Encoding.ASCII;
                if (chkUnicode.Checked)
                    encoding = Encoding.UTF8;
                mNFS.Connect(ipAddress, UserId, GroupId, (int)nupTimeOut.Value, encoding, chkUsePrivilegedPorts.Checked);
                cboxRemoteDevices.Items.Clear();
                foreach (string strDev in mNFS.GetExportedDevices())
                    cboxRemoteDevices.Items.Add(strDev);
                if (cboxRemoteDevices.Items.Count > 0)
                    gboxMount.Enabled = true;
                btnConnect.Enabled = false;
                btnDisconnect.Enabled = true;
                ipAddressControl1.Enabled = false;
                cboxVer.Enabled = false;
                tbGroupId.Enabled = false;
                tbUserId.Enabled = false;
                nupTimeOut.Enabled = false;
                chkUnicode.Enabled = false;
                chkAutoConnect.Enabled = false;
                chkUsePrivilegedPorts.Enabled = false;

                if (cboxLocalDrive.Items.Count > NekoDrive.Properties.Settings.Default.DriveLetter)
                    cboxLocalDrive.SelectedIndex = NekoDrive.Properties.Settings.Default.DriveLetter;

                if (cboxRemoteDevices.Items.Count > NekoDrive.Properties.Settings.Default.RemoteDevice)
                    cboxRemoteDevices.SelectedIndex = NekoDrive.Properties.Settings.Default.RemoteDevice;

                chkAutoMount.Checked = NekoDrive.Properties.Settings.Default.AutoMount;
                tbDriveLabel.Text = NekoDrive.Properties.Settings.Default.DriveLabel;
                chkUnicode.Checked = NekoDrive.Properties.Settings.Default.Unicode;

                if (chkAutoMount.Checked)
                {
                    this.WindowState = FormWindowState.Minimized;
                    MountDrive();
                }
            }
            else
                throw new ApplicationException("Server not found!");
        }
Example #2
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                IPAddress ipAddress = new IPAddress(ipAddressControl1.GetAddressBytes());
                if (PingServer(ipAddress))
                {
                    NFSLibrary.NFSClient.NFSVersion ver = NFSLibrary.NFSClient.NFSVersion.v2;
                    if (cboxVer.SelectedItem.ToString() == "V3")
                        ver = NFSLibrary.NFSClient.NFSVersion.v3;

                    nfsClient = new NFSLibrary.NFSClient(ver);
                    nfsClient.DataEvent += new NFSLibrary.NFSClient.NFSDataEventHandler(nfsClient_DataEvent);
                    Encoding encoding = Encoding.ASCII;
                    if (chkUseUnicode.Checked)
                        encoding = Encoding.UTF8;
                    nfsClient.Connect(ipAddress, 1000, 1000, (int) nupTimeOut.Value * 1000, encoding, chkUseSecurePort.Checked);
                    nfsDevs = nfsClient.GetExportedDevices();
                    cboxRemoteDevices.Items.Clear();
                    foreach (string nfsdev in nfsDevs)
                        cboxRemoteDevices.Items.Add(nfsdev);
                    RefreshLocal(Environment.CurrentDirectory);
                    listViewRemote.Items.Clear();
                    pnlMain.Enabled = true;
                    
                }
                else
                    throw new Exception("Server not found!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "NFS Client");
                pnlMain.Enabled = false;
            }
        }
Example #3
0
        public void connect()
        {
            if (connected)
            {
                dissconect(false);
                return;
            }


            if (serverAdress == null)
            {
                MessageBox.Show("Please add a server to server list or add one time server.", "NFS Client");
                return;
            }

            IPAddress ipAddress;


            if (GetResolvedConnecionIPAddress(serverAdress, out ipAddress))
            {
                addToStatusLog("Resolved IP: " + ipAddress.ToString());
            }
            else
                return;

            bool pinged = false;

            try
            {
               pinged = PingServer(ipAddress);
            }
            catch (Exception e)
            {
                MessageBox.Show("Can't ping server, check your connection,host adress and NFS server. Code: " + e.Message, "NFS Client");
                addToStatusLog("Connection failed!");
                return;
            }

            if (pinged)
            {
                addToStatusLog("Pinged server...OK");
                //TODO
                NFSLibrary.NFSClient.NFSVersion ver;
                if (serverVersion == "v3")
                {
                    ver = NFSLibrary.NFSClient.NFSVersion.v3;
                    addToStatusLog("Using NFS version 3");
                }
                else if (serverVersion == "v2")
                {
                    ver = NFSLibrary.NFSClient.NFSVersion.v2;
                    addToStatusLog("Using NFS version 2");
                }
                else
                {
                    ver = NFSLibrary.NFSClient.NFSVersion.v4;
                    addToStatusLog("Using NFS version 4.1 !!! (experimantal)");
                }

                 addToStatusLog("Using uid: " + serverUid);


                nfsClient = new NFSLibrary.NFSClient(ver);
                nfsClient.DataEvent += new NFSLibrary.NFSClient.NFSDataEventHandler(nfsClient_DataEvent);
                Encoding encoding = Encoding.UTF8;       
                addToStatusLog("Connecting....");

                try
                {
                    nfsClient.Connect(ipAddress, serverUid,serverGid, NFSClient.Properties.Settings.Default.ConnectionTimeout * 1000, encoding,serverSecurePort, NFSClient.Properties.Settings.Default.UseFhCache);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Connection failed, check your host adress and NFS server. Code: " + ex.Message, "NFS Client");
                    addToStatusLog("Connection failed!");
                    return;
                }
                addToStatusLog("Connected!");
                connected = true;

                this.Text = "NFS Client - Connected, " + ipAddress + ", " + serverVersion;

                button_connect.Text = "Disconnect";
                label2.Visible = true;
                cboxRemoteDevices.Visible = true;
                addToStatusLog("Geting exported devices");
                try
                {
                    nfsDevs = nfsClient.GetExportedDevices();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "NFS Client - Error");
                    addToStatusLog("Connection failed!");
                    return;
                }
                cboxRemoteDevices.Items.Clear();
                foreach (string nfsdev in nfsDevs)
                    cboxRemoteDevices.Items.Add(nfsdev);

                listViewRemote.Items.Clear();

                //automatic connect to fist one
                if (cboxRemoteDevices.Items.Count > 0)
                {
                    try
                    {
                        //selected index change automaticly mount the device anyway
                        cboxRemoteDevices.SelectedIndex = 0;
                        //MountDevice(0);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "NFS Client - Error");
                    }
                }

            }
            else
                MessageBox.Show("Server not found!", "NFS Client"); 
        }
Example #4
0
 public Operations(NFSLibrary.NFSClient nfsClient, NFSClient.MainForm mainForm)
 {
     // TODO: Complete member initialization
     this.nfsClient = nfsClient;
     this.mainForm = mainForm;
 }
Example #5
0
 public Operations(NFSLibrary.NFSClient nfsClient, NFSClient.MainForm mainForm)
 {
     // TODO: Complete member initialization
     this.nfsClient = nfsClient;
     this.mainForm  = mainForm;
 }
Example #6
-1
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                IPAddress ipAddress = new IPAddress(ipAddressControl1.GetAddressBytes());
                if (PingServer(ipAddress))
                {
                    NFSLibrary.NFSClient.NFSVersion ver = NFSLibrary.NFSClient.NFSVersion.v2;
                    if (cboxVer.SelectedItem.ToString() == "V3")
                    {
                        ver = NFSLibrary.NFSClient.NFSVersion.v3;
                    }

                    nfsClient            = new NFSLibrary.NFSClient(ver);
                    nfsClient.DataEvent += new NFSLibrary.NFSClient.NFSDataEventHandler(nfsClient_DataEvent);
                    Encoding encoding = Encoding.ASCII;
                    if (chkUseUnicode.Checked)
                    {
                        encoding = Encoding.UTF8;
                    }
                    nfsClient.Connect(ipAddress, 1000, 1000, (int)nupTimeOut.Value * 1000, encoding, chkUseSecurePort.Checked);
                    nfsDevs = nfsClient.GetExportedDevices();
                    cboxRemoteDevices.Items.Clear();
                    foreach (string nfsdev in nfsDevs)
                    {
                        cboxRemoteDevices.Items.Add(nfsdev);
                    }
                    RefreshLocal(Environment.CurrentDirectory);
                    listViewRemote.Items.Clear();
                    pnlMain.Enabled = true;
                }
                else
                {
                    throw new Exception("Server not found!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "NFS Client");
                pnlMain.Enabled = false;
            }
        }