зеркало из https://github.com/mozilla/pjs.git
add support for custom folder identities, and support them for delegated imap folders, sr=mscott 285474
This commit is contained in:
Родитель
aedf3bd409
Коммит
769f5b3ce5
|
@ -193,7 +193,9 @@ function ComposeMessage(type, format, folder, messageArray)
|
|||
newsgroup = folder.folderURL;
|
||||
}
|
||||
|
||||
identity = getIdentityForServer(server);
|
||||
identity = folder.customIdentity;
|
||||
if (!identity)
|
||||
identity = getIdentityForServer(server);
|
||||
// dump("identity = " + identity + "\n");
|
||||
}
|
||||
}
|
||||
|
@ -246,6 +248,13 @@ function ComposeMessage(type, format, folder, messageArray)
|
|||
var hdr = messenger.msgHdrFromURI(messageUri);
|
||||
// If we treat reply from sent specially, do we check for that folder flag here ?
|
||||
var hintForIdentity = (type == msgComposeType.Template) ? hdr.author : hdr.recipients + hdr.ccList;
|
||||
var customIdentity = null;
|
||||
if (folder)
|
||||
{
|
||||
server = folder.server;
|
||||
customIdentity = folder.customIdentity;
|
||||
}
|
||||
|
||||
var accountKey = hdr.accountKey;
|
||||
if (accountKey.length > 0)
|
||||
{
|
||||
|
@ -254,8 +263,9 @@ function ComposeMessage(type, format, folder, messageArray)
|
|||
server = account.incomingServer;
|
||||
}
|
||||
|
||||
if (server)
|
||||
identity = getIdentityForServer(server, hintForIdentity);
|
||||
identity = (server && !customIdentity)
|
||||
? getIdentityForServer(server, hintForIdentity)
|
||||
: customIdentity;
|
||||
|
||||
var messageID = hdr.messageId;
|
||||
var messageIDScheme = messageID ? messageID.split(":")[0] : "";
|
||||
|
|
|
@ -65,12 +65,13 @@ interface nsIFileSpec;
|
|||
interface nsIOutputStream;
|
||||
interface nsIInputStream;
|
||||
interface nsILocalFile;
|
||||
interface nsIMsgIdentity;
|
||||
|
||||
typedef long nsMsgBiffState;
|
||||
// enumerated type for determining if a message has been replied to, forwarded, etc.
|
||||
typedef long nsMsgDispositionState;
|
||||
|
||||
[scriptable, uuid(cc921aaf-8ff1-4fd3-8a3d-1269bf87f459)]
|
||||
[scriptable, uuid(07f2093e-fcd6-4b51-8e95-7c73129d7bda)]
|
||||
interface nsIMsgFolder : nsICollection {
|
||||
|
||||
const nsMsgBiffState nsMsgBiffState_NewMail = 0; // User has new mail waiting.
|
||||
|
@ -496,5 +497,9 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
// would figure out the diffs, but these methods might be more convenient.
|
||||
void addKeywordToMessages(in nsISupportsArray aMessages, in string aKeyword);
|
||||
void removeKeywordFromMessages(in nsISupportsArray aMessages, in string aKeyword);
|
||||
// this allows a folder to have a special identity. E.g., you might want to
|
||||
// associate an identity with a particular newsgroup, or for IMAP shared folders in
|
||||
// the other users namespace, you might want to create a delegated identity
|
||||
readonly attribute nsIMsgIdentity customIdentity;
|
||||
|
||||
};
|
||||
|
|
|
@ -5379,3 +5379,10 @@ NS_IMETHODIMP nsMsgDBFolder::RemoveKeywordFromMessages(nsISupportsArray *aMessag
|
|||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsMsgDBFolder::GetCustomIdentity(nsIMsgIdentity **aIdentity)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aIdentity);
|
||||
*aIdentity = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@
|
|||
#include "nsMsgCompCID.h"
|
||||
#include "nsICacheEntryDescriptor.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
@ -8589,3 +8591,84 @@ NS_IMETHODIMP nsImapMailFolder::RemoveKeywordFromMessages(nsISupportsArray *aMes
|
|||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::GetCustomIdentity(nsIMsgIdentity **aIdentity)
|
||||
{
|
||||
if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool delegateOtherUsersFolders = PR_FALSE;
|
||||
nsCOMPtr<nsIPrefBranch> prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
prefBranch->GetBoolPref("mail.imap.delegateOtherUsersFolders", &delegateOtherUsersFolders);
|
||||
// if we're automatically delegating other user's folders, we need to
|
||||
// cons up an e-mail address for the other user. We do that by
|
||||
// taking the other user's name and the current user's domain name,
|
||||
// assuming they'll be the same. So, <otherUsersName>@<ourDomain>
|
||||
if (delegateOtherUsersFolders)
|
||||
{
|
||||
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryReferent(mServer, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIMsgAccountManager> accountManager =
|
||||
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsIMsgIdentity> ourIdentity;
|
||||
nsCOMPtr <nsIMsgIdentity> retIdentity;
|
||||
nsCOMPtr <nsIMsgAccount> account;
|
||||
nsXPIDLCString foldersUserName;
|
||||
nsXPIDLCString ourEmailAddress;
|
||||
|
||||
accountManager->FindAccountForServer(server, getter_AddRefs(account));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
account->GetDefaultIdentity(getter_AddRefs(ourIdentity));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ourIdentity->GetEmail(getter_Copies(ourEmailAddress));
|
||||
PRInt32 atPos = ourEmailAddress.FindChar('@');
|
||||
if (atPos != -1)
|
||||
{
|
||||
nsXPIDLCString otherUsersEmailAddress;
|
||||
|
||||
GetFolderOwnerUserName(getter_Copies(otherUsersEmailAddress));
|
||||
otherUsersEmailAddress.Append(Substring(ourEmailAddress, atPos, ourEmailAddress.Length()));
|
||||
nsCOMPtr <nsISupportsArray> identities;
|
||||
rv = accountManager->GetIdentitiesForServer(server, getter_AddRefs(identities));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRUint32 numIdentities;
|
||||
rv = identities->Count(&numIdentities);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
for (PRUint32 identityIndex = 0; identityIndex < numIdentities; identityIndex++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgIdentity> identity = do_QueryElementAt(identities, identityIndex);
|
||||
if (!identity)
|
||||
continue;
|
||||
nsXPIDLCString identityEmail;
|
||||
identity->GetEmail(getter_Copies(identityEmail));
|
||||
if (identityEmail.Equals(otherUsersEmailAddress))
|
||||
{
|
||||
retIdentity = identity;;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!retIdentity)
|
||||
{
|
||||
// create the identity
|
||||
rv = accountManager->CreateIdentity(getter_AddRefs(retIdentity));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
retIdentity->SetEmail(otherUsersEmailAddress);
|
||||
nsCOMPtr <nsIMsgAccount> account;
|
||||
accountManager->FindAccountForServer(server, getter_AddRefs(account));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
account->AddIdentity(retIdentity);
|
||||
|
||||
}
|
||||
}
|
||||
if (retIdentity)
|
||||
{
|
||||
NS_ADDREF(*aIdentity = retIdentity);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nsMsgDBFolder::GetCustomIdentity(aIdentity);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,8 @@
|
|||
class nsImapMoveCoalescer;
|
||||
class nsHashtable;
|
||||
class nsHashKey;
|
||||
class nsIMsgIdentity;
|
||||
|
||||
#define COPY_BUFFER_SIZE 16384
|
||||
|
||||
/* b64534f0-3d53-11d3-ac2a-00805f8ac968 */
|
||||
|
@ -323,6 +325,7 @@ public:
|
|||
|
||||
NS_IMETHOD IsCommandEnabled(const char *command, PRBool *result);
|
||||
NS_IMETHOD SetFilterList(nsIMsgFilterList *aMsgFilterList);
|
||||
NS_IMETHOD GetCustomIdentity(nsIMsgIdentity **aIdentity);
|
||||
|
||||
nsresult MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
|
||||
nsIMsgDatabase *sourceDB,
|
||||
|
|
|
@ -89,6 +89,8 @@ pref("mail.delete_matches_sort_order", false);
|
|||
// mailnews tcp read+write timeout in seconds.
|
||||
pref("mailnews.tcptimeout", 60);
|
||||
|
||||
pref("mailnews.headers.showSender", false);
|
||||
|
||||
// Mail server preferences, pop by default
|
||||
pref("mail.server_type", 0); // 0 pop, 1 imap,
|
||||
// (Unix only:)
|
||||
|
@ -121,6 +123,10 @@ pref("mail.imap.mime_parts_on_demand_threshold", 30000);
|
|||
pref("mail.imap.use_literal_plus", true);
|
||||
pref("mail.imap.expunge_after_delete", false);
|
||||
pref("mail.imap.check_deleted_before_expunge", false);
|
||||
// if true, we assume that a user access a folder in the other users namespace
|
||||
// is acting as a delegate for that folder, and wishes to use the other users
|
||||
// identity when acting on messages in other users folders.
|
||||
pref("mail.imap.delegateOtherUsersFolders", false);
|
||||
pref("mail.thread_without_re", true); // if false, only thread by subject if Re:
|
||||
pref("mail.strict_threading", false); // if true, don't thread by suject at all
|
||||
pref("mail.leave_on_server", false);
|
||||
|
|
Загрузка…
Ссылка в новой задаче