PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/thunderbird-14.0/comm-release/mailnews/extensions/newsblog/content/newsblogOverlay.js

#
JavaScript | 144 lines | 121 code | 11 blank | 12 comment | 16 complexity | d8d649e461371cff4d0ea89a43fab065 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, JSON, LGPL-3.0, AGPL-1.0, CC-BY-SA-3.0, LGPL-2.1, BSD-3-Clause, GPL-2.0, Apache-2.0, 0BSD, MIT
  1. # -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. #
  5. # The contents of this file are subject to the Mozilla Public License Version
  6. # 1.1 (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. # http://www.mozilla.org/MPL/
  9. #
  10. # Software distributed under the License is distributed on an "AS IS" basis,
  11. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. # for the specific language governing rights and limitations under the
  13. # License.
  14. #
  15. # The Original Code is Thunderbird Newsblog Overlay
  16. #
  17. # The Initial Developer of the Original Code is
  18. # The Mozilla Foundation.
  19. # Portions created by the Initial Developer are Copyright (C) 2005
  20. # the Initial Developer. All Rights Reserved.
  21. #
  22. # Contributor(s):
  23. # Scott MacGregor <mscott@mozilla.org>
  24. # David Bienvenu <bienvenu@nventure.com>
  25. #
  26. # Alternatively, the contents of this file may be used under the terms of
  27. # either the GNU General Public License Version 2 or later (the "GPL"), or
  28. # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. # in which case the provisions of the GPL or the LGPL are applicable instead
  30. # of those above. If you wish to allow use of your version of this file only
  31. # under the terms of either the GPL or the LGPL, and not to allow others to
  32. # use your version of this file under the terms of the MPL, indicate your
  33. # decision by deleting the provisions above and replace them with the notice
  34. # and other provisions required by the GPL or the LGPL. If you do not delete
  35. # the provisions above, a recipient may use your version of this file under
  36. # the terms of any one of the MPL, the GPL or the LGPL.
  37. #
  38. # ***** END LICENSE BLOCK ******
  39. Components.utils.import("resource:///modules/gloda/mimemsg.js");
  40. Components.utils.import("resource:///modules/mailServices.js");
  41. Components.utils.import("resource://gre/modules/Services.jsm");
  42. function openSubscriptionsDialog(aFolder)
  43. {
  44. // Check for an existing feed subscriptions window and focus it.
  45. let subscriptionsWindow =
  46. Services.wm.getMostRecentWindow("Mail:News-BlogSubscriptions");
  47. if (subscriptionsWindow)
  48. {
  49. if (aFolder)
  50. subscriptionsWindow.gFeedSubscriptionsWindow.selectFolder(aFolder);
  51. subscriptionsWindow.focus();
  52. }
  53. else
  54. {
  55. window.openDialog("chrome://messenger-newsblog/content/feed-subscriptions.xul",
  56. "", "centerscreen,chrome,dialog=no,resizable",
  57. { folder: aFolder});
  58. }
  59. }
  60. // Special case attempts to reply/forward/edit as new RSS articles. We are
  61. // here only if the message's account server is rss. Feed messages moved to
  62. // other account types will have their summaries loaded, as viewing web pages
  63. // only happens in an rss account. The user may choose whether to load a
  64. // summary or web page link by ensuring the current feed message is being
  65. // viewed as either a summary or web page.
  66. function openComposeWindowForRSSArticle(aMsgComposeWindow, aMsgHdr, aMessageUri,
  67. aType, aFormat, aIdentity, aMsgWindow)
  68. {
  69. if (gShowFeedSummary)
  70. {
  71. // The user is viewing the summary.
  72. MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
  73. aType, aFormat, aIdentity, aMsgWindow);
  74. }
  75. else
  76. {
  77. // Set up the compose message and get the feed message's web page link.
  78. let Cc = Components.classes;
  79. let Ci = Components.interfaces;
  80. let msgHdr = aMsgHdr;
  81. let type = aType;
  82. let msgComposeType = Ci.nsIMsgCompType;
  83. let subject = msgHdr.mime2DecodedSubject;
  84. let fwdPrefix = Services.prefs.getCharPref("mail.forward_subject_prefix");
  85. fwdPrefix = fwdPrefix ? fwdPrefix + ": " : "";
  86. let params = Cc["@mozilla.org/messengercompose/composeparams;1"].
  87. createInstance(Ci.nsIMsgComposeParams);
  88. let composeFields = Cc["@mozilla.org/messengercompose/composefields;1"].
  89. createInstance(Ci.nsIMsgCompFields);
  90. if (type == msgComposeType.Reply ||
  91. type == msgComposeType.ReplyAll ||
  92. type == msgComposeType.ReplyToSender ||
  93. type == msgComposeType.ReplyToGroup ||
  94. type == msgComposeType.ReplyToSenderAndGroup)
  95. {
  96. subject = "Re: " + subject;
  97. }
  98. else if (type == msgComposeType.ForwardInline ||
  99. type == msgComposeType.ForwardAsAttachment)
  100. {
  101. subject = fwdPrefix + subject;
  102. }
  103. params.composeFields = composeFields;
  104. params.composeFields.subject = subject;
  105. params.composeFields.characterSet = msgHdr.Charset;
  106. params.composeFields.body = "";
  107. params.bodyIsLink = false;
  108. params.identity = aIdentity;
  109. try
  110. {
  111. // The feed's web page url is stored in the Content-Base header.
  112. MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
  113. if (aMimeMsg && aMimeMsg.headers["content-base"] &&
  114. aMimeMsg.headers["content-base"][0])
  115. {
  116. params.composeFields.body = aMimeMsg.headers["content-base"];
  117. params.bodyIsLink = true;
  118. MailServices.compose.OpenComposeWindowWithParams(null, params);
  119. }
  120. else
  121. // No content-base url, use the summary.
  122. MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
  123. aType, aFormat, aIdentity, aMsgWindow);
  124. });
  125. }
  126. catch (ex)
  127. {
  128. // Error getting header, use the summary.
  129. MailServices.compose.OpenComposeWindow(aMsgComposeWindow, aMsgHdr, aMessageUri,
  130. aType, aFormat, aIdentity, aMsgWindow);
  131. }
  132. }
  133. }