This commit is contained in:
putterman%netscape.com 1999-08-24 21:48:44 +00:00
Родитель 26d761907c
Коммит 4ebac4b8bd
8 изменённых файлов: 216 добавлений и 56 удалений

Просмотреть файл

@ -352,7 +352,8 @@ Rights Reserved.
<menuitem value="&markByDateCmd.label;" oncommand="MsgMarkByDate();"/>
<menuitem value="&markAllReadCmd.label;" oncommand="MsgMarkAllRead();"/>
<menuseparator/>
<menuitem value="&markFlaggedCmd.label;" oncommand="MsgMarkAsFlagged();"/>
<menuitem value="&markFlaggedCmd.label;" oncommand="MsgMarkAsFlagged(true);"/>
<menuitem value="&markUnflaggedCmd.label;" oncommand="MsgMarkAsFlagged(false);"/>
</menupopup>
</menu>
<menuseparator/>

Просмотреть файл

@ -491,7 +491,16 @@ function MsgMarkAllRead()
}
}
function MsgMarkAsFlagged() {}
function MsgMarkAsFlagged(markFlagged)
{
dump("\MsgMarkMsgAsFlagged from XUL\n");
var tree = GetThreadTree();
//get the selected elements
var messageList = tree.selectedItems;
messenger.MarkMessagesFlagged(tree.database, messageList, markFlagged);
}
function MsgIgnoreThread() {}
function MsgWatchThread() {}

Просмотреть файл

