+2007-07-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
+
+ * 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 <wsourdeau@inverse.ca>
* OGoContentStore/iCalRepeatableEntityObject+OCS.m
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "iCalRepeatableEntityObject+OCS.h"
#include "common.h"
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
return @"message/rfc822";
}
-- (NSString *)contentAsString {
+- (NSString *) contentAsString
+{
NSString *s;
NSData *content;
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",
"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";
\
UIxMailListView.m \
UIxMailView.m \
+ UIxMailSourceView.m \
UIxMailPopupView.m \
UIxMailMoveToPopUp.m \
UIxMailFilterPanel.m \
--- /dev/null
+/* UIxMailSourceView.h - this file is part of SOGo
+ *
+ * Copyright (C) 2007 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * 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 <NGObjWeb/WODirectAction.h>
+
+@interface UIxMailSourceView : WODirectAction
+
+@end
+
+
+#endif /* UIXMAILSOURCEVIEW_H */
--- /dev/null
+/* UIxMailSourceView.m - this file is part of SOGo
+ *
+ * Copyright (C) 2007 Inverse groupe conseil
+ *
+ * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
+ *
+ * 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 <NGObjWeb/WOContext.h>
+#import <NGObjWeb/WOResponse.h>
+#import <Foundation/NSString.h>
+#import <SoObjects/Mailer/SOGoMailObject.h>
+
+#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
protectedBy = "View";
pageName = "UIxMailView";
};
+ viewsource = {
+ protectedBy = "View";
+ actionClass = "UIxMailSourceView";
+ actionName = "viewSource";
+ };
popupview = {
protectedBy = "View";
pageName = "UIxMailPopupView";
<li><var:string label:value="Mark"/></li>
<li><!-- separator --></li>
<li><var:string label:value="Save As..."/></li>
+ <li><var:string label:value="View Message Source"/></li>
<li><var:string label:value="Print Preview"/></li>
<li><var:string label:value="Print..."/></li>
<li><var:string label:value="Delete Message"/></li>
<li><var:string label:value="Mark"/></li>
<li><!-- separator --></li>
<li><var:string label:value="Save As..."/></li>
+ <li><var:string label:value="View Message Source"/></li>
<li><var:string label:value="Print Preview"/></li>
<li><var:string label:value="Print..."/></li>
<li><var:string label:value="Delete Message"/></li>
"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";
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 */,
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) {
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;
onMenuForwardMessage, null,
"-", "moveMailboxMenu",
"copyMailboxMenu", "label-menu",
- "mark-menu", "-", null, null,
+ "mark-menu", "-", null,
+ onMenuViewMessageSource, null,
null, onMenuDeleteMessage);
menus["messageContentMenu"] = new Array(onMenuReplyToSender,
onMenuReplyToAll,
"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);