зеркало из https://github.com/mozilla/gecko-dev.git
initial entry into cvs of msgdb api
This commit is contained in:
Родитель
ab59a88a4c
Коммит
5771409cd1
|
@ -0,0 +1,33 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXPORTS= \
|
||||
nsMsgHdr.h \
|
||||
nsMsgDatabase.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsMsgHdr.h"
|
||||
|
||||
class ListContext;
|
||||
|
||||
// I don't think this is going to be an interface, actually, since it's just
|
||||
// a thin layer above MDB that defines the msg db schema.
|
||||
|
||||
class nsMsgDatabase
|
||||
{
|
||||
public:
|
||||
nsMsgDatabase();
|
||||
virtual ~nsMsgDatabase();
|
||||
|
||||
nsresult OpenMDB(const char *dbName, PR_Bool create);
|
||||
nsresult CloseMDB(PR_Bool commit = TRUE);
|
||||
// get a message header for the given key. Caller must release()!
|
||||
nsresult GetMsgHdrForKey(MessageKey messageKey, nsMsgHdr **msgHdr);
|
||||
|
||||
// iterator methods
|
||||
// iterate through message headers, in no particular order
|
||||
// Caller must unrefer returned nsMsgHdr when done with it.
|
||||
// nsMsgEndOfList will be returned when return nsMsgHdr * is NULL.
|
||||
// Caller must call ListDone to free up the ListContext.
|
||||
nsresult ListFirst(ListContext **pContext, nsMsgHdr **pResult);
|
||||
nsresult ListNext(ListContext *pContext, nsMsgHdr **pResult);
|
||||
nsresult ListDone(ListContext *pContext);
|
||||
protected:
|
||||
mdbEnv *m_mdbEnv; // to be used in all the db calls.
|
||||
};
|
|
@ -0,0 +1,61 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsString.h"
|
||||
#include "mdb.h"
|
||||
|
||||
// this could inherit from nsISupports mainly to get ref-counting semantics
|
||||
// but I don't intend it to be a public interface. I'll just
|
||||
// declare AddRef and Release as methods..
|
||||
|
||||
class nsMsgHdr
|
||||
{
|
||||
public:
|
||||
nsMsgHdr();
|
||||
virtual ~nsMsgHdr();
|
||||
nsrefcnt AddRef(void);
|
||||
nsrefcnt Release(void);
|
||||
nsresult GetProperty(const char *propertyName, nsString &resultProperty);
|
||||
uint16 GetNumReferences();
|
||||
nsresult GetStringReference(int32 refNum, nsString &resultReference);
|
||||
time_t GetDate() {return m_date;}
|
||||
|
||||
MessageKey GetArticleNum();
|
||||
MessageKey GetMessageKey();
|
||||
MessageKey GetThreadId();
|
||||
|
||||
// this is almost always the m_messageKey, except for the first message.
|
||||
// NeoAccess doesn't allow fID's of 0.
|
||||
virtual uint32 GetMessageOffset() {return m_messageKey;}
|
||||
protected:
|
||||
nsrefcnt mRefCnt;
|
||||
|
||||
MessageKey m_threadId;
|
||||
MessageKey m_messageKey; //news: article number, mail mbox offset, imap uid...
|
||||
time_t m_date;
|
||||
uint32 m_messageSize; // lines for news articles, bytes for mail messages
|
||||
uint32 m_flags;
|
||||
uint16 m_numReferences; // x-ref header for threading
|
||||
|
||||
// nsMsgHdrs will have to know what db and row they belong to, since they are really
|
||||
// just a wrapper around the msg row in the mdb. This could cause problems,
|
||||
// though I hope not.
|
||||
nsIMsgDatabase *m_mdb;
|
||||
mdbRow *m_mdbRow;
|
||||
}
|
Загрузка…
Ссылка в новой задаче