Open a separate 3 pane Mail window using Javascrip

This commit is contained in:
chuang%netscape.com 1999-02-12 00:05:13 +00:00
Родитель 886796c607
Коммит edc19d406c
5 изменённых файлов: 65 добавлений и 55 удалений

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

@ -26,6 +26,7 @@ class nsIDOMMsgAppCore : public nsIDOMBaseAppCore {
/* void GetNewMail (); */ /* void GetNewMail (); */
NS_IMETHOD GetNewMail() = 0; NS_IMETHOD GetNewMail() = 0;
NS_IMETHOD Open3PaneWindow()=0;
}; };
#endif /* __gen_nsIDOMMsgAppCore_h__ */ #endif /* __gen_nsIDOMMsgAppCore_h__ */

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

@ -43,6 +43,7 @@
interface nsIDOMMsgAppCore : nsIDOMBaseAppCore { interface nsIDOMMsgAppCore : nsIDOMBaseAppCore {
void GetNewMail(); void GetNewMail();
void Open3PaneWindow();
}; };

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

@ -1,54 +0,0 @@
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function OpenMailWindow()
{
var appCore = AppCoresManager.Find("MailCore");
if (appCore==null) {
appCore = new MailCore();
if (appCore != null) {
appCore.Init("MailCore");
appCore.SetWindow(window);
appCore.Open3PaneWindow();
}
} else {
appCore.Open3PaneWindow();
}
}
// End -->
</script>
<title>Mozilla Messenger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#C0C0C0">
<style type="text/css">
/* This style sheet should be in a seperate file */
BODY,TD {
font-family: Sans-Serif;
background-color: #C0C0C0;
}
BODY,TD,INPUT {
font-size: 9pt;
}
BODY {
margin: 0px 0px 0px 0px;
}
</style>
<iframe src="msgbar.xml" name="messenger.toolbar" width="100%" height="56" >
<iframe src="frames.html" name="messenger.3pane" width="100%" height="500" >
<iframe src="status.html" name="messenger.status" width="100%" height="34" >
</body>
</html>

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

@ -163,6 +163,33 @@ MsgAppCoreGetNewMail(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsva
return JS_TRUE; return JS_TRUE;
} }
//
// Native method Open3PaneWindow
//
PR_STATIC_CALLBACK(JSBool)
MsgAppCoreOpen3PaneWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMMailCore *nativeThis = (nsIDOMMailCore*)JS_GetPrivate(cx, obj);
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc ==0 ) {
if (NS_OK != nativeThis->Open3PaneWindow()) {
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Open3PaneWindow don't have argument");
return JS_FALSE;
}
return JS_TRUE;
}
// this was in the old MailCore // this was in the old MailCore
#if 0 #if 0
// //
@ -319,6 +346,7 @@ static JSFunctionSpec MsgAppCoreMethods[] =
{ {
// don't have old MailCore methods // don't have old MailCore methods
{"GetNewMail", MsgAppCoreGetNewMail, 0}, {"GetNewMail", MsgAppCoreGetNewMail, 0},
{"Open3PaneWindow", MsgAppCoreOpen3PaneWindow, 0},
#if 0 #if 0
{"SendMail", MsgAppCoreSendMail, 3}, {"SendMail", MsgAppCoreSendMail, 3},
{"MailCompleteCallback", MsgAppCoreMailCompleteCallback, 1}, {"MailCompleteCallback", MsgAppCoreMailCompleteCallback, 1},
@ -476,3 +504,4 @@ extern "C" NS_DOM nsresult NS_NewScriptMsgAppCore(nsIScriptContext *aContext, ns
return NS_OK; return NS_OK;
} }

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

@ -50,10 +50,10 @@ public:
NS_IMETHOD SetScriptObject(void* aScriptObject); NS_IMETHOD SetScriptObject(void* aScriptObject);
// nsIMsgAppCore // nsIMsgAppCore
NS_IMETHOD Open3PaneWindow();
NS_IMETHOD GetNewMail(); NS_IMETHOD GetNewMail();
NS_IMETHOD SetWindow(nsIDOMWindow* aWin); NS_IMETHOD SetWindow(nsIDOMWindow* aWin);
private: private:
nsString mId; nsString mId;
@ -167,6 +167,39 @@ nsMsgAppCore::GetId(nsString& aId)
// //
// nsIMsgAppCore // nsIMsgAppCore
// //
NS_IMETHODIMP
nsMsgAppCore::Open3PaneWindow()
{
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
nsIAppShellService* appShell;
char * urlstr=nsnull;
nsresult rv;
nsString controllerCID;
urlstr = "resource:/res/samples/messenger.html";
rv = nsServiceManager::GetService(kAppShellServiceCID,
kIAppShellServiceIID,
(nsISupports**)&appShell);
nsIURL* url;
nsIWidget* newWindow;
rv = NS_NewURL(&url, urlstr);
if (NS_FAILED(rv)) {
goto done;
}
controllerCID = "6B75BB61-BD41-11d2-9D31-00805F8ADDDE";
appShell->CreateTopLevelWindow(url, controllerCID, newWindow, nsnull);
done:
NS_RELEASE(url);
if (nsnull != appShell) {
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
}
return NS_OK;
}
nsresult nsresult
nsMsgAppCore::GetNewMail() nsMsgAppCore::GetNewMail()
{ {