From 13ae1c9b22733d2dbbdc925adf3730711705408a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Bl=C3=A4sing?= Date: Wed, 5 Feb 2025 21:44:04 +0100 Subject: [PATCH] Drop native libraries for browser control and use JNA This reduces the amount of native code that needs to be shipped with NetBeans and allows to support running on more platforms. The DDE based control was completely removed as in tests MS Edge, Google Chrome and Mozilla Firefox all did not support DDE. Closes: #8218 --- ide/extbrowser/build.xml | 39 -- ide/extbrowser/external/binaries-list | 17 - .../extbrowser-dlls-18.03.15-license.txt | 387 ------------- ide/extbrowser/manifest.mf | 5 +- ide/extbrowser/native/NbDDEBrowserImpl.cpp | 547 ------------------ ide/extbrowser/native/NbDDEBrowserImpl.h | 36 -- ide/extbrowser/native/StdAfx.h | 45 -- .../org-netbeans-modules-extbrowser.sig | 8 +- ide/extbrowser/nbproject/project.properties | 2 - ide/extbrowser/nbproject/project.xml | 28 +- .../modules/extbrowser/ChromeBrowser.java | 7 +- .../modules/extbrowser/ChromiumBrowser.java | 1 - .../modules/extbrowser/ExtWebBrowser.java | 140 ++--- .../modules/extbrowser/FirefoxBrowser.java | 3 +- .../modules/extbrowser/IExplorerBrowser.java | 3 +- .../modules/extbrowser/MozillaBrowser.java | 3 +- .../modules/extbrowser/NbDdeBrowserImpl.java | 471 +++++---------- .../modules/extbrowser/ExtWebBrowserTest.java | 10 - ide/ide.kit/nbproject/project.xml | 10 +- ide/web.browser.api/nbproject/project.xml | 26 +- javafx/javafx2.project/nbproject/project.xml | 4 +- .../extbrowser.chrome/nbproject/project.xml | 4 +- 22 files changed, 238 insertions(+), 1558 deletions(-) delete mode 100644 ide/extbrowser/external/binaries-list delete mode 100644 ide/extbrowser/external/extbrowser-dlls-18.03.15-license.txt delete mode 100644 ide/extbrowser/native/NbDDEBrowserImpl.cpp delete mode 100644 ide/extbrowser/native/NbDDEBrowserImpl.h delete mode 100644 ide/extbrowser/native/StdAfx.h diff --git a/ide/extbrowser/build.xml b/ide/extbrowser/build.xml index 231fbb21cb60..d95835269ade 100644 --- a/ide/extbrowser/build.xml +++ b/ide/extbrowser/build.xml @@ -23,43 +23,4 @@ - - - - - - - - - - - - - - - - - - - - - - ${OpenIDE-Module-Name} - NetBeans - ${OpenIDE-Module-Short-Description} - ${OpenIDE-Module-Long-Description} - - - - - - - - - - - ]]> - - - diff --git a/ide/extbrowser/external/binaries-list b/ide/extbrowser/external/binaries-list deleted file mode 100644 index bfe07dcef27a..000000000000 --- a/ide/extbrowser/external/binaries-list +++ /dev/null @@ -1,17 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -2DC61D81338329D31905395F4738F58FFDCF8F2E extbrowser-dlls-18.03.15.zip diff --git a/ide/extbrowser/external/extbrowser-dlls-18.03.15-license.txt b/ide/extbrowser/external/extbrowser-dlls-18.03.15-license.txt deleted file mode 100644 index 4fbe0329c1b0..000000000000 --- a/ide/extbrowser/external/extbrowser-dlls-18.03.15-license.txt +++ /dev/null @@ -1,387 +0,0 @@ -Name: External Browser DLLs -Description: Windows DLLs for external browser integration -Version: 18.03.15 -License: CDDL-1.0 -Source: https://netbeans.org/ -Origin: NetBeans - -COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 - -1. Definitions. - -1.1. "Contributor" means each individual or entity that -creates or contributes to the creation of Modifications. - -1.2. "Contributor Version" means the combination of the -Original Software, prior Modifications used by a -Contributor (if any), and the Modifications made by that -particular Contributor. - -1.3. "Covered Software" means (a) the Original Software, or -(b) Modifications, or (c) the combination of files -containing Original Software with files containing -Modifications, in each case including portions thereof. - -1.4. "Executable" means the Covered Software in any form -other than Source Code. - -1.5. "Initial Developer" means the individual or entity -that first makes Original Software available under this -License. - -1.6. "Larger Work" means a work which combines Covered -Software or portions thereof with code not governed by the -terms of this License. - -1.7. "License" means this document. - -1.8. "Licensable" means having the right to grant, to the -maximum extent possible, whether at the time of the initial -grant or subsequently acquired, any and all of the rights -conveyed herein. - -1.9. "Modifications" means the Source Code and Executable -form of any of the following: - -A. Any file that results from an addition to, -deletion from or modification of the contents of a -file containing Original Software or previous -Modifications; - -B. Any new file that contains any part of the -Original Software or previous Modification; or - -C. Any new file that is contributed or otherwise made -available under the terms of this License. - -1.10. "Original Software" means the Source Code and -Executable form of computer software code that is -originally released under this License. - -1.11. "Patent Claims" means any patent claim(s), now owned -or hereafter acquired, including without limitation, -method, process, and apparatus claims, in any patent -Licensable by grantor. - -1.12. "Source Code" means (a) the common form of computer -software code in which modifications are made and (b) -associated documentation included in or with such code. - -1.13. "You" (or "Your") means an individual or a legal -entity exercising rights under, and complying with all of -the terms of, this License. For legal entities, "You" -includes any entity which controls, is controlled by, or is -under common control with You. For purposes of this -definition, "control" means (a) the power, direct or -indirect, to cause the direction or management of such -entity, whether by contract or otherwise, or (b) ownership -of more than fifty percent (50%) of the outstanding shares -or beneficial ownership of such entity. - -2. License Grants. - -2.1. The Initial Developer Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, the -Initial Developer hereby grants You a world-wide, -royalty-free, non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Initial Developer, -to use, reproduce, modify, display, perform, -sublicense and distribute the Original Software (or -portions thereof), with or without Modifications, -and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using or selling of Original Software, to make, have -made, use, practice, sell, and offer for sale, and/or -otherwise dispose of the Original Software (or -portions thereof). - -(c) The licenses granted in Sections 2.1(a) and (b) -are effective on the date Initial Developer first -distributes or otherwise makes the Original Software -available to a third party under the terms of this -License. - -(d) Notwithstanding Section 2.1(b) above, no patent -license is granted: (1) for code that You delete from -the Original Software, or (2) for infringements -caused by: (i) the modification of the Original -Software, or (ii) the combination of the Original -Software with other software or devices. - -2.2. Contributor Grant. - -Conditioned upon Your compliance with Section 3.1 below and -subject to third party intellectual property claims, each -Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than -patent or trademark) Licensable by Contributor to -use, reproduce, modify, display, perform, sublicense -and distribute the Modifications created by such -Contributor (or portions thereof), either on an -unmodified basis, with other Modifications, as -Covered Software and/or as part of a Larger Work; and - -(b) under Patent Claims infringed by the making, -using, or selling of Modifications made by that -Contributor either alone and/or in combination with -its Contributor Version (or portions of such -combination), to make, use, sell, offer for sale, -have made, and/or otherwise dispose of: (1) -Modifications made by that Contributor (or portions -thereof); and (2) the combination of Modifications -made by that Contributor with its Contributor Version -(or portions of such combination). - -(c) The licenses granted in Sections 2.2(a) and -2.2(b) are effective on the date Contributor first -distributes or otherwise makes the Modifications -available to a third party. - -(d) Notwithstanding Section 2.2(b) above, no patent -license is granted: (1) for any code that Contributor -has deleted from the Contributor Version; (2) for -infringements caused by: (i) third party -modifications of Contributor Version, or (ii) the -combination of Modifications made by that Contributor -with other software (except as part of the -Contributor Version) or other devices; or (3) under -Patent Claims infringed by Covered Software in the -absence of Modifications made by that Contributor. - -3. Distribution Obligations. - -3.1. Availability of Source Code. - -Any Covered Software that You distribute or otherwise make -available in Executable form must also be made available in -Source Code form and that Source Code form must be -distributed only under the terms of this License. You must -include a copy of this License with every copy of the -Source Code form of the Covered Software You distribute or -otherwise make available. You must inform recipients of any -such Covered Software in Executable form as to how they can -obtain such Covered Software in Source Code form in a -reasonable manner on or through a medium customarily used -for software exchange. - -3.2. Modifications. - -The Modifications that You create or to which You -contribute are governed by the terms of this License. You -represent that You believe Your Modifications are Your -original creation(s) and/or You have sufficient rights to -grant the rights conveyed by this License. - -3.3. Required Notices. - -You must include a notice in each of Your Modifications -that identifies You as the Contributor of the Modification. -You may not remove or alter any copyright, patent or -trademark notices contained within the Covered Software, or -any notices of licensing or any descriptive text giving -attribution to any Contributor or the Initial Developer. - -3.4. Application of Additional Terms. - -You may not offer or impose any terms on any Covered -Software in Source Code form that alters or restricts the -applicable version of this License or the recipients' -rights hereunder. You may choose to offer, and to charge a -fee for, warranty, support, indemnity or liability -obligations to one or more recipients of Covered Software. -However, you may do so only on Your own behalf, and not on -behalf of the Initial Developer or any Contributor. You -must make it absolutely clear that any such warranty, -support, indemnity or liability obligation is offered by -You alone, and You hereby agree to indemnify the Initial -Developer and every Contributor for any liability incurred -by the Initial Developer or such Contributor as a result of -warranty, support, indemnity or liability terms You offer. - -3.5. Distribution of Executable Versions. - -You may distribute the Executable form of the Covered -Software under the terms of this License or under the terms -of a license of Your choice, which may contain terms -different from this License, provided that You are in -compliance with the terms of this License and that the -license for the Executable form does not attempt to limit -or alter the recipient's rights in the Source Code form -from the rights set forth in this License. If You -distribute the Covered Software in Executable form under a -different license, You must make it absolutely clear that -any terms which differ from this License are offered by You -alone, not by the Initial Developer or Contributor. You -hereby agree to indemnify the Initial Developer and every -Contributor for any liability incurred by the Initial -Developer or such Contributor as a result of any such terms -You offer. - -3.6. Larger Works. - -You may create a Larger Work by combining Covered Software -with other code not governed by the terms of this License -and distribute the Larger Work as a single product. In such -a case, You must make sure the requirements of this License -are fulfilled for the Covered Software. - -4. Versions of the License. - -4.1. New Versions. - -Sun Microsystems, Inc. is the initial license steward and -may publish revised and/or new versions of this License -from time to time. Each version will be given a -distinguishing version number. Except as provided in -Section 4.3, no one other than the license steward has the -right to modify this License. - -4.2. Effect of New Versions. - -You may always continue to use, distribute or otherwise -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. If the Initial Developer includes a -notice in the Original Software prohibiting it from being -distributed or otherwise made available under any -subsequent version of the License, You must distribute and -make the Covered Software available under the terms of the -version of the License under which You originally received -the Covered Software. Otherwise, You may also choose to -use, distribute or otherwise make the Covered Software -available under the terms of any subsequent version of the -License published by the license steward. - -4.3. Modified Versions. - -When You are an Initial Developer and You want to create a -new license for Your Original Software, You may create and -use a modified version of this License if You: (a) rename -the license and remove any references to the name of the -license steward (except to note that the license differs -from this License); and (b) otherwise make it clear that -the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" -BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, -INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED -SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR -PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND -PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY -COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE -INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF -ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF -WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF -ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS -DISCLAIMER. - -6. TERMINATION. - -6.1. This License and the rights granted hereunder will -terminate automatically if You fail to comply with terms -herein and fail to cure such breach within 30 days of -becoming aware of the breach. Provisions which, by their -nature, must remain in effect beyond the termination of -this License shall survive. - -6.2. If You assert a patent infringement claim (excluding -declaratory judgment actions) against Initial Developer or -a Contributor (the Initial Developer or Contributor against -whom You assert such claim is referred to as "Participant") -alleging that the Participant Software (meaning the -Contributor Version where the Participant is a Contributor -or the Original Software where the Participant is the -Initial Developer) directly or indirectly infringes any -patent, then any and all rights granted directly or -indirectly to You by such Participant, the Initial -Developer (if the Initial Developer is not the Participant) -and all Contributors under Sections 2.1 and/or 2.2 of this -License shall, upon 60 days notice from Participant -terminate prospectively and automatically at the expiration -of such 60 day notice period, unless if within such 60 day -period You withdraw Your claim with respect to the -Participant Software against such Participant either -unilaterally or pursuant to a written agreement with -Participant. - -6.3. In the event of termination under Sections 6.1 or 6.2 -above, all end user licenses that have been validly granted -by You or any distributor hereunder prior to termination -(excluding licenses granted to You by any distributor) -shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT -(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF -COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE -LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR -CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT -LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK -STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER -COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN -INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF -LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT -APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO -NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR -CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT -APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a "commercial item," as that term is -defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial -computer software" (as that term is defined at 48 C.F.R. -252.227-7014(a)(1)) and "commercial computer software -documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. -1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 -through 227.7202-4 (June 1995), all U.S. Government End Users -acquire Covered Software with only those rights set forth herein. -This U.S. Government Rights clause is in lieu of, and supersedes, -any other FAR, DFAR, or other clause or provision that addresses -Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the -extent necessary to make it enforceable. This License shall be -governed by the law of the jurisdiction specified in a notice -contained within the Original Software (except to the extent -applicable law, if any, provides otherwise), excluding such -jurisdiction's conflict-of-law provisions. Any litigation -relating to this License shall be subject to the jurisdiction of -the courts located in the jurisdiction and venue specified in a -notice contained within the Original Software, with the losing -party responsible for costs, including, without limitation, court -costs and reasonable attorneys' fees and expenses. The -application of the United Nations Convention on Contracts for the -International Sale of Goods is expressly excluded. Any law or -regulation which provides that the language of a contract shall -be construed against the drafter shall not apply to this License. -You agree that You alone are responsible for compliance with the -United States export administration regulations (and the export -control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is -responsible for claims and damages arising, directly or -indirectly, out of its utilization of rights under this License -and You agree to work with Initial Developer and Contributors to -distribute such responsibility on an equitable basis. Nothing -herein is intended or shall be deemed to constitute any admission -of liability. diff --git a/ide/extbrowser/manifest.mf b/ide/extbrowser/manifest.mf index e5ae71d0ac56..4f4f3c5b3554 100644 --- a/ide/extbrowser/manifest.mf +++ b/ide/extbrowser/manifest.mf @@ -1,6 +1,5 @@ Manifest-Version: 1.0 -OpenIDE-Module: org.netbeans.modules.extbrowser/1 +OpenIDE-Module: org.netbeans.modules.extbrowser/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extbrowser/Bundle.properties OpenIDE-Module-Layer: org/netbeans/modules/extbrowser/resources/layer.xml -OpenIDE-Module-Specification-Version: 1.81 -AutoUpdate-Show-In-Client: false +OpenIDE-Module-Specification-Version: 2.0 diff --git a/ide/extbrowser/native/NbDDEBrowserImpl.cpp b/ide/extbrowser/native/NbDDEBrowserImpl.cpp deleted file mode 100644 index 1d61de675f6d..000000000000 --- a/ide/extbrowser/native/NbDDEBrowserImpl.cpp +++ /dev/null @@ -1,547 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// BrowserClient.cpp : Defines the entry point for the DLL application. -// - -// #include "stdafx.h" - -#include -#include -/* -#include -#include -#include - */ - -#include - -// ........................................................ - -extern "C" { - - /********************************************************** - * Static variables - *********************************************************/ - - /** Instance ID for DDE */ - static DWORD InstId = 0; - - /** counter for topic generation */ - static DWORD dwcounter = 0; - - /********************************************************** - * Static functions - *********************************************************/ - - static int InitDDE(void); - - static void ClearDde(void); - - static HDDEDATA CALLBACK DdeCallback - (UINT Type, UINT Fmt, HCONV ConvHan, - HSZ Str1, HSZ Str2, - HDDEDATA Data, ULONG_PTR Dta1, ULONG_PTR Dta2); - - /********************************************************** - * function 'InitDDE' WIN - * desc : Initialize DDE comunication - * returns: 0 <==> OK - * other value <==> an error occured - *********************************************************/ - static int InitDDE(void) { - /** is this already initialized? */ - // static char Set= 0; - - // if(Set && InstId) return(0); - if (InstId) return (0); - - if (DdeInitialize(&InstId, DdeCallback, - APPCLASS_STANDARD /* | - APPCMD_FILTERINITS | - CBF_SKIP_ALLNOTIFICATIONS | - CBF_FAIL_ADVISES | - CBF_FAIL_EXECUTES | - CBF_FAIL_SELFCONNECTIONS | - CBF_SKIP_CONNECT_CONFIRMS | - CBF_SKIP_DISCONNECTS*/ | - CBF_SKIP_REGISTRATIONS | - CBF_SKIP_UNREGISTRATIONS, 0) != DMLERR_NO_ERROR) { - printf("Error init DDE\n"); - return (-1); - } - // printf("INIT DDE OK\n"); - // if(!Set) atexit(ClearDde); - // Set= 1; - return (0); - } - - /********************************************************** - * function 'ClearDde' WINDOWS - * desc : quits comunitation through DDE - *********************************************************/ - static void ClearDde(void) { - if (!InstId) return; - DdeUninitialize(InstId); - InstId = 0; - } - - /********************************************************** - * function 'DDEcallback' WINDOWS - * desc : - *********************************************************/ - static HDDEDATA CALLBACK DdeCallback - (UINT Type, UINT Fmt, HCONV ConvHan, - HSZ Str1, HSZ Str2, - HDDEDATA Data, ULONG_PTR Dta1, ULONG_PTR Dta2) { - /** conversation handle */ - static HCONV shConv = NULL; - - char Item[256]; - char Service[256]; - char Topic[256]; - - /* transaction type */ - switch (Type) { - /* transaction type */ - case XTYP_CONNECT: - - if (!(DdeQueryString(InstId, Str1, Topic, 256, CP_WINANSI))) return (FALSE); - if (!(DdeQueryString(InstId, Str2, Service, 256, CP_WINANSI))) return (FALSE); - printf("XTYP_CONNECT >%s< >%s<\n", Service, Topic); - fflush(stdout); - - - // accept WWW_*Progress* topic - if (!strcmp(Topic, "WWW_BeginProgress")) { - shConv = ConvHan; - - dwcounter++; - return (HDDEDATA) TRUE; - } - if (!strcmp(Topic, "WWW_SetProgressRange")) - return (HDDEDATA) TRUE; - if (!strcmp(Topic, "WWW_MakingProgress")) - return (HDDEDATA) TRUE; - if (!strcmp(Topic, "WWW_EndProgress")) - return (HDDEDATA) TRUE; - - if (!strcmp(Topic, "WWW_URLEcho")) - return (HDDEDATA) TRUE; - - return (FALSE); - - case XTYP_POKE: - - if (!(DdeQueryString(InstId, Str1, Topic, 256, CP_WINANSI))) return (DDE_FNOTPROCESSED); - if (!(DdeQueryString(InstId, Str2, Item, 256, CP_WINANSI))) return (DDE_FNOTPROCESSED); - printf("XTYP_POKE >%s< >%s<\n", Topic, Item); - fflush(stdout); - - if (!strcmp(Topic, "WWW_SetProgressRange")) { - return ((HDDEDATA) DDE_FACK); - } - if (!strcmp(Topic, "WWW_EndProgress")) { - return ((HDDEDATA) DDE_FACK); - } - - if (!strcmp(Topic, "WWW_URLEcho")) { - return ((HDDEDATA) DDE_FACK); - } - return (DDE_FNOTPROCESSED); - - case XTYP_REQUEST: - - if (!(DdeQueryString(InstId, Str1, Topic, 256, CP_WINANSI))) return (DDE_FNOTPROCESSED); - if (!(DdeQueryString(InstId, Str2, Item, 256, CP_WINANSI))) return (DDE_FNOTPROCESSED); - printf("XTYP_REQUEST >%s< >%s<\n", Topic, Item); - fflush(stdout); - - if (!strcmp(Topic, "WWW_BeginProgress")) { - - HDDEDATA Dta; - - if (!(Dta = DdeCreateDataHandle - (InstId, (unsigned char *) &dwcounter, sizeof (DWORD), 0, Str2, CF_TEXT, 0))) { - printf("CANNOT CREATE DATA\n"); - return (NULL); - } - return (Dta); - }// www_beginprogress - else if (!strcmp(Topic, "WWW_MakingProgress")) { - - HDDEDATA Dta; - char *s = "FALSE"; - - if (!(Dta = DdeCreateDataHandle - (InstId, (unsigned char*) s, strlen(s), 0, Str2, CF_TEXT, 0))) { - printf("CANNOT CREATE DATA\n"); - return (NULL); - } - return (Dta); - } // making progress - - - return (NULL); - - case XTYP_XACT_COMPLETE: - printf("XTYP_XACT_COMPLETE\n"); - return ((HDDEDATA) DDE_FACK); - - case XTYP_ADVDATA: - printf("XTYP_ADVDATA\n"); - return ((HDDEDATA) DDE_FACK); - - case XTYP_ERROR: - printf("XTYP_ERROR\n"); - break; - -#if defined(DEBUG) - case XTYP_CONNECT_CONFIRM: - shConv = ConvHan; - printf("XTYP_CONNECT_CONFIRM\n"); - break; - - case XTYP_DISCONNECT: - printf("XTYP_DISCONNECT\n"); - break; - - case XTYP_REGISTER: - printf("XTYP_REGISTER\n"); - break; - - case XTYP_UNREGISTER: - printf("XTYP_UNREGISTER\n"); - break; - - default: - if (Type & XCLASS_NOTIFICATION) { - printf("XCLASS_NOTIFICATION\n"); - } - if (Type & XCLASS_FLAGS) { - printf("XCLASS_FLAGS\n"); - } - if (Type & XCLASS_DATA) { - printf("XCLASS_DATA\n"); - } - if (Type & XCLASS_BOOL) { - printf("XCLASS_BOOL\n"); - } - printf("type not of interest\n"); -#else - default: -#endif /* DEBUG */ - break; - } - return (0); - } - - /********************************************************** - * function - * desc - * - * param - * returns - * throws - *********************************************************/ - JNIEXPORT jbyteArray Java_org_netbeans_modules_extbrowser_NbDdeBrowserImpl_reqDdeMessage - (JNIEnv *env, - jobject obj, - jstring server, - jstring topic, - jstring item, - jint timeout) { - DWORD len = 1024; - char buff[1024]; - char msg[1024]; - jbyteArray retData = NULL; - - const char *Server = env->GetStringUTFChars(server, 0); - const char *Topic = env->GetStringUTFChars(topic, 0); - const char *Item = env->GetStringUTFChars(item, 0); - - HCONV Curr = 0; - HSZ StrHproc, StrHitem, StrHtopic; - HDDEDATA TrRes; - DWORD Result; // transaction result - - // INIT (REINIT DDE) - if (InitDDE()) { - // printf("Cannot initialize DDE\n"); - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Cannot initialize DDE"); - return NULL; - } - - // create string handles - StrHproc = DdeCreateStringHandle(InstId, Server, CP_WINANSI); - StrHtopic = DdeCreateStringHandle(InstId, Topic, CP_WINANSI); - StrHitem = DdeCreateStringHandle(InstId, Item, CP_WINANSI); - - // connect - if (!(Curr = DdeConnect(InstId, StrHproc, StrHtopic, NULL))) { - // printf("Cannot connect to DDE server\n"); - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - sprintf(msg, "DdeConnect errno >%X< when connecting to server %s, topic %s.\n", DdeGetLastError(InstId), Server, Topic); - env->ThrowNew(excClass, msg); - DdeFreeStringHandle(InstId, StrHtopic); - DdeFreeStringHandle(InstId, StrHitem); - DdeFreeStringHandle(InstId, StrHproc); - ClearDde(); - return NULL; - } else { - // printf("SEND TO >%s< TOPIC >%s< ITEM >%s<\n", - // Server, Topic, Item); fflush (stdout); - - if (!(TrRes = DdeClientTransaction - (NULL, 0, Curr, StrHitem, CF_TEXT, XTYP_REQUEST, timeout, &Result))) { - // printf("DDE Tx failed\n"); - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - sprintf(msg, "DdeClientTransaction errno >%X<\n", DdeGetLastError(InstId)); - fflush(stdout); - env->ThrowNew(excClass, msg); - } else { - - // process result - LPBYTE pData = DdeAccessData(TrRes, &len); - memcpy(buff, pData, len); - DdeUnaccessData(TrRes); - DdeFreeDataHandle(TrRes); - - retData = env->NewByteArray(len); - for (DWORD i = 0; i < len; i++) - env->SetByteArrayRegion(retData, i, 1, (jbyte*) (buff + i)); - } - - // release string handles - DdeFreeStringHandle(InstId, StrHtopic); - DdeFreeStringHandle(InstId, StrHitem); - DdeFreeStringHandle(InstId, StrHproc); - - DdeDisconnect(Curr); - } - - env->ReleaseStringUTFChars(server, Server); - env->ReleaseStringUTFChars(topic, Topic); - env->ReleaseStringUTFChars(item, Item); - - ClearDde(); - return retData; - } - - /********************************************************** - * Reads value from - * HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\Windows\CurrentVersion\\App Paths\\.exe - * desc - * - * param - * returns - * throws - *********************************************************/ - JNIEXPORT jstring Java_org_netbeans_modules_extbrowser_NbDdeBrowserImpl_getBrowserPath - (JNIEnv *env, - jclass cls, - jstring browser) { - DWORD len = 1024; - DWORD type; - char sSubKey[1024]; - char sReg[1024]; - char sPath[1024]; - HKEY hKey = NULL; - jstring path = NULL; - - // In the past we used : - // HKEY_CLASSES_ROOT\Applications\\.exe\shell\open\command key - // It seems to be better to use : - // - const char *b = env->GetStringUTFChars(browser, 0); - sprintf(sSubKey, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe", b); - env->ReleaseStringUTFChars(browser, b); - - // open registry key - // printf("LOOKING FOR >%s<\n", - // sSubKey); fflush (stdout); - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, sSubKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - char msg[1024]; - strcpy(msg, "RegOpenKeyEx() failed for "); - strcat(msg, sSubKey); - strcat(msg, "."); - env->ThrowNew(excClass, msg); - return NULL; - } - - // query value - if (RegQueryValueEx(hKey, NULL, NULL, &type, (LPBYTE) sReg, &len) != ERROR_SUCCESS) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegQueryValueEx() failed."); - return NULL; - } - - // process data - switch (type) { - case REG_EXPAND_SZ: - // expand variables - if (!ExpandEnvironmentStrings(sReg, sPath, 1024)) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "ExpandEnvironmentStrings() failed."); - return NULL; - } - break; - case REG_SZ: - strcpy(sPath, sReg); - break; - default: - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Unsupported registry type."); - return NULL; - } - - if (RegCloseKey(hKey) != ERROR_SUCCESS) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegCloseKey() failed."); - return NULL; - } - - if ((path = env->NewStringUTF(sPath)) == NULL) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Error when retrieving path to browser."); - return NULL; - } - - return path; - } - - /********************************************************** - * function - * desc - * - * param - * returns - * throws - *********************************************************/ - JNIEXPORT jstring Java_org_netbeans_modules_extbrowser_NbDdeBrowserImpl_getDefaultOpenCommand - (JNIEnv *env, - jclass cls) { - DWORD len = 1024; - DWORD type; - // char sSubKey[1024]; - wchar_t sBrowser[1024]; - wchar_t sReg[1024]; - wchar_t sPath[1024]; - HKEY hKey = NULL; - jstring path = NULL; - - // find HKEY_CLASSES_ROOT ".html" - sBrowser[0] = '\0'; - - // open registry key - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L".html", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - // query value - if (RegQueryValueExW(hKey, NULL, NULL, &type, (LPBYTE) sReg, &len) == ERROR_SUCCESS) { - // process data - switch (type) { - case REG_SZ: - wcscpy(sBrowser, sReg); - break; - default: - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Unsupported registry type."); - return NULL; - } - - if (RegCloseKey(hKey) != ERROR_SUCCESS) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegCloseKey() failed."); - return NULL; - } - } else { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegQueryValueEx() failed."); - return NULL; - } - } else { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegOpenKeyEx() failed for .html."); - return NULL; - } - - if (wcslen(sBrowser) == 0) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Browser not found."); - return NULL; - } - - wcscat(sBrowser, L"\\shell\\open\\command"); - - // now query real command - // open registry key - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, sBrowser, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { - // query value - len = 1024; - sReg [0] = '\0'; - if (RegQueryValueExW(hKey, NULL, NULL, &type, (BYTE *) & sReg, &len) == ERROR_SUCCESS) { - // process data - switch (type) { - case REG_EXPAND_SZ: - // expand variables - if (!ExpandEnvironmentStringsW(sReg, sPath, 1024)) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "ExpandEnvironmentStrings() failed."); - return NULL; - } - break; - case REG_SZ: - wcscpy(sPath, sReg); - break; - default: - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Unsupported registry type."); - return NULL; - } - - if (RegCloseKey(hKey) != ERROR_SUCCESS) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegCloseKey() failed."); - return NULL; - } - - } else { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegQueryValueEx() failed."); - return NULL; - } - - } else { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "RegOpenKeyEx() failed when trying to open 'browser' key."); - return NULL; - } - - // sPath contains command that starts default browser - if ((path = env->NewString((jchar*) sPath, wcslen(sPath))) == NULL) { - jclass excClass = env->FindClass("org/netbeans/modules/extbrowser/NbBrowserException"); - env->ThrowNew(excClass, "Error when retrieving path to browser."); - return NULL; - } - - return path; - } - -} // extern "C" diff --git a/ide/extbrowser/native/NbDDEBrowserImpl.h b/ide/extbrowser/native/NbDDEBrowserImpl.h deleted file mode 100644 index 6e4c647f4a62..000000000000 --- a/ide/extbrowser/native/NbDDEBrowserImpl.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef __NBDDEBROWSERIMPL_INCLUDED__ -#define __NBDDEBROWSERIMPL_INCLUDED__ - -extern "C" { - -struct ddesrv { - char *name; - char *topic; -}; -typedef struct ddesrv ddesrv_t; - - -DWORD WINAPI BrowserThread (LPVOID param); - -} // extern "C" - -#endif /* __NBDDEBROWSERIMPL_INCLUDED__ */ \ No newline at end of file diff --git a/ide/extbrowser/native/StdAfx.h b/ide/extbrowser/native/StdAfx.h deleted file mode 100644 index 3278a2949abb..000000000000 --- a/ide/extbrowser/native/StdAfx.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__8E31F536_2A25_4490_87D5_A0D0E4F48A3C__INCLUDED_) -#define AFX_STDAFX_H__8E31F536_2A25_4490_87D5_A0D0E4F48A3C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -#define _WIN32_WINNT 0x0400 // !!!!!!!! to include winbase.h headers correclty - - -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__8E31F536_2A25_4490_87D5_A0D0E4F48A3C__INCLUDED_) diff --git a/ide/extbrowser/nbproject/org-netbeans-modules-extbrowser.sig b/ide/extbrowser/nbproject/org-netbeans-modules-extbrowser.sig index bb0a5f6d90bc..c48a77c238f5 100644 --- a/ide/extbrowser/nbproject/org-netbeans-modules-extbrowser.sig +++ b/ide/extbrowser/nbproject/org-netbeans-modules-extbrowser.sig @@ -1,5 +1,5 @@ #Signature file v4.1 -#Version 1.79 +#Version 2.0 CLSS public abstract java.awt.Component cons protected init() @@ -749,7 +749,6 @@ fld protected final static int DEFAULT_OPENURL_TIMEOUT = 3000 fld protected int activateTimeout fld protected int openurlTimeout fld protected java.beans.PropertyChangeSupport pcs -fld protected java.lang.String ddeServer fld protected java.lang.String name fld protected org.openide.execution.NbProcessDescriptor browserExecutable fld public final static java.lang.String CHROME = "CHROME" @@ -758,7 +757,6 @@ fld public final static java.lang.String FIREFOX = "FIREFOX" fld public final static java.lang.String IEXPLORE = "IEXPLORE" fld public final static java.lang.String MOZILLA = "MOZILLA" fld public final static java.lang.String PROP_BROWSER_EXECUTABLE = "browserExecutable" -fld public final static java.lang.String PROP_DDESERVER = "dDEServer" fld public final static java.lang.String PROP_DDE_ACTIVATE_TIMEOUT = "activateTimeout" fld public final static java.lang.String PROP_DDE_OPENURL_TIMEOUT = "openurlTimeout" fld public final static java.lang.String PROP_NAME = "name" @@ -770,7 +768,6 @@ intf org.openide.awt.HtmlBrowser$Factory meth protected org.openide.execution.NbProcessDescriptor defaultBrowserExecutable() meth public int getActivateTimeout() meth public int getOpenurlTimeout() -meth public java.lang.String getDDEServer() meth public java.lang.String getName() meth public org.netbeans.modules.extbrowser.PrivateBrowserFamilyId getPrivateBrowserFamilyId() meth public org.openide.awt.HtmlBrowser$Impl createHtmlBrowserImpl() @@ -781,7 +778,6 @@ meth public void propertyChange(java.beans.PropertyChangeEvent) meth public void removePropertyChangeListener(java.beans.PropertyChangeListener) meth public void setActivateTimeout(int) meth public void setBrowserExecutable(org.openide.execution.NbProcessDescriptor) -meth public void setDDEServer(java.lang.String) meth public void setName(java.lang.String) meth public void setOpenurlTimeout(int) meth public void useBrowserExecutableDelegate(org.netbeans.modules.extbrowser.ExtWebBrowser) @@ -892,8 +888,6 @@ meth public int getOpenUrlTimeout() meth public static java.lang.String getBrowserPath(java.lang.String) throws org.netbeans.modules.extbrowser.NbBrowserException meth public static java.lang.String getDefaultOpenCommand() throws org.netbeans.modules.extbrowser.NbBrowserException supr org.netbeans.modules.extbrowser.ExtBrowserImpl -hfds EXTBROWSER_DLL,EXTBROWSER_DLL_64BIT,WWW_ACTIVATE,WWW_OPEN_URL,nativeRunnable,nativeThread -hcls DisplayTask,URLDisplayer CLSS public final !enum org.netbeans.modules.extbrowser.PrivateBrowserFamilyId fld public final static org.netbeans.modules.extbrowser.PrivateBrowserFamilyId CHROME diff --git a/ide/extbrowser/nbproject/project.properties b/ide/extbrowser/nbproject/project.properties index 527b9f3e6628..94f37e8e0b83 100644 --- a/ide/extbrowser/nbproject/project.properties +++ b/ide/extbrowser/nbproject/project.properties @@ -18,8 +18,6 @@ javadoc.arch=${basedir}/arch.xml # test.unit.cp.extra and/or test.unit.run.cp.extra javac.source=1.8 -release.external/extbrowser-dlls-18.03.15.zip!/extbrowser.dll=modules/lib/extbrowser.dll -release.external/extbrowser-dlls-18.03.15.zip!/extbrowser64.dll=modules/lib/extbrowser64.dll test.config.stableBTD.includes=**/*Test.class test.config.stableBTD.excludes=\ **/ExtWebBrowserTest.class,\ diff --git a/ide/extbrowser/nbproject/project.xml b/ide/extbrowser/nbproject/project.xml index f537787a0a36..4400af45de23 100644 --- a/ide/extbrowser/nbproject/project.xml +++ b/ide/extbrowser/nbproject/project.xml @@ -34,6 +34,24 @@ 1.21 + + org.netbeans.libs.jna + + + + 2 + 2.22 + + + + org.netbeans.libs.jna.platform + + + + 2 + 2.22 + + org.netbeans.modules.extexecution @@ -101,7 +119,7 @@ - org.openide.util.ui + org.openide.util @@ -109,19 +127,19 @@ - org.openide.util + org.openide.util.lookup - 9.3 + 8.0 - org.openide.util.lookup + org.openide.util.ui - 8.0 + 9.3 diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromeBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromeBrowser.java index 267980e54bb1..255754e97e4f 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromeBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromeBrowser.java @@ -38,7 +38,6 @@ public class ChromeBrowser extends ExtWebBrowser implements PropertyChangeListen /** Creates new ExtWebBrowser */ public ChromeBrowser() { super(PrivateBrowserFamilyId.CHROME); - ddeServer = ExtWebBrowser.CHROME; } public static Boolean isHidden () { @@ -111,7 +110,6 @@ protected NbProcessDescriptor defaultBrowserExecutable() { params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; // NOI18N File file = getLocalAppPath(); if ( file.exists() && file.canExecute() ){ - setDDEServer(ExtWebBrowser.CHROME); return new NbProcessDescriptor (file.getPath(), params); } /* @@ -125,7 +123,6 @@ protected NbProcessDescriptor defaultBrowserExecutable() { try { b = NbDdeBrowserImpl.getBrowserPath("chrome"); // NOI18N if ((b != null) && (b.trim().length() > 0)) { - setDDEServer(ExtWebBrowser.CHROME); return new NbProcessDescriptor(b, params); } } catch (NbBrowserException e) { @@ -136,9 +133,7 @@ protected NbProcessDescriptor defaultBrowserExecutable() { if (!chrome.isFile()) { chrome = new File("C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"); // NOI18N } - if (chrome.isFile() - && chrome.canExecute()) { - setDDEServer(ExtWebBrowser.CHROME); + if (chrome.isFile() && chrome.canExecute()) { return new NbProcessDescriptor(chrome.getPath(), params); } } diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromiumBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromiumBrowser.java index 620fe7f50ace..570e8ac8e4aa 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromiumBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ChromiumBrowser.java @@ -36,7 +36,6 @@ public class ChromiumBrowser extends ExtWebBrowser implements PropertyChangeList /** Creates new ExtWebBrowser */ public ChromiumBrowser() { super(PrivateBrowserFamilyId.CHROMIUM); - ddeServer = ExtWebBrowser.CHROMIUM; } public static Boolean isHidden () { diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ExtWebBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ExtWebBrowser.java index 53e86a010304..004b1f5e71fb 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/ExtWebBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/ExtWebBrowser.java @@ -36,16 +36,13 @@ public class ExtWebBrowser implements HtmlBrowser.Factory, java.io.Serializable, private static final long serialVersionUID = -3021027901671504127L; public static final String PROP_NAME = "name"; // NOI18N - + /** Browser executable property name */ public static final String PROP_BROWSER_EXECUTABLE = "browserExecutable"; // NOI18N - - /** DDE server property name */ - public static final String PROP_DDESERVER = "dDEServer"; // NOI18N - + /** DDE activate timeout property name */ public static final String PROP_DDE_ACTIVATE_TIMEOUT = "activateTimeout"; // NOI18N - + /** DDE openURL timeout property name */ public static final String PROP_DDE_OPENURL_TIMEOUT = "openurlTimeout"; // NOI18N @@ -63,16 +60,13 @@ public class ExtWebBrowser implements HtmlBrowser.Factory, java.io.Serializable, public static final String MOZILLA = "MOZILLA"; // NOI18N /** Name of DDE server corresponding to Firefox */ public static final String FIREFOX = "FIREFOX"; // NOI18N - + /** Default for DDE activate timeout property */ protected static final int DEFAULT_ACTIVATE_TIMEOUT = 2000; /** Default for DDE openURL timeout property */ protected static final int DEFAULT_OPENURL_TIMEOUT = 3000; - - /** storage for DDE server property */ - protected String ddeServer; - + /** storage for DDE activate timeout property */ protected int activateTimeout = DEFAULT_ACTIVATE_TIMEOUT; @@ -81,7 +75,7 @@ public class ExtWebBrowser implements HtmlBrowser.Factory, java.io.Serializable, /** Logger for extbrowser module. */ private static final Logger err = Logger.getLogger("org.netbeans.modules.extbrowser"); // NOI18N - + protected String name; private PrivateBrowserFamilyId family; @@ -89,17 +83,21 @@ public class ExtWebBrowser implements HtmlBrowser.Factory, java.io.Serializable, public static Logger getEM() { return err; } - + /** Holds value of property browserExecutable. */ protected NbProcessDescriptor browserExecutable; - + protected transient PropertyChangeSupport pcs; public ExtWebBrowser () { this(PrivateBrowserFamilyId.UNKNOWN); } - /** Creates new Browser */ + /** + * Creates new Browser + * + * @param family + */ public ExtWebBrowser (PrivateBrowserFamilyId family) { this.family = family; init(); @@ -108,7 +106,7 @@ public ExtWebBrowser (PrivateBrowserFamilyId family) { /** initialize object */ private void init () { if (err.isLoggable(Level.FINE)) { - err.log(Level.FINE, getClass().getName() + " " + System.currentTimeMillis() + "> init"); + err.log(Level.FINE, "{0} {1}> init", new Object[]{getClass().getName(), System.currentTimeMillis()}); } pcs = new PropertyChangeSupport(this); if (Utilities.isWindows()) { @@ -120,36 +118,15 @@ private void init () { /** * This method allows browser factory to delegate its browser executable - * to some other browser factory. For example "Chrome with NB integration" + * to some other browser factory.For example "Chrome with NB integration" * should be executed just like regular "Chrome" browser. + * + * @param otherBrowser */ public void useBrowserExecutableDelegate(ExtWebBrowser otherBrowser) { this.browserExecutableDelegate = otherBrowser; } - - /** - * Gets DDE server name - * @return server name of DDEserver. - * null when no server is selected (means default web browser). - */ - public String getDDEServer () { - return ddeServer; - } - - /** - * Sets DDE server name - * @param ddeServer name of DDE server or null - */ - public void setDDEServer (String ddeServer) { - if ((ddeServer != null) && !ddeServer.equals(this.ddeServer)) { - String old = this.ddeServer; - this.ddeServer = ddeServer; - pcs.firePropertyChange (PROP_DDESERVER, old, ddeServer); - err.log(Level.INFO, "DDEServer changed to: " + ddeServer); // NOI18N - } - } - /** Getter for property openurlTimeout. * @return Value of property openurlTimeout. * @@ -157,7 +134,7 @@ public void setDDEServer (String ddeServer) { public int getOpenurlTimeout() { return openurlTimeout; } - + /** Setter for property openurlTimeout. * @param openurlTimeout New value of property openurlTimeout. * @@ -169,7 +146,7 @@ public void setOpenurlTimeout(int openurlTimeout) { pcs.firePropertyChange(PROP_DDE_OPENURL_TIMEOUT, oldVal, openurlTimeout); } } - + /** Getter for property activeTimeout. * @return Value of property activeTimeout. * @@ -177,7 +154,7 @@ public void setOpenurlTimeout(int openurlTimeout) { public int getActivateTimeout() { return activateTimeout; } - + /** Setter for property activeTimeout. * @param activateTimeout New value of property activeTimeout. */ @@ -193,7 +170,7 @@ public void setActivateTimeout(int activateTimeout) { public String getName() { return name; } - + /** Setter for browser name * @param name browser name */ @@ -204,7 +181,7 @@ public void setName(String name) { pcs.firePropertyChange(PROP_NAME, oldVal, name); } } - + /** Getter for property browserExecutable. * @return Value of property browserExecutable. */ @@ -217,12 +194,11 @@ public NbProcessDescriptor getBrowserExecutable () { result = defaultBrowserExecutable(); } if (err.isLoggable(Level.FINE)) { - err.log(Level.FINE, "" + System.currentTimeMillis() + " getBrowserExecutable: " + // NOI18N - (result == null ? "null" : result.getProcessName() + " " + result.getArguments())); // NOI18N + err.log(Level.FINE, "{0} getBrowserExecutable: {1} {2}", new Object[]{System.currentTimeMillis(), result.getProcessName(), result.getArguments()}); // NOI18N } return result; } - + /** Setter for property browserExecutable. * @param browserExecutable New value of property browserExecutable. */ @@ -246,20 +222,7 @@ public void propertyChange(PropertyChangeEvent evt) { if (np instanceof NbProcessDescriptor) { String processName = ((NbProcessDescriptor)np).getProcessName(); if (err.isLoggable(Level.FINE)) { - err.log(Level.FINE, "" + System.currentTimeMillis() + "> propertychange: " + processName); - } - if ((processName != null) && (processName.trim().length() > 0)) { - if (processName.toUpperCase().indexOf("IEXPLORE.EXE") > -1) { // NOI18N - setDDEServer(IEXPLORE); - } else if (processName.toUpperCase().indexOf("MOZILLA.EXE") > -1) { // NOI18N - setDDEServer(MOZILLA); - } else if (processName.toUpperCase().indexOf("FIREFOX.EXE") > -1) { // NOI18N - setDDEServer(FIREFOX); - } else if (processName.toUpperCase().indexOf("CHROME.EXE") > -1) { // NOI18N - setDDEServer(CHROME); - } else { - setDDEServer(null); - } + err.log(Level.FINE, "{0}> propertychange: {1}", new Object[]{System.currentTimeMillis(), processName}); } } } @@ -273,7 +236,7 @@ public void propertyChange(PropertyChangeEvent evt) { protected NbProcessDescriptor defaultBrowserExecutable () { String b = "mozilla"; // NOI18N if (err.isLoggable(Level.FINE)) { - err.log(Level.FINE, "" + System.currentTimeMillis() + "> ExtBrowser: defaultBrowserExecutable: "); + err.log(Level.FINE, "{0}> ExtBrowser: defaultBrowserExecutable: ", System.currentTimeMillis()); } if (Utilities.isWindows()) { String params = ""; // NOI18N @@ -287,51 +250,42 @@ protected NbProcessDescriptor defaultBrowserExecutable () { throw new NbBrowserException (); } b = args[0]; - if (args[0].toUpperCase().indexOf("IEXPLORE.EXE") > -1) { // NOI18N - setDDEServer(IEXPLORE); + if (args[0].toUpperCase().contains("IEXPLORE.EXE")) { // NOI18N params = "-nohome "; // NOI18N - } else if (args[0].toUpperCase().indexOf("MOZILLA.EXE") > -1) { // NOI18N - setDDEServer(MOZILLA); - } else if (args[0].toUpperCase().indexOf("FIREFOX.EXE") > -1) { // NOI18N - setDDEServer(FIREFOX); - } else if (args[0].toUpperCase().indexOf("CHROME.EXE") > -1) { // NOI18N - setDDEServer(CHROME); + } else if (args[0].toUpperCase().contains("MOZILLA.EXE")) { // NOI18N + } else if (args[0].toUpperCase().contains("FIREFOX.EXE")) { // NOI18N + } else if (args[0].toUpperCase().contains("CHROME.EXE")) { // NOI18N } params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; return new NbProcessDescriptor(b, params); - + } catch (NbBrowserException e) { try { b = NbDdeBrowserImpl.getBrowserPath("IEXPLORE"); // NOI18N if ((b != null) && (b.trim().length() > 0)) { - setDDEServer(IEXPLORE); params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; return new NbProcessDescriptor(b, params); } b = NbDdeBrowserImpl.getBrowserPath("MOZILLA"); // NOI18N if ((b != null) && (b.trim().length() > 0)) { - setDDEServer(MOZILLA); params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; return new NbProcessDescriptor(b, params); } b = NbDdeBrowserImpl.getBrowserPath("FIREFOX"); // NOI18N if ((b != null) && (b.trim().length() > 0)) { - setDDEServer(FIREFOX); params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; return new NbProcessDescriptor(b, params); } b = NbDdeBrowserImpl.getBrowserPath("chrome"); // NOI18N if ((b != null) && (b.trim().length() > 0)) { - setDDEServer(CHROME); params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; return new NbProcessDescriptor(b, params); } } catch (NbBrowserException e2) { - setDDEServer(IEXPLORE); - b = "C:\\Program Files\\Internet Explorer\\iexplore.exe"; // NOI18N + b = "C:\\Program Files\\Internet Explorer\\iexplore.exe"; // NOI18N } } catch (UnsatisfiedLinkError e) { // someone is customizing this on non-Win platform @@ -342,7 +296,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { // Unix but not MacOSX } else if (Utilities.isUnix() && !Utilities.isMac()) { - + // Linux -> Mozilla should be default if (Utilities.getOperatingSystem() == Utilities.OS_LINUX) { b = "mozilla"; // NOI18N @@ -368,7 +322,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { "-remote \"openURL({" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "})\"", // NOI18N ExtWebBrowser.UnixBrowserFormat.getHint() ); - + // OS/2 } else if (Utilities.getOperatingSystem () == Utilities.OS_OS2) { return new NbProcessDescriptor( @@ -377,7 +331,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { " {" + UnixBrowserFormat.TAG_URL + "}", // NOI18N ExtWebBrowser.UnixBrowserFormat.getHint() ); - + // Mac OS } else if (Utilities.isMac()) { return new NbProcessDescriptor( @@ -386,7 +340,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { " {" + UnixBrowserFormat.TAG_URL + "}", // NOI18N ExtWebBrowser.UnixBrowserFormat.getHint() ); - + // Other } else { return new NbProcessDescriptor( @@ -408,23 +362,23 @@ public HtmlBrowser.Impl createHtmlBrowserImpl() { } /** - * @param l new PropertyChangeListener */ + * @param l new PropertyChangeListener */ public void addPropertyChangeListener (PropertyChangeListener l) { if (pcs == null) { pcs = new PropertyChangeSupport(this); } pcs.addPropertyChangeListener (l); } - + /** - * @param l PropertyChangeListener to be removed */ + * @param l PropertyChangeListener to be removed */ public void removePropertyChangeListener (PropertyChangeListener l) { if (pcs != null) { pcs.removePropertyChangeListener (l); } } - - private void readObject (java.io.ObjectInputStream ois) + + private void readObject (java.io.ObjectInputStream ois) throws java.io.IOException, ClassNotFoundException { ois.defaultReadObject (); if (browserExecutable != null && browserExecutable.getArguments() != null) { @@ -474,14 +428,14 @@ void setPrivateBrowserFamilyId(PrivateBrowserFamilyId family) { } - /** Default format that can format tags related to execution. + /** Default format that can format tags related to execution. * Currently this is only the URL. */ public static class UnixBrowserFormat extends org.openide.util.MapFormat { - + /** SVUID for serialization. */ private static final long serialVersionUID = -699340388834127437L; - + /** Tag used to pass URL */ public static final String TAG_URL = "URL"; // NOI18N @@ -490,14 +444,14 @@ public static class UnixBrowserFormat extends org.openide.util.MapFormat { */ public UnixBrowserFormat (String url) { super(new java.util.HashMap ()); - java.util.Map map = getMap (); + java.util.Map map = getMap (); map.put (TAG_URL, url); } - + public static String getHint() { return NbBundle.getMessage(ExtWebBrowser.class, "MSG_BrowserExecutorHint"); // NOI18N } } - + } diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/FirefoxBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/FirefoxBrowser.java index df41853e56a2..a6dea5b8a29f 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/FirefoxBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/FirefoxBrowser.java @@ -34,7 +34,6 @@ public class FirefoxBrowser extends ExtWebBrowser { public FirefoxBrowser() { super(PrivateBrowserFamilyId.FIREFOX); - ddeServer = ExtWebBrowser.FIREFOX; } /** Determines whether the browser should be visible or not @@ -106,7 +105,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { if (Utilities.isWindows()) { params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; try { - prg = NbDdeBrowserImpl.getBrowserPath(getDDEServer()); + prg = NbDdeBrowserImpl.getBrowserPath(ExtWebBrowser.FIREFOX); return new NbProcessDescriptor (prg, params); } catch (NbBrowserException e) { prg = "C:\\Program Files\\Mozilla Firefox\\firefox.exe"; // NOI18N diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/IExplorerBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/IExplorerBrowser.java index 1fa2b0b059d7..46691597545b 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/IExplorerBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/IExplorerBrowser.java @@ -46,7 +46,6 @@ public static Boolean isHidden () { /** Creates new ExtWebBrowser */ public IExplorerBrowser() { super(PrivateBrowserFamilyId.IE); - ddeServer = ExtWebBrowser.IEXPLORE; } /** Getter for browser name @@ -90,7 +89,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; try { - b = NbDdeBrowserImpl.getBrowserPath(getDDEServer ()); + b = NbDdeBrowserImpl.getBrowserPath(ExtWebBrowser.IEXPLORE); } catch (NbBrowserException e) { b = "C:\\Program Files\\Internet Explorer\\iexplore.exe"; // NOI18N } catch (UnsatisfiedLinkError e) { diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/MozillaBrowser.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/MozillaBrowser.java index e65b30660af0..f2824e00bf7e 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/MozillaBrowser.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/MozillaBrowser.java @@ -35,7 +35,6 @@ public class MozillaBrowser extends ExtWebBrowser { /** Creates new ExtWebBrowser */ public MozillaBrowser() { super(PrivateBrowserFamilyId.MOZILLA); - ddeServer = ExtWebBrowser.MOZILLA; } /** Determines whether the browser should be visible or not @@ -105,7 +104,7 @@ protected NbProcessDescriptor defaultBrowserExecutable () { if (Utilities.isWindows()) { params += "{" + ExtWebBrowser.UnixBrowserFormat.TAG_URL + "}"; try { - prg = NbDdeBrowserImpl.getBrowserPath(getDDEServer()); + prg = NbDdeBrowserImpl.getBrowserPath(ExtWebBrowser.MOZILLA); return new NbProcessDescriptor (prg, params); } catch (NbBrowserException e) { prg = "C:\\Program Files\\Mozilla.org\\Mozilla\\mozilla.exe"; // NOI18N diff --git a/ide/extbrowser/src/org/netbeans/modules/extbrowser/NbDdeBrowserImpl.java b/ide/extbrowser/src/org/netbeans/modules/extbrowser/NbDdeBrowserImpl.java index 6c88131f1dd5..793995866de8 100644 --- a/ide/extbrowser/src/org/netbeans/modules/extbrowser/NbDdeBrowserImpl.java +++ b/ide/extbrowser/src/org/netbeans/modules/extbrowser/NbDdeBrowserImpl.java @@ -19,27 +19,25 @@ package org.netbeans.modules.extbrowser; +import com.sun.jna.Memory; +import com.sun.jna.Native; +import com.sun.jna.Pointer; +import com.sun.jna.platform.win32.Advapi32; +import com.sun.jna.platform.win32.Advapi32Util; +import com.sun.jna.platform.win32.Kernel32Util; +import com.sun.jna.platform.win32.W32Errors; +import com.sun.jna.platform.win32.Win32Exception; +import com.sun.jna.platform.win32.WinNT; +import com.sun.jna.platform.win32.WinReg; +import com.sun.jna.platform.win32.WinReg.HKEY; +import com.sun.jna.ptr.IntByReference; +import com.sun.jna.win32.W32APITypeMapper; import java.awt.EventQueue; import java.net.*; -import javax.swing.*; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Vector; - -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.awt.StatusDisplayer; import org.openide.execution.NbProcessDescriptor; -import org.openide.util.Utilities; -import org.openide.util.NbBundle; - -import java.io.File; -import java.io.FileWriter; import java.io.IOException; -import java.nio.file.Files; import java.util.logging.Level; -import org.openide.util.Exceptions; /** @@ -52,11 +50,11 @@ * * *

Limitations: Mozilla doesn't support WWW_Activate now - * IE has different implementation on Win9x and on WinNT/Win2000. + * IE has different implementation on Win9x and on WinNT/Win2000. * WWW_Activate creates always new window on Win9x so we don't use it. * Also it accepts only "0xFFFFFFFF" for WWW_Activate on WinNT/Win2K. * - *

Documentation can be found + *

Documentation can be found * * here. * @@ -64,50 +62,6 @@ */ public class NbDdeBrowserImpl extends ExtBrowserImpl { - /** DDE topic names */ - private static final String WWW_ACTIVATE = "WWW_Activate"; // NOI18N - private static final String WWW_OPEN_URL = "WWW_OpenURL"; // NOI18N - - private static final String EXTBROWSER_DLL = "extbrowser"; //NOI18N - private static final String EXTBROWSER_DLL_64BIT = "extbrowser64"; //NOI18N - - static { - logFine("NbDdeBrowser: static initializer: "); // NOI18N - try { - if (org.openide.util.Utilities.isWindows()) { - - // should be 32 or 64 bit, but it may not be present on some jdks - String sunDataModel = System.getProperty("sun.arch.data.model"); //NOI18N - if (sunDataModel != null) { - if ("64".equals(sunDataModel)) { //NOI18N - System.loadLibrary(EXTBROWSER_DLL_64BIT); - } else { - System.loadLibrary(EXTBROWSER_DLL); - } - } else { - String javaVMName = System.getProperty("java.vm.name"); //NOI18N - if ((javaVMName != null) && (javaVMName.contains("64"))) { //NOI18N - System.loadLibrary(EXTBROWSER_DLL_64BIT); - } else { - System.loadLibrary(EXTBROWSER_DLL); - } - } - - } - } catch (Exception e) { - DialogDisplayer.getDefault ().notify ( - new NotifyDescriptor.Message(NbBundle.getMessage(NbDdeBrowserImpl.class, "ERR_cant_locate_dll"), - NotifyDescriptor.INFORMATION_MESSAGE) - ); - } - } - - /** native thread that displays URLs */ - private static Thread nativeThread = null; - - /** runnable class that implements the work of nativeThread */ - private static NbDdeBrowserImpl.URLDisplayer nativeRunnable = null; - /** Creates new NbDdeBrowserImpl * @param extBrowserFactory factory to use */ @@ -116,17 +70,104 @@ public NbDdeBrowserImpl (ExtWebBrowser extBrowserFactory) { this.extBrowserFactory = extBrowserFactory; logFine("NbDdeBrowserImpl created with factory:", extBrowserFactory); // NOI18N } - - private native byte [] reqDdeMessage (String srv, String topic, String item, int timeout) throws NbBrowserException; - - /** finds registry entry for browser opening */ - public static native String getBrowserPath (String browser) throws NbBrowserException; - - /** returns the command that executes default application for opening of - * .html files + + /** + * finds registry entry for browser opening + * + * @param browser + * @return + * @throws org.netbeans.modules.extbrowser.NbBrowserException */ - public static native String getDefaultOpenCommand() throws NbBrowserException; - + public static String getBrowserPath(String browser) throws NbBrowserException { + String key = String.format("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\%s.exe", browser); + + try { + return getKeyValueExpanded(WinReg.HKEY_LOCAL_MACHINE, key, null); + } catch (Win32Exception ex) { + ExtWebBrowser.getEM().log(Level.FINE, "Failed to read registry entry for " + key, ex); + throw new NbBrowserException("Error when retrieving path to browser."); + } + } + + /** + * returns the command that executes default application for opening of + * .html files + * + * @return + * @throws org.netbeans.modules.extbrowser.NbBrowserException + */ + public static String getDefaultOpenCommand() throws NbBrowserException { + String sBrowser; + try { + sBrowser = Advapi32Util.registryGetStringValue(WinReg.HKEY_CLASSES_ROOT, ".html", null); + } catch (Win32Exception ex) { + ExtWebBrowser.getEM().log(Level.FINE, "Failed to read registry entry for .html", ex); + throw new NbBrowserException("Failed to read registry entry for .html"); + } + if(sBrowser.isEmpty()) { + throw new NbBrowserException("Browser not found."); + } + + sBrowser += "\\shell\\open\\command"; + + String path; + try { + path = getKeyValueExpanded(WinReg.HKEY_CLASSES_ROOT, sBrowser, null); + } catch (Win32Exception ex) { + ExtWebBrowser.getEM().log(Level.FINE, "Failed to read registry entry for " + sBrowser, ex); + throw new NbBrowserException("Failed to read registry entry for " + sBrowser); + } + + if(path == null || path.isEmpty()) { + throw new NbBrowserException("Error when retrieving path to browser."); + } + + return path; + } + + private static String getKeyValueExpanded(HKEY root, String key, String value) throws Win32Exception, NbBrowserException { + WinReg.HKEYByReference phkKey = new WinReg.HKEYByReference(); + int rc = Advapi32.INSTANCE.RegOpenKeyEx(root, key, 0, WinNT.KEY_READ, phkKey); + if (rc != W32Errors.ERROR_SUCCESS) { + throw new Win32Exception(rc); + } + try { + IntByReference data = new IntByReference(); + IntByReference type = new IntByReference(); + rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0, type, (Pointer) null, data); + if (rc != W32Errors.ERROR_SUCCESS + && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) { + throw new Win32Exception(rc); + } + if (type.getValue() != WinNT.REG_SZ + && type.getValue() != WinNT.REG_EXPAND_SZ) { + throw new NbBrowserException("Unexpected registry type " + + type.getValue() + + "for: " + key); + } + if (data.getValue() == 0) { + return ""; + } + assert W32APITypeMapper.DEFAULT == W32APITypeMapper.UNICODE; + Memory mem = new Memory(data.getValue() + Native.WCHAR_SIZE); + mem.clear(); + rc = Advapi32.INSTANCE.RegQueryValueEx(phkKey.getValue(), value, 0, type, mem, data); + if (rc != W32Errors.ERROR_SUCCESS) { + throw new Win32Exception(rc); + } + String result = mem.getWideString(0); + if(type.getValue() == WinNT.REG_EXPAND_SZ) { + return Kernel32Util.expandEnvironmentStrings(result); + } + return result; + } finally { + rc = Advapi32.INSTANCE.RegCloseKey(phkKey.getValue()); + if (rc != W32Errors.ERROR_SUCCESS) { + throw new Win32Exception(rc); + } + } + } + /** Sets current URL. * * @param url URL to show in the browser. @@ -138,39 +179,29 @@ protected void loadURLInBrowserInternal(URL url) { if (url == null) { return; } - if (isInternetExplorer()) { - if (nativeThread == null) { - nativeRunnable = new NbDdeBrowserImpl.URLDisplayer (); - nativeThread = new Thread(nativeRunnable, "URLdisplayer"); // NOI18N - nativeThread.start (); - } - nativeRunnable.postTask (new DisplayTask (url, this)); - } - else { - NbProcessDescriptor np = extBrowserFactory.getBrowserExecutable(); - try { - url = URLUtil.createExternalURL(url, false); - String urlTxt; - if (url == null) { - urlTxt = ""; // NOI18N; - } else { - try { - urlTxt = url.toURI().toASCIIString(); - } catch (URISyntaxException ex) { - logInfo(ex); - urlTxt = url.toString(); - } - } - if (np != null) { - np.exec(new SimpleExtBrowser.BrowserFormat(urlTxt)); + NbProcessDescriptor np = extBrowserFactory.getBrowserExecutable(); + try { + url = URLUtil.createExternalURL(url, false); + String urlTxt; + if (url == null) { + urlTxt = ""; // NOI18N; + } else { + try { + urlTxt = url.toURI().toASCIIString(); + } catch (URISyntaxException ex) { + logInfo(ex); + urlTxt = url.toString(); } - } catch (IOException ex) { - logInfo(ex); - BrowserUtils.notifyMissingBrowser(np.getProcessName()); } + if (np != null) { + np.exec(new SimpleExtBrowser.BrowserFormat(urlTxt)); + } + } catch (IOException ex) { + logInfo(ex); + BrowserUtils.notifyMissingBrowser(np.getProcessName()); } } - + private static void logInfo(Exception ex) { ExtWebBrowser.getEM().log(Level.INFO, null, ex); } @@ -200,19 +231,15 @@ protected PrivateBrowserFamilyId detectPrivateBrowserFamilyId(){ return id; } - /** Finds the name of DDE server. - * If is set then it resolves it into either + /** Finds the name of DDE server. + * If is set then it resolves it into either * Netscape or IExplore */ - private String realDDEServer () { + private String realDDEServer() { logFine("NbDdeBrowserImpl.realDDEServer"); // NOI18N - String srv = extBrowserFactory.getDDEServer (); - if (srv != null) { - return srv; - } - + try { - String cmd = getDefaultOpenCommand (); + String cmd = getDefaultOpenCommand(); if (cmd != null) { cmd = cmd.toUpperCase(); if (cmd.contains(ExtWebBrowser.IEXPLORE)) { @@ -227,7 +254,7 @@ private String realDDEServer () { if (cmd.contains(ExtWebBrowser.FIREFOX)) { return ExtWebBrowser.FIREFOX; } - + if (cmd.contains(ExtWebBrowser.MOZILLA)) { return ExtWebBrowser.MOZILLA; } @@ -239,7 +266,7 @@ private String realDDEServer () { // guess IE return ExtWebBrowser.IEXPLORE; } - + /** Getter for property activateTimeout. * @return Value of property activateTimeout. * @@ -247,7 +274,7 @@ private String realDDEServer () { public int getActivateTimeout() { return extBrowserFactory.getActivateTimeout(); } - + /** Getter for property openUrlTimeout. * @return Value of property openUrlTimeout. * @@ -256,224 +283,4 @@ public int getOpenUrlTimeout() { return extBrowserFactory.getOpenurlTimeout(); } - private boolean isInternetExplorer() { - return realDDEServer().equals(ExtWebBrowser.IEXPLORE); - } - - /** - * Singleton for doing all DDE operations. - */ - static class URLDisplayer implements Runnable { // NOI18N - - private static final int ADDITIONAL_WAIT_TIMEOUT = 6000; - - /** FIFO of urls that should be displayed */ - Vector tasks; - - /** This is set to true during displaying of URL. - * Used by Timer to interrupt displaying and print error message - */ - boolean isDisplaying = false; - - private URLDisplayer () { - tasks = new Vector (); - } - - private void postTask (DisplayTask task) { - synchronized (this) { - boolean shouldNotify = tasks.isEmpty (); - tasks.add (task); - if (shouldNotify) { - notifyAll(); - } - } - } - - /** - * Returns next URL from queue that was posted for displaying. - * This method blocks other processing until there is an request - */ - private synchronized DisplayTask getNextTask() throws InterruptedException { - do { - - if (!tasks.isEmpty ()) { - return (DisplayTask)tasks.remove(0); - } - wait(); - - } while (true); - } - - @NbBundle.Messages("NbDdeBrowserImpl.browser.external=external browser") - @Override - public void run() { - logFine("NbDdeBrowserImpl.run"); // NOI18N - while (true) { - try { - /** url to be displayed */ - DisplayTask task = getNextTask(); - - isDisplaying = true; - Timer timer = new Timer(); - timer.schedule(new TimerTask() { - @Override - public void run() { - if (isDisplaying) { - NbDdeBrowserImpl.nativeThread.interrupt(); - logFine("interrupted in URLDisplayer.run.TimerTask.run()"); // NOI18N - BrowserUtils.notifyMissingBrowser(Bundle.NbDdeBrowserImpl_browser_external()); - } - } - }, /*task.browser.extBrowserFactory.getBrowserStartTimeout() + */ADDITIONAL_WAIT_TIMEOUT); - dispatchURL (task); - timer.cancel(); - } catch (InterruptedException ex) { - ExtWebBrowser.getEM().log(Level.INFO, "interrupted in run(): " + ex); // NOI18N - // do nothing - } finally { - isDisplaying = false; - } - } - } - - public void dispatchURL (DisplayTask task) { - logFine("NbDdeBrowserImpl.dispatchURL:", task); // NOI18N - try { - URL url = task.url; - logFine("URLDispatcher.url:", url); // NOI18N - - // internal protocols cannot be displayed in external viewer - url = URLUtil.createExternalURL(url, URLUtil.browserHandlesJarURLs(task.browser.realDDEServer())); // XXX support Netscape too? - - logFine("url:", url); // NOI18N - - String urlStr = url.toString(); - - boolean triedStart = false; - final int MAX_URL_LENGTH = 199; - - if ((urlStr != null) && (urlStr.length() > MAX_URL_LENGTH)) { - urlStr = getFileUrl(urlStr); - } - - logFine("urlstr:", urlStr); // NOI18N - if (!win9xHack(task.browser.realDDEServer())) { - StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage (NbDdeBrowserImpl.class, "MSG_activatingBrowser")); - try { - task.browser.reqDdeMessage(task.browser.realDDEServer(),WWW_ACTIVATE,"-1,0x0",task.browser.getActivateTimeout()); - } catch (NbBrowserException ex) { - logFine("Exception, gonna start browser:", ex); - triedStart = true; - startBrowser(task.browser.extBrowserFactory.getBrowserExecutable(), urlStr); - } - } - logFine("firstpart"); // NOI18N - - if (!triedStart) { - StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(NbDdeBrowserImpl.class, "MSG_openingURLInBrowser", urlStr)); - String args1 = "\""+urlStr+"\",,-1,0x1,,,"; // NOI18N - - try { - Thread.sleep(500); // trying hack for bug #42438 - Browser executes twice which is a Mozilla bug - task.browser.reqDdeMessage(task.browser.realDDEServer(),WWW_OPEN_URL,args1,task.browser.getOpenUrlTimeout()); - } catch (NbBrowserException ex) { - logFine("Restarting browser."); // NOI18N - startBrowser(task.browser.extBrowserFactory.getBrowserExecutable(), urlStr); - } catch (InterruptedException ex) { - // just ignore - } - } - logFine("secondpart"); // NOI18N - - task.browser.pcs.firePropertyChange(PROP_URL, task.browser.getURL(), url); - - } catch (final Exception ex) { - logFine("Interrupted in URLDisplayer.dispatchURL.end"); // NOI18N - Exceptions.attachLocalizedMessage(ex, NbBundle.getMessage(NbDdeBrowserImpl.class, "MSG_win_browser_invocation_failed")); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - Exceptions.printStackTrace(ex); - } - }); - } - } - - - /** - * - */ - private String getFileUrl(String url) { - logFine("Gonna get redirect file for long url:", url); // NOI18N - String newurl = null; - FileWriter fw = null; - File f = null; - - int retries = 10; - - while ((f == null) && (retries > 0)) { - retries--; - try { - f = Files.createTempFile("extbrowser", ".html").toFile(); // NOI18N - logFine("file:", f); // NOI18N - if (f != null) { - fw = new FileWriter(f); - if (f.canWrite()) { - String s1 = org.openide.util.NbBundle.getMessage(NbDdeBrowserImpl.class, "TXT_RedirectURL1"); //NOI18N - String s2 = org.openide.util.NbBundle.getMessage(NbDdeBrowserImpl.class, "TXT_RedirectURL2"); //NOI18N - String s = s1.concat(url).concat(s2); - fw.write(s); - fw.flush(); - } - newurl = "file:/" + f.getAbsolutePath(); // NOI18N - } - } catch (IOException ioe) { - logInfo(ioe); - } finally { - if (fw != null) { - try { - fw.close(); - } catch (IOException ioe) { - logInfo(ioe); - } - } - } - } - if (newurl != null) { - logFine("New URL:", newurl); // NOI18N - return newurl; - } - return url; - } - - /** - * Checks for IExplorer & Win9x combination. - */ - private boolean win9xHack (String browser) { - return browser.equals(ExtWebBrowser.IEXPLORE) - && (Utilities.getOperatingSystem() == Utilities.OS_WIN98 - || Utilities.getOperatingSystem() == Utilities.OS_WIN95); - } - - /** - * Utility function that tries to start new browser process. - * - * It is used when WWW_Activate or WWW_OpenURL fail - */ - private void startBrowser(NbProcessDescriptor cmd, String url) throws java.io.IOException { - StatusDisplayer.getDefault ().setStatusText (NbBundle.getMessage(NbDdeBrowserImpl.class, "MSG_startingBrowser", url)); - cmd.exec(new ExtWebBrowser.UnixBrowserFormat(url)); - } - } - - /** Encapsulating class for URL and browser that asks for its displaying */ - private static class DisplayTask { - URL url; - NbDdeBrowserImpl browser; - - DisplayTask (URL url, NbDdeBrowserImpl browser) { - this.url = url; - this.browser = browser; - } - } } diff --git a/ide/extbrowser/test/unit/src/org/netbeans/modules/extbrowser/ExtWebBrowserTest.java b/ide/extbrowser/test/unit/src/org/netbeans/modules/extbrowser/ExtWebBrowserTest.java index 5f4977b6a11e..98d0ac3d2092 100644 --- a/ide/extbrowser/test/unit/src/org/netbeans/modules/extbrowser/ExtWebBrowserTest.java +++ b/ide/extbrowser/test/unit/src/org/netbeans/modules/extbrowser/ExtWebBrowserTest.java @@ -92,16 +92,6 @@ public void propertyChange (PropertyChangeEvent evt) {} }); } - /** Test of getDDEServer method, of class org.netbeans.modules.extbrowser.ExtWebBrowser. */ - public void testGetDDEServer () { - testObject.getDDEServer (); - } - - /** Test of setDDEServer method, of class org.netbeans.modules.extbrowser.ExtWebBrowser. */ - public void testSetDDEServer () { - testObject.setDDEServer ("NETSCAPE"); - } - protected ExtWebBrowser testObject; protected void setUp () { diff --git a/ide/ide.kit/nbproject/project.xml b/ide/ide.kit/nbproject/project.xml index 3b19e4769a8e..dcda640f17db 100644 --- a/ide/ide.kit/nbproject/project.xml +++ b/ide/ide.kit/nbproject/project.xml @@ -147,15 +147,15 @@ - org.netbeans.modules.editor.settings.storage + org.netbeans.modules.editor.settings.lib - 1 1.49 - org.netbeans.modules.editor.settings.lib + org.netbeans.modules.editor.settings.storage + 1 1.49 @@ -176,8 +176,8 @@ org.netbeans.modules.extbrowser - 1 - 1.11 + 2 + 2.0 diff --git a/ide/web.browser.api/nbproject/project.xml b/ide/web.browser.api/nbproject/project.xml index a8b0b93fab01..7fd39cf03e67 100644 --- a/ide/web.browser.api/nbproject/project.xml +++ b/ide/web.browser.api/nbproject/project.xml @@ -52,6 +52,15 @@ 1.30 + + org.netbeans.modules.extbrowser + + + + 2 + 2.0 + + org.netbeans.modules.projectapi @@ -143,14 +152,6 @@ 6.55 - - org.openide.util.ui - - - - 9.3 - - org.openide.util @@ -168,20 +169,19 @@ - org.openide.windows + org.openide.util.ui - 6.51 + 9.3 - org.netbeans.modules.extbrowser + org.openide.windows - 1 - 1.51 + 6.51 diff --git a/javafx/javafx2.project/nbproject/project.xml b/javafx/javafx2.project/nbproject/project.xml index de8c2b35eb51..2900a9de99c7 100644 --- a/javafx/javafx2.project/nbproject/project.xml +++ b/javafx/javafx2.project/nbproject/project.xml @@ -99,8 +99,8 @@ - 1 - 1.25 + 2 + 2.0 diff --git a/webcommon/extbrowser.chrome/nbproject/project.xml b/webcommon/extbrowser.chrome/nbproject/project.xml index b13058e18bc3..eab7b04c3329 100644 --- a/webcommon/extbrowser.chrome/nbproject/project.xml +++ b/webcommon/extbrowser.chrome/nbproject/project.xml @@ -57,8 +57,8 @@ - 1 - 1.39 + 2 + 2.0