зеркало из https://github.com/mozilla/pjs.git
214893 - Mail Integration UI - add "Mail" button to toolbar palette, with a submenu providing convenient access to mail, newsgroups. also adds Ctrl+M to compose new message.
This commit is contained in:
Родитель
255fa04f9c
Коммит
a1767488d5
|
@ -76,8 +76,14 @@
|
|||
<command id="cmd_newNavigatorTab" oncommand="BrowserOpenTab();"/>
|
||||
<command id="Browser:OpenFile" oncommand="BrowserOpenFileWindow();"/>
|
||||
<command id="Browser:SavePage" oncommand="saveDocument(window._content.document);"/>
|
||||
<command id="Browser:SendLink" oncommand="sendLink(Components.lookupMethod(window._content, 'location').call(window._content).href,
|
||||
Components.lookupMethod(window._content.document, 'title').call(window._content.document));"/>
|
||||
|
||||
<command id="Browser:SendLink" oncommand="MailIntegration.sendLinkForContent();"/>
|
||||
<command id="Browser:NewMessage" oncommand="MailIntegration.sendMessage('', '');"/>
|
||||
#ifdef XP_WIN
|
||||
<command id="Browser:ReadMail" oncommand="MailIntegration.readMail();"/>
|
||||
<command id="Browser:ReadNews" oncommand="MailIntegration.readNews();"/>
|
||||
#endif
|
||||
|
||||
<command id="cmd_print" oncommand="PrintUtils.print();"/>
|
||||
<command id="cmd_close" oncommand="BrowserCloseTabOrWindow()"/>
|
||||
<command id="cmd_closeWindow" oncommand="BrowserCloseWindow()"/>
|
||||
|
@ -256,6 +262,8 @@
|
|||
|
||||
<key id="key_openDownloads" key="&downloads.commandkey;" command="Tools:Downloads" modifiers="accel"/>
|
||||
|
||||
<key id="key_newMessage" key="&sendMessage.commandkey;" command="Browser:NewMessage" modifiers="accel"/>
|
||||
|
||||
<key id="key_textZoomReduce" key="&textZoomReduceCmd.commandkey;" command="cmd_textZoomReduce" modifiers="accel"/>
|
||||
<key id="key_textZoomEnlarge" key="&textZoomEnlargeCmd.commandkey;" command="cmd_textZoomEnlarge" modifiers="accel"/>
|
||||
<key key="&textZoomEnlargeCmd.commandkey2;" command="cmd_textZoomEnlarge" modifiers="accel"/>
|
||||
|
|
|
@ -1503,7 +1503,6 @@ function updateToolbarStates(toolbarMenuElt)
|
|||
|
||||
function BrowserImport()
|
||||
{
|
||||
// goats
|
||||
#ifdef XP_MACOSX
|
||||
var features = "centerscreen,chrome,resizable=no";
|
||||
#else
|
||||
|
@ -3207,14 +3206,14 @@ nsContextMenu.prototype = {
|
|||
saveURL( this.linkURL(), this.linkText(), null, true, true );
|
||||
},
|
||||
sendLink : function () {
|
||||
sendLink( this.linkURL(), "" ); // we don't know the title of the link so pass in an empty string
|
||||
MailIntegration.sendMessage( this.linkURL(), "" ); // we don't know the title of the link so pass in an empty string
|
||||
},
|
||||
// Save URL of clicked-on image.
|
||||
saveImage : function () {
|
||||
saveURL( this.imageURL, null, "SaveImageTitle", false );
|
||||
},
|
||||
sendImage : function () {
|
||||
sendLink(this.imageURL, "");
|
||||
MailIntegration.sendMessage(this.imageURL, "");
|
||||
},
|
||||
toggleImageBlocking : function (aBlock) {
|
||||
var nsIPermissionManager = Components.interfaces.nsIPermissionManager;
|
||||
|
@ -3942,27 +3941,6 @@ function charsetLoadListener (event)
|
|||
}
|
||||
}
|
||||
|
||||
// a generic method which can be used to pass arbitrary urls to the operating system.
|
||||
// aURL --> a nsIURI which represents the url to launch
|
||||
function launchExternalUrl(aURL)
|
||||
{
|
||||
var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);
|
||||
if (extProtocolSvc)
|
||||
extProtocolSvc.loadUrl(aURL);
|
||||
}
|
||||
|
||||
function sendLink(url, title)
|
||||
{
|
||||
// generate a mailto url based on the url and the url's title
|
||||
var mailtoUrl = url ? "mailto:?body=" + encodeURIComponent(url) + "&subject=" + encodeURIComponent(title) : "mailto:";
|
||||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
var uri = ioService.newURI(mailtoUrl, null, null);
|
||||
|
||||
// now pass this url to the operating system
|
||||
launchExternalUrl(uri);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
const nsIWindowDataSource = Components.interfaces.nsIWindowDataSource;
|
||||
|
||||
|
@ -4317,3 +4295,61 @@ function WindowIsClosing()
|
|||
|
||||
return reallyClose;
|
||||
}
|
||||
|
||||
var MailIntegration = {
|
||||
sendLinkForContent: function ()
|
||||
{
|
||||
this.sendMessage(Components.lookupMethod(window._content, 'location').call(window._content).href,
|
||||
Components.lookupMethod(window._content.document, 'title').call(window._content.document));
|
||||
},
|
||||
|
||||
sendMessage: function (aBody, aSubject)
|
||||
{
|
||||
// generate a mailto url based on the url and the url's title
|
||||
var mailtoUrl = aBody ? "mailto:?body=" + encodeURIComponent(aBody) + "&subject=" + encodeURIComponent(aSubject) : "mailto:";
|
||||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
var uri = ioService.newURI(mailtoUrl, null, null);
|
||||
|
||||
// now pass this url to the operating system
|
||||
this._launchExternalUrl(uri);
|
||||
},
|
||||
|
||||
// a generic method which can be used to pass arbitrary urls to the operating system.
|
||||
// aURL --> a nsIURI which represents the url to launch
|
||||
_launchExternalUrl: function(aURL)
|
||||
{
|
||||
var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);
|
||||
if (extProtocolSvc)
|
||||
extProtocolSvc.loadUrl(aURL);
|
||||
#ifdef XP_WIN
|
||||
},
|
||||
|
||||
readMail: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
whs.openDefaultClient("Mail");
|
||||
},
|
||||
|
||||
readNews: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
whs.openDefaultClient("News");
|
||||
},
|
||||
|
||||
updateUnreadCount: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
var unreadCount = whs.unreadMailCount;
|
||||
var message = gNavigatorBundle.getFormattedString("mailUnreadTooltip", [unreadCount]);
|
||||
var element = document.getElementById("mail-button");
|
||||
element.setAttribute("tooltiptext", message);
|
||||
|
||||
message = gNavigatorBundle.getFormattedString("mailUnreadMenuitem", [unreadCount]);
|
||||
element = document.getElementById("readMailItem");
|
||||
element.setAttribute("label", message);
|
||||
}
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
};
|
|
@ -290,6 +290,30 @@
|
|||
observes="viewHistorySidebar"
|
||||
tooltiptext="&historyButton.tooltip;"/>
|
||||
|
||||
#ifdef XP_WIN
|
||||
<toolbarbutton id="mail-button" type="menu" class="toolbarbutton-1"
|
||||
label="&mailButton.label;" orient="horizontal"
|
||||
onmouseover="MailIntegration.updateUnreadCount();"
|
||||
tooltiptext="&mailButton.tooltip;">
|
||||
<menupopup tooltiptext="">
|
||||
<menuitem label="&mailButton.readMail.label;"
|
||||
id="readMailItem"
|
||||
accesskey="&mailButton.readMail.accesskey;"
|
||||
command="Browser:ReadMail"/>
|
||||
<menuitem label="&mailButton.newMessage.label;"
|
||||
accesskey="&mailButton.newMessage.accesskey;"
|
||||
command="Browser:NewMessage"/>
|
||||
<menuitem label="&mailButton.sendLink.label;"
|
||||
accesskey="&mailButton.sendLink.accesskey;"
|
||||
command="Browser:SendLink"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&mailButton.readNews.label;"
|
||||
accesskey="&mailButton.readNews.accesskey;"
|
||||
command="Browser:ReadNews"/>
|
||||
</menupopup>
|
||||
</toolbarbutton>
|
||||
#endif
|
||||
|
||||
<toolbarbutton id="bookmarks-button" class="toolbarbutton-1"
|
||||
observes="viewBookmarksSidebar"
|
||||
tooltiptext="&bookmarksButton.tooltip;"/>
|
||||
|
|
|
@ -268,6 +268,18 @@
|
|||
<!ENTITY historyButton.label "History">
|
||||
<!ENTITY historyButton.tooltip "Display pages you've viewed recently">
|
||||
|
||||
<!ENTITY mailButton.label "Mail">
|
||||
<!ENTITY mailButton.tooltip "Read and Send Mail">
|
||||
<!ENTITY mailButton.readMail.label "Read Mail">
|
||||
<!ENTITY mailButton.readMail.accesskey "M">
|
||||
<!ENTITY mailButton.newMessage.label "New Message...">
|
||||
<!ENTITY mailButton.newMessage.accesskey "w">
|
||||
<!ENTITY mailButton.sendLink.label "Send Link...">
|
||||
<!ENTITY mailButton.sendLink.accesskey "L">
|
||||
<!ENTITY mailButton.readNews.label "Read News">
|
||||
<!ENTITY mailButton.readNews.accesskey "N">
|
||||
<!ENTITY sendMessage.commandkey "m">
|
||||
|
||||
<!ENTITY newTabButton.tooltip "Open a new tab">
|
||||
<!ENTITY newWindowButton.tooltip "Open a new window">
|
||||
<!ENTITY sidebarCloseButton.tooltip "Close sidebar">
|
||||
|
|
|
@ -56,3 +56,6 @@ tabs.closeWarningTitle=Confirm close
|
|||
tabs.closeWarning=This Browser window has %S tabs open. Do you want to close it and all its tabs?
|
||||
tabs.closeButton=Close all tabs
|
||||
tabs.closeWarningPromptMe=Warn me when closing multiple tabs
|
||||
|
||||
mailUnreadTooltip=Read Mail and News (%S new messages)
|
||||
mailUnreadMenuitem=Read Mail (%S new)
|
||||
|
|
|
@ -302,6 +302,17 @@ toolbar[mode="text"] .toolbarbutton-text {
|
|||
-moz-image-region: rect(64px 224px 96px 192px);
|
||||
}
|
||||
|
||||
#mail-button {
|
||||
-moz-image-region: rect(0px 224px 32px 192px);
|
||||
}
|
||||
#mail-button:hover,
|
||||
#mail-button[checked="true"] {
|
||||
-moz-image-region: rect(32px 224px 64px 192px);
|
||||
}
|
||||
#mail-button[disabled="true"] {
|
||||
-moz-image-region: rect(64px 224px 96px 192px);
|
||||
}
|
||||
|
||||
#cut-button {
|
||||
-moz-image-region: rect(0px 384px 32px 352px);
|
||||
}
|
||||
|
@ -453,6 +464,17 @@ toolbar[iconsize="small"] #history-button[disabled="true"] {
|
|||
-moz-image-region: rect(40px 140px 60px 120px) !important;
|
||||
}
|
||||
|
||||
toolbar[iconsize="small"] #mail-button {
|
||||
-moz-image-region: rect(0px 140px 20px 120px);
|
||||
}
|
||||
toolbar[iconsize="small"] #mail-button:hover,
|
||||
toolbar[iconsize="small"] #mail-button[checked="true"] {
|
||||
-moz-image-region: rect(20px 140px 40px 120px);
|
||||
}
|
||||
toolbar[iconsize="small"] #mail-button[disabled="true"] {
|
||||
-moz-image-region: rect(40px 140px 60px 120px) !important;
|
||||
}
|
||||
|
||||
toolbar[iconsize="small"] #cut-button {
|
||||
-moz-image-region: rect(0px 240px 20px 220px);
|
||||
}
|
||||
|
|
|
@ -1,769 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law <law@netscape.com>
|
||||
* Syd Logan <syd@netscape.com> added turbo mode stuff
|
||||
* Joe Elwell <jelwell@netscape.com>
|
||||
* Håkan Waara <hwaara@chello.se>
|
||||
* Aaron Kaluszka <ask@swva.net>
|
||||
* Blake Ross <blake@blakeross.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
||||
// Implementation utilities.
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMemory.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsWindowsHooksUtil.cpp"
|
||||
#include "nsWindowsHooks.h"
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlguid.h>
|
||||
|
||||
// for set as wallpaper
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
|
||||
#define RUNKEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
|
||||
|
||||
// Objects that describe the Windows registry entries that we need to tweak.
|
||||
static ProtocolRegistryEntry
|
||||
http( "http" ),
|
||||
https( "https" ),
|
||||
ftp( "ftp" ),
|
||||
chrome( "chrome" ),
|
||||
gopher( "gopher" );
|
||||
const char *xhtmExts[] = { ".xht", ".xhtml", 0 };
|
||||
const char *htmExts[] = { ".htm", ".html", ".shtml", 0 };
|
||||
|
||||
static FileTypeRegistryEntry
|
||||
xhtml( xhtmExts, "MozillaXHTML", "XHTML Document", "", "doc-file.ico"),
|
||||
mozillaMarkup( htmExts, "MozillaHTML", "HTML Document", "htmlfile", "doc-file.ico");
|
||||
|
||||
// Implementation of the nsIWindowsHooksSettings interface.
|
||||
// Use standard implementation of nsISupports stuff.
|
||||
NS_IMPL_ISUPPORTS1( nsWindowsHooksSettings, nsIWindowsHooksSettings )
|
||||
|
||||
nsWindowsHooksSettings::nsWindowsHooksSettings() {
|
||||
}
|
||||
|
||||
nsWindowsHooksSettings::~nsWindowsHooksSettings() {
|
||||
}
|
||||
|
||||
// Generic getter.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooksSettings::Get( PRBool *result, PRBool nsWindowsHooksSettings::*member ) {
|
||||
NS_ENSURE_ARG( result );
|
||||
NS_ENSURE_ARG( member );
|
||||
*result = this->*member;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Generic setter.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooksSettings::Set( PRBool value, PRBool nsWindowsHooksSettings::*member ) {
|
||||
NS_ENSURE_ARG( member );
|
||||
this->*member = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Macros to define specific getter/setter methods.
|
||||
#define DEFINE_GETTER_AND_SETTER( attr, member ) \
|
||||
NS_IMETHODIMP \
|
||||
nsWindowsHooksSettings::Get##attr ( PRBool *result ) { \
|
||||
return this->Get( result, &nsWindowsHooksSettings::member ); \
|
||||
} \
|
||||
NS_IMETHODIMP \
|
||||
nsWindowsHooksSettings::Set##attr ( PRBool value ) { \
|
||||
return this->Set( value, &nsWindowsHooksSettings::member ); \
|
||||
}
|
||||
|
||||
// Define all the getter/setter methods:
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingHTML, mHandleHTML )
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingXHTML, mHandleXHTML )
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingHTTP, mHandleHTTP )
|
||||
DEFINE_GETTER_AND_SETTER( IsHandlingHTTPS, mHandleHTTPS )
|
||||
DEFINE_GETTER_AND_SETTER( ShowDialog, mShowDialog )
|
||||
DEFINE_GETTER_AND_SETTER( HaveBeenSet, mHaveBeenSet )
|
||||
|
||||
|
||||
// Implementation of the nsIWindowsHooks interface.
|
||||
// Use standard implementation of nsISupports stuff.
|
||||
NS_IMPL_ISUPPORTS2( nsWindowsHooks, nsIWindowsHooks, nsIWindowsRegistry )
|
||||
|
||||
nsWindowsHooks::nsWindowsHooks() {
|
||||
}
|
||||
|
||||
nsWindowsHooks::~nsWindowsHooks() {
|
||||
}
|
||||
|
||||
// Internal GetPreferences.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::GetSettings( nsWindowsHooksSettings **result ) {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Validate input arg.
|
||||
NS_ENSURE_ARG( result );
|
||||
|
||||
// Allocate prefs object.
|
||||
nsWindowsHooksSettings *prefs = *result = new nsWindowsHooksSettings;
|
||||
NS_ENSURE_TRUE( prefs, NS_ERROR_OUT_OF_MEMORY );
|
||||
|
||||
// Got it, increment ref count.
|
||||
NS_ADDREF( prefs );
|
||||
|
||||
// Get each registry value and copy to prefs structure.
|
||||
prefs->mHandleHTTP = BoolRegistryEntry( "isHandlingHTTP" );
|
||||
prefs->mHandleHTTPS = BoolRegistryEntry( "isHandlingHTTPS" );
|
||||
prefs->mHandleHTML = BoolRegistryEntry( "isHandlingHTML" );
|
||||
prefs->mHandleXHTML = BoolRegistryEntry( "isHandlingXHTML" );
|
||||
prefs->mShowDialog = BoolRegistryEntry( "showDialog" );
|
||||
prefs->mHaveBeenSet = BoolRegistryEntry( "haveBeenSet" );
|
||||
|
||||
#ifdef DEBUG_law
|
||||
NS_WARN_IF_FALSE( NS_SUCCEEDED( rv ), "GetPreferences failed" );
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Public interface uses internal plus a QI to get to the proper result.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::GetSettings( nsIWindowsHooksSettings **_retval ) {
|
||||
// Allocate prefs object.
|
||||
nsWindowsHooksSettings *prefs;
|
||||
nsresult rv = this->GetSettings( &prefs );
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// QI to proper interface.
|
||||
rv = prefs->QueryInterface( NS_GET_IID( nsIWindowsHooksSettings ), (void**)_retval );
|
||||
// Release (to undo our Get...).
|
||||
NS_RELEASE( prefs );
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static PRBool misMatch( const PRBool &flag, const ProtocolRegistryEntry &entry ) {
|
||||
PRBool result = PR_FALSE;
|
||||
// Check if we care.
|
||||
if ( flag ) {
|
||||
// Compare registry entry setting to what it *should* be.
|
||||
if ( entry.currentSetting() != entry.setting ) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// isAccessRestricted - Returns PR_TRUE iff this user only has restricted access
|
||||
// to the registry keys we need to modify.
|
||||
static PRBool isAccessRestricted() {
|
||||
char subKey[] = "Software\\Mozilla - Test Key";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx( HKEY_LOCAL_MACHINE,
|
||||
subKey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&key,
|
||||
&dwDisp );
|
||||
|
||||
if ( rc == ERROR_SUCCESS ) {
|
||||
// Key was opened; first close it.
|
||||
::RegCloseKey( key );
|
||||
// Delete it if we just created it.
|
||||
switch( dwDisp ) {
|
||||
case REG_CREATED_NEW_KEY:
|
||||
::RegDeleteKey( HKEY_LOCAL_MACHINE, subKey );
|
||||
break;
|
||||
case REG_OPENED_EXISTING_KEY:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Can't create/open it; we don't have access.
|
||||
result = PR_TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Implementation of method that checks whether the settings match what's in the
|
||||
// Windows registry.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooksSettings::GetRegistryMatches( PRBool *_retval ) {
|
||||
NS_ENSURE_ARG( _retval );
|
||||
*_retval = PR_TRUE;
|
||||
// Test registry for all selected attributes.
|
||||
if ( misMatch( mHandleHTTP, http )
|
||||
||
|
||||
misMatch( mHandleHTTPS, https )
|
||||
||
|
||||
misMatch( mHandleHTML, mozillaMarkup )
|
||||
||
|
||||
misMatch( mHandleXHTML, xhtml ) ) {
|
||||
// Registry is out of synch.
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Implementation of method that checks settings versus registry and prompts user
|
||||
// if out of synch.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::CheckSettings( nsIDOMWindowInternal *aParent,
|
||||
PRBool *_retval ) {
|
||||
nsresult rv = NS_OK;
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
// Only do this once!
|
||||
static PRBool alreadyChecked = PR_FALSE;
|
||||
if ( alreadyChecked ) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
alreadyChecked = PR_TRUE;
|
||||
// Don't check further if we don't have sufficient access.
|
||||
if ( isAccessRestricted() ) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Get settings.
|
||||
nsWindowsHooksSettings *settings;
|
||||
rv = this->GetSettings( &settings );
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) && settings ) {
|
||||
// If not set previously, set to defaults so that they are
|
||||
// set properly when/if the user says to.
|
||||
if ( !settings->mHaveBeenSet ) {
|
||||
settings->mHandleHTTP = PR_TRUE;
|
||||
settings->mHandleHTTPS = PR_TRUE;
|
||||
settings->mHandleHTML = PR_TRUE;
|
||||
settings->mHandleXHTML = PR_TRUE;
|
||||
|
||||
settings->mShowDialog = PR_TRUE;
|
||||
}
|
||||
|
||||
// If launched with "-installer" then override mShowDialog.
|
||||
PRBool installing = PR_FALSE;
|
||||
if ( !settings->mShowDialog ) {
|
||||
// Get command line service.
|
||||
nsCID cmdLineCID = NS_COMMANDLINE_SERVICE_CID;
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs( do_GetService( cmdLineCID, &rv ) );
|
||||
if ( NS_SUCCEEDED( rv ) && cmdLineArgs ) {
|
||||
// See if "-installer" was specified.
|
||||
nsXPIDLCString installer;
|
||||
rv = cmdLineArgs->GetCmdLineValue( "-installer", getter_Copies( installer ) );
|
||||
if ( NS_SUCCEEDED( rv ) && installer ) {
|
||||
installing = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// First, make sure the user cares.
|
||||
if ( settings->mShowDialog || installing ) {
|
||||
// Look at registry setting for all things that are set.
|
||||
PRBool matches = PR_TRUE;
|
||||
settings->GetRegistryMatches( &matches );
|
||||
if ( !matches ) {
|
||||
// Need to prompt user.
|
||||
// First:
|
||||
// o We need the common dialog service to show the dialog.
|
||||
// o We need the string bundle service to fetch the appropriate
|
||||
// dialog text.
|
||||
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
|
||||
nsCOMPtr<nsIPromptService> promptService( do_GetService("@mozilla.org/embedcomp/prompt-service;1"));
|
||||
nsCOMPtr<nsIStringBundleService> bundleService( do_GetService( bundleCID, &rv ) );
|
||||
|
||||
if ( promptService && bundleService ) {
|
||||
// Next, get bundle that provides text for dialog.
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle( "chrome://global-platform/locale/nsWindowsHooks.properties",
|
||||
getter_AddRefs( bundle ) );
|
||||
rv = bundleService->CreateBundle( "chrome://global/locale/brand.properties",
|
||||
getter_AddRefs( brandBundle ) );
|
||||
if ( NS_SUCCEEDED( rv ) && bundle && brandBundle ) {
|
||||
nsXPIDLString text, label, shortName;
|
||||
if ( NS_SUCCEEDED( ( rv = brandBundle->GetStringFromName( NS_LITERAL_STRING( "brandShortName" ).get(),
|
||||
getter_Copies( shortName ) ) ) ) ) {
|
||||
const PRUnichar* formatStrings[] = { shortName.get() };
|
||||
if ( NS_SUCCEEDED( ( rv = bundle->FormatStringFromName( NS_LITERAL_STRING( "promptText" ).get(),
|
||||
formatStrings, 1, getter_Copies( text ) ) ) )
|
||||
&&
|
||||
NS_SUCCEEDED( ( rv = bundle->GetStringFromName( NS_LITERAL_STRING( "checkBoxLabel" ).get(),
|
||||
getter_Copies( label ) ) ) ) ) {
|
||||
// Got the text, now show dialog.
|
||||
PRBool showDialog = settings->mShowDialog;
|
||||
PRInt32 dlgResult = -1;
|
||||
// No checkbox for initial display.
|
||||
const PRUnichar *labelArg = 0;
|
||||
if ( settings->mHaveBeenSet ) {
|
||||
// Subsequent display uses label string.
|
||||
labelArg = label;
|
||||
}
|
||||
// Note that the buttons need to be passed in this order:
|
||||
// o Yes
|
||||
// o Cancel
|
||||
// o No
|
||||
rv = promptService->ConfirmEx(aParent, shortName, text,
|
||||
(nsIPromptService::BUTTON_TITLE_YES * nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_CANCEL * nsIPromptService::BUTTON_POS_1) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO * nsIPromptService::BUTTON_POS_2),
|
||||
nsnull, nsnull, nsnull, labelArg, &showDialog, &dlgResult);
|
||||
|
||||
if ( NS_SUCCEEDED( rv ) ) {
|
||||
// Dialog was shown
|
||||
*_retval = PR_TRUE;
|
||||
|
||||
// Did they say go ahead?
|
||||
switch ( dlgResult ) {
|
||||
case 0:
|
||||
// User says: make the changes.
|
||||
// Remember "show dialog" choice.
|
||||
settings->mShowDialog = showDialog;
|
||||
// Apply settings; this single line of
|
||||
// code will do different things depending
|
||||
// on whether this is the first time (i.e.,
|
||||
// when "haveBeenSet" is false). The first
|
||||
// time, this will set all prefs to true
|
||||
// (because that's how we initialized 'em
|
||||
// in GetSettings, above) and will update the
|
||||
// registry accordingly. On subsequent passes,
|
||||
// this will only update the registry (because
|
||||
// the settings we got from GetSettings will
|
||||
// not have changed).
|
||||
//
|
||||
// BTW, the term "prefs" in this context does not
|
||||
// refer to conventional Mozilla "prefs." Instead,
|
||||
// it refers to "Desktop Integration" prefs which
|
||||
// are stored in the windows registry.
|
||||
rv = SetSettings( settings );
|
||||
#ifdef DEBUG_law
|
||||
printf( "Yes, SetSettings returned 0x%08X\n", (int)rv );
|
||||
#endif
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// User says: Don't mess with Windows.
|
||||
// We update only the "showDialog" and
|
||||
// "haveBeenSet" keys. Note that this will
|
||||
// have the effect of setting all the prefs
|
||||
// *off* if the user says no to the initial
|
||||
// prompt.
|
||||
BoolRegistryEntry( "haveBeenSet" ).set();
|
||||
if ( showDialog ) {
|
||||
BoolRegistryEntry( "showDialog" ).set();
|
||||
} else {
|
||||
BoolRegistryEntry( "showDialog" ).reset();
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
printf( "No, haveBeenSet=1 and showDialog=%d\n", (int)showDialog );
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
// User says: I dunno. Make no changes (which
|
||||
// should produce the same dialog next time).
|
||||
#ifdef DEBUG_law
|
||||
printf( "Cancel\n" );
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
else { printf( "Registry and prefs match\n" ); }
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG_law
|
||||
else { printf( "showDialog is false and not installing\n" ); }
|
||||
#endif
|
||||
|
||||
// Release the settings.
|
||||
settings->Release();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Utility to set PRBool registry value from getter method.
|
||||
nsresult putPRBoolIntoRegistry( const char* valueName,
|
||||
nsIWindowsHooksSettings *prefs,
|
||||
nsWindowsHooksSettings::getter memFun ) {
|
||||
// Use getter method to extract attribute from prefs.
|
||||
PRBool boolValue;
|
||||
(void)(prefs->*memFun)( &boolValue );
|
||||
// Convert to DWORD.
|
||||
DWORD dwordValue = boolValue;
|
||||
// Store into registry.
|
||||
BoolRegistryEntry pref( valueName );
|
||||
nsresult rv = boolValue ? pref.set() : pref.reset();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* void setPreferences (in nsIWindowsHooksSettings prefs); */
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::SetSettings(nsIWindowsHooksSettings *prefs) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
putPRBoolIntoRegistry( "isHandlingHTTP", prefs, &nsIWindowsHooksSettings::GetIsHandlingHTTP );
|
||||
putPRBoolIntoRegistry( "isHandlingHTTPS", prefs, &nsIWindowsHooksSettings::GetIsHandlingHTTPS );
|
||||
putPRBoolIntoRegistry( "isHandlingHTML", prefs, &nsIWindowsHooksSettings::GetIsHandlingHTML );
|
||||
putPRBoolIntoRegistry( "isHandlingXHTML", prefs, &nsIWindowsHooksSettings::GetIsHandlingXHTML );
|
||||
putPRBoolIntoRegistry( "showDialog", prefs, &nsIWindowsHooksSettings::GetShowDialog );
|
||||
|
||||
// Indicate that these settings have indeed been set.
|
||||
BoolRegistryEntry( "haveBeenSet" ).set();
|
||||
|
||||
rv = SetRegistry();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Get preferences and start handling everything selected.
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::SetRegistry() {
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get raw prefs object.
|
||||
nsWindowsHooksSettings *prefs;
|
||||
rv = this->GetSettings( &prefs );
|
||||
|
||||
NS_ENSURE_TRUE( NS_SUCCEEDED( rv ), rv );
|
||||
|
||||
if ( prefs->mHandleHTML ) {
|
||||
(void) mozillaMarkup.set();
|
||||
} else {
|
||||
(void) mozillaMarkup.reset();
|
||||
}
|
||||
if ( prefs->mHandleXHTML ) {
|
||||
(void) xhtml.set();
|
||||
} else {
|
||||
(void) xhtml.reset();
|
||||
}
|
||||
if ( prefs->mHandleHTTP ) {
|
||||
(void) http.set();
|
||||
} else {
|
||||
(void) http.reset();
|
||||
}
|
||||
if ( prefs->mHandleHTTPS ) {
|
||||
(void) https.set();
|
||||
} else {
|
||||
(void) https.reset();
|
||||
}
|
||||
// Call SHChangeNotify() to notify the windows shell that file
|
||||
// associations changed, and that an update of the icons need to occur.
|
||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindowsHooks::GetRegistryEntry( PRInt32 aHKEYConstant, const char *aSubKeyName, const char *aValueName, char **aResult ) {
|
||||
NS_ENSURE_ARG( aResult );
|
||||
*aResult = 0;
|
||||
// Calculate HKEY_* starting point based on input nsIWindowsHooks constant.
|
||||
HKEY hKey;
|
||||
switch ( aHKEYConstant ) {
|
||||
case HKCR:
|
||||
hKey = HKEY_CLASSES_ROOT;
|
||||
break;
|
||||
case HKCC:
|
||||
hKey = HKEY_CURRENT_CONFIG;
|
||||
break;
|
||||
case HKCU:
|
||||
hKey = HKEY_CURRENT_USER;
|
||||
break;
|
||||
case HKLM:
|
||||
hKey = HKEY_LOCAL_MACHINE;
|
||||
break;
|
||||
case HKU:
|
||||
hKey = HKEY_USERS;
|
||||
break;
|
||||
default:
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
// Get requested registry entry.
|
||||
nsCAutoString entry( RegistryEntry( hKey, aSubKeyName, aValueName, 0 ).currentSetting() );
|
||||
|
||||
// Copy to result.
|
||||
*aResult = PL_strdup( entry.get() );
|
||||
|
||||
return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WriteBitmap(nsString& aPath, gfxIImageFrame* aImage)
|
||||
{
|
||||
PRInt32 width, height;
|
||||
aImage->GetWidth(&width);
|
||||
aImage->GetHeight(&height);
|
||||
|
||||
PRUint8* bits;
|
||||
PRUint32 length;
|
||||
aImage->GetImageData(&bits, &length);
|
||||
if (!bits) return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 bpr;
|
||||
aImage->GetImageBytesPerRow(&bpr);
|
||||
PRInt32 bitCount = bpr/width;
|
||||
|
||||
// initialize these bitmap structs which we will later
|
||||
// serialize directly to the head of the bitmap file
|
||||
LPBITMAPINFOHEADER bmi = (LPBITMAPINFOHEADER)new BITMAPINFO;
|
||||
bmi->biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi->biWidth = width;
|
||||
bmi->biHeight = height;
|
||||
bmi->biPlanes = 1;
|
||||
bmi->biBitCount = (WORD)bitCount*8;
|
||||
bmi->biCompression = BI_RGB;
|
||||
bmi->biSizeImage = 0; // don't need to set this if bmp is uncompressed
|
||||
bmi->biXPelsPerMeter = 0;
|
||||
bmi->biYPelsPerMeter = 0;
|
||||
bmi->biClrUsed = 0;
|
||||
bmi->biClrImportant = 0;
|
||||
|
||||
BITMAPFILEHEADER bf;
|
||||
bf.bfType = 0x4D42; // 'BM'
|
||||
bf.bfReserved1 = 0;
|
||||
bf.bfReserved2 = 0;
|
||||
bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
|
||||
bf.bfSize = bf.bfOffBits + bmi->biSizeImage;
|
||||
|
||||
// get a file output stream
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> path;
|
||||
rv = NS_NewLocalFile(aPath, PR_TRUE, getter_AddRefs(path));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIOutputStream> stream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(stream), path);
|
||||
|
||||
// write the bitmap headers and rgb pixel data to the file
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (stream) {
|
||||
PRUint32 written;
|
||||
stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
|
||||
if (written == sizeof(BITMAPFILEHEADER)) {
|
||||
stream->Write((const char*)bmi, sizeof(BITMAPINFOHEADER), &written);
|
||||
if (written == sizeof(BITMAPINFOHEADER)) {
|
||||
stream->Write((const char*)bits, length, &written);
|
||||
if (written == length)
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::GetDesktopColor(PRUint32* aColors)
|
||||
{
|
||||
PRUint32 color = ::GetSysColor(COLOR_DESKTOP);
|
||||
*aColors = (GetRValue(color) << 16) | (GetGValue(color) << 8) | GetBValue(color);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::SetDesktopColor(PRUint32 aColor)
|
||||
{
|
||||
int aParameters[2] = { COLOR_BACKGROUND, COLOR_DESKTOP };
|
||||
BYTE r = (aColor >> 16);
|
||||
BYTE g = (aColor << 16) >> 24;
|
||||
BYTE b = (aColor << 24) >> 24;
|
||||
COLORREF colors[2] = { RGB(r,g,b), RGB(r,g,b) };
|
||||
|
||||
::SetSysColors(sizeof(aParameters) / sizeof(int), aParameters, colors);
|
||||
|
||||
char subKey[] = "Control Panel\\Colors";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx(HKEY_CURRENT_USER,
|
||||
subKey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&key,
|
||||
&dwDisp);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
char* rgb = new char[12];
|
||||
sprintf(rgb, "%u %u %u\0", r, g, b);
|
||||
::RegSetValueEx(key, "Background", 0, REG_SZ, (const unsigned char*)rgb, strlen(rgb));
|
||||
delete[] rgb;
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsHooks::SetImageAsWallpaper(nsIDOMElement* aElement, PRBool aUseBackground, PRInt32 position)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<gfxIImageFrame> gfxFrame;
|
||||
if (aUseBackground) {
|
||||
// XXX write background loading stuff!
|
||||
} else {
|
||||
nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement, &rv);
|
||||
if (!imageContent) return rv;
|
||||
|
||||
// get the image container
|
||||
nsCOMPtr<imgIRequest> request;
|
||||
rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(request));
|
||||
if (!request) return rv;
|
||||
nsCOMPtr<imgIContainer> container;
|
||||
rv = request->GetImage(getter_AddRefs(container));
|
||||
if (!request) return rv;
|
||||
|
||||
// get the current frame, which holds the image data
|
||||
container->GetCurrentFrame(getter_AddRefs(gfxFrame));
|
||||
}
|
||||
|
||||
if (!gfxFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get the windows directory ('c:\windows' usually)
|
||||
char winDir[256];
|
||||
::GetWindowsDirectory(winDir, sizeof(winDir));
|
||||
nsAutoString winPath;
|
||||
winPath.AssignWithConversion(winDir);
|
||||
|
||||
// get the product brand name from localized strings
|
||||
nsXPIDLString brandName;
|
||||
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID));
|
||||
if (bundleService) {
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle("chrome://global/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
if (NS_SUCCEEDED(rv) && brandBundle) {
|
||||
if (NS_FAILED(rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName))))
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// build the file name
|
||||
winPath.Append(NS_LITERAL_STRING("\\").get());
|
||||
winPath.Append(brandName);
|
||||
winPath.Append(NS_LITERAL_STRING(" Wallpaper.bmp").get());
|
||||
|
||||
// write the bitmap to a file in the windows dir
|
||||
rv = WriteBitmap(winPath, gfxFrame);
|
||||
|
||||
// if the file was written successfully, set it as the system wallpaper
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char subKey[] = "Control Panel\\Desktop";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx( HKEY_CURRENT_USER,
|
||||
subKey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&key,
|
||||
&dwDisp );
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
unsigned char tile[2];
|
||||
unsigned char style[2];
|
||||
if (position == WALLPAPER_TILE) {
|
||||
tile[0] = '1';
|
||||
style[0] = '1';
|
||||
}
|
||||
else if (position == WALLPAPER_CENTER) {
|
||||
tile[0] = '0';
|
||||
style[0] = '0';
|
||||
}
|
||||
else if (position == WALLPAPER_STRETCH) {
|
||||
tile[0] = '0';
|
||||
style[0] = '2';
|
||||
}
|
||||
tile[1] = '\0';
|
||||
style[1] = '\0';
|
||||
::RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, tile, sizeof(tile));
|
||||
::RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, style, sizeof(style));
|
||||
::SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ToNewCString(winPath), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Aaron Kaluszka <ask@swva.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nswindowshooks_h____
|
||||
#define nswindowshooks_h____
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIWindowsHooks.h"
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
||||
/* c09bc130-0a71-11d4-8076-00600811a9c3 */
|
||||
#define NS_IWINDOWSHOOKS_CID \
|
||||
{ 0xc09bc130, 0x0a71, 0x11d4, {0x80, 0x76, 0x00, 0x60, 0x08, 0x11, 0xa9, 0xc3} }
|
||||
|
||||
class nsWindowsHooksSettings : public nsIWindowsHooksSettings {
|
||||
public:
|
||||
// ctor/dtor
|
||||
nsWindowsHooksSettings();
|
||||
virtual ~nsWindowsHooksSettings();
|
||||
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWSHOOKSSETTINGS
|
||||
|
||||
// Typedef for nsIWindowsHooksSettings getter/setter member functions.
|
||||
typedef
|
||||
NS_STDCALL_FUNCPROTO(nsresult,
|
||||
getter,
|
||||
nsIWindowsHooksSettings, GetShowDialog,
|
||||
(PRBool*));
|
||||
|
||||
typedef
|
||||
NS_STDCALL_FUNCPROTO(nsresult,
|
||||
setter,
|
||||
nsIWindowsHooksSettings, SetShowDialog,
|
||||
(PRBool));
|
||||
|
||||
protected:
|
||||
// General purpose getter.
|
||||
NS_IMETHOD Get( PRBool *result, PRBool nsWindowsHooksSettings::*member );
|
||||
// General purpose setter.
|
||||
NS_IMETHOD Set( PRBool value, PRBool nsWindowsHooksSettings::*member );
|
||||
|
||||
private:
|
||||
// Internet shortcut protocols.
|
||||
PRBool mHandleHTTP;
|
||||
PRBool mHandleHTTPS;
|
||||
// File types.
|
||||
PRBool mHandleHTML;
|
||||
PRBool mHandleXHTML;
|
||||
// Dialog
|
||||
PRBool mShowDialog;
|
||||
|
||||
// Special member to handle initialization.
|
||||
PRBool mHaveBeenSet;
|
||||
NS_IMETHOD GetHaveBeenSet( PRBool * );
|
||||
NS_IMETHOD SetHaveBeenSet( PRBool );
|
||||
|
||||
// Give nsWindowsHooks full access.
|
||||
friend class nsWindowsHooks;
|
||||
}; // nsWindowsHooksSettings
|
||||
|
||||
class nsWindowsHooks : public nsIWindowsHooks, public nsIWindowsRegistry {
|
||||
public:
|
||||
// ctor/dtor
|
||||
nsWindowsHooks();
|
||||
virtual ~nsWindowsHooks();
|
||||
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWSHOOKS
|
||||
NS_DECL_NSIWINDOWSREGISTRY
|
||||
|
||||
protected:
|
||||
// Internal flavor of GetPreferences.
|
||||
NS_IMETHOD GetSettings( nsWindowsHooksSettings ** );
|
||||
|
||||
// Set registry according to settings.
|
||||
NS_IMETHOD SetRegistry();
|
||||
char mShortcutPath[MAX_BUF];
|
||||
char mShortcutName[MAX_BUF];
|
||||
char mShortcutBase[MAX_BUF];
|
||||
char mShortcutProg[MAX_BUF];
|
||||
}; // nsWindowsHooksSettings
|
||||
|
||||
#endif // nswindowshooks_h____
|
|
@ -1,215 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law <law@netscape.com>
|
||||
* Aaron Kaluszka <ask@swva.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
/* These interface provides support for integrating Mozilla into Windows.
|
||||
* This integration consists primarily of setting Mozilla as the "default
|
||||
* browser." Or more precisely, setting Mozilla as the executable to
|
||||
* handle certain file types.
|
||||
*
|
||||
* There are two subtly different types of desktop objects that Mozilla
|
||||
* can be configured to "handle:"
|
||||
* o File types (based on file extension)
|
||||
* o Internet shortcuts (based on URL protocol).
|
||||
*
|
||||
* While these are different types of objects, the mechanism by which
|
||||
* applications are matched with them is essentially the same.
|
||||
*
|
||||
* In the case of files, there is one more level of indirection. File
|
||||
* extensions are assigned a "file type" via a Windows registry entry.
|
||||
* For example, given the file extension ".foo", the file type is
|
||||
* determined by examing the value stored in the "default" value stored
|
||||
* at the registry key HKEY_LOCAL_MACHINE\Software\Classes\.foo.
|
||||
*
|
||||
* Once you have the "file type" then you use that the same way you use
|
||||
* Internet Shortcut protocol names to determine which application to
|
||||
* launch. The application is specified by the default value stored in
|
||||
* the registry key
|
||||
* HKEY_LOCAL_MACHINE\Software\Classes\<X>\shell\open\command, where
|
||||
* <X> is the "file type" or protocol name.
|
||||
*
|
||||
* If there are additional keys under "shell" then these appear on the
|
||||
* context menu for files/shortcuts of this type. Typically, there are
|
||||
* entries for "print." But Mozilla does not currently support a command
|
||||
* line option to print so we don't offer that.
|
||||
*
|
||||
* Previously, Netscape Communicator made itself the handler of standard
|
||||
* web things by creating a new file type "NetscapeMarkup" and mapping
|
||||
* extensions to that (.htm, .html, .shtml, .xbm), or, by setting itself
|
||||
* up as the "handler" for the file types of other web things (.jpg, .gif)
|
||||
* and Internet Shortcut protocols (ftp, gopher, http, https, mailto, news,
|
||||
* snews).
|
||||
*
|
||||
* In order to better enable Mozilla to co-exist with other browsers
|
||||
* (including Communicator), it will create yet another new file type,
|
||||
* "MozillaMarkup," that will be used to make Mozilla the default handler
|
||||
* for certain file extensions. This will be done by remapping those
|
||||
* extensions to this new type.
|
||||
*
|
||||
* Mozilla will attempt to remember the original mapping and restore it
|
||||
* when the user decides to no longer have Mozilla be the default handler
|
||||
* for that extension.
|
||||
*
|
||||
* Mozilla will drop support for some items that are no longer germane:
|
||||
* the .shtml file extension and the gopher: protocol. We will also, perhaps
|
||||
* only temporarily, drop support for protocols that aren't accessible from
|
||||
* the command line: mailto:, news:, and snews:.
|
||||
*
|
||||
* We will be adding support for the chrome: protocol (using the "-chrome"
|
||||
* command line option) and for .png, .xul and .xml file extensions.
|
||||
*
|
||||
* Missing Features:
|
||||
*
|
||||
* Currently, there is no way to extend the set of file types or protocols
|
||||
* that Mozilla can be associated with (save manually tweaking the Windows
|
||||
* registry). This is likely to be a problem for branded Mozilla browsers
|
||||
* that might support specialized file types or protocols (e.g., .aim files).
|
||||
*
|
||||
* The plan is to extend this interface so that such file types and protocols
|
||||
* can be set up using the implementation of the interfaces defined here.
|
||||
*/
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
interface nsIDOMElement;
|
||||
|
||||
/* nsIWindowsHooksSettings
|
||||
*
|
||||
* This interface is used to get/set the user preferences relating to
|
||||
* "windows hooks" (aka "windows integration"). It is basically just
|
||||
* a conglomeration of a bunch of boolean attributes; it exists mainly
|
||||
* for historical reasons (it corresponds to the internal Prefs struct
|
||||
* that was in nsIDefaultBrowser.h in Mozilla Classic).
|
||||
*/
|
||||
[scriptable, uuid(4ce9aa90-0a6a-11d4-8076-00600811a9c3)]
|
||||
interface nsIWindowsHooksSettings : nsISupports {
|
||||
|
||||
// Internet shortcuts (based on "protocol").
|
||||
attribute boolean isHandlingHTTP;
|
||||
attribute boolean isHandlingHTTPS;
|
||||
|
||||
// File handling (based on extension).
|
||||
attribute boolean isHandlingHTML;
|
||||
attribute boolean isHandlingXHTML;
|
||||
|
||||
// Nag dialog flag. Set this so that dialog
|
||||
// appears on startup if there is a mismatch
|
||||
// between registry and these settings.
|
||||
attribute boolean showDialog;
|
||||
|
||||
// Registry mismatch indicator.
|
||||
// This is true if the Win32 registry is
|
||||
// currently set to match the preferences
|
||||
// in this object.
|
||||
readonly attribute boolean registryMatches;
|
||||
};
|
||||
|
||||
/* nsIWindowsHooks
|
||||
*
|
||||
* This interface describes the service that you can use to
|
||||
* get/set the various windows integration features specified
|
||||
* by the nsIWindowsHooksPrefs attributes.
|
||||
*/
|
||||
[scriptable, uuid(19c9fbb0-06a3-11d4-8076-00600811a9c3)]
|
||||
interface nsIWindowsHooks : nsISupports {
|
||||
|
||||
// settings
|
||||
// --------
|
||||
// Get/set this to query or modify them. The Windows
|
||||
// registry is updated when you set this attribute.
|
||||
attribute nsIWindowsHooksSettings settings;
|
||||
|
||||
// checkSettings
|
||||
// -------------
|
||||
// Check that registry matches settings and if not,
|
||||
// prompt user for whether to reset. This is
|
||||
// controlled by the showDialog setting. This will
|
||||
// perform the check only the first time the
|
||||
// service is called.
|
||||
// aParent - parent window for any dialogs that
|
||||
// will appear
|
||||
// Returns true if the windows integration dialog was shown
|
||||
boolean checkSettings( in nsIDOMWindowInternal aParent );
|
||||
|
||||
const PRInt32 WALLPAPER_TILE = 0;
|
||||
const PRInt32 WALLPAPER_STRETCH = 1;
|
||||
const PRInt32 WALLPAPER_CENTER = 2;
|
||||
|
||||
/**
|
||||
* Accepts an element, either an HTML img element or an element with
|
||||
* a background image, serializes the image to a bitmap file
|
||||
* in the windows directory, and sets it to be the desktop wallpaper.
|
||||
*/
|
||||
void setImageAsWallpaper(in nsIDOMElement aImageElement, in boolean useBackground, in PRInt32 position);
|
||||
PRUint32 getDesktopColor();
|
||||
void setDesktopColor(in PRUint32 color);
|
||||
|
||||
};
|
||||
|
||||
/* nsIWindowsRegistry
|
||||
*
|
||||
* This interface describes the service that you can use to
|
||||
* get/set Win32 registry entries.
|
||||
*
|
||||
* Notice: This interface is incomplete and should be used at your own risk!
|
||||
*/
|
||||
[scriptable, uuid(e07e7430-8d11-417c-83ee-c994400c452f)]
|
||||
interface nsIWindowsRegistry : nsISupports {
|
||||
/**
|
||||
* Returns a Win32 registry entry value. The returned string will be truncated
|
||||
* at 4096 bytes. The constants define the set of valid starting keys. You
|
||||
* pass in the subkey name and a value identifier (an empty string returns
|
||||
* the "default" value for that subkey).
|
||||
*/
|
||||
const long HKCR = 0; // HKEY_CLASSES_ROOT
|
||||
const long HKCC = 1; // HKEY_CURRENT_CONFIG
|
||||
const long HKCU = 2; // HKEY_CURRENT_USER
|
||||
const long HKLM = 3; // HKEY_LOCAL_MACHINE
|
||||
const long HKU = 4; // HKEY_USERS
|
||||
string getRegistryEntry( in long aHKeyConstant, in string aSubKeyName, in string aValueName );
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IWINDOWSHOOKS_CONTRACTID "@mozilla.org/winhooks;1"
|
||||
#define NS_IWINDOWSHOOKS_CLASSNAME "Mozilla Windows Integration Hooks"
|
||||
|
||||
// The key that is used to write the quick launch appname in the windows registry
|
||||
#define NS_QUICKLAUNCH_RUN_KEY "Mozilla Quick Launch"
|
||||
%}
|
|
@ -30,6 +30,21 @@
|
|||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="menu-orient" display="xul:menu"
|
||||
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton">
|
||||
<content>
|
||||
<children includes="observes|template|menupopup|tooltip"/>
|
||||
<xul:hbox flex="1" align="center">
|
||||
<xul:box xbl:inherits="orient" flex="1">
|
||||
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,toolbarmode,buttonstyle"/>
|
||||
<xul:label class="toolbarbutton-text" crop="right" flex="1"
|
||||
xbl:inherits="value=label,accesskey,crop,dragover-top,toolbarmode,buttonstyle"/>
|
||||
</xul:box>
|
||||
<xul:dropmarker type="menu" class="toolbarbutton-menu-dropmarker" xbl:inherits="disabled"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="menu-button" display="xul:menu"
|
||||
extends="chrome://global/content/bindings/button.xml#menu-button-base">
|
||||
<resources>
|
||||
|
|
|
@ -123,6 +123,10 @@ toolbarbutton[type="menu"] {
|
|||
-moz-binding: url("chrome://global/content/bindings/toolbarbutton.xml#menu");
|
||||
}
|
||||
|
||||
toolbarbutton[orient] {
|
||||
-moz-binding: url("chrome://global/content/bindings/toolbarbutton.xml#menu-orient");
|
||||
}
|
||||
|
||||
toolbarbutton[type="menu-button"] {
|
||||
-moz-binding: url("chrome://global/content/bindings/toolbarbutton.xml#menu-button");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче