Back to index

lightning-sunbird  0.9+nobinonly
scd.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00039 // Plugin Manager Methods to support the JVM Plugin API
00041 
00042 #include "nsJVMManager.h"
00043 
00044 static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
00045 static NS_DEFINE_IID(kISymantecDebugManagerIID, NS_ISYMANTECDEBUGMANAGER_IID);
00046 
00047 NS_IMPL_AGGREGATED(nsSymantecDebugManager)
00048 
00049 nsSymantecDebugManager::nsSymantecDebugManager(nsISupports* outer, nsJVMManager* jvmMgr)
00050     : fJVMMgr(jvmMgr)
00051 {
00052     NS_INIT_AGGREGATED(outer);
00053 }
00054 
00055 nsSymantecDebugManager::~nsSymantecDebugManager()
00056 {
00057 }
00058 
00059 NS_METHOD
00060 nsSymantecDebugManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr)
00061 {
00062         if (!aInstancePtr)
00063             return NS_ERROR_INVALID_POINTER;
00064 
00065         if (aIID.Equals(NS_GET_IID(nsISupports)))
00066             *aInstancePtr = GetInner();
00067     else if (aIID.Equals(kISymantecDebugManagerIID))
00068         *aInstancePtr = NS_STATIC_CAST(nsISymantecDebugManager*, this);
00069         else {
00070             *aInstancePtr = nsnull;
00071                 return NS_NOINTERFACE;
00072         }
00073 
00074         NS_ADDREF((nsISupports*)*aInstancePtr);
00075         return NS_OK;
00076 }
00077 
00078 NS_METHOD
00079 nsSymantecDebugManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr, 
00080                                nsJVMManager* jvmMgr)
00081 {
00082         if (!aInstancePtr)
00083             return NS_ERROR_INVALID_POINTER;
00084     if (outer && !aIID.Equals(kISupportsIID))
00085         return NS_ERROR_INVALID_ARG;
00086     nsSymantecDebugManager* dbgr = new nsSymantecDebugManager(outer, jvmMgr);
00087     if (dbgr == NULL)
00088         return NS_ERROR_OUT_OF_MEMORY;
00089 
00090         nsresult rv = dbgr->AggregatedQueryInterface(aIID, aInstancePtr);
00091         if (NS_FAILED(rv)) {
00092             delete dbgr;
00093                 return rv;
00094         }
00095     return rv;
00096 }
00097 
00098 #if defined(XP_WIN) && defined(_WIN32)
00099 extern "C" HWND FindNavigatorHiddenWindow(void);
00100 #endif
00101 
00102 NS_METHOD
00103 nsSymantecDebugManager::SetDebugAgentPassword(PRInt32 pwd)
00104 {
00105 #if defined(XP_WIN) && defined(_WIN32)
00106     HWND win = NULL;
00107     /*
00108     ** TODO:amusil Get to a hidden window for symantec debugger to get its password from.
00109     HWND win = FindNavigatorHiddenWindow();
00110     */
00111     HANDLE sem;
00112     long err;
00113 
00114     /* set up by aHiddenFrameClass in CNetscapeApp::InitInstance */
00115     err = SetWindowLong(win, 0, pwd);     
00116     if (err == 0) {
00117 //        PR_LOG(NSJAVA, PR_LOG_ALWAYS,
00118 //               ("SetWindowLong returned %ld (err=%d)\n", err, GetLastError()));
00119         /* continue so that we try to wake up the DebugManager */
00120     }
00121     sem = OpenSemaphore(SEMAPHORE_MODIFY_STATE, FALSE, "Netscape-Symantec Debugger");
00122     if (sem) {
00123         ReleaseSemaphore(sem, 1, NULL);
00124         CloseHandle(sem);
00125     }
00126     return NS_OK;
00127 #else
00128     return NS_ERROR_FAILURE;
00129 #endif
00130 }
00131