Esempio n. 1
0
        public override CommandResult Execute()
        {
            CommandResult result = new CommandResult(Command, Args);

            if (Args.Length == 0)
            {                
                return CommandResult.CreateError(Command, Args, "You are missing some arguments");
            }

            //Arguments args = new Arguments(Args);
            ArgumentParser parser = new ArgumentParser(Args);

            if (parser["o"] == null && parser["n"] == null)
            {
                return CommandResult.CreateError(Command, Args, "You are missing some arguments");
            }

            string sourceFolder = parser["o"].Trim(' ','"');
            string destFolder = parser["n"].Trim(' ','"');

            IFolder sourceFolderObj = Shell.FindFolder(sourceFolder);

            // if we can't find it at all, then throw an error
            if (sourceFolderObj == null)
            {
                return CommandResult.CreateError(Command, Args,
                                                 String.Format(
                                                     "The source folder '{0}' could not be found. Try specifying its full path.",
                                                     sourceFolder));
            }

            IFolder parentFolder = sourceFolderObj.Parent;
            RenameFolderRequest rfr = new RenameFolderRequest(sourceFolderObj, destFolder,
                delegate(IRequest req)
                    {
                        if (req.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE)
                        {
                            Shell.Client.MailboxManager.RenameFolder(sourceFolderObj, destFolder);
                        }
                    });

            Shell.Client.RequestManager.SubmitAndWait(rfr, false);

            return result;
        }
Esempio n. 2
0
        public override CommandResult Execute()
        {
            CommandResult result = new CommandResult(Command, Args);

            ArgumentParser parser = new ArgumentParser(Args);
            if (parser.Count < 2)
            {                
                return CommandResult.CreateError(Command, Args, "Incorrect number of arguments");
            }

            if (parser["f"] == null && parser["p"] == null)
            {                
                return CommandResult.CreateError(Command, Args, "Missing -f and/or -p arguments");
            }

            IFolder sourceFolder = Shell.FindFolder(parser["f"].Trim());
            IFolder parentFolder = Shell.FindFolder(parser["p"].Trim());

            if (sourceFolder == null)
                return CommandResult.CreateError(Command, Args, "Source folder could not be found");
            

            if (parentFolder == null && !parser["p"].Trim().Equals("/"))
                return CommandResult.CreateError(Command, Args, "Parent folder could not be found");

            if (sourceFolder == Shell.CurrentFolder)
            {
                return CommandResult.CreateError(Command, Args,
                                                 "You cannot move the current folder. Please change to a different folder first.");
            }

            Shell.Client.RequestManager.SubmitAndWait(new MoveFolderRequest(sourceFolder, parentFolder,
                delegate(IRequest req)
                    {
                        if (req.Result.Response == IMAPResponse.IMAP_SUCCESS_RESPONSE)
                            Shell.Client.MailboxManager.MoveFolder(sourceFolder, parentFolder);
                    }),false);

            return result;
        }