Ejemplo n.º 1
0
        /// <summary>
        /// Adds new shared root folder to virtual server.
        /// </summary>
        /// <param name="enabled">Specifies if shared root folder is enabled.</param>
        /// <param name="name">Shared root folder name.</param>
        /// <param name="description">Shared root folder description.</param>
        /// <param name="type">Shared root folder type.</param>
        /// <param name="boundedUser">Bounded user.</param>
        /// <param name="boundedFolder">Bounded folder.</param>
        public SharedRootFolder Add(bool enabled, string name, string description, SharedFolderRootType_enum type, string boundedUser, string boundedFolder)
        {
            /* AddSharedRootFolder <virtualServerID> "<rootFolderID>" "<rootFolderName>" "<description>" <type> "<boundedUser>" "boundedFolder" <enabled>
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddSharedRootFolder
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("AddSharedRootFolder " +
                                                                  m_pVirtualServer.VirtualServerID + " " +
                                                                  TextUtils.QuoteString(id) + " " +
                                                                  TextUtils.QuoteString(name) + " " +
                                                                  TextUtils.QuoteString(description) + " " +
                                                                  (int)type + " " +
                                                                  TextUtils.QuoteString(boundedUser) + " " +
                                                                  TextUtils.QuoteString(boundedFolder) + " " +
                                                                  enabled
                                                                  );

            string response = m_pVirtualServer.Server.ReadLine();

            if (!response.ToUpper().StartsWith("+OK"))
            {
                throw new Exception(response);
            }

            SharedRootFolder rootFolder = new SharedRootFolder(m_pVirtualServer, this, id, enabled, name, description, type, boundedUser, boundedFolder);

            m_pRootFolders.Add(rootFolder);
            return(rootFolder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds new shared root folder to virtual server.
        /// </summary>
        /// <param name="enabled">Specifies if shared root folder is enabled.</param>
        /// <param name="name">Shared root folder name.</param>
        /// <param name="description">Shared root folder description.</param>
        /// <param name="type">Shared root folder type.</param>
        /// <param name="boundedUser">Bounded user.</param>
        /// <param name="boundedFolder">Bounded folder.</param>
        public SharedRootFolder Add(bool enabled,string name,string description,SharedFolderRootType_enum type,string boundedUser,string boundedFolder)
        {
            /* AddSharedRootFolder <virtualServerID> "<rootFolderID>" "<rootFolderName>" "<description>" <type> "<boundedUser>" "boundedFolder" <enabled>
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddSharedRootFolder
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("AddSharedRootFolder " + 
                m_pVirtualServer.VirtualServerID + " " + 
                TextUtils.QuoteString(id) + " " + 
                TextUtils.QuoteString(name) + " " + 
                TextUtils.QuoteString(description) + " " + 
                (int)type + " " +
                TextUtils.QuoteString(boundedUser) + " " + 
                TextUtils.QuoteString(boundedFolder) + " " + 
                enabled
            );
                        
            string response = m_pVirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            SharedRootFolder rootFolder = new SharedRootFolder(m_pVirtualServer,this,id,enabled,name,description,type,boundedUser,boundedFolder);
            m_pRootFolders.Add(rootFolder);
            return rootFolder;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Edit constructor.
        /// </summary>
        /// <param name="virtualServer">Virtual server.</param>
        /// <param name="root">Root Folder to update.</param>
        public wfrm_SharedFolders_RootFolder(VirtualServer virtualServer,SharedRootFolder root)
        {
            m_pVirtualServer = virtualServer;
            m_pRootFolder    = root;

            InitUI();

            m_pEnabled.Checked = root.Enabled;
            if(root.Type == SharedFolderRootType_enum.BoundedRootFolder){
                m_pRootFolderType.SelectedIndex = 0;
            }
            else if(root.Type == SharedFolderRootType_enum.UsersSharedFolder){
                m_pRootFolderType.SelectedIndex = 1;
            }
            m_pRootFolderName.Text = root.Name;
            m_pDescription.Text = root.Description;
            m_pBoundedUser.Text = root.BoundedUser;
            m_pBoundedFolder.Text = root.BoundedFolder;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes specified shared root folder from virtual server.
        /// </summary>
        /// <param name="sharedFolder">Shared folder to delete.</param>
        public void Remove(SharedRootFolder sharedFolder)
        {
            /* DeleteSharedRootFolder <virtualServerID> "<rootFolderID>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteGroup
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteSharedRootFolder " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(sharedFolder.ID));
                        
            string response = m_pVirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            m_pRootFolders.Remove(sharedFolder);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Removes specified shared root folder from virtual server.
        /// </summary>
        /// <param name="sharedFolder">Shared folder to delete.</param>
        public void Remove(SharedRootFolder sharedFolder)
        {
            /* DeleteSharedRootFolder <virtualServerID> "<rootFolderID>"
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteGroup
            m_pVirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteSharedRootFolder " + m_pVirtualServer.VirtualServerID + " " + TextUtils.QuoteString(sharedFolder.ID));

            string response = m_pVirtualServer.Server.ReadLine();

            if (!response.ToUpper().StartsWith("+OK"))
            {
                throw new Exception(response);
            }

            m_pRootFolders.Remove(sharedFolder);
        }
Ejemplo n.º 6
0
        private void m_Ok_Click(object sender, EventArgs e)
        {
            SharedFolderRootType_enum rootType = (SharedFolderRootType_enum)((WComboBoxItem)m_pRootFolderType.SelectedItem).Tag;

            //--- Validate values ------------------------//
            if(rootType == SharedFolderRootType_enum.BoundedRootFolder && m_pBoundedUser.Text == ""){
                MessageBox.Show(this,"Please select bounded user !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            if(rootType == SharedFolderRootType_enum.BoundedRootFolder && m_pBoundedFolder.Text == ""){
                MessageBox.Show(this,"Please select bounded folder !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
                return;
            }
            //--------------------------------------------//


            // Add new 
            if(m_pRootFolder == null){
                m_pRootFolder = m_pVirtualServer.RootFolders.Add(
                    m_pEnabled.Checked,
                    m_pRootFolderName.Text,
                    m_pDescription.Text,
                    (SharedFolderRootType_enum)((WComboBoxItem)m_pRootFolderType.SelectedItem).Tag,
                    m_pBoundedUser.Text,
                    m_pBoundedFolder.Text
                );
            }
            // Update
            else{
                m_pRootFolder.Enabled = m_pEnabled.Checked;
                m_pRootFolder.Name = m_pRootFolderName.Text;
                m_pRootFolder.Description = m_pDescription.Text;
                m_pRootFolder.Type = (SharedFolderRootType_enum)((WComboBoxItem)m_pRootFolderType.SelectedItem).Tag;
                m_pRootFolder.BoundedUser = m_pBoundedUser.Text;
                m_pRootFolder.BoundedFolder = m_pBoundedFolder.Text;
                m_pRootFolder.Commit();
            }

            this.DialogResult = DialogResult.OK;
        }