Bug=82189

author=ashuk
r=edburns

Files modified
A mozilla/java/webclient/classes_spec/org/mozilla/webclient/stubs
A mozilla/java/webclient/classes_spec/org/mozilla/webclient/ProfileManager.java
A mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/ProfileManagerImpl.java
A mozilla/java/webclient/config/rules.mk
A mozilla/java/webclient/config/rules.mak
A mozilla/java/webclient/import
A mozilla/java/webclient/import/Makefile.in
A mozilla/java/webclient/import/Makefile.win
A mozilla/java/webclient/import/chPackage.pl
M mozilla/java/webclient/Makefile.in
M mozilla/java/webclient/Makefile.win
M mozilla/java/webclient/classes_spec/Makefile.in
M mozilla/java/webclient/classes_spec/Makefile.win
M mozilla/java/webclient/classes_spec/org/mozilla/webclient/BrowserControl.java
M mozilla/java/webclient/classes_spec/org/mozilla/webclient/BrowserControlImpl.java
M mozilla/java/webclient/classes_spec/org/mozilla/webclient/test/EMWindow.java
M mozilla/java/webclient/classes_spec/org/mozilla/webclient/wrapper_native/WrapperFactoryImpl.java
M mozilla/java/webclient/src_share/runem.pl

This fix adds the new ProfileManager interface in the Webclient API.
This is also the first integration of BlackConnect in Webclient.
Webclient uses this ProfileManager interface to provide an interface
to the nsIProfile api in Mozilla for profile management. It uses
BlackConnect for this.
This commit is contained in:
ashuk%eng.sun.com 2001-05-24 21:13:50 +00:00
parent ab25003da8
commit 5fe3250b5a
16 changed files with 513 additions and 14 deletions

View File

@ -25,7 +25,7 @@ include $(DEPTH)/config/autoconf.mk
#// DIRS - There are subdirectories to process
#//
#//------------------------------------------------------------------------
DIRS= classes_spec src_share src_moz
DIRS= import classes_spec src_share src_moz
#//------------------------------------------------------------------------
#//

View File

@ -35,7 +35,8 @@ IGNORE_MANIFEST=1
#//------------------------------------------------------------------------
DEPTH = ..\..
DIRS = classes_spec \
DIRS = import \
classes_spec \
src_share \
$(NULL)

View File

@ -32,6 +32,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = webclient
JMODS = org/mozilla/webclient \
org/mozilla/webclient/stubs \
org/mozilla/webclient/wrapper_native \
org/mozilla/webclient/wrapper_native/motif \
org/mozilla/webclient/test

View File

@ -46,6 +46,7 @@ include <$(DEPTH)\java\config\localdefs.mak>
JAR_WEBCLIENT_CLASSES = \
org\mozilla\webclient \
org\mozilla\webclient\stubs \
org\mozilla\webclient\wrapper_native \
org\mozilla\webclient\wrapper_native\win32 \
org\mozilla\webclient\test \

View File

