Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Static Public Attributes | Private Types | Static Private Member Functions | Static Private Attributes | Friends
nsNativeAppSupportOS2 Class Reference
Inheritance diagram for nsNativeAppSupportOS2:
Inheritance graph
[legend]
Collaboration diagram for nsNativeAppSupportOS2:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_NSIOBSERVER
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD 
Start (PRBool *aResult)
NS_IMETHOD Stop (PRBool *aResult)
NS_IMETHOD Quit ()
NS_IMETHOD Enable ()
NS_IMETHOD StartDDE ()
void CheckConsole ()
NS_IMETHOD Start (PRBool *aResult)
NS_IMETHOD Stop (PRBool *aResult)
NS_IMETHOD Quit ()
NS_IMETHOD StartServerMode ()
NS_IMETHOD OnLastWindowClosing ()
NS_IMETHOD SetIsServerMode (PRBool isServerMode)
NS_IMETHOD EnsureProfile (nsICmdLineService *args)
NS_IMETHOD StartDDE ()
PRBool CheckConsole ()
NS_DECL_NSINATIVEAPPSUPPORT
NS_IMETHOD 
CreateSplashScreen (nsISplashScreen **splash)
 NS_IMETHOD_ (nsrefcnt) AddRef()
 NS_IMETHOD_ (nsrefcnt) Release()
NS_IMETHOD QueryInterface (const nsIID &iid, void **p)
boolean start ()
boolean start ()
void enable ()
boolean stop ()
boolean stop ()
void quit ()
void quit ()
void onLastWindowClosing ()
void onLastWindowClosing ()
void ReOpen ()
void ReOpen ()
void ensureProfile (in nsICmdLineService aCmdService)
void showSplashScreen ()
void hideSplashScreen ()
void startServerMode ()
void observe (in nsISupports aSubject, in string aTopic, in wstring aData)
 Observe will be called when there is a notification for the topic |aTopic|.

Public Attributes

nsrefcnt mRefCnt
nsCOMPtr< nsISplashScreenmSplash
PRBool mServerMode
PRBool mShouldShowUI
PRBool mShownTurboDialog
attribute boolean isServerMode
attribute boolean shouldShowUI

Static Public Attributes

static PRBool mLastWindowIsConfirmation = PR_FALSE

Private Types

enum  {
  topicOpenURL, topicActivate, topicCancelProgress, topicVersion,
  topicRegisterViewer, topicUnRegisterViewer, topicGetWindowInfo, topicCount
}
enum  {
  topicOpenURL, topicActivate, topicCancelProgress, topicVersion,
  topicRegisterViewer, topicUnRegisterViewer, topicGetWindowInfo, topicCount
}

Static Private Member Functions

static HDDEDATA APIENTRY HandleDDENotification (ULONG idInst, USHORT uType, USHORT uFmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG dwData1, ULONG dwData2)
static void HandleCommandLine (const char *aCmdLineString, nsIFile *aWorkingDir, PRUint32 aState)
static void ParseDDEArg (HSZ args, int index, nsCString &string)
static void ParseDDEArg (const char *args, int index, nsCString &aString)
static void ActivateLastWindow ()
static HDDEDATA CreateDDEData (DWORD value)
static HDDEDATA CreateDDEData (LPBYTE value, DWORD len)
static PRBool InitTopicStrings ()
static int FindTopic (HSZ topic)
static nsresult OpenWindow (const char *urlstr, const char *args)
static nsresult OpenBrowserWindow ()
static HDDEDATA APIENTRY HandleDDENotification (ULONG idInst, USHORT uType, USHORT uFmt, HCONV hconv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG dwData1, ULONG dwData2)
static nsresult HandleRequest (LPBYTE request, PRBool newWindow, nsIDOMWindow **aResult)
static void ParseDDEArg (HSZ args, int index, nsCString &string)
static void ParseDDEArg (const char *args, int index, nsCString &aString)
static void ActivateLastWindow ()
static HDDEDATA CreateDDEData (DWORD value)
static HDDEDATA CreateDDEData (LPBYTE value, DWORD len)
static PRBool InitTopicStrings ()
static int FindTopic (HSZ topic)
static nsresult GetCmdLineArgs (LPBYTE request, nsICmdLineService **aResult)
static nsresult OpenWindow (const char *urlstr, const char *args, nsIDOMWindow **aResult)
static nsresult OpenBrowserWindow (const char *args, PRBool newWindow, nsIDOMWindow **aResult)
static nsresult ReParent (nsISupports *window, HWND newParent)
static nsresult GetStartupURL (nsICmdLineService *args, nsCString &taskURL)

Static Private Attributes

static int mConversations = 0
static HSZ mApplication = 0
static HSZ mTopics [topicCount] = { 0 }
static DWORD mInstance = 0
static PRBool mCanHandleRequests = PR_FALSE
static char mMutexName [] = { 0 }
static PRBool mUseDDE = PR_FALSE
static char * mAppName = nameBuffer
static PRBool mInitialWindowActive = PR_FALSE
static PRBool mForceProfileStartup = PR_FALSE

Friends

struct MessageWindow

Detailed Description

Definition at line 297 of file nsNativeAppSupportOS2.cpp.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
topicOpenURL 
topicActivate 
topicCancelProgress 
topicVersion 
topicRegisterViewer 
topicUnRegisterViewer 
topicGetWindowInfo 
topicCount 

Definition at line 340 of file nsNativeAppSupportOS2.cpp.

         {
        topicOpenURL,
        topicActivate,
        topicCancelProgress,
        topicVersion,
        topicRegisterViewer,
        topicUnRegisterViewer,
        topicGetWindowInfo,
        // Note: Insert new values above this line!!!!!
        topicCount // Count of the number of real topics
    };
anonymous enum [private]
Enumerator:
topicOpenURL 
topicActivate 
topicCancelProgress 
topicVersion 
topicRegisterViewer 
topicUnRegisterViewer 
topicGetWindowInfo 
topicCount 

Definition at line 414 of file nsNativeAppSupportOS2.cpp.

         {
        topicOpenURL,
        topicActivate,
        topicCancelProgress,
        topicVersion,
        topicRegisterViewer,
        topicUnRegisterViewer,
        topicGetWindowInfo,
        // Note: Insert new values above this line!!!!!
        topicCount // Count of the number of real topics
    };

Member Function Documentation

Definition at line 1401 of file nsNativeAppSupportOS2.cpp.

                                               {
    nsCOMPtr<nsIDOMWindowInternal> navWin;
    GetMostRecentWindow( NS_LITERAL_STRING("navigator:browser").get(), getter_AddRefs( navWin ) );
    if ( navWin )
        // Activate that window.
        activateWindow( navWin );
    else
        // Need to create a Navigator window, then.
        OpenBrowserWindow();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void nsNativeAppSupportOS2::ActivateLastWindow ( ) [static, private]

Definition at line 368 of file nsNativeAppSupportOS2.cpp.

                                    {
    return;
}

Here is the caller graph for this function:

HDDEDATA nsNativeAppSupportOS2::CreateDDEData ( DWORD  value) [static, private]

Definition at line 1412 of file nsNativeAppSupportOS2.cpp.

                                                           {
    return CreateDDEData( (LPBYTE)&value, sizeof value );
}

Here is the caller graph for this function:

HDDEDATA nsNativeAppSupportOS2::CreateDDEData ( LPBYTE  value,
DWORD  len 
) [static, private]

Definition at line 1416 of file nsNativeAppSupportOS2.cpp.

                                                                       {
    HDDEDATA result = WinDdeCreateDataHandle( value,
                                              len,
                                              0,
                                              mApplication,
                                              CF_TEXT,
                                              0 );
    return result;
}
static HDDEDATA nsNativeAppSupportOS2::CreateDDEData ( DWORD  value) [static, private]
static HDDEDATA nsNativeAppSupportOS2::CreateDDEData ( LPBYTE  value,
DWORD  len 
) [static, private]

Definition at line 145 of file nsNativeAppSupportBase.cpp.

                                                                     {
    NS_ENSURE_ARG( splash );
    *splash = 0;
    return NS_CreateSplashScreen( splash );
}

Here is the call graph for this function:

Definition at line 999 of file nsNativeAppSupportOS2.cpp.

{
    mCanHandleRequests = PR_TRUE;
    nsCOMPtr<nsIObserverService> obs
        (do_GetService("@mozilla.org/observer-service;1"));
    if (obs) {
        obs->AddObserver(this, "quit-application", PR_FALSE);
    } else {
        NS_ERROR("No observer service?");
    }

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 2135 of file nsNativeAppSupportOS2.cpp.

{
  nsresult rv;  

  nsCOMPtr<nsIProfileInternal> profileMgr(do_GetService(NS_PROFILE_CONTRACTID, &rv));
  if (NS_FAILED(rv)) return rv;
  nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
  if (NS_FAILED(rv)) return rv;

  // If we have a profile, everything is fine.
  // unless mForceProfileStartup is TRUE. This flag is set when the
  // last window is closed in -turbo mode. When TRUE, it forces the
  // profile UI to come up at the beginning of the next -turbo session
  // even if we currently have a profile.
  PRBool haveProfile;
  rv = profileMgr->IsCurrentProfileAvailable(&haveProfile);
  if (!mForceProfileStartup && NS_SUCCEEDED(rv) && haveProfile)
      return NS_OK;
 
  // If the profile selection is happening, fail.
  PRBool doingProfileStartup;
  rv = profileMgr->GetIsStartingUp(&doingProfileStartup);
  if (NS_FAILED(rv) || doingProfileStartup) return NS_ERROR_FAILURE;

  // See if profile manager is being suppressed via -silent flag.
  PRBool canInteract = PR_TRUE;
  nsXPIDLCString arg;
  if (NS_SUCCEEDED(args->GetCmdLineValue("-silent", getter_Copies(arg)))) {
    if (!arg.IsEmpty()) {
      canInteract = PR_FALSE;
    }
  }
  rv = appStartup->DoProfileStartup(args, canInteract);

  mForceProfileStartup = PR_FALSE;

  return rv;
}

Here is the call graph for this function:

int nsNativeAppSupportOS2::FindTopic ( HSZ  topic) [static, private]

Definition at line 860 of file nsNativeAppSupportOS2.cpp.

                                            {
    for ( int i = 0; i < topicCount; i++ ) {
        if ( DdeCmpStringHandles( topic, mTopics[i] ) == 0 ) {
            return i;
        }
    }
    return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int nsNativeAppSupportOS2::FindTopic ( HSZ  topic) [static, private]
nsresult nsNativeAppSupportOS2::GetCmdLineArgs ( LPBYTE  request,
nsICmdLineService **  aResult 
) [static, private]

Definition at line 1984 of file nsNativeAppSupportOS2.cpp.

                                                                                   {
    nsresult rv = NS_OK;

    int justCounting = 1;
    char **argv = 0;
    // Flags, etc.
    int between = 1, quoted = 0, bSlashCount = 0;
    int argc = 0;
    char *p = (char*)request;
    nsCAutoString arg;
    // We loop if we've not finished the second pass through.
    while ( 1 ) {
        if ( between ) {
            // We are traversing whitespace between args.
            // Check for start of next arg.
            if (  *p != 0 && !isspace( *p ) ) {
                // Start of another arg.
                between = 0;
                arg = "";
                switch ( *p ) {
                    case '\\':
                        // Count the backslash.
                        bSlashCount = 1;
                        break;
                    case '"':
                        // Remember we're inside quotes.
                        quoted = 1;
                        break;
                    default:
                        // Add character to arg.
                        arg += *p;
                        break;
                }
            } else {
                // Another space between args, ignore it.
            }
        } else {
            // We are processing the contents of an argument.
            // Check for whitespace or end.
            if ( *p == 0 || ( !quoted && isspace( *p ) ) ) {
                // Process pending backslashes (interpret them 
                // literally since they're not followed by a ").
                while( bSlashCount ) {
                    arg += '\\';
                    bSlashCount--;
                }
                // End current arg.
                if ( !justCounting ) {
                    argv[argc] = new char[ arg.Length() + 1 ];
                    strcpy( argv[argc], arg.get() ); 
                }
                argc++;
                // We're now between args.
                between = 1;
            } else {
                // Still inside argument, process the character.
                switch ( *p ) {
                    case '"':
                        // First, digest preceding backslashes (if any).
                        while ( bSlashCount > 1 ) {
                            // Put one backsplash in arg for each pair.
                            arg += '\\';
                            bSlashCount -= 2;
                        }
                        if ( bSlashCount ) {
                            // Quote is literal.
                            arg += '"';
                            bSlashCount = 0;
                        } else {
                            // Quote starts or ends a quoted section.
                            if ( quoted ) {
                                // Check for special case of consecutive double
                                // quotes inside a quoted section.
                                if ( *(p+1) == '"' ) {
                                    // This implies a literal double-quote.  Fake that
                                    // out by causing next double-quote to look as
                                    // if it was preceded by a backslash.
                                    bSlashCount = 1;
                                } else {
                                    quoted = 0;
                                }
                            } else {
                                quoted = 1;
                            }
                        }
                        break;
                    case '\\':
                        // Add to count.
                        bSlashCount++;
                        break;
                    default:
                        // Accept any preceding backslashes literally.
                        while ( bSlashCount ) {
                            arg += '\\';
                            bSlashCount--;
                        }
                        // Just add next char to the current arg.
                        arg += *p;
                        break;
                }
            }
        }
        // Check for end of input.
        if ( *p ) {
            // Go to next character.
            p++;
        } else {
            // If on first pass, go on to second.
            if ( justCounting ) {
                // Allocate argv array.
                argv = new char*[ argc ];
    
                // Start second pass, initialize again
                justCounting = 0;
                p = (char*)request;
                between = 1;
                argc = quoted = bSlashCount = 0;
            } else {
                // Quit.
                break;
            }
        }
    }

    nsCOMPtr<nsIComponentManager> compMgr;
    NS_GetComponentManager(getter_AddRefs(compMgr));
    rv = compMgr->CreateInstanceByContractID(
                    NS_COMMANDLINESERVICE_CONTRACTID,
                    nsnull, NS_GET_IID(nsICmdLineService),
                    (void**) aResult);

    if ( NS_FAILED( rv ) || NS_FAILED( ( rv = (*aResult)->Initialize( argc, argv ) ) ) ) {
#if MOZ_DEBUG_DDE
        printf( "Error creating command line service = 0x%08X (argc=%d, argv=0x%08X)\n", (int)rv, (int)argc, (int)argv );
#endif
    }

    // Cleanup.
    while ( argc ) {
        delete [] argv[ --argc ];
    }
    delete [] argv;

    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static nsresult nsNativeAppSupportOS2::GetStartupURL ( nsICmdLineService args,
nsCString taskURL 
) [static, private]
void nsNativeAppSupportOS2::HandleCommandLine ( const char *  aCmdLineString,
nsIFile aWorkingDir,
PRUint32  aState 
) [static, private]

Definition at line 1428 of file nsNativeAppSupportOS2.cpp.

{
    nsresult rv;

    int justCounting = 1;
    char **argv = 0;
    // Flags, etc.
    int init = 1;
    int between, quoted, bSlashCount;
    int argc;
    const char *p;
    nsCAutoString arg;

    nsCOMPtr<nsICommandLineRunner> cmdLine
        (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
    if (!cmdLine) {
        NS_ERROR("Couldn't create command line!");
        return;
    }

    // We loop if we've not finished the second pass through.
    while ( 1 ) {
        // Initialize if required.
        if ( init ) {
            p = aCmdLineString;
            between = 1;
            argc = quoted = bSlashCount = 0;

            init = 0;
        }
        if ( between ) {
            // We are traversing whitespace between args.
            // Check for start of next arg.
            if (  *p != 0 && !isspace( *p ) ) {
                // Start of another arg.
                between = 0;
                arg = "";
                switch ( *p ) {
                    case '\\':
                        // Count the backslash.
                        bSlashCount = 1;
                        break;
                    case '"':
                        // Remember we're inside quotes.
                        quoted = 1;
                        break;
                    default:
                        // Add character to arg.
                        arg += *p;
                        break;
                }
            } else {
                // Another space between args, ignore it.
            }
        } else {
            // We are processing the contents of an argument.
            // Check for whitespace or end.

            // if the argument we are parsing is a mailto url then all
            // of the remaining command line data needs to be part of
            // the mailto url even if it has spaces. See Bug #231032
            nsDependentCString mailtoUrlScheme (kMailtoUrlScheme);

            if ( *p == 0 || ( !quoted && isspace( *p ) && !StringBeginsWith(arg, mailtoUrlScheme, nsCaseInsensitiveCStringComparator()) ) ) {
                // Process pending backslashes (interpret them
                // literally since they're not followed by a ").
                while( bSlashCount ) {
                    arg += '\\';
                    bSlashCount--;
                }
                // End current arg.
                if ( !justCounting ) {
                    argv[argc] = new char[ arg.Length() + 1 ];
                    strcpy( argv[argc], arg.get() );
                }
                argc++;
                // We're now between args.
                between = 1;
            } else {
                // Still inside argument, process the character.
                switch ( *p ) {
                    case '"':
                        // First, digest preceding backslashes (if any).
                        while ( bSlashCount > 1 ) {
                            // Put one backsplash in arg for each pair.
                            arg += '\\';
                            bSlashCount -= 2;
                        }
                        if ( bSlashCount ) {
                            // Quote is literal.
                            arg += '"';
                            bSlashCount = 0;
                        } else {
                            // Quote starts or ends a quoted section.
                            if ( quoted ) {
                                // Check for special case of consecutive double
                                // quotes inside a quoted section.
                                if ( *(p+1) == '"' ) {
                                    // This implies a literal double-quote.  Fake that
                                    // out by causing next double-quote to look as
                                    // if it was preceded by a backslash.
                                    bSlashCount = 1;
                                } else {
                                    quoted = 0;
                                }
                            } else {
                                quoted = 1;
                            }
                        }
                        break;
                    case '\\':
                        // Add to count.
                        bSlashCount++;
                        break;
                    default:
                        // Accept any preceding backslashes literally.
                        while ( bSlashCount ) {
                            arg += '\\';
                            bSlashCount--;
                        }
                        // Just add next char to the current arg.
                        arg += *p;
                        break;
                }
            }
        }
        // Check for end of input.
        if ( *p ) {
            // Go to next character.
            p++;
        } else {
            // If on first pass, go on to second.
            if ( justCounting ) {
                // Allocate argv array.
                argv = new char*[ argc ];

                // Start second pass
                justCounting = 0;
                init = 1;
            } else {
                // Quit.
                break;
            }
        }
    }

    rv = cmdLine->Init(argc, argv, aWorkingDir, aState);

    // if these OS/2-specific flags aren't removed,
    // any URL following them will be ignored
    PRBool found;
    cmdLine->HandleFlag(NS_LITERAL_STRING("console"), PR_FALSE, &found);
    cmdLine->HandleFlag(NS_LITERAL_STRING("dde"), PR_FALSE, &found);

    // Cleanup.
    while ( argc ) {
        delete [] argv[ --argc ];
    }
    delete [] argv;

    if (NS_FAILED(rv)) {
        NS_ERROR("Error initializing command line.");
        return;
    }

    cmdLine->Run();
}

Here is the call graph for this function:

Here is the caller graph for this function:

HDDEDATA APIENTRY nsNativeAppSupportOS2::HandleDDENotification ( ULONG  idInst,
USHORT  uType,
USHORT  uFmt,
HCONV  hconv,
HSZ  hsz1,
HSZ  hsz2,
HDDEDATA  hdata,
ULONG  dwData1,
ULONG  dwData2 
) [static, private]

Definition at line 1078 of file nsNativeAppSupportOS2.cpp.

                                                              { // transaction-specific data

#if MOZ_DEBUG_DDE
    printf( "DDE: uType  =%s\n",      uTypeDesc( uType ).get() );
    printf( "     uFmt   =%u\n",      (unsigned)uFmt );
    printf( "     hconv  =%08x\n",    (int)hconv );
    printf( "     hsz1   =%08x:%s\n", (int)hsz1, hszValue( mInstance, hsz1 ).get() );
    printf( "     hsz2   =%08x:%s\n", (int)hsz2, hszValue( mInstance, hsz2 ).get() );
    printf( "     hdata  =%08x\n",    (int)hdata );
    printf( "     dwData1=%08x\n",    (int)dwData1 );
    printf( "     dwData2=%08x\n",    (int)dwData2 );
#endif

    HDDEDATA result = 0;
    if ( uType & XCLASS_BOOL ) {
        switch ( uType ) {
            case XTYP_CONNECT:
                // Make sure its for our service/topic.
                if ( FindTopic( hsz1 ) != -1 ) {
                    // We support this connection.
                    result = (HDDEDATA)1;
                }
                break;
            case XTYP_CONNECT_CONFIRM:
                // We don't care about the conversation handle, at this point.
                result = (HDDEDATA)1;
                break;
        }
    } else if ( uType & XCLASS_DATA ) {
        if ( uType == XTYP_REQUEST ) {
            switch ( FindTopic( hsz1 ) ) {
                case topicOpenURL: {
                    // Open a given URL...

                    // Get the URL from the first argument in the command.
                    nsCAutoString url;
                    ParseDDEArg(hsz2, 0, url);

                    // Read the 3rd argument in the command to determine if a
                    // new window is to be used.
                    nsCAutoString windowID;
                    ParseDDEArg(hsz2, 2, windowID);
                    // to open the URL in a new window, the old OS/2 code
                    // looks for "0" while the new Win32 code looks for "";
                    // not knowing which is correct, we'll look for both
                    if (windowID.Equals( "0" ) || windowID.Equals( "" ))
                        url.Insert("mozilla -new-window ", 0);
                    else
                        url.Insert("mozilla -url ", 0);

#if MOZ_DEBUG_DDE
                    printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
#endif
                    // Now handle it.
                    HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
                    // Return pseudo window ID.
                    result = CreateDDEData( 1 );
                    break;
                }
                case topicGetWindowInfo: {
                    // This topic has to get the current URL, get the current
                    // page title and then format the output into the DDE
                    // return string.  The return value is "URL","Page Title",
                    // "Window ID" however the window ID is not used for this
                    // command, therefore it is returned as a null string

                    // This isn't really a loop.  We just use "break"
                    // statements to bypass the remaining steps when
                    // something goes wrong.
                    do {
                        // Get most recently used Nav window.
                        nsCOMPtr<nsIDOMWindowInternal> navWin;
                        GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(),
                                             getter_AddRefs( navWin ) );
                        if ( !navWin ) {
                            // There is not a window open
                            break;
                        }
                        // Get content window.
                        nsCOMPtr<nsIDOMWindow> content;
                        navWin->GetContent( getter_AddRefs( content ) );
                        if ( !content ) {
                            break;
                        }
                        // Convert that to internal interface.
                        nsCOMPtr<nsIDOMWindowInternal> internalContent( do_QueryInterface( content ) );
                        if ( !internalContent ) {
                            break;
                        }
                        // Get location.
                        nsCOMPtr<nsIDOMLocation> location;
                        internalContent->GetLocation( getter_AddRefs( location ) );
                        if ( !location ) {
                            break;
                        }
                        // Get href for URL.
                        nsAutoString url;
                        if ( NS_FAILED( location->GetHref( url ) ) ) {
                            break;
                        }
                        // Escape any double-quotes.
                        escapeQuotes( url );

                        // Now for the title; first, get the "window" script global object.
                        nsCOMPtr<nsIScriptGlobalObject> scrGlobalObj( do_QueryInterface( internalContent ) );
                        if ( !scrGlobalObj ) {
                            break;
                        }
                        // Then from its doc shell get the base window...
                        nsCOMPtr<nsIBaseWindow> baseWindow =
                          do_QueryInterface( scrGlobalObj->GetDocShell() );
                        if ( !baseWindow ) {
                            break;
                        }
                        // And from the base window we can get the title.
                        nsXPIDLString title;
                        if(!baseWindow) {
                            break;
                        }
                        baseWindow->GetTitle(getter_Copies(title));
                        // Escape any double-quotes in the title.
                        escapeQuotes( title );

                        // Use a string buffer for the output data, first
                        // save a quote.
                        nsCAutoString   outpt( NS_LITERAL_CSTRING("\"") );
                        // Now copy the URL converting the Unicode string
                        // to a single-byte ASCII string
                        outpt.Append( NS_LossyConvertUCS2toASCII( url ) );
                        // Add the "," used to separate the URL and the page
                        // title
                        outpt.Append( NS_LITERAL_CSTRING("\",\"") );
                        // Now copy the current page title to the return string
                        outpt.Append( NS_LossyConvertUCS2toASCII( title.get() ));
                        // Fill out the return string with the remainin ",""
                        outpt.Append( NS_LITERAL_CSTRING( "\",\"\"" ));

                        // Create a DDE handle to a char string for the data
                        // being returned, this copies and creates a "shared"
                        // copy of the DDE response until the calling APP
                        // reads it and says it can be freed.
                        result = CreateDDEData( (LPBYTE)(const char*)outpt.get(),
                                                outpt.Length() + 1 );
#if MOZ_DEBUG_DDE
                        printf( "WWW_GetWindowInfo->%s\n", outpt.get() );
#endif
                    } while ( PR_FALSE );
                    break;
                }
                case topicActivate: {
                    // Activate a Nav window...
                    nsCAutoString windowID;
                    ParseDDEArg(hsz2, 0, windowID);
                    // 4294967295 is decimal for 0xFFFFFFFF which is also a
                    //   correct value to do that Activate last window stuff
                    if ( windowID.Equals( "-1" ) ||
                         windowID.Equals( "4294967295" ) ) {
                        // We only support activating the most recent window (or a new one).
                        ActivateLastWindow();
                        // Return pseudo window ID.
                        result = CreateDDEData( 1 );
                    }
                    break;
                }
                case topicVersion: {
                    // Return version.  We're restarting at 1.0!
                    DWORD version = 1 << 16; // "1.0"
                    result = CreateDDEData( version );
                    break;
                }
                case topicRegisterViewer: {
                    // Register new viewer (not implemented).
                    result = CreateDDEData( PR_FALSE );
                    break;
                }
                case topicUnRegisterViewer: {
                    // Unregister new viewer (not implemented).
                    result = CreateDDEData( PR_FALSE );
                    break;
                }
                default:
                    break;
            }
        } else if ( uType & XTYP_POKE ) {
            switch ( FindTopic( hsz1 ) ) {
                case topicCancelProgress: {
                    // "Handle" progress cancel (actually, pretty much ignored).
                    result = (HDDEDATA)DDE_FACK;
                    break;
                }
                default:
                    break;
            }
        }
    } else if ( uType & XCLASS_FLAGS ) {
        if ( uType == XTYP_EXECUTE ) {
            // Prove that we received the request.
            DWORD bytes;
            LPBYTE request = (LPBYTE)WinDdeAccessData( hdata, &bytes );
#if MOZ_DEBUG_DDE
            printf( "Handling dde request: [%s]...\n", (char*)request );
#endif
            nsCAutoString url;
            ParseDDEArg((const char*) request, 0, url);

            // Read the 3rd argument in the command to determine if a
            // new window is to be used.
            nsCAutoString windowID;
            ParseDDEArg((const char*) request, 2, windowID);

            // to open the URL in a new window, the old OS/2 code
            // looks for "0" while the new Win32 code looks for "";
            // not knowing which is correct, we'll look for both
            if (windowID.Equals( "0" ) || windowID.Equals( "" ))
                url.Insert("mozilla -new-window ", 0);
            else
                url.Insert("mozilla -url ", 0);

#if MOZ_DEBUG_DDE
            printf( "Handling dde XTYP_REQUEST request: [%s]...\n", url.get() );
#endif
            // Now handle it.
            HandleCommandLine(url.get(), nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);

            // Release the data.
//            DdeUnaccessData( hdata );
            result = (HDDEDATA)DDE_FACK;
        } else {
            result = (HDDEDATA)DDE_NOTPROCESSED;
        }
    } else if ( uType & XCLASS_NOTIFICATION ) {
    }
#if MOZ_DEBUG_DDE
    printf( "DDE result=%d (0x%08X)\n", (int)result, (int)result );
#endif
    return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static HDDEDATA APIENTRY nsNativeAppSupportOS2::HandleDDENotification ( ULONG  idInst,
USHORT  uType,
USHORT  uFmt,
HCONV  hconv,
HSZ  hsz1,
HSZ  hsz2,
HDDEDATA  hdata,
ULONG  dwData1,
ULONG  dwData2 
) [static, private]
nsresult nsNativeAppSupportOS2::HandleRequest ( LPBYTE  request,
PRBool  newWindow,
nsIDOMWindow **  aResult 
) [static, private]

Definition at line 1858 of file nsNativeAppSupportOS2.cpp.

                                                                                               {

    // if initial hidden window is still being displayed, we need to ignore requests
    // because such requests might not function properly.  See bug 147223 for details

    if (mInitialWindowActive) {
      return NS_ERROR_FAILURE;
    }

    // Parse command line.

    nsCOMPtr<nsICmdLineService> args;
    nsresult rv;

    rv = GetCmdLineArgs( request, getter_AddRefs( args ) );
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsINativeAppSupport> nativeApp;
    rv = appStartup->GetNativeAppSupport(getter_AddRefs( nativeApp ));
    if (NS_FAILED(rv)) return rv;

    // first see if there is a url
    nsXPIDLCString arg;
    rv = args->GetURLToLoad(getter_Copies(arg));
    if (NS_FAILED(rv)) return rv;

    if (!arg.IsEmpty() ) {
      // Launch browser.
#if MOZ_DEBUG_DDE
      printf( "Launching browser on url [%s]...\n", arg.get() );
#endif
      rv = nativeApp->EnsureProfile(args);
      if (NS_SUCCEEDED(rv))
        rv = OpenBrowserWindow( arg.get(), newWindow, aResult );
      return rv;
    }


    // ok, let's try the -chrome argument
    rv = args->GetCmdLineValue("-chrome", getter_Copies(arg));
    if (NS_SUCCEEDED(rv) && (const char*)arg ) {
      // Launch chrome.
#if MOZ_DEBUG_DDE
      printf( "Launching chrome url [%s]...\n", (const char*)arg );
#endif
      rv = nativeApp->EnsureProfile(args);
      if (NS_SUCCEEDED(rv))
        rv = OpenWindow( arg.get(), "", aResult );
      return rv;
    }

    // try for the "-profilemanager" argument, in which case we want the
    // profile manager to appear, but only if there are no windows open

    rv = args->GetCmdLineValue( "-profilemanager", getter_Copies(arg));
    if ( NS_SUCCEEDED(rv) && (const char*)arg ) { // -profilemanager on command line
      nsCOMPtr<nsIDOMWindowInternal> window;
      GetMostRecentWindow(0, getter_AddRefs(window));
      if (!window) { // there are no open windows
        mForceProfileStartup = PR_TRUE;
      }
    }

    // try for the "-kill" argument, to shut down the server
    rv = args->GetCmdLineValue( "-kill", getter_Copies(arg));
    if ( NS_SUCCEEDED(rv) && (const char*)arg ) {
      // Turn off server mode.
      nsCOMPtr<nsIAppStartup> appStartup
        (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
      if (NS_FAILED(rv)) return rv;

      nsCOMPtr<nsINativeAppSupport> native;
      rv = appStartup->GetNativeAppSupport( getter_AddRefs( native ));
      if (NS_SUCCEEDED(rv)) {
        native->SetIsServerMode( PR_FALSE );

        // close app if there are no more top-level windows.
        rv = appStartup->Quit(nsIAppStartup::eConsiderQuit);
      }

      return rv;
    }

    // Try standard startup's command-line handling logic from nsAppRunner.cpp...

    // Need profile before opening windows.
    rv = nativeApp->EnsureProfile(args);
    if (NS_FAILED(rv)) return rv;

    // This will tell us whether the command line processing opened a window.
    PRBool windowOpened = PR_FALSE;

    // Process command line options.
    rv = DoCommandLines( args, &windowOpened );

    // If a window was opened, then we're done.
    // Note that we keep on trying in the unlikely event of an error.
    if (rv == NS_ERROR_NOT_AVAILABLE || rv == NS_ERROR_ABORT || windowOpened) {
      return NS_OK;
    }

    // ok, no idea what the param is.
#if MOZ_DEBUG_DDE
    printf( "Unknown request [%s]\n", (char*) request );
#endif
    // if all else fails, open a browser window
    const char * const contractID =
      "@mozilla.org/commandlinehandler/general-startup;1?type=browser";
    nsCOMPtr<nsICmdLineHandler> handler = do_GetService(contractID, &rv);
    if (NS_FAILED(rv)) return rv;

    nsXPIDLString defaultArgs;
    rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));
    if (NS_FAILED(rv) || defaultArgs.IsEmpty()) return rv;

    NS_ConvertUTF16toUTF8 url( defaultArgs );
    return OpenBrowserWindow(url.get(), newWindow, aResult);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 850 of file nsNativeAppSupportOS2.cpp.

                                        {
    for ( int i = 0; i < topicCount; i++ ) {
        if ( !( mTopics[ i ] = WinDdeCreateStringHandle( (PSZ)topicNames[ i ], CP_WINANSI ) ) ) {
            return PR_FALSE;
        }
    }
    return PR_TRUE;
}

Here is the caller graph for this function:

static PRBool nsNativeAppSupportOS2::InitTopicStrings ( ) [static, private]
void nsIObserver::observe ( in nsISupports  aSubject,
in string  aTopic,
in wstring  aData 
) [inherited]

Observe will be called when there is a notification for the topic |aTopic|.

This assumes that the object implementing this interface has been registered with an observer service such as the nsIObserverService.

If you expect multiple topics/subjects, the impl is responsible for filtering.

You should not modify, add, remove, or enumerate notifications in the implemention of observe.

Parameters:
aSubject: Notification specific interface pointer.
aTopic: The notification topic or subject.
aData: Notification specific wide string. subject event.

Definition at line 2405 of file nsNativeAppSupportOS2.cpp.

                                           {
 
    if ( !mServerMode )
        return NS_OK;

    // If the last window closed is our special "turbo" window made
    // in StartServerMode(), don't do anything.
    if ( mInitialWindowActive ) {
        mInitialWindowActive = PR_FALSE;
        return NS_OK;
    }

    nsresult rv;

    // If activated by the browser.turbo.singleProfileOnly pref,
    // check for multi-profile situation and turn off turbo mode
    // if there are multiple profiles.
    PRBool singleProfileOnly = PR_FALSE;
    nsCOMPtr<nsIPrefBranch> prefService( do_GetService( NS_PREFSERVICE_CONTRACTID, &rv ) );
    if ( NS_SUCCEEDED( rv ) ) {
        prefService->GetBoolPref( "browser.turbo.singleProfileOnly", &singleProfileOnly );
    }
    if ( singleProfileOnly ) {
        nsCOMPtr<nsIProfile> profileMgr( do_GetService( NS_PROFILE_CONTRACTID, &rv ) );
        if ( NS_SUCCEEDED( rv ) ) {
            PRInt32 profileCount = 0;
            if ( NS_SUCCEEDED( profileMgr->GetProfileCount( &profileCount ) ) &&
                 profileCount > 1 ) {
                // Turn off turbo mode and quit the application.
                SetIsServerMode( PR_FALSE );
                nsCOMPtr<nsIAppStartup> appStartup
                    (do_GetService(NS_APPSTARTUP_CONTRACTID, &rv));
                if ( NS_SUCCEEDED( rv ) ) {
                    appStartup->Quit(nsIAppStartup::eAttemptQuit);
                }
                return NS_OK;
            }
        }
    }

    nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
    if (NS_FAILED(rv)) return rv;
    observerService->NotifyObservers(nsnull, "session-logout", nsnull);

    mForceProfileStartup = PR_TRUE;

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 1693 of file nsNativeAppSupportOS2.cpp.

{
    nsresult rv = NS_OK;

    // Open the argument URL in the most recently used Navigator window.
    // If there is no Nav window, open a new one.

    // If at all possible, hand the request off to the most recent
    // browser window.

    nsCOMPtr<nsIDOMWindowInternal> navWin;
    GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) );

    // This isn't really a loop.  We just use "break" statements to fall
    // out to the OpenWindow call when things go awry.
    do {
        // If caller requires a new window, then don't use an existing one.
        if ( !navWin ) {
            // Have to open a new one.
            break;
        }

        nsCOMPtr<nsIBrowserDOMWindow> bwin;
        { // scope a bunch of temporary cruft used to generate bwin
          nsCOMPtr<nsIWebNavigation> navNav( do_GetInterface( navWin ) );
          nsCOMPtr<nsIDocShellTreeItem> navItem( do_QueryInterface( navNav ) );
          if ( navItem ) {
            nsCOMPtr<nsIDocShellTreeItem> rootItem;
            navItem->GetRootTreeItem( getter_AddRefs( rootItem ) );
            nsCOMPtr<nsIDOMWindow> rootWin( do_GetInterface( rootItem ) );
            nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
            if ( chromeWin )
              chromeWin->GetBrowserDOMWindow( getter_AddRefs ( bwin ) );
          }
        }
        if ( bwin ) {
          nsCOMPtr<nsIURI> uri;
          NS_NewURI( getter_AddRefs( uri ), NS_LITERAL_CSTRING("about:blank"), 0, 0 );
          if ( uri ) {
            nsCOMPtr<nsIDOMWindow> container;
            rv = bwin->OpenURI( uri, 0,
                                nsIBrowserDOMWindow::OPEN_DEFAULTWINDOW,
                                nsIBrowserDOMWindow::OPEN_EXTERNAL,
                                getter_AddRefs( container ) );
            if ( NS_SUCCEEDED( rv ) )
              return NS_OK;
          }
        }

        NS_ERROR("failed to hand off external URL to extant window\n");
    } while ( PR_FALSE );

    // open a new window if caller requested it or if anything above failed

    char* argv[] = { 0 };
    nsCOMPtr<nsICommandLineRunner> cmdLine
        (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
    NS_ENSURE_TRUE(cmdLine, NS_ERROR_FAILURE);

    rv = cmdLine->Init(0, argv, nsnull, nsICommandLine::STATE_REMOTE_EXPLICIT);
    NS_ENSURE_SUCCESS(rv, rv);

    return cmdLine->Run();
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsNativeAppSupportOS2::OpenBrowserWindow ( const char *  args,
PRBool  newWindow,
nsIDOMWindow **  aResult 
) [static, private]

Definition at line 2274 of file nsNativeAppSupportOS2.cpp.

                                                                                                     {
    nsresult rv = NS_OK;
    // Open the argument URL according to the external link preference.
    // If there is no Nav window, or newWindow is PR_TRUE, open a new one.
    
    // Get most recently used Nav window.
    nsCOMPtr<nsIDOMWindowInternal> navWin;
    GetMostRecentWindow( NS_LITERAL_STRING( "navigator:browser" ).get(), getter_AddRefs( navWin ) );

    // This isn't really a loop.  We just use "break" statements to fall
    // out to the OpenWindow call when things go awry.
    do {
        // If caller requires a new window, then don't use an existing one.
        if ( newWindow ) {
            break;
        }
        if ( !navWin ) {
            // Have to open a new one.
            break;
        }
        nsCOMPtr<nsIDOMChromeWindow> chromeWin( do_QueryInterface( navWin ) );
        if ( !chromeWin ) {
            break;
        }
        nsCOMPtr<nsIBrowserDOMWindow> bwin;
        chromeWin->GetBrowserDOMWindow( getter_AddRefs( bwin ) );
        if ( !bwin ) {
            break;
        }
        nsCOMPtr<nsIIOService> io( do_GetService( "@mozilla.org/network/io-service;1" ) );
        if ( !io ) {
            break;
        }
        nsCOMPtr<nsIURI> uri;
        io->NewURI( nsDependentCString( args ), nsnull, nsnull, getter_AddRefs( uri ) );
        if ( !uri ) {
            break;
        }
        return bwin->OpenURI( uri, nsnull, nsIBrowserDOMWindow::OPEN_DEFAULTWINDOW, nsIBrowserDOMWindow::OPEN_EXTERNAL, aResult );
    } while ( PR_FALSE );

    nsCOMPtr<nsICmdLineHandler> handler(do_GetService("@mozilla.org/commandlinehandler/general-startup;1?type=browser", &rv));
    if (NS_FAILED(rv)) return rv;

    nsXPIDLCString chromeUrlForTask;
    rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));
    if (NS_FAILED(rv)) return rv;

    // Last resort is to open a brand new window.
    return OpenWindow( chromeUrlForTask.get(), args, aResult );
}

Here is the call graph for this function:

nsresult nsNativeAppSupportOS2::OpenWindow ( const char *  urlstr,
const char *  args 
) [static, private]

Definition at line 1600 of file nsNativeAppSupportOS2.cpp.

                                                                       {

  nsresult rv = NS_ERROR_FAILURE;

  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
  nsCOMPtr<nsISupportsCString> sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
  if (sarg)
    sarg->SetData(nsDependentCString(args));

  if (wwatch && sarg) {
    nsCOMPtr<nsIDOMWindow> newWindow;
    rv = wwatch->OpenWindow(0, urlstr, "_blank", "chrome,dialog=no,all",
                   sarg, getter_AddRefs(newWindow));
#if MOZ_DEBUG_DDE
  } else {
      printf("Get WindowWatcher (or create string) failed\n");
#endif
  }
  return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsNativeAppSupportOS2::OpenWindow ( const char *  urlstr,
const char *  args,
nsIDOMWindow **  aResult 
) [static, private]

Definition at line 2175 of file nsNativeAppSupportOS2.cpp.

                                                                                               {

  nsresult rv = NS_ERROR_FAILURE;

  nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
  nsCOMPtr<nsISupportsCString> sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
  if (sarg)
    sarg->SetData(nsDependentCString(args));

  if (wwatch && sarg) {
    rv = wwatch->OpenWindow(0, urlstr, "_blank", "chrome,dialog=no,all",
                   sarg, aResult);
#if MOZ_DEBUG_DDE
  } else {
      printf("Get WindowWatcher (or create string) failed\n");
#endif
  }
  return rv;
}

Here is the call graph for this function:

void nsNativeAppSupportOS2::ParseDDEArg ( HSZ  args,
int  index,
nsCString string 
) [static, private]

Definition at line 1387 of file nsNativeAppSupportOS2.cpp.

                                                                                {
    DWORD argLen = WinDdeQueryString( args, NULL, NULL, CP_WINANSI );
    // there wasn't any string, so return empty string
    if ( !argLen ) return;
    nsCAutoString temp;
    // Ensure result's buffer is sufficiently big.
    temp.SetLength( argLen );
    // Now get the string contents.
    WinDdeQueryString( args, temp.BeginWriting(), temp.Length(), CP_WINANSI );
    // Parse out the given arg.
    ParseDDEArg(temp.get(), index, aString);
    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nsNativeAppSupportOS2::ParseDDEArg ( const char *  args,
int  index,
nsCString aString 
) [static, private]

Definition at line 1346 of file nsNativeAppSupportOS2.cpp.

                                                                                        {
    if ( args ) {
        int argLen = strlen(args);
        nsDependentCString temp(args, argLen);

        // offset points to the comma preceding the desired arg.
        PRInt32 offset = -1;
        // Skip commas till we get to the arg we want.
        while( index-- ) {
            // If this arg is quoted, then go to closing quote.
            offset = advanceToEndOfQuotedArg( args, offset, argLen);
            // Find next comma.
            offset = temp.FindChar( ',', offset );
            if ( offset == kNotFound ) {
                // No more commas, give up.
                aString = args;
                return;
            }
        }
        // The desired argument starts just past the preceding comma,
        // which offset points to, and extends until the following
        // comma (or the end of the string).
        //
        // Since the argument might be enclosed in quotes, we need to
        // deal with that before searching for the terminating comma.
        // We advance offset so it ends up pointing to the start of
        // the argument we want.
        PRInt32 end = advanceToEndOfQuotedArg( args, offset++, argLen );
        // Find next comma (or end of string).
        end = temp.FindChar( ',', end );
        if ( end == kNotFound ) {
            // Arg is the rest of the string.
            end = argLen;
        }
        // Extract result.
        aString.Assign( args + offset, end - offset );
    }
    return;
}

Here is the call graph for this function:

static void nsNativeAppSupportOS2::ParseDDEArg ( HSZ  args,
int  index,
nsCString string 
) [static, private]
static void nsNativeAppSupportOS2::ParseDDEArg ( const char *  args,
int  index,
nsCString aString 
) [static, private]

Definition at line 169 of file nsNativeAppSupportBase.cpp.

                                                                  {
    nsresult rv = NS_OK;
    if ( p ) {
        *p = 0;
        if ( iid.Equals( NS_GET_IID( nsINativeAppSupport ) ) ) {
            nsINativeAppSupport *result = this;
            *p = result;
            NS_ADDREF( result );
        } else if ( iid.Equals( NS_GET_IID( nsISupports ) ) ) {
            nsISupports *result = NS_STATIC_CAST( nsISupports*, this );
            *p = result;
            NS_ADDREF( result );
        } else {
            rv = NS_NOINTERFACE;
        }
    } else {
        rv = NS_ERROR_NULL_POINTER;
    }
    return rv;
}

Here is the call graph for this function:

Definition at line 962 of file nsNativeAppSupportOS2.cpp.

                            {
    // If another process wants to look for the message window, they need
    // to wait to hold the lock, in which case they will not find the
    // window as we will destroy ours under our lock.
    // When the mutex goes off the stack, it is unlocked via destructor.
    Mutex mutexLock(mMutexName);
    NS_ENSURE_TRUE(mutexLock.Lock(MOZ_DDE_START_TIMEOUT), NS_ERROR_FAILURE);

    // If we've got a message window to receive IPC or new window requests,
    // get rid of it as we are shutting down.
    // Note:  Destroy calls DestroyWindow, which will only work on a window
    //  created by the same thread.
    MessageWindow mw;
    mw.Destroy();

    if ( mInstance ) {
        // Unregister application name.
        WinDdeNameService( mInstance, mApplication, 0, DNS_UNREGISTER );
        // Clean up strings.
        if ( mApplication ) {
            WinDdeFreeStringHandle( mApplication );
            mApplication = 0;
        }
        for ( int i = 0; i < topicCount; i++ ) {
            if ( mTopics[i] ) {
                WinDdeFreeStringHandle( mTopics[i] );
                mTopics[i] = 0;
            }
        }
        WinDdeUninitialize( mInstance );
        mInstance = 0;
    }

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Implemented in nsNativeAppSupportMac.

Implemented in nsNativeAppSupportMac.

nsresult nsNativeAppSupportOS2::ReParent ( nsISupports *  window,
HWND  newParent 
) [static, private]

Definition at line 2214 of file nsNativeAppSupportOS2.cpp.

                                                                     {
    HWND hMainClient = hwndForDOMWindow( window );
    if ( !hMainClient ) {
        return NS_ERROR_FAILURE;
    }
    HWND hMainFrame = WinQueryWindow(hMainClient, QW_PARENT);

    // Reset the parent.
    WinSetParent( hMainFrame, newParent, FALSE );

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2400 of file nsNativeAppSupportOS2.cpp.

Here is the caller graph for this function:

Definition at line 760 of file nsNativeAppSupportOS2.cpp.

                                              {
    NS_ENSURE_ARG( aResult );
    NS_ENSURE_TRUE( mInstance == 0, NS_ERROR_NOT_INITIALIZED );

    nsresult rv = NS_ERROR_FAILURE;
    *aResult = PR_FALSE;

    // see if DDE should be enabled AND remove OS/2-specific
    // options the app's commandline handler won't recognize
    // (-console was handled earlier by StartOS2App())
    for (int i = 1; i < gArgc; i++) {
        if (stricmp("-dde", gArgv[i]) == 0 ||
            stricmp("/dde", gArgv[i]) == 0)
            mUseDDE = PR_TRUE;
        else
            if (stricmp("-console", gArgv[i]) != 0 &&
                stricmp("/console", gArgv[i]) != 0)
                continue;

        for (int j = i; j < gArgc; j++)
            gArgv[j] = gArgv[j+1];
        gArgc--;
        i--;
    }

    // if this is a standalone instance, turn off DDE regardless of the
    // commandline, then skip out before we look for another instance
    if (getenv("MOZ_NO_REMOTE")) {
        mUseDDE = PR_FALSE;
        *aResult = PR_TRUE;
        return NS_OK;
    }

    // Grab mutex first.

    // Build mutex name from app name.
    PR_snprintf( mMutexName, sizeof mMutexName, "%s%s", gAppData->name, MOZ_STARTUP_MUTEX_NAME );
    Mutex startupLock = Mutex( mMutexName );

    NS_ENSURE_TRUE( startupLock.Lock( MOZ_DDE_START_TIMEOUT ), NS_ERROR_FAILURE );

    /* We need to have a message queue to do the MessageWindow stuff (for both
     * Create() and SendRequest()).  If we don't have one, make it now.
     * If we are going to end up going away right after ::Start() returns,
     * then make sure to clean up the message queue.
     */
    MQINFO mqinfo;
    HAB hab;
    HMQ hmqCurrent = WinQueryQueueInfo( HMQ_CURRENT, &mqinfo, 
                                        sizeof( MQINFO ) );
    if( !hmqCurrent ) {
        hab = WinInitialize( 0 );
        hmqCurrent = WinCreateMsgQueue( hab, 0 );
    }

    // Search for existing message window.
    MessageWindow msgWindow;
    if ( msgWindow.getHWND() ) {
        // We are a client process.  Pass request to message window.
        char *cmd = GetCommandLine();
        rv = msgWindow.SendRequest( cmd );
    } else {
        // We will be server.
        rv = msgWindow.Create();
        if ( NS_SUCCEEDED( rv ) ) {
            // Start up DDE server
            if (mUseDDE)
                this->StartDDE();
            // Tell caller to spin message loop.
            *aResult = PR_TRUE;
        }
    }

    startupLock.Unlock();

    if( *aResult == PR_FALSE )
    {
        /* This process isn't going to continue much longer.  Make sure that we
         * clean up the message queue
         */
        if (hmqCurrent)
           WinDestroyMsgQueue(hmqCurrent);
        if (hab)
           WinTerminate(hab);
    }

    return rv;
}

Here is the call graph for this function:

Definition at line 880 of file nsNativeAppSupportOS2.cpp.

                                {
    NS_ENSURE_TRUE( mInstance == 0, NS_ERROR_NOT_INITIALIZED );

    /* Get entrypoints for PMDDEML */
    BOOL bDDEML = SetupOS2ddeml();

    /* If we couldn't initialize DDEML, set mUSEDDE to PR_FALSE */
    /* so we don't do anything else DDE related */
    if (!bDDEML) {
       mUseDDE = PR_FALSE;
       return NS_OK;
    }

    // Initialize DDE.
    NS_ENSURE_TRUE( DDEERR_NO_ERROR == WinDdeInitialize( &mInstance,
                                                         nsNativeAppSupportOS2::HandleDDENotification,
                                                         APPCLASS_STANDARD,
                                                         0 ),
                    NS_ERROR_FAILURE );

    // Allocate DDE strings.
    NS_ENSURE_TRUE( ( mApplication = WinDdeCreateStringHandle( (char*) gAppData->name, CP_WINANSI ) ) && InitTopicStrings(),
                    NS_ERROR_FAILURE );

    // Next step is to register a DDE service.
    NS_ENSURE_TRUE( WinDdeNameService( mInstance, mApplication, 0, DNS_REGISTER ), NS_ERROR_FAILURE );

#if MOZ_DEBUG_DDE
    printf( "DDE server started\n" );
#endif

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2333 of file nsNativeAppSupportOS2.cpp.

                                       {

    if (mShouldShowUI) {
        // We dont have to anything anymore. The native UI
        // will create the window
        return NS_OK;
    } else {
        // Sometimes a window will have been opened even though mShouldShowUI is false
        // (e.g., "seamonkey -mail -turbo").  Detect that by testing whether there's a
        // window already open.
        nsCOMPtr<nsIDOMWindowInternal> win;
        GetMostRecentWindow( 0, getter_AddRefs( win ) );
        if ( win ) {
            // Window already opened, don't need this special Nav window.
            return NS_OK;
        }
    }

    // Since native UI wont create any window, we create a hidden window
    // so thing work alright.

    // Create some of the objects we'll need.
    nsCOMPtr<nsIWindowWatcher>   ww(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
    nsCOMPtr<nsISupportsString> arg1(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
    nsCOMPtr<nsISupportsString> arg2(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
    if ( !ww || !arg1 || !arg2 ) {
        return NS_OK;
    }

    // Create the array for the arguments.
    nsCOMPtr<nsISupportsArray> argArray = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID);
    if ( !argArray ) {
        return NS_OK;
    }

    // arg1 is the url to load.
    // arg2 is the string that tells navigator.js to auto-close.
    arg1->SetData( NS_LITERAL_STRING( "about:blank" ) );
    arg2->SetData( NS_LITERAL_STRING( "turbo=yes" ) );

    // Put args into array.
    if ( NS_FAILED( argArray->AppendElement( arg1 ) ) ||
        NS_FAILED( argArray->AppendElement( arg2 ) ) ) {
        return NS_OK;
    }

    // Now open the window.
    nsCOMPtr<nsIDOMWindow> newWindow;
    ww->OpenWindow( 0,
        "chrome://navigator/content",
        "_blank",
        "chrome,dialog=no,toolbar=no",
        argArray,
        getter_AddRefs( newWindow ) );

    if ( !newWindow ) {
        return NS_OK;
    }
    mInitialWindowActive = PR_TRUE;

    // Hide this window by re-parenting it (to ensure it doesn't appear).
    ReParent( newWindow, MessageWindow().getHWND() );

    return NS_OK;
}

Here is the call graph for this function:

Definition at line 916 of file nsNativeAppSupportOS2.cpp.

                                             {
    NS_ENSURE_ARG( aResult );
    NS_ENSURE_TRUE( mInstance, NS_ERROR_NOT_INITIALIZED );

    nsresult rv = NS_OK;
    *aResult = PR_TRUE;

    if (!mUseDDE) {
       return rv;
    }

    Mutex ddeLock( mMutexName );

    if ( ddeLock.Lock( MOZ_DDE_STOP_TIMEOUT ) ) {
        if ( mConversations == 0 ) {
            this->Quit();
        } else {
            *aResult = PR_FALSE;
        }

        ddeLock.Unlock();
    }
    else {
        // No DDE application name specified, but that's OK.  Just
        // forge ahead.
        *aResult = PR_TRUE;
    }

    return rv;
}

Here is the call graph for this function:


Friends And Related Function Documentation

MessageWindow [friend]

Definition at line 357 of file nsNativeAppSupportOS2.cpp.


Member Data Documentation

Definition at line 186 of file nsINativeAppSupport.idl.

Definition at line 352 of file nsNativeAppSupportOS2.cpp.

char * nsNativeAppSupportOS2::mAppName = nameBuffer [static, private]

Definition at line 428 of file nsNativeAppSupportOS2.cpp.

Definition at line 354 of file nsNativeAppSupportOS2.cpp.

Definition at line 339 of file nsNativeAppSupportOS2.cpp.

Definition at line 430 of file nsNativeAppSupportOS2.cpp.

Definition at line 429 of file nsNativeAppSupportOS2.cpp.

DWORD nsNativeAppSupportOS2::mInstance = 0 [static, private]

Definition at line 353 of file nsNativeAppSupportOS2.cpp.

Definition at line 73 of file nsNativeAppSupportBase.h.

char nsNativeAppSupportOS2::mMutexName = { 0 } [static, private]

Definition at line 355 of file nsNativeAppSupportOS2.cpp.

Definition at line 68 of file nsNativeAppSupportBase.h.

Definition at line 70 of file nsNativeAppSupportBase.h.

Definition at line 71 of file nsNativeAppSupportBase.h.

Definition at line 72 of file nsNativeAppSupportBase.h.

Definition at line 69 of file nsNativeAppSupportBase.h.

HSZ nsNativeAppSupportOS2::mTopics = { 0 } [static, private]

Definition at line 352 of file nsNativeAppSupportOS2.cpp.

Definition at line 356 of file nsNativeAppSupportOS2.cpp.

Definition at line 187 of file nsINativeAppSupport.idl.


The documentation for this class was generated from the following files: