Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
nsNativeAppSupportWin.cpp File Reference
#include "nsStringSupport.h"
#include "nsIStringBundle.h"
#include "nsNativeAppSupportBase.h"
#include "nsNativeAppSupportWin.h"
#include "nsICmdLineService.h"
#include "nsCOMPtr.h"
#include "nsIComponentManager.h"
#include "nsComponentManagerUtils.h"
#include "nsIServiceManager.h"
#include "nsServiceManagerUtils.h"
#include "nsICmdLineHandler.h"
#include "nsIDOMWindow.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsISupportsArray.h"
#include "nsIWindowWatcher.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMChromeWindow.h"
#include "nsIBrowserDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocShell.h"
#include "nsIBaseWindow.h"
#include "nsIWidget.h"
#include "nsIAppStartup.h"
#include "nsIProfileInternal.h"
#include "nsIXULWindow.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsIWindowsHooks.h"
#include "nsIPromptService.h"
#include "nsNetCID.h"
#include "nsIIOService.h"
#include "nsIURI.h"
#include "nsIObserverService.h"
#include "nsXPFEComponentsCID.h"
#include "nsEmbedCID.h"
#include "nsIURIFixup.h"
#include "nsCDefaultURIFixup.h"
#include "nsIDOMLocation.h"
#include "nsIJSContextStack.h"
#include "nsIWindowMediator.h"
#include <windows.h>
#include <shellapi.h>
#include <ddeml.h>
#include <stdlib.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <ctype.h>

Go to the source code of this file.

Classes

class  nsSplashScreenWin
struct  Mutex
class  nsNativeAppSupportWin
struct  MessageWindow
class  SafeJSContext

Defines

#define TURBO_NAVIGATOR   1
#define TURBO_MAIL   2
#define TURBO_EDITOR   3
#define TURBO_ADDRESSBOOK   4
#define TURBO_DISABLE   5
#define TURBO_EXIT   6
#define MAPI_STARTUP_ARG   "/MAPIStartUp"
#define LWA_ALPHA   2
#define WS_EX_LAYERED   0x80000
#define SM_REMOTESESSION   0x1000
#define REG_SUCCEEDED(val)   (val == ERROR_SUCCESS)
#define MOZ_STARTUP_MUTEX_NAME   "StartupMutex"
#define MOZ_DDE_START_TIMEOUT   30000
#define MOZ_DDE_STOP_TIMEOUT   15000
#define MOZ_DDE_EXEC_TIMEOUT   15000

Typedefs

typedef BOOL(WINAPI * MOZ_SetLayeredWindowAttributesProc )(HWND, COLORREF, BYTE, DWORD)

Functions

static HWND hwndForDOMWindow (nsISupports *)
static nsresult GetMostRecentWindow (const PRUnichar *aType, nsIDOMWindowInternal **aWindow)
static char * GetACPString (const nsString &aStr)
static void activateWindow (nsIDOMWindowInternal *win)
nsresult NS_CreateNativeAppSupport (nsINativeAppSupport **aResult)
 Create the nativeappsupport implementation.
nsresult NS_CreateSplashScreen (nsISplashScreen **aResult)
static PRBool handlingHTTP ()
static DWORD deleteKey (HKEY baseKey, const char *keyName)
PRBool NS_CanRun ()
static nsCString hszValue (DWORD, HSZ)
static void escapeQuotes (nsString &aString)
static PRInt32 advanceToEndOfQuotedArg (const char *p, PRInt32 offset, PRInt32 len)
static LRESULT CALLBACK focusFilterProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
void AppendMenuItem (HMENU &menu, PRInt32 aIdentifier, const nsString &aText)

Variables

PRBool gAbortServer = PR_FALSE
const char *const topicNames []
static char nameBuffer [128] = { 0 }
static nsCString uTypeDesc (UINT)
static char procPropertyName [] = "MozillaProcProperty"
static const char sJSStackContractID [] = "@mozilla.org/js/xpc/ContextStack;1"

Define Documentation

#define LWA_ALPHA   2

Definition at line 111 of file nsNativeAppSupportWin.cpp.

#define MAPI_STARTUP_ARG   "/MAPIStartUp"

Definition at line 108 of file nsNativeAppSupportWin.cpp.

Definition at line 801 of file nsNativeAppSupportWin.cpp.

Definition at line 799 of file nsNativeAppSupportWin.cpp.

Definition at line 800 of file nsNativeAppSupportWin.cpp.

#define MOZ_STARTUP_MUTEX_NAME   "StartupMutex"

Definition at line 798 of file nsNativeAppSupportWin.cpp.

Definition at line 122 of file nsNativeAppSupportWin.cpp.

#define SM_REMOTESESSION   0x1000

Definition at line 119 of file nsNativeAppSupportWin.cpp.

Definition at line 104 of file nsNativeAppSupportWin.cpp.

Definition at line 105 of file nsNativeAppSupportWin.cpp.

Definition at line 103 of file nsNativeAppSupportWin.cpp.

#define TURBO_EXIT   6

Definition at line 106 of file nsNativeAppSupportWin.cpp.

#define TURBO_MAIL   2

Definition at line 102 of file nsNativeAppSupportWin.cpp.

Definition at line 101 of file nsNativeAppSupportWin.cpp.

#define WS_EX_LAYERED   0x80000

Definition at line 115 of file nsNativeAppSupportWin.cpp.


Typedef Documentation

Definition at line 176 of file nsNativeAppSupportWin.cpp.


Function Documentation

static void activateWindow ( nsIDOMWindowInternal win) [static]

Definition at line 154 of file nsNativeAppSupportWin.cpp.

                                            {
    // Try to get native window handle.
    HWND hwnd = hwndForDOMWindow( win );
    if ( hwnd ) {
        // Restore the window if it is minimized.
        if ( ::IsIconic( hwnd ) ) {
            ::ShowWindow( hwnd, SW_RESTORE );
        }
        // Use the OS call, if possible.
        ::SetForegroundWindow( hwnd );
    } else {
        // Use internal method.
        win->Focus();
    }
}

Here is the call graph for this function:

static PRInt32 advanceToEndOfQuotedArg ( const char *  p,
PRInt32  offset,
PRInt32  len 
) [static]

Definition at line 1700 of file nsNativeAppSupportWin.cpp.

                                                                                     {
    // Check whether the current arg is quoted.
    if ( p[++offset] == '"' ) {
        // Advance past the closing quote.
        while ( offset < len && p[++offset] != '"' ) {
            // If the current character is a backslash, then the
            // next character can't be a *real* '"', so skip it.
            if ( p[offset] == '\\' ) {
                offset++;
            }
        }
    }
    return offset;
}
void AppendMenuItem ( HMENU menu,
PRInt32  aIdentifier,
const nsString aText 
)

Definition at line 2410 of file nsNativeAppSupportWin.cpp.

                                                                               {
  char* ACPText = GetACPString( aText );
  if ( ACPText ) {
    ::AppendMenu( menu, MF_STRING, aIdentifier, ACPText );
    delete [] ACPText;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static DWORD deleteKey ( HKEY  baseKey,
const char *  keyName 
) [static]

Definition at line 1207 of file nsNativeAppSupportWin.cpp.

                                                            {
    // Make sure input subkey isn't null.
    DWORD rc;
    if ( keyName && ::strlen(keyName) ) {
        // Open subkey.
        HKEY key;
        rc = ::RegOpenKeyEx( baseKey,
                             keyName,
                             0,
                             KEY_ENUMERATE_SUB_KEYS | DELETE,
                             &key );
        // Continue till we get an error or are done.
        while ( rc == ERROR_SUCCESS ) {
            char subkeyName[_MAX_PATH];
            DWORD len = sizeof subkeyName;
            // Get first subkey name.  Note that we always get the
            // first one, then delete it.  So we need to get
            // the first one next time, also.
            rc = ::RegEnumKeyEx( key,
                                 0,
                                 subkeyName,
                                 &len,
                                 0,
                                 0,
                                 0,
                                 0 );
            if ( rc == ERROR_NO_MORE_ITEMS ) {
                // No more subkeys.  Delete the main one.
                rc = ::RegDeleteKey( baseKey, keyName );
                break;
            } else if ( rc == ERROR_SUCCESS ) {
                // Another subkey, delete it, recursively.
                rc = deleteKey( key, subkeyName );
            }
        }
        // Close the key we opened.
        ::RegCloseKey( key );
    } else {
        rc = ERROR_BADKEY;
    }
    return rc;
}

Here is the caller graph for this function:

static void escapeQuotes ( nsString aString) [static]

Definition at line 1421 of file nsNativeAppSupportWin.cpp.

                                              {
    PRInt32 offset = -1;
    while( 1 ) {
       // Find next '"'.
       offset = FindCharInString(aString, '"', ++offset );
       if ( offset == kNotFound ) {
           // No more quotes, exit.
           break;
       } else {
           // Insert back-slash ahead of the '"'.
           aString.Insert( PRUnichar('\\'), offset );
           // Increment offset because we just inserted a slash
           offset++;
       }
    }
    return;
}

Here is the call graph for this function:

static LRESULT CALLBACK focusFilterProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
) [static]

Definition at line 2236 of file nsNativeAppSupportWin.cpp.

                                                                                              {
    if ( uMsg == WM_SETFOCUS ) {
        // Don't let SeaMonkey's window procedure see this.
        return 0;
    } else {
        // Pass on all other messages to SeaMonkey's window proc.
        HANDLE oldProc = ::GetProp( hwnd, procPropertyName );
        if ( oldProc ) {
            return ::CallWindowProc( (WNDPROC)oldProc, hwnd, uMsg, wParam, lParam );
        } else {
            // Last resort is the default window proc.
            return ::DefWindowProc( hwnd, uMsg, wParam, lParam );
        }
    }
}

Here is the caller graph for this function:

static char* GetACPString ( const nsString aStr) [static]

Definition at line 140 of file nsNativeAppSupportWin.cpp.

{
    int acplen = aStr.Length() * 2 + 1;
    char * acp = new char[ acplen ];
    if( acp ) {
        int outlen = ::WideCharToMultiByte( CP_ACP, 0, aStr.get(), aStr.Length(),
                                            acp, acplen-1, NULL, NULL );
        acp[ outlen ] = '\0';  // null terminate
    }
    return acp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult GetMostRecentWindow ( const PRUnichar aType,
nsIDOMWindowInternal **  aWindow 
) [static]

Definition at line 128 of file nsNativeAppSupportWin.cpp.

                                                                            {
    nsresult rv;
    nsCOMPtr<nsIWindowMediator> med( do_GetService( NS_WINDOWMEDIATOR_CONTRACTID, &rv ) );
    if ( NS_FAILED( rv ) )
        return rv;

    if ( med )
        return med->GetMostRecentWindow( aType, aWindow );

    return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PRBool handlingHTTP ( ) [static]

Definition at line 1158 of file nsNativeAppSupportWin.cpp.

                             {
    PRBool result = PR_FALSE; // Answer no if an error occurs.
    // See if we're the "default browser" (i.e., handling http Internet shortcuts)
    nsCOMPtr<nsIWindowsHooks> winhooks( do_GetService( NS_IWINDOWSHOOKS_CONTRACTID ) );
    if ( winhooks ) {
        nsCOMPtr<nsIWindowsHooksSettings> settings;
        nsresult rv = winhooks->GetSettings( getter_AddRefs( settings ) );
        if ( NS_SUCCEEDED( rv ) ) {
            settings->GetIsHandlingHTTP( &result );
            if ( result ) {
                // The user *said* to handle http.  See if we really
                // are doing it.  We need to check *only* the HTTP
                // settings.  If we don't mask off all others, we
                // may erroneously conclude that we're not handling
                // HTTP when really we are (although, a false negative
                // is much better than a false positive).  Please note
                // that setting these attributes false only affects
                // this "Settings" object.  It *does not* change the
                // actual user preferences stored in the registry!

                // First, turn off all the other protocols.
                settings->SetIsHandlingHTTPS( PR_FALSE );
#ifndef MOZ_PHOENIX
                settings->SetIsHandlingFTP( PR_FALSE );
                settings->SetIsHandlingCHROME( PR_FALSE );
                settings->SetIsHandlingGOPHER( PR_FALSE );
#endif
                // Next, all the file types.
                settings->SetIsHandlingHTML( PR_FALSE );
                settings->SetIsHandlingXHTML( PR_FALSE );
#ifndef MOZ_PHOENIX
                settings->SetIsHandlingJPEG( PR_FALSE );
                settings->SetIsHandlingGIF( PR_FALSE );
                settings->SetIsHandlingPNG( PR_FALSE );
                settings->SetIsHandlingMNG( PR_FALSE );
                settings->SetIsHandlingBMP( PR_FALSE );
                settings->SetIsHandlingICO( PR_FALSE );
                settings->SetIsHandlingXML( PR_FALSE );
                settings->SetIsHandlingXUL( PR_FALSE );
#endif
                // Now test the HTTP setting in the registry.
                settings->GetRegistryMatches( &result );
            }
        }
    }
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsCString hszValue ( DWORD  ,
HSZ   
) [static]

Definition at line 1414 of file nsNativeAppSupportWin.cpp.

                                        {
    return nsCString( "?" );
}
static HWND hwndForDOMWindow ( nsISupports *  window) [static]

Definition at line 1362 of file nsNativeAppSupportWin.cpp.

{
      return PR_TRUE;
}

Create the nativeappsupport implementation.

Note:
XPCOMInit has not happened yet.

Definition at line 753 of file nsNativeAppSupportWin.cpp.

                                                           {
    if ( aResult ) {
        nsNativeAppSupportWin *pNative = new nsNativeAppSupportWin;
        if ( pNative ) {
            *aResult = pNative;
            NS_ADDREF( *aResult );
            // Check for dynamic console creation request.
            pNative->CheckConsole();
        } else {
            return NS_ERROR_OUT_OF_MEMORY;
        }
    } else {
        return NS_ERROR_NULL_POINTER;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 773 of file nsNativeAppSupportWin.cpp.

                                                   {
    if ( aResult ) {
        *aResult = 0;
        for ( int i = 1; i < __argc; i++ ) {
            if ( strcmp( "-quiet", __argv[i] ) == 0
                 ||
                 strcmp( "/quiet", __argv[i] ) == 0 ) {
                // No splash screen, please.
                return NS_OK;
            }
        }
        *aResult = new nsSplashScreenWin;
        if ( *aResult ) {
            NS_ADDREF( *aResult );
        } else {
            return NS_ERROR_OUT_OF_MEMORY;
        }
    } else {
        return NS_ERROR_NULL_POINTER;
    }

    return NS_OK;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 635 of file nsNativeAppSupportWin.cpp.

char nameBuffer[128] = { 0 } [static]

Definition at line 1068 of file nsNativeAppSupportWin.cpp.

char procPropertyName[] = "MozillaProcProperty" [static]

Definition at line 2233 of file nsNativeAppSupportWin.cpp.

const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1" [static]

Definition at line 2306 of file nsNativeAppSupportWin.cpp.

Initial value:
 { "WWW_OpenURL",
                                    "WWW_Activate",
                                    "WWW_CancelProgress",
                                    "WWW_Version",
                                    "WWW_RegisterViewer",
                                    "WWW_UnRegisterViewer",
                                    "WWW_GetWindowInfo" }

Definition at line 804 of file nsNativeAppSupportWin.cpp.

Definition at line 1411 of file nsNativeAppSupportWin.cpp.

                                   {
    return nsCString( "?" );
}