@ -106,51 +106,16 @@ public:
nsMessenger();
virtual ~nsMessenger();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
// nsIMessenger
NS_IMETHOD GetTransactionManager(nsITransactionManager * *aTxnMgr);
NS_IMETHOD Open3PaneWindow();
NS_IMETHOD GetNewMessages(nsIRDFCompositeDataSource *db, nsIDOMXULElement *folderElement);
NS_IMETHOD SetWindow(nsIDOMWindow *ptr, nsIMsgStatusFeedback *statusFeedback);
NS_IMETHOD OpenURL(const char * url);
NS_IMETHOD DoPrint();
NS_IMETHOD DoPrintPreview();
NS_IMETHOD DeleteMessages(nsIDOMXULElement *tree, nsIDOMXULElement *srcFolderElement, nsIDOMNodeList *nodeList);
NS_IMETHOD DeleteFolders(nsIRDFCompositeDataSource *db, nsIDOMXULElement *parentFolder, nsIDOMXULElement *folder);
NS_IMETHOD CopyMessages(nsIRDFCompositeDataSource *database, nsIDOMXULElement *srcFolderElement,
nsIDOMXULElement *dstFolderElement, nsIDOMNodeList *messages, PRBool isMove);
NS_IMETHOD GetRDFResourceForMessage(nsIDOMXULElement *tree,
nsIDOMNodeList *nodeList, nsISupports
**aSupport);
NS_IMETHOD Exit();
NS_IMETHOD Close();
NS_IMETHOD OnUnload();
NS_IMETHOD MarkMessagesRead(nsIRDFCompositeDataSource *database, nsIDOMNodeList *messages, PRBool markRead);
NS_IMETHOD MarkMessageRead(nsIRDFCompositeDataSource *database, nsIDOMXULElement *message, PRBool markRead);
NS_IMETHOD MarkAllMessagesRead(nsIRDFCompositeDataSource *database, nsIDOMXULElement *folder);
NS_IMETHOD NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
const char *name);
NS_IMETHOD RenameFolder(nsIRDFCompositeDataSource* db,
nsIDOMXULElement* folder,
const char* name);
NS_IMETHOD CompactFolder(nsIRDFCompositeDataSource* db,
nsIDOMXULElement* folder);
NS_IMETHOD EmptyTrash(nsIRDFCompositeDataSource* db,
nsIDOMXULElement* folder);
NS_IMETHOD Undo();
NS_IMETHOD Redo();
NS_IMETHOD SendUnsentMessages();
NS_IMETHOD LoadFirstDraft();
NS_IMETHOD SetDocumentCharset(const PRUnichar *characterSet);
NS_DECL_NSIMESSENGER
protected:
nsresult DoDelete(nsIRDFCompositeDataSource* db, nsISupportsArray *srcArray, nsISupportsArray *deletedArray);
nsresult DoCommand(nsIRDFCompositeDataSource *db, char * command, nsISupportsArray *srcArray,
nsISupportsArray *arguments);
nsresult DoMarkMessagesRead(nsIRDFCompositeDataSource *database, nsISupportsArray *resourceArray, PRBool markRead);
nsresult DoMarkMessagesFlagged(nsIRDFCompositeDataSource *database, nsISupportsArray *resourceArray, PRBool markFlagged);
private:
nsString mId;
@ -850,6 +815,74 @@ nsMessenger::MarkAllMessagesRead(nsIRDFCompositeDataSource *database, nsIDOMXULE
return rv;
}
NS_IMETHODIMP
nsMessenger::MarkMessageFlagged(nsIRDFCompositeDataSource *database, nsIDOMXULElement *message, PRBool markFlagged)
{
if(!database || !message)
return NS_ERROR_NULL_POINTER;
nsresult rv;
nsCOMPtr<nsIRDFResource> messageResource;
rv = message->GetResource(getter_AddRefs(messageResource));
if(NS_FAILED(rv))
return rv;
nsCOMPtr<nsISupportsArray> resourceArray;
rv = NS_NewISupportsArray(getter_AddRefs(resourceArray));
if(NS_FAILED(rv))
return NS_ERROR_OUT_OF_MEMORY;
resourceArray->AppendElement(messageResource);
rv = DoMarkMessagesFlagged(database, resourceArray, markFlagged);
return rv;
}
NS_IMETHODIMP
nsMessenger::MarkMessagesFlagged(nsIRDFCompositeDataSource *database, nsIDOMNodeList *messages, PRBool markFlagged)
{
nsresult rv;
if(!database || !messages)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsISupportsArray> resourceArray;
rv =ConvertDOMListToResourceArray(messages, getter_AddRefs(resourceArray));
if(NS_FAILED(rv))
return rv;
rv= DoMarkMessagesFlagged(database, resourceArray, markFlagged);
return rv;
}
nsresult
nsMessenger::DoMarkMessagesFlagged(nsIRDFCompositeDataSource *database, nsISupportsArray *resourceArray, PRBool markFlagged)
{
nsresult rv;
nsCOMPtr<nsISupportsArray> argumentArray;
rv = NS_NewISupportsArray(getter_AddRefs(argumentArray));
if(NS_FAILED(rv))
{
return NS_ERROR_OUT_OF_MEMORY;
}
if(markFlagged)
rv = DoCommand(database, NC_RDF_MARKFLAGGED, resourceArray, argumentArray);
else
rv = DoCommand(database, NC_RDF_MARKUNFLAGGED, resourceArray, argumentArray);
return rv;
}
NS_IMETHODIMP
nsMessenger::NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
const char *name)

Просмотреть файл

@ -41,15 +41,18 @@ static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
nsIRDFResource* nsMsgMessageDataSource::kNC_Subject;
nsIRDFResource* nsMsgMessageDataSource::kNC_Sender;
nsIRDFResource* nsMsgMessageDataSource::kNC_Date;
nsIRDFResource* nsMsgMessageDataSource::kNC_Status;
nsIRDFResource* nsMsgMessageDataSource::kNC_Subject = nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_Sender= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_Date= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_Status= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_Flagged= nsnull;
//commands
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkRead;
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkUnread;
nsIRDFResource* nsMsgMessageDataSource::kNC_ToggleRead;
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkRead= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkUnread= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_ToggleRead= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkFlagged= nsnull;
nsIRDFResource* nsMsgMessageDataSource::kNC_MarkUnflagged= nsnull;
nsMsgMessageDataSource::nsMsgMessageDataSource():
@ -81,12 +84,18 @@ nsMsgMessageDataSource::~nsMsgMessageDataSource (void)
NS_RELEASE2(kNC_Date, refcnt);
if (kNC_Status)
NS_RELEASE2(kNC_Status, refcnt);
if (kNC_Flagged)
NS_RELEASE2(kNC_Flagged, refcnt);
if (kNC_MarkRead)
NS_RELEASE2(kNC_MarkRead, refcnt);
if (kNC_MarkUnread)
NS_RELEASE2(kNC_MarkUnread, refcnt);
if (kNC_ToggleRead)
NS_RELEASE2(kNC_ToggleRead, refcnt);
if (kNC_MarkRead)
NS_RELEASE2(kNC_MarkFlagged, refcnt);
if (kNC_MarkUnread)
NS_RELEASE2(kNC_MarkUnflagged, refcnt);
nsServiceManager::ReleaseService(kRDFServiceCID, mRDFService); // XXX probably need shutdown listener here
NS_IF_RELEASE(mHeaderParser);
@ -125,10 +134,13 @@ nsresult nsMsgMessageDataSource::Init()
mRDFService->GetResource(NC_RDF_SENDER, &kNC_Sender);
mRDFService->GetResource(NC_RDF_DATE, &kNC_Date);
mRDFService->GetResource(NC_RDF_STATUS, &kNC_Status);
mRDFService->GetResource(NC_RDF_FLAGGED, &kNC_Flagged);
mRDFService->GetResource(NC_RDF_MARKREAD, &kNC_MarkRead);
mRDFService->GetResource(NC_RDF_MARKUNREAD, &kNC_MarkUnread);
mRDFService->GetResource(NC_RDF_TOGGLEREAD, &kNC_ToggleRead);
mRDFService->GetResource(NC_RDF_MARKFLAGGED, &kNC_MarkFlagged);
mRDFService->GetResource(NC_RDF_MARKUNFLAGGED, &kNC_MarkUnflagged);
}
mInitialized = PR_TRUE;
@ -235,7 +247,7 @@ NS_IMETHODIMP nsMsgMessageDataSource::GetTargets(nsIRDFResource* source,
nsCOMPtr<nsIMessage> message(do_QueryInterface(source, &rv));
if (NS_SUCCEEDED(rv)) {
if((kNC_Subject == property) || (kNC_Date == property) ||
(kNC_Status == property))
(kNC_Status == property) || kNC_Flagged == property)
{
nsSingletonEnumerator* cursor =
new nsSingletonEnumerator(source);
@ -338,15 +350,16 @@ nsMsgMessageDataSource::getMessageArcLabelsOut(nsIMessage *folder,
nsISupportsArray **arcs)
{
nsresult rv;
rv = NS_NewISupportsArray(arcs);
rv = NS_NewISupportsArray(arcs);
if(NS_FAILED(rv))
return rv;
(*arcs)->AppendElement(kNC_Subject);
(*arcs)->AppendElement(kNC_Sender);
(*arcs)->AppendElement(kNC_Date);
(*arcs)->AppendElement(kNC_Subject);
(*arcs)->AppendElement(kNC_Sender);
(*arcs)->AppendElement(kNC_Date);
(*arcs)->AppendElement(kNC_Status);
return NS_OK;
(*arcs)->AppendElement(kNC_Flagged);
return NS_OK;
}
@ -421,6 +434,10 @@ nsMsgMessageDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources
rv = DoMarkMessagesRead(aSources, PR_TRUE);
else if((aCommand == kNC_MarkUnread))
rv = DoMarkMessagesRead(aSources, PR_FALSE);
if((aCommand == kNC_MarkFlagged))
rv = DoMarkMessagesFlagged(aSources, PR_TRUE);
else if((aCommand == kNC_MarkUnflagged))
rv = DoMarkMessagesFlagged(aSources, PR_FALSE);
//for the moment return NS_OK, because failure stops entire DoCommand process.
return NS_OK;
@ -463,6 +480,17 @@ NS_IMETHODIMP nsMsgMessageDataSource::OnItemPropertyFlagChanged(nsISupports *ite
return rv;
rv = NotifyPropertyChanged(resource, kNC_Status, oldStatusStr, newStatusStr);
}
else if(PL_strcmp("Flagged", property) == 0)
{
nsCAutoString oldFlaggedStr, newFlaggedStr;
rv = createFlaggedStringFromFlag(oldFlag, oldFlaggedStr);
if(NS_FAILED(rv))
return rv;
rv = createFlaggedStringFromFlag(newFlag, newFlaggedStr);
if(NS_FAILED(rv))
return rv;
rv = NotifyPropertyChanged(resource, kNC_Flagged, oldFlaggedStr, newFlaggedStr);
}
}
return rv;
}
@ -479,8 +507,10 @@ nsMsgMessageDataSource::createMessageNode(nsIMessage *message,
return createMessageSenderNode(message, sort, target);
else if ((kNC_Date == property))
return createMessageDateNode(message, target);
else if ((kNC_Status == property))
else if ((kNC_Status == property))
return createMessageStatusNode(message, target);
else if ((kNC_Flagged == property))
return createMessageFlaggedNode(message, target);
else
return NS_RDF_NO_VALUE;
}
@ -582,11 +612,29 @@ nsMsgMessageDataSource::createMessageStatusNode(nsIMessage *message,
return rv;
}
nsresult
nsMsgMessageDataSource::createMessageFlaggedNode(nsIMessage *message,
nsIRDFNode **target)
{
nsresult rv;
PRUint32 flags;
nsCAutoString statusStr;
rv = message->GetFlags(&flags);
if(NS_FAILED(rv))
return rv;
rv = createFlaggedStringFromFlag(flags, statusStr);
if(NS_FAILED(rv))
return rv;
nsString uniStr = statusStr;
rv = createNode(uniStr, target);
return rv;
}
nsresult
nsMsgMessageDataSource::createStatusStringFromFlag(PRUint32 flags, nsCAutoString &statusStr)
{
nsresult rv = NS_OK;
statusStr = "";
statusStr = " ";
if(flags & MSG_FLAG_REPLIED)
statusStr = "replied";
else if(flags & MSG_FLAG_FORWARDED)
@ -598,6 +646,17 @@ nsMsgMessageDataSource::createStatusStringFromFlag(PRUint32 flags, nsCAutoString
return rv;
}
nsresult
nsMsgMessageDataSource::createFlaggedStringFromFlag(PRUint32 flags, nsCAutoString &statusStr)
{
nsresult rv = NS_OK;
if(flags & MSG_FLAG_MARKED)
statusStr = "flagged";
else
statusStr = "unflagged";
return rv;
}
nsresult
nsMsgMessageDataSource::DoMarkMessagesRead(nsISupportsArray *messages, PRBool markRead)
{
@ -629,6 +688,37 @@ nsMsgMessageDataSource::DoMarkMessagesRead(nsISupportsArray *messages, PRBool ma
return rv;
}
nsresult
nsMsgMessageDataSource::DoMarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged)
{
PRUint32 count;
nsresult rv;
nsCOMPtr<nsITransactionManager> transactionManager;
rv = GetTransactionManager(messages, getter_AddRefs(transactionManager));
if(NS_FAILED(rv))
return rv;
rv = messages->Count(&count);
if(NS_FAILED(rv))
return rv;
while(count > 0)
{
nsCOMPtr<nsISupportsArray> messageArray;
nsCOMPtr<nsIMsgFolder> folder;
rv = GetMessagesAndFirstFolder(messages, getter_AddRefs(folder), getter_AddRefs(messageArray));
if(NS_FAILED(rv))
return rv;
folder->MarkMessagesFlagged(messageArray, markFlagged);
rv = messages->Count(&count);
if(NS_FAILED(rv))
return rv;
}
return rv;
}
nsresult nsMsgMessageDataSource::NotifyPropertyChanged(nsIRDFResource *resource,
nsIRDFResource *propertyResource,
const char *oldValue, const char *newValue)

Просмотреть файл

@ -138,7 +138,12 @@ protected:
nsIRDFNode **target);
nsresult createStatusStringFromFlag(PRUint32 flags, nsCAutoString &statusStr);
nsresult createMessageFlaggedNode(nsIMessage *message,
nsIRDFNode **target);
nsresult createFlaggedStringFromFlag(PRUint32 flags, nsCAutoString &statusStr);
nsresult DoMarkMessagesRead(nsISupportsArray *messages, PRBool markRead);
nsresult DoMarkMessagesFlagged(nsISupportsArray *messages, PRBool markFlagged);
nsresult NotifyPropertyChanged(nsIRDFResource *resource,
nsIRDFResource *propertyResource,
@ -158,11 +163,14 @@ protected:
static nsIRDFResource* kNC_Sender;
static nsIRDFResource* kNC_Date;
static nsIRDFResource* kNC_Status;
static nsIRDFResource* kNC_Flagged;
// commands
static nsIRDFResource* kNC_MarkRead;
static nsIRDFResource* kNC_MarkUnread;
static nsIRDFResource* kNC_ToggleRead;
static nsIRDFResource* kNC_MarkFlagged;
static nsIRDFResource* kNC_MarkUnflagged;
};

Просмотреть файл

@ -37,6 +37,7 @@ typedef struct _nsMsgRDFNotification {
#define NC_RDF_SENDER NC_NAMESPACE_URI "Sender"
#define NC_RDF_DATE NC_NAMESPACE_URI "Date"
#define NC_RDF_STATUS NC_NAMESPACE_URI "Status"
#define NC_RDF_FLAGGED NC_NAMESPACE_URI "Flagged"
#define NC_RDF_CHILD NC_NAMESPACE_URI "child"
#define NC_RDF_MESSAGECHILD NC_NAMESPACE_URI "MessageChild"
@ -65,7 +66,8 @@ typedef struct _nsMsgRDFNotification {
#define NC_RDF_MARKREAD NC_NAMESPACE_URI "MarkRead"
#define NC_RDF_MARKUNREAD NC_NAMESPACE_URI "MarkUnread"
#define NC_RDF_TOGGLEREAD NC_NAMESPACE_URI "ToggleRead"
#define NC_RDF_MARKFLAGGED NC_NAMESPACE_URI "MarkFlagged"
#define NC_RDF_MARKUNFLAGGED NC_NAMESPACE_URI "MarkUnflagged"
//Returns PR_TRUE if r1 is equal to r2 and r2 is the sort property.
PRBool

Просмотреть файл

@ -74,6 +74,7 @@ public:
// Mark message routines
NS_IMETHOD MarkRead(PRBool bRead);
NS_IMETHOD MarkFlagged(PRBool bRead);
NS_IMETHOD GetMessageKey(nsMsgKey *result);
NS_IMETHOD GetThreadId(nsMsgKey *result);

Просмотреть файл

@ -181,6 +181,22 @@ NS_IMETHODIMP nsMsgHdr::MarkRead(PRBool bRead)
return rv;
}
NS_IMETHODIMP nsMsgHdr::MarkFlagged(PRBool bFlagged)
{
nsresult rv = NS_OK;
if(m_mdb)
{
nsMsgKey key;
rv = GetMessageKey(&key);
if(NS_SUCCEEDED(rv))
rv = m_mdb->MarkMarked(key, bFlagged, nsnull);
}
return rv;
}
NS_IMETHODIMP nsMsgHdr::GetProperty(const char *propertyName, nsString &resultProperty)
{
nsresult err = NS_OK;