diff --git a/UI/MailerUI/GNUmakefile b/UI/MailerUI/GNUmakefile index 57091377c..7467c0262 100644 --- a/UI/MailerUI/GNUmakefile +++ b/UI/MailerUI/GNUmakefile @@ -25,6 +25,7 @@ MailerUI_OBJC_FILES += \ UIxMailFilterPanel.m \ \ UIxMailAccountActions.m \ + UIxMailFolderActions.m \ UIxMailEditor.m \ UIxMailEditorAttach.m \ UIxMailEditorAction.m \ diff --git a/UI/MailerUI/UIxMailFolderActions.h b/UI/MailerUI/UIxMailFolderActions.h new file mode 100644 index 000000000..df473df60 --- /dev/null +++ b/UI/MailerUI/UIxMailFolderActions.h @@ -0,0 +1,40 @@ +/* UIxMailFolderActions.h - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef UIXMAILFOLDERACTIONS_H +#define UIXMAILFOLDERACTIONS_H + +#import + +@class WOResponse; + +@interface UIxMailFolderActions : WODirectAction +{ +} + +- (WOResponse *) createFolderAction; +- (WOResponse *) renameFolderAction; +- (WOResponse *) deleteFolderAction; + +@end + +#endif /* UIXMAILFOLDERACTIONS_H */ diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m new file mode 100644 index 000000000..e5f9550e0 --- /dev/null +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -0,0 +1,126 @@ +/* UIxMailFolderActions.m - this file is part of SOGo + * + * Copyright (C) 2007 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import + +#import +#import +#import +#import + +#import + +#import "UIxMailFolderActions.h" + +@implementation UIxMailFolderActions + +- (WOResponse *) createFolderAction +{ + SOGoMailFolder *co; + WOResponse *response; + NGImap4Connection *connection; + NSException *error; + NSString *folderName; + + co = [self clientObject]; + response = [context response]; + + folderName = [[context request] formValueForKey: @"name"]; + if ([folderName length] > 0) + { + connection = [co imap4Connection]; + error = [connection createMailbox: folderName atURL: [co imap4URL]]; + if (error) + { + [response setStatus: 403]; + [response appendContentString: @"Unable to create folder."]; + } + else + [response setStatus: 204]; + } + else + { + [response setStatus: 403]; + [response appendContentString: @"Missing 'name' parameter."]; + } + + return response; +} + +- (WOResponse *) renameFolderAction +{ + SOGoMailFolder *co; + WOResponse *response; + NGImap4Connection *connection; + NSException *error; + NSString *folderName; + + co = [self clientObject]; + response = [context response]; + + folderName = [[context request] formValueForKey: @"name"]; + if ([folderName length] > 0) + { +// connection = [co imap4Connection]; +// error = [connection createMailbox: folderName atURL: [co imap4URL]]; +// if (error) +// { + [response setStatus: 403]; + [response appendContentString: @"Unable to rename folder."]; +// } +// else +// [response setStatus: 204]; + } + else + { + [response setStatus: 403]; + [response appendContentString: @"Missing 'name' parameter."]; + } + + return response; +} + +- (WOResponse *) deleteFolderAction +{ + SOGoMailFolder *co; + WOResponse *response; + NGImap4Connection *connection; + NSException *error; + + co = [self clientObject]; + response = [context response]; + connection = [co imap4Connection]; + error = [connection deleteMailboxAtURL: [co imap4URL]]; + if (error) + { + [response setStatus: 403]; + [response appendContentString: @"Unable to delete folder."]; + } + else + [response setStatus: 204]; + + return response; +} + +@end diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 50d92f343..7adcfbca2 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -123,13 +123,18 @@ }; createFolder = { protectedBy = "View"; - pageName = "UIxMailListView"; - actionName = "createFolder"; + actionClass = "UIxMailFolderActions"; + actionName = "createFolder"; + }; + renameFolder = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "renameFolder"; }; deleteFolder = { protectedBy = "View"; - pageName = "UIxMailListView"; - actionName = "deleteFolder"; + actionClass = "UIxMailFolderActions"; + actionName = "deleteFolder"; }; compose = { protectedBy = "View";