@ -35,7 +35,7 @@ package org.mozilla.webclient;
*
* @version $Id: BrowserControl.java,v 1.1 2000/03/04 01:10:51 edburns%acm.org Exp $
* @version $Id: BrowserControl.java,v 1.2 2001/05/24 21:13:30 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
* */
@ -54,7 +54,7 @@ public static String CACHE_MANAGER_NAME = "webclient.cache.NetDataCacheManager";
public static String PREFERENCES_NAME = "webclient.Preferences";
public static String PRINT_NAME = "webclient.Print";
public static String WINDOW_CONTROL_NAME = "webclient.WindowControl";
public static String PROFILE_MANAGER_NAME = "webclient.ProfileManager";
/**

View File

@ -71,6 +71,7 @@ private Navigation navigation = null;
private History history = null;
private static Bookmarks bookmarks = null;
private static Preferences prefs = null;
private static ProfileManager profileManager = null;
//
// Constructors and Initializers
@ -157,6 +158,10 @@ static void appTerminate() throws Exception
((ImplObject)prefs).delete();
prefs = null;
}
if (null != profileManager) {
((ImplObject)profileManager).delete();
profileManager = null;
}
wrapperFactory.terminate();
}
@ -281,6 +286,13 @@ public Object queryInterface(String interfaceName) throws ClassNotFoundException
}
return prefs;
}
if (PROFILE_MANAGER_NAME.equals(interfaceName)) {
if (null == profileManager) {
profileManager = (ProfileManager)
wrapperFactory.newImpl(PROFILE_MANAGER_NAME, this);
}
return profileManager;
}
// extensibility mechanism: just see if wrapperFactory can make one!
return wrapperFactory.newImpl(interfaceName, this);
}
@ -296,7 +308,7 @@ public static void main(String [] args)
Assert.setEnabled(true);
Log.setApplicationName("BrowserControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.4 2001/04/02 21:13:43 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: BrowserControlImpl.java,v 1.5 2001/05/24 21:13:30 ashuk%eng.sun.com Exp $");
}

View File

@ -0,0 +1,44 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashu Kulkarni <ashuk@eng.sun.com>
*/
package org.mozilla.webclient;
public interface ProfileManager
{
public int GetProfileCount();
public String [] GetProfileList(int [] length);
public boolean ProfileExists(String profileName);
public String GetCurrentProfile();
public void SetCurrentProfile(String profileName);
public void CreateNewProfile(String profileName, String nativeProfileDir, String langcode, boolean useExistingDir);
public void RenameProfile(String currName, String newName);
public void DeleteProfile(String profileName, boolean canDeleteFiles);
public void CloneProfile(String currName);
}

View File

@ -57,7 +57,7 @@ import java.io.FileInputStream;
* This is a test application for using the BrowserControl.
*
* @version $Id: EMWindow.java,v 1.30 2001/05/23 22:26:51 edburns%acm.org Exp $
* @version $Id: EMWindow.java,v 1.31 2001/05/24 21:13:45 ashuk%eng.sun.com Exp $
*
* @see org.mozilla.webclient.BrowserControlFactory
@ -110,6 +110,8 @@ private UniversalDialog uniDialog = null;
private MenuItem popup_ViewSource, popup_SelectAll;
private PopupActionListener contextListener;
private ProfileManager profileManager = null;
private String myBinDir;
public static void main(String [] arg)
{
@ -123,6 +125,7 @@ private UniversalDialog uniDialog = null;
creator = Creator;
currentURL = url;
winNum = winnum;
myBinDir = binDir;
System.out.println("constructed with binDir: " + binDir + " url: " +
url);
setSize(defaultWidth, defaultHeight);
@ -134,6 +137,7 @@ private UniversalDialog uniDialog = null;
Menu viewMenu = new Menu("View");
Menu searchMenu = new Menu("Search");
Menu editMenu = new Menu("Edit");
Menu profileMenu = new Menu("Profile");
MenuItem newItem = new MenuItem("New Window");
MenuItem closeItem = new MenuItem("Close");
MenuItem findItem = new MenuItem("Find");
@ -142,10 +146,19 @@ private UniversalDialog uniDialog = null;
MenuItem pageInfoItem = new MenuItem("View Page Info");
MenuItem selectAllItem = new MenuItem("Select All");
MenuItem copyItem = new MenuItem("Copy");
MenuItem createProfileItem = new MenuItem("Create Profile");
MenuItem deleteProfileItem = new MenuItem("Delete Profile");
menuBar.add(fileMenu);
menuBar.add(viewMenu);
menuBar.add(searchMenu);
menuBar.add(editMenu);
menuBar.add(profileMenu);
profileMenu.add(createProfileItem);
createProfileItem.addActionListener(this);
profileMenu.add(deleteProfileItem);
deleteProfileItem.addActionListener(this);
fileMenu.add(newItem);
newItem.addActionListener(this);
fileMenu.add(closeItem);
@ -310,6 +323,7 @@ private UniversalDialog uniDialog = null;
"network.cookie.warnAboutCookies",
"This IS the Closure!");
prefs.setPref("network.cookie.warnAboutCookies", "true");
prefs.setPref("browser.cache.disk_cache_size", "0");
// pull out the proxies, and make java aware of them
Properties prefsProps = prefs.getPrefs();
@ -417,11 +431,6 @@ public void delete()
currentDocument = null;
}
public BrowserControl getBrowserControl()
{
return browserControl;
}
public void actionPerformed (ActionEvent evt)
{
@ -466,6 +475,20 @@ public void actionPerformed (ActionEvent evt)
}
else if (command.equals("Copy")) {
currentPage.copyCurrentSelectionToSystemClipboard();
}
else if (command.equals("Create Profile")) {
if (profileManager == null) {
profileManager = (ProfileManager)
browserControl.queryInterface(BrowserControl.PROFILE_MANAGER_NAME);
}
profileManager.CreateNewProfile("Tester", myBinDir, null, true);
}
else if (command.equals("Delete Profile")) {
if (profileManager == null) {
profileManager = (ProfileManager)
browserControl.queryInterface(BrowserControl.PROFILE_MANAGER_NAME);
}
profileManager.DeleteProfile("Tester", true);
}
else if(command.equals("Stop")) {
navigation.stop();

View File

@ -0,0 +1,162 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ashu Kulkarni <ashuk@eng.sun.com>
*/
package org.mozilla.webclient.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.ProfileManager;
import org.mozilla.webclient.WindowControl;
import org.mozilla.webclient.WrapperFactory;
import org.mozilla.webclient.UnimplementedException;
import org.mozilla.xpcom.*;
import org.mozilla.webclient.stubs.*;
public class ProfileManagerImpl extends ImplObjectNative implements ProfileManager
{
// local variables
private nsIXPIDLServiceManager serviceMgr;
private nsIProfile profileStub;
private CID nsProfileCID = new CID("02b0625b-e7f3-11d2-9f5a-006008a6efe9");
public ProfileManagerImpl(WrapperFactory yourFactory,
BrowserControl yourBrowserControl)
{
super(yourFactory, yourBrowserControl);
// Make whatever native calls are required to initialize the
// BlackConnect Profile module here
InterfaceRegistry.register(nsIProfile.class);
serviceMgr = org.mozilla.xpcom.Components.getServiceManager();
nsISupports profile = serviceMgr.getService(nsProfileCID, nsIProfile.IID);
profileStub = (nsIProfile) profile.queryInterface(nsIProfile.IID);
}
public int GetProfileCount()
{
myFactory.throwExceptionIfNotInitialized();
int count;
synchronized(myBrowserControl) {
count = profileStub.getProfileCount();
}
return count;
}
public String [] GetProfileList(int [] length)
{
myFactory.throwExceptionIfNotInitialized();
String [] list = null;
synchronized(myBrowserControl) {
list = profileStub.getProfileList(length);
}
return list;
}
public boolean ProfileExists(String profileName)
{
myFactory.throwExceptionIfNotInitialized();
boolean exists = false;
synchronized(myBrowserControl) {
exists = profileStub.profileExists(profileName);
}
return exists;
}
public String GetCurrentProfile()
{
myFactory.throwExceptionIfNotInitialized();
String currProfile = null;
synchronized(myBrowserControl) {
currProfile = profileStub.getCurrentProfile();
}
return currProfile;
}
public void SetCurrentProfile(String profileName)
{
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
profileStub.setCurrentProfile(profileName);
}
}
public void CreateNewProfile(String profileName, String nativeProfileDir, String langcode, boolean useExistingDir)
{
myFactory.throwExceptionIfNotInitialized();
System.out.println("\nIn ProfileManager CreateNewProfile\n");
synchronized(myBrowserControl) {
profileStub.createNewProfile(profileName, nativeProfileDir, langcode, useExistingDir);
}
}
public void RenameProfile(String currName, String newName)
{
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
profileStub.renameProfile(currName, newName);
}
}
public void DeleteProfile(String profileName, boolean canDeleteFiles)
{
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
profileStub.deleteProfile(profileName, canDeleteFiles);
}
}
public void CloneProfile(String currName)
{
myFactory.throwExceptionIfNotInitialized();
synchronized(myBrowserControl) {
profileStub.cloneProfile(currName);
}
}
protected void finalize()
{
if (profileStub != null) {
//Release any service that we may be holding on to
nsISupports obj = (nsISupports) profileStub.queryInterface(nsISupports.IID);
serviceMgr.releaseService(nsProfileCID, obj);
}
}
}

View File

@ -35,6 +35,11 @@ public class WrapperFactoryImpl extends WrapperFactory
// Protected Constants
//
final String [] stubsImplementedInterfaces =
{
BrowserControl.PROFILE_MANAGER_NAME
};
//
// Class Variables
//
@ -109,7 +114,7 @@ public Object newImpl(String interfaceName,
Object result = null;
synchronized(this) {
if (!nativeDoesImplement(interfaceName)) {
if (!stubsDoImplement(interfaceName) && !nativeDoesImplement(interfaceName)) {
throw new ClassNotFoundException("Can't instantiate " +
interfaceName +
": not implemented.");
@ -144,6 +149,10 @@ public Object newImpl(String interfaceName,
result = new PreferencesImpl(this, browserControl);
return result;
}
if (BrowserControl.PROFILE_MANAGER_NAME == interfaceName) {
result = new ProfileManagerImpl(this, browserControl);
return result;
}
}
return result;
@ -174,6 +183,19 @@ public boolean hasBeenInitialized()
return initialized;
}
private boolean stubsDoImplement(String interfaceName)
{
boolean foundInterface = false;
for (int i=0; i<stubsImplementedInterfaces.length; i++) {
if (interfaceName.equals(stubsImplementedInterfaces[i])) {
foundInterface = true;
}
}
return foundInterface;
}
//
// Native methods
//
@ -226,7 +248,7 @@ public static void main(String [] args)
WrapperFactory me = new WrapperFactoryImpl();
Log.setApplicationName("WrapperFactoryImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.4 2001/04/02 21:13:59 ashuk%eng.sun.com Exp $");
Log.setApplicationVersionDate("$Id: WrapperFactoryImpl.java,v 1.5 2001/05/24 21:13:34 ashuk%eng.sun.com Exp $");
}

View File

@ -0,0 +1,30 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Ashu Kulkarni <ashuk@eng.sun.com>
#
XPIDL_PROG=$(DIST)\bin\xpidl
.SUFFIXES: .java .idl
XPIDL_JAVA=$(JAVAXPIDLSRCS:.idl=.java)
idl2java: $(XPIDL_JAVA)
.idl.java:
$(XPIDL_PROG) -m java -w $(XPIDL_INCLUDES) -I$(DEPTH)\dist\idl\ $<

View File

@ -0,0 +1,29 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# Ashu Kulkarni <ashuk@eng.sun.com>
#
.SUFFIXES: .java .idl
XPIDL_JAVA=$(JAVAXPIDLSRCS:.idl=.java)
XPIDL_PROG=$(DIST)/bin/xpidl
idl2java: $(XPIDL_JAVA)
.idl.java:
$(XPIDL_PROG) -m java -w $(XPIDL_INCLUDES) -I$(DEPTH)/dist/idl/ $<

View File

@ -0,0 +1,52 @@
#!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) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# Contributor(s):
# Ashu Kulkarni <ashuk@eng.sun.com>
#
#//------------------------------------------------------------------------
#//
#// Makefile to build the java stubs for Webclient
#//
#//------------------------------------------------------------------------
DEPTH = ../../..
JAVAXPIDLSRCS = nsIProfile.idl \
$(NULL)
include $(DEPTH)/config/rules.mk
include ../config/rules.mk
.SUFFIXES: .idl .java
import: $(JAVAXPIDLSRCS)
$(JAVAXPIDLSRCS) :
cp $(DEPTH)/dist/idl/$(@F) .
mvjava2stubs:
mv *.java ../classes_spec/org/mozilla/webclient/stubs
chPackageinStubs:
perl chPackage.pl unix nsIProfile.java "org.mozilla.webclient.stubs"
export:: import idl2java chPackageinStubs mvjava2stubs
clobber_all::
rm -rf *.idl
rm -rf ../classes_spec/org/mozilla/webclient/stubs/*.java

View File

@ -0,0 +1,52 @@
#!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) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# Contributor(s):
# Ashu Kulkarni <ashuk@eng.sun.com>
#
#//------------------------------------------------------------------------
#//
#// Makefile to build the java stubs for Webclient
#//
#//------------------------------------------------------------------------
DEPTH = ..\..\..
JAVAXPIDLSRCS = nsIProfile.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>
include ..\config\rules.mak
.SUFFIXES: .idl .java
import: $(JAVAXPIDLSRCS)
$(JAVAXPIDLSRCS) :
cp $(DEPTH)\dist\idl\$(@F) .
mvjava2stubs:
move *.java ..\classes_spec\org\mozilla\webclient\stubs
chPackageinStubs:
perl.exe chPackage.pl win nsIProfile.java "org.mozilla.webclient.stubs"
export:: import idl2java chPackageinStubs mvjava2stubs
clobber_all::
rm -rf *.idl
rm -rf ..\classes_spec\org\mozilla\webclient\stubs\*.java

View File

@ -0,0 +1,70 @@
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are
# Copyright (C) 1999 Sun Microsystems, Inc. All
# Rights Reserved.
#
# Contributor(s):
# Ashu Kulkarni <ashuk@eng.sun.com>
#
# this script must be run in the directory in which it resides.
#
# Verification, usage checking
#
$ARGC = $#ARGV + 1;
$NUM_ARGC = 3;
if ($NUM_ARGC != $ARGC) {
print "usage: chPackage.pl <OS> <file name> <package name>\n";
exit -1;
}
if ($ARGV[0] ne "unix" && $ARGV[0] ne "win") {
print "usage: chPackage.pl <OS> <file name> <package name>\n";
print " <OS> can be either \"unix\" or \"win\" \n";
}
open(FILE_R, "<$ARGV[1]");
open(FILE_W, ">tmp.tmp");
while ($line = <FILE_R>) {
if ($line =~ "package") {
$line_w = "package $ARGV[2];";
print FILE_W $line_w;
print FILE_W "\n\nimport org.mozilla.xpcom.*;\n";
}
else {
print FILE_W $line;
}
}
close(FILE_R);
close(FILE_W);
if ($ARGV[0] eq "unix") {
$cmd = "mv tmp.tmp $ARGV[1]; rm -f tmp.tmp";
exec $cmd;
}
else {
$cmd = "move tmp.tmp $ARGV[1]";
exec $cmd;
$cmd = "del tmp.tmp";
exec $cmd;
}

View File

@ -121,7 +121,7 @@ else {
}
#tack on the java library path
$cmd = $cmd . " -Djava.library.path=" . $BINDIR;
$cmd = $cmd . " -Djava.library.path=" . $BINDIR . $CPSEP . $BINDIR . $SEP . "components";
#tack on the classpath, class name, and bin dir
$cmd = $cmd . " -classpath " . $ENV{"CLASSPATH"} . " " . $CLASSNAME . " " .
$BINDIR;