From 645123f250ff37ba2b6df8612a5d9b4e324ed6fa Mon Sep 17 00:00:00 2001 From: wolfgang Date: Wed, 4 Jul 2007 16:12:59 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1097 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 8 ++++ .../iCalRepeatableEntityObject+OCS.m | 1 - SOPE/NGCards/CardElement.m | 7 +-- SoObjects/Mailer/SOGoMailObject.m | 8 ++-- UI/MailerUI/French.lproj/Localizable.strings | 1 + UI/MailerUI/GNUmakefile | 1 + UI/MailerUI/UIxMailSourceView.h | 33 +++++++++++++ UI/MailerUI/UIxMailSourceView.m | 48 +++++++++++++++++++ UI/MailerUI/product.plist | 5 ++ UI/Templates/MailerUI/UIxMailMainFrame.wox | 2 + UI/WebServerResources/MailerUI.js | 35 ++++++++++---- 11 files changed, 134 insertions(+), 15 deletions(-) create mode 100644 UI/MailerUI/UIxMailSourceView.h create mode 100644 UI/MailerUI/UIxMailSourceView.m diff --git a/ChangeLog b/ChangeLog index 7eada783..85d34b25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-07-04 Wolfgang Sourdeau + + * UI/MailerUI/UIxMailSourceView.[hm]: new class module designed to + return the message source code in plain text. + + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + -contentAsString]): returns the message encoded in UTF8. + 2007-07-03 Wolfgang Sourdeau * OGoContentStore/iCalRepeatableEntityObject+OCS.m diff --git a/OGoContentStore/iCalRepeatableEntityObject+OCS.m b/OGoContentStore/iCalRepeatableEntityObject+OCS.m index 5491d12f..5bedb6e2 100644 --- a/OGoContentStore/iCalRepeatableEntityObject+OCS.m +++ b/OGoContentStore/iCalRepeatableEntityObject+OCS.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "iCalRepeatableEntityObject+OCS.h" #include "common.h" diff --git a/SOPE/NGCards/CardElement.m b/SOPE/NGCards/CardElement.m index f715de76..45c9180f 100644 --- a/SOPE/NGCards/CardElement.m +++ b/SOPE/NGCards/CardElement.m @@ -424,9 +424,10 @@ string = [renderer render: self]; [renderer release]; - return (([string length] > 1) - ? [string substringToIndex: [string length] - 2] - : @""); + if ([string hasSuffix: @"\r\n"]) + string = [string substringToIndex: [string length] - 2]; + + return string; } - (CardElement *) elementWithClass: (Class) elementClass diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index 6f7d6ad7..a8b76bdb 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -425,7 +425,8 @@ static BOOL debugSoParts = NO; return @"message/rfc822"; } -- (NSString *)contentAsString { +- (NSString *) contentAsString +{ NSString *s; NSData *content; @@ -434,8 +435,9 @@ static BOOL debugSoParts = NO; if ([content isKindOfClass:[NSException class]]) return (id)content; - s = [[NSString alloc] initWithData:content - encoding:NSISOLatin1StringEncoding]; +#warning the encoding here might be wrong... + s = [[NSString alloc] initWithData: content + encoding: NSUTF8StringEncoding]; if (s == nil) { [self logWithFormat: @"ERROR: could not convert data of length %d to string", diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index c9fe7dfa..b3c4aaf4 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -147,6 +147,7 @@ "Mark" = "Marquer"; "Save As..." = "Enregistrer comme..."; "Print Preview" = "Aperçu avant impression"; +"View Message Source" = "Voir le code source"; "Print..." = "Imprimer..."; "Delete Message" = "Supprimer le message"; diff --git a/UI/MailerUI/GNUmakefile b/UI/MailerUI/GNUmakefile index 7467c026..38ee9ab7 100644 --- a/UI/MailerUI/GNUmakefile +++ b/UI/MailerUI/GNUmakefile @@ -20,6 +20,7 @@ MailerUI_OBJC_FILES += \ \ UIxMailListView.m \ UIxMailView.m \ + UIxMailSourceView.m \ UIxMailPopupView.m \ UIxMailMoveToPopUp.m \ UIxMailFilterPanel.m \ diff --git a/UI/MailerUI/UIxMailSourceView.h b/UI/MailerUI/UIxMailSourceView.h new file mode 100644 index 00000000..51ed7987 --- /dev/null +++ b/UI/MailerUI/UIxMailSourceView.h @@ -0,0 +1,33 @@ +/* UIxMailSourceView.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 UIXMAILSOURCEVIEW_H +#define UIXMAILSOURCEVIEW_H + +#import + +@interface UIxMailSourceView : WODirectAction + +@end + + +#endif /* UIXMAILSOURCEVIEW_H */ diff --git a/UI/MailerUI/UIxMailSourceView.m b/UI/MailerUI/UIxMailSourceView.m new file mode 100644 index 00000000..c0586221 --- /dev/null +++ b/UI/MailerUI/UIxMailSourceView.m @@ -0,0 +1,48 @@ +/* UIxMailSourceView.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 "UIxMailSourceView.h" + +@implementation UIxMailSourceView + +- (WOResponse *) viewSourceAction +{ + NSString *source; + WOResponse *response; + + source = [[self clientObject] contentAsString]; + + response = [context response]; + [response setStatus: 200]; + [response setHeader: @"text/plain; charset=utf-8" + forKey: @"content-type"]; + [response appendContentString: source]; + + return response; +} + +@end diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 2ad34027..32f6c3eb 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -192,6 +192,11 @@ categories = { protectedBy = "View"; pageName = "UIxMailView"; }; + viewsource = { + protectedBy = "View"; + actionClass = "UIxMailSourceView"; + actionName = "viewSource"; + }; popupview = { protectedBy = "View"; pageName = "UIxMailPopupView"; diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 343ad30d..47c56d98 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -95,6 +95,7 @@
  • +
  • @@ -114,6 +115,7 @@
  • +
  • diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 6e30e03a..0534c65f 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -90,7 +90,7 @@ function clickedEditorAttach(sender) { "width=320,height=320,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); return false; /* stop following the link */ - } +} function clickedEditorSave(sender) { document.pageform.action = "save"; @@ -208,7 +208,7 @@ function openMessageWindowsForSelection(action) { window.messageURL + "/" + action /* url */); else { var messageList = $("messageList"); - var rows = messageList.getSelectedRowsId(); + var rows = messageList.getSelectedRowsId(); var idset = ""; for (var i = 0; i < rows.length; i++) win = openMessageWindow(rows[i].substr(4) /* msguid */, @@ -676,15 +676,19 @@ function configureLinksInMessage() { var messageDiv = $('messageContent'); var mailContentDiv = document.getElementsByClassName('mailer_mailcontent', messageDiv)[0]; - Event.observe(mailContentDiv, "contextmenu", onMessageContentMenu.bindAsEventListener(mailContentDiv)); + Event.observe(mailContentDiv, "contextmenu", + onMessageContentMenu.bindAsEventListener(mailContentDiv)); var anchors = messageDiv.getElementsByTagName('a'); for (var i = 0; i < anchors.length; i++) if (anchors[i].href.substring(0,7) == "mailto:") { - Event.observe(anchors[i], "click", onEmailAddressClick.bindAsEventListener(anchors[i])); - Event.observe(anchors[i], "contextmenu", onEmailAddressClick.bindAsEventListener(anchors[i])); + Event.observe(anchors[i], "click", + onEmailAddressClick.bindAsEventListener(anchors[i])); + Event.observe(anchors[i], "contextmenu", + onEmailAddressClick.bindAsEventListener(anchors[i])); } else - Event.observe(anchors[i], "click", onMessageAnchorClick); + Event.observe(anchors[i], "click", + onMessageAnchorClick); } function onMessageContentMenu(event) { @@ -794,6 +798,19 @@ function onMenuForwardMessage(event) { return openMessageWindowsForSelection('forward'); } +function onMenuViewMessageSource(event) { + var messageList = $("messageList"); + var rows = messageList.getSelectedRowsId(); + + if (rows.length > 0) { + var url = (ApplicationBaseURL + currentMailbox + "/" + + rows[0].substr(4) + "/viewsource"); + window.open(url); + } + + preventDefault(event); +} + /* contacts */ function newContactFromEmail(event) { var mailto = document.menuTarget.innerHTML; @@ -1326,7 +1343,8 @@ function getMenus() { onMenuForwardMessage, null, "-", "moveMailboxMenu", "copyMailboxMenu", "label-menu", - "mark-menu", "-", null, null, + "mark-menu", "-", null, + onMenuViewMessageSource, null, null, onMenuDeleteMessage); menus["messageContentMenu"] = new Array(onMenuReplyToSender, onMenuReplyToAll, @@ -1335,7 +1353,8 @@ function getMenus() { "copyMailboxMenu", "-", "label-menu", "mark-menu", "-", - null, null, null, + null, onMenuViewMessageSource, + null, null, onMenuDeleteMessage); menus["label-menu"] = new Array(null, "-", null , null, null, null , null, null); -- 2.39.5