зеркало из https://github.com/mozilla/gecko-dev.git
Added NewFolder
This commit is contained in:
Родитель
ad3d72305e
Коммит
8f60e96f9e
|
@ -106,6 +106,9 @@ NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MAILNEWS, value)
|
|||
|
||||
#define NS_MSG_FOLDER_BUSY NS_MSG_GENERATE_FAILURE(10)
|
||||
|
||||
#define NS_MSG_COULD_NOT_CREATE_DIRECTORY NS_MSG_GENERATE_FAILURE(11)
|
||||
#define NS_MSG_CANT_CREATE_FOLDER NS_MSG_GENERATE_FAILURE(12)
|
||||
|
||||
#ifdef XP_MAC
|
||||
# define LINEBREAK "\012" /* ducarroz: it must be defined to \012 to avoid
|
||||
definition conflit with fe_proto.h */
|
||||
|
|
|
@ -66,6 +66,9 @@ class nsIDOMMsgAppCore : public nsIDOMBaseAppCore {
|
|||
/* void ViewAllThreadMessages (in nsIRDFCompositeDataSource database); */
|
||||
NS_IMETHOD ViewAllThreadMessages(nsIRDFCompositeDataSource *database) = 0;
|
||||
|
||||
/* void NewFolder (in nsIDOMXULElement parentFolderElement, in string name); */
|
||||
NS_IMETHOD NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement, const char *name) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIDOMMsgAppCore *priv);
|
||||
|
|
|
@ -59,6 +59,8 @@ interface nsIDOMMsgAppCore : nsIDOMBaseAppCore {
|
|||
void ViewAllMessages(in nsIRDFCompositeDataSource database);
|
||||
void ViewUnreadMessages(in nsIRDFCompositeDataSource database);
|
||||
void ViewAllThreadMessages(in nsIRDFCompositeDataSource database);
|
||||
void NewFolder(in nsIRDFCompositeDataSource database, in nsIDOMXULElement parentFolderElement,
|
||||
in string name);
|
||||
};
|
||||
|
||||
/* hack to make MsgAppCore visible from AppCore */
|
||||
|
|
|
@ -81,7 +81,7 @@ class nsIMsgFolder : public nsIFolder {
|
|||
NS_IMETHOD RecursiveDelete(PRBool deleteStorage) = 0;
|
||||
|
||||
/* void CreateSubfolder (in string leafNameFromUser, out nsIMsgFolder outFolder, out unsigned long outPos); */
|
||||
NS_IMETHOD CreateSubfolder(const char *leafNameFromUser, nsIMsgFolder **outFolder, PRUint32 *outPos) = 0;
|
||||
NS_IMETHOD CreateSubfolder(const char *folderName) = 0;
|
||||
|
||||
/* void Rename (in string name); */
|
||||
NS_IMETHOD Rename(const char *name) = 0;
|
||||
|
|
|
@ -57,7 +57,7 @@ interface nsIMsgFolder : nsIFolder {
|
|||
void PropagateDelete(inout nsIMsgFolder folder, in boolean deleteStorage);
|
||||
void RecursiveDelete(in boolean deleteStorage);
|
||||
|
||||
void CreateSubfolder(in string leafNameFromUser, out nsIMsgFolder outFolder, out unsigned long outPos);
|
||||
void CreateSubfolder(in string folderName);
|
||||
|
||||
void Rename(in string name);
|
||||
void Adopt(in nsIMsgFolder srcFolder, out unsigned long outPos);
|
||||
|
|
|
@ -604,6 +604,61 @@ MsgAppCoreViewAllThreadMessages(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
MsgAppCoreNewFolder(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
|
||||
nsIDOMMsgAppCore *nativeThis = (nsIDOMMsgAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMXULElement *parentFolder;
|
||||
nsIRDFCompositeDataSource *db;
|
||||
nsAutoString nameStr;
|
||||
const nsString typeName;
|
||||
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
rBool = nsJSUtils::nsConvertJSValToObject((nsISupports**)&db,
|
||||
nsIRDFCompositeDataSource::GetIID(),
|
||||
typeName,
|
||||
cx,
|
||||
argv[0]);
|
||||
|
||||
|
||||
|
||||
rBool = rBool && nsJSUtils::nsConvertJSValToObject((nsISupports**)&parentFolder,
|
||||
nsIDOMXULElement::GetIID(),
|
||||
typeName,
|
||||
cx,
|
||||
argv[1]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(nameStr, cx, argv[2]);
|
||||
|
||||
char * name = nameStr.ToNewCString();
|
||||
|
||||
|
||||
if (!rBool || NS_OK != nativeThis->NewFolder(db, parentFolder, name)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
delete[] name;
|
||||
|
||||
NS_RELEASE(parentFolder);
|
||||
NS_RELEASE(db);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function NewFolder requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for MsgAppCore
|
||||
|
@ -648,6 +703,7 @@ static JSFunctionSpec MsgAppCoreMethods[] =
|
|||
{"ViewAllMessages", MsgAppCoreViewAllMessages, 1},
|
||||
{"ViewUnreadMessages", MsgAppCoreViewUnreadMessages, 1},
|
||||
{"ViewAllThreadMessages", MsgAppCoreViewAllThreadMessages, 1},
|
||||
{"NewFolder", MsgAppCoreNewFolder, 3},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -114,6 +114,9 @@ public:
|
|||
NS_IMETHOD ViewAllMessages(nsIRDFCompositeDataSource *databsae);
|
||||
NS_IMETHOD ViewUnreadMessages(nsIRDFCompositeDataSource *databsae);
|
||||
NS_IMETHOD ViewAllThreadMessages(nsIRDFCompositeDataSource *database);
|
||||
NS_IMETHOD NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
|
||||
const char *name);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
@ -810,7 +813,61 @@ nsMsgAppCore::ViewAllThreadMessages(nsIRDFCompositeDataSource *database)
|
|||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgAppCore::NewFolder(nsIRDFCompositeDataSource *database, nsIDOMXULElement *parentFolderElement,
|
||||
const char *name)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIRDFResource *resource;
|
||||
nsIMsgFolder *parentFolder;
|
||||
nsISupportsArray *nameArray, *folderArray;
|
||||
|
||||
if(!parentFolderElement || !name)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
rv = parentFolderElement->GetResource(&resource);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = resource->QueryInterface(nsIMsgFolder::GetIID(), (void**)&parentFolder);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(NS_FAILED(NS_NewISupportsArray(&nameArray)))
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if(NS_FAILED(NS_NewISupportsArray(&folderArray)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
folderArray->AppendElement(parentFolder);
|
||||
|
||||
nsIRDFService* gRDFService = nsnull;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) &gRDFService);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsString nameStr = name;
|
||||
nsIRDFLiteral *nameLiteral;
|
||||
nsIRDFResource *newFolderResource;
|
||||
|
||||
gRDFService->GetLiteral(nameStr, &nameLiteral);
|
||||
nameArray->AppendElement(nameLiteral);
|
||||
if(NS_SUCCEEDED(rv = gRDFService->GetResource("http://home.netscape.com/NC-rdf#NewFolder", &newFolderResource)))
|
||||
{
|
||||
rv = database->DoCommand(folderArray, newFolderResource, nameArray);
|
||||
NS_RELEASE(newFolderResource);
|
||||
}
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
}
|
||||
NS_IF_RELEASE(nameArray);
|
||||
NS_IF_RELEASE(resource);
|
||||
NS_IF_RELEASE(parentFolder);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// to load the webshell!
|
||||
|
|
|
@ -638,7 +638,7 @@ NS_IMETHODIMP nsMsgFolder::RecursiveDelete(PRBool deleteStorage)
|
|||
return status;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::CreateSubfolder(const char *, nsIMsgFolder**, PRUint32*)
|
||||
NS_IMETHODIMP nsMsgFolder::CreateSubfolder(const char *folderName)
|
||||
{
|
||||
return NS_OK;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "nsRDFResource.h"
|
||||
#include "nsIRDFResourceFactory.h"
|
||||
#include "nsIDBFolderInfo.h"
|
||||
#include "nsMsgDatabase.h"
|
||||
#include "nsIMsgDatabase.h"
|
||||
|
||||
/*
|
||||
* MsgFolder
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
NS_IMETHOD PropagateDelete(nsIMsgFolder **folder, PRBool deleteStorage);
|
||||
NS_IMETHOD RecursiveDelete(PRBool deleteStorage); // called by PropagateDelete
|
||||
|
||||
NS_IMETHOD CreateSubfolder(const char *leafNameFromuser, nsIMsgFolder** outFolder, PRUint32* outPos);
|
||||
NS_IMETHOD CreateSubfolder(const char *folderName);
|
||||
|
||||
NS_IMETHOD Rename(const char *name);
|
||||
NS_IMETHOD Adopt(const nsIMsgFolder *srcFolder, PRUint32*);
|
||||
|
|
Загрузка…
Ссылка в новой задаче