コード例 #1
0
        /// <summary>
        /// Default consturctor.
        /// </summary>
        internal UserFolderAclCollection(UserFolder folder)
        {
            m_pFolder     = folder;
            m_pAclEntries = new List<UserFolderAcl>();

            Bind();
        }
コード例 #2
0
ファイル: UserFolderCollection.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Adds new folder to user.
        /// </summary>
        /// <param name="newFolder">Folder to add. NOTE: Folder may not conatian path parts like folder/subfolder !</param>
        public UserFolder Add(string newFolder)
        {
            /* AddUserFolder <virtualServerID> "<folderOwnerUser>" "<folder>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();
            string path = "";
            string folderFullPath = newFolder;
            if(m_pFolder != null){
                path = m_pFolder.FolderFullPath;
                folderFullPath = path + "/" + newFolder; 
            }

            // Call TCP AddUserFolder
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("AddUserFolder " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pUser.UserName) + " " + TextUtils.QuoteString(folderFullPath));
                        
            string response = m_pUser.VirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            UserFolder folder = new UserFolder(this,m_pUser,m_pFolder,path,newFolder);
            m_pFolders.Add(folder);
            return folder;
        }
コード例 #3
0
        /// <summary>
        /// Default consturctor.
        /// </summary>
        internal UserFolderAclCollection(UserFolder folder)
        {
            m_pFolder     = folder;
            m_pAclEntries = new List <UserFolderAcl>();

            Bind();
        }
コード例 #4
0
        /// <summary>
        /// Adds new folder to user.
        /// </summary>
        /// <param name="newFolder">Folder to add. NOTE: Folder may not conatian path parts like folder/subfolder !</param>
        public UserFolder Add(string newFolder)
        {
            /* AddUserFolder <virtualServerID> "<folderOwnerUser>" "<folder>"
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

            string id             = Guid.NewGuid().ToString();
            string path           = "";
            string folderFullPath = newFolder;

            if (m_pFolder != null)
            {
                path           = m_pFolder.FolderFullPath;
                folderFullPath = path + "/" + newFolder;
            }

            // Call TCP AddUserFolder
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("AddUserFolder " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pUser.UserName) + " " + TextUtils.QuoteString(folderFullPath));

            string response = m_pUser.VirtualServer.Server.ReadLine();

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

            UserFolder folder = new UserFolder(this, m_pUser, m_pFolder, path, newFolder);

            m_pFolders.Add(folder);
            return(folder);
        }
コード例 #5
0
ファイル: UserFolderAcl.cs プロジェクト: genesissupsup/nkd
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="owner">Owner UserFolderAclCollection collection that owns this object.</param>
 /// <param name="folder">Folder to what that ACl entry applies.</param>
 /// <param name="userOrGroup">User or group to who this acl apply.</param>
 /// <param name="permissions">Permissions to owner folder.</param>
 internal UserFolderAcl(UserFolderAclCollection owner, UserFolder folder, string userOrGroup, IMAP_ACL_Flags permissions)
 {
     m_pOwner      = owner;
     m_pFolder     = folder;
     m_UserOrGroup = userOrGroup;
     m_Permissions = permissions;
 }
コード例 #6
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="owner">Owner UserFolderAclCollection collection that owns this object.</param>
 /// <param name="folder">Folder to what that ACl entry applies.</param>
 /// <param name="userOrGroup">User or group to who this acl apply.</param>
 /// <param name="permissions">Permissions to owner folder.</param>
 internal UserFolderAcl(UserFolderAclCollection owner,UserFolder folder,string userOrGroup,IMAP_ACL_Flags permissions)
 {
     m_pOwner      = owner;
     m_pFolder     = folder;
     m_UserOrGroup = userOrGroup;
     m_Permissions = permissions;
 }
コード例 #7
0
ファイル: wfrm_Compose.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Default constructor.
        /// </summary>
        public wfrm_Compose(UserFolder folder)
        {	
            m_pFolder = folder;
		
            InitUI();

            m_pFrom.Text = "\"" + m_pFolder.User.VirtualServer.Server.UserName + "\" <" + m_pFolder.User.VirtualServer.Server.UserName + "@localhost>";
        }
コード例 #8
0
ファイル: UserFolder.cs プロジェクト: dioptre/nkd
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="owner">Owner UserFolderCollection collection that owns this object.</param>
 /// <param name="user">Owner user.</param>
 /// <param name="parent">Gets parent folder.</param>
 /// <param name="folderPath">Folder path where folder belongs to.</param>
 /// <param name="folderName">Folder name.</param>
 internal UserFolder(UserFolderCollection owner,User user,UserFolder parent,string folderPath,string folderName)
 {
     m_pOwner        = owner;
     m_pUser         = user;
     m_pParent       = parent;
     m_Path          = folderPath;
     m_FolderName    = folderName;
     m_pChildFolders = new UserFolderCollection(false,this,m_pUser);
 }
コード例 #9
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="virtualServer">Virtual server.</param>
        /// <param name="folder">Folder what messages to show.</param>
        public wfrm_User_FolderMessages(VirtualServer virtualServer,UserFolder folder)
        {
            m_pVirtualServer = virtualServer;
            m_pFolder        = folder;

            InitUI();

            LoadData();
        }
コード例 #10
0
ファイル: UserFolder.cs プロジェクト: genesissupsup/nkd
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="owner">Owner UserFolderCollection collection that owns this object.</param>
 /// <param name="user">Owner user.</param>
 /// <param name="parent">Gets parent folder.</param>
 /// <param name="folderPath">Folder path where folder belongs to.</param>
 /// <param name="folderName">Folder name.</param>
 internal UserFolder(UserFolderCollection owner, User user, UserFolder parent, string folderPath, string folderName)
 {
     m_pOwner        = owner;
     m_pUser         = user;
     m_pParent       = parent;
     m_Path          = folderPath;
     m_FolderName    = folderName;
     m_pChildFolders = new UserFolderCollection(false, this, m_pUser);
 }
コード例 #11
0
        /// <summary>
        /// Gets server user folders and binds them to this, if not binded already.
        /// </summary>
        private void Bind()
        {
            /* GetUserFolders <virtualServerID> <userID>
             *    Responses:
             +OK <sizeOfData>
             *      <data>
             *
             + ERR <errorText>
             */

            lock (m_pUser.VirtualServer.Server.LockSynchronizer){
                // Call TCP GetUserEmailAddresses
                m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("GetUserFolders " + m_pUser.VirtualServer.VirtualServerID + " " + m_pUser.UserID);

                string response = m_pUser.VirtualServer.Server.ReadLine();
                if (!response.ToUpper().StartsWith("+OK"))
                {
                    throw new Exception(response);
                }

                int          sizeOfData = Convert.ToInt32(response.Split(new char[] { ' ' }, 2)[1]);
                MemoryStream ms         = new MemoryStream();
                m_pUser.VirtualServer.Server.TcpClient.TcpStream.ReadFixedCount(ms, sizeOfData);

                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);

                if (ds.Tables.Contains("Folders"))
                {
                    foreach (DataRow dr in ds.Tables["Folders"].Rows)
                    {
                        string[]             folderPathParts = dr["Folder"].ToString().Split('/');
                        UserFolderCollection current         = this;
                        string currentPath = "";
                        foreach (string pathPart in folderPathParts)
                        {
                            if (!current.Contains(pathPart))
                            {
                                UserFolder f = new UserFolder(current, m_pUser, current.Parent, currentPath, pathPart);
                                current.List.Add(f);
                            }

                            current = current[pathPart].ChildFolders;
                            if (currentPath == "")
                            {
                                currentPath = pathPart;
                            }
                            else
                            {
                                currentPath += "/" + pathPart;
                            }
                        }
                    }
                }
            }
        }
コード例 #12
0
ファイル: UserFolderCollection.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="bind"></param>
        /// <param name="folder">Owner folder or null if root.</param>
        /// <param name="user">Owner user.</param>
        internal UserFolderCollection(bool bind,UserFolder folder,User user)
        {
            m_pFolder  = folder;
            m_pUser    = user;
            m_pFolders = new List<UserFolder>();

            if(bind){
                Bind();
            }
        }
コード例 #13
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="bind"></param>
        /// <param name="folder">Owner folder or null if root.</param>
        /// <param name="user">Owner user.</param>
        internal UserFolderCollection(bool bind, UserFolder folder, User user)
        {
            m_pFolder  = folder;
            m_pUser    = user;
            m_pFolders = new List <UserFolder>();

            if (bind)
            {
                Bind();
            }
        }
コード例 #14
0
ファイル: UserFolderCollection.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Removes specified folder.
        /// </summary>
        /// <param name="folder">Folder to remove.</param>
        public void Remove(UserFolder folder)
        {
            /* DeleteUserFolder <virtualServerID> "<folderOwnerUser>" "<folder>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

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

            // Call TCP DeleteUserFolder
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteUserFolder " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pUser.UserName) + " " + TextUtils.QuoteString(folder.FolderFullPath));
                        
            string response = m_pUser.VirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            m_pFolders.Remove(folder);
        }
コード例 #15
0
        /// <summary>
        /// Removes specified folder.
        /// </summary>
        /// <param name="folder">Folder to remove.</param>
        public void Remove(UserFolder folder)
        {
            /* DeleteUserFolder <virtualServerID> "<folderOwnerUser>" "<folder>"
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

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

            // Call TCP DeleteUserFolder
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteUserFolder " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(m_pUser.UserName) + " " + TextUtils.QuoteString(folder.FolderFullPath));

            string response = m_pUser.VirtualServer.Server.ReadLine();

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

            m_pFolders.Remove(folder);
        }
コード例 #16
0
ファイル: UserFolderCollection.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Gets server user folders and binds them to this, if not binded already.
        /// </summary>
        private void Bind()
        {            
            /* GetUserFolders <virtualServerID> <userID>
                  Responses:
                    +OK <sizeOfData>
                    <data>
                    
                    + ERR <errorText>
            */

            lock(m_pUser.VirtualServer.Server.LockSynchronizer){
                // Call TCP GetUserEmailAddresses
                m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("GetUserFolders " + m_pUser.VirtualServer.VirtualServerID + " " + m_pUser.UserID);

                string response = m_pUser.VirtualServer.Server.ReadLine();
                if(!response.ToUpper().StartsWith("+OK")){
                    throw new Exception(response);
                }

                int sizeOfData = Convert.ToInt32(response.Split(new char[]{' '},2)[1]);
                MemoryStream ms = new MemoryStream();
                m_pUser.VirtualServer.Server.TcpClient.TcpStream.ReadFixedCount(ms,sizeOfData);
                
                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);
                
                if(ds.Tables.Contains("Folders")){
                    foreach(DataRow dr in ds.Tables["Folders"].Rows){
                        string[] folderPathParts = dr["Folder"].ToString().Split('/');
                        UserFolderCollection current = this;
                        string currentPath = "";
                        foreach(string pathPart in folderPathParts){
                            if(!current.Contains(pathPart)){                            
                                UserFolder f = new UserFolder(current,m_pUser,current.Parent,currentPath,pathPart);
                                current.List.Add(f);
                            }
                         
                            current = current[pathPart].ChildFolders;
                            if(currentPath == ""){
                                currentPath = pathPart;
                            }
                            else{
                                currentPath += "/" + pathPart;
                            }
                        }
                    }
                }
            }
        }