nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsresult NS_MsgBuildSmtpUrl(nsIFileSpec * aFilePath,                            const char* aSmtpHostName,                             PRInt32 aSmtpPort,                            const char* aSmtpUserName,                             const char * aRecipients,                             nsIMsgIdentity * aSenderIdentity,                            nsIUrlListener * aUrlListener,                             nsIMsgStatusFeedback *aStatusFeedback,                            nsIInterfaceRequestor* aNotificationCallbacks,                            nsIURI ** aUrl){    // mscott: this function is a convience hack until netlib actually dispatches smtp urls.    // in addition until we have a session to get a password, host and other stuff from, we need to use default values....    // ..for testing purposes....    nsresult rv = NS_OK;    nsCOMPtr <nsISmtpUrl> smtpUrl (do_CreateInstance(kCSmtpUrlCID, &rv));    if (NS_SUCCEEDED(rv) && smtpUrl)    {        nsCAutoString urlSpec("smtp://");        if (aSmtpUserName)         {            nsXPIDLCString escapedUsername;            *((char **)getter_Copies(escapedUsername)) = nsEscape(aSmtpUserName, url_XAlphas);            urlSpec += escapedUsername;            urlSpec += '@';        }        urlSpec += aSmtpHostName;        if (!PL_strchr(aSmtpHostName, ':'))        {            urlSpec += ':';            urlSpec.AppendInt((aSmtpPort > 0) ? aSmtpPort : nsISmtpUrl::DEFAULT_SMTP_PORT);        }        if (urlSpec.get())        {            nsCOMPtr<nsIMsgMailNewsUrl> url = do_QueryInterface(smtpUrl);            url->SetSpec(urlSpec);            smtpUrl->SetRecipients(aRecipients);            smtpUrl->SetPostMessageFile(aFilePath);            smtpUrl->SetSenderIdentity(aSenderIdentity);            smtpUrl->SetNotificationCallbacks(aNotificationCallbacks);            nsCOMPtr<nsIPrompt> smtpPrompt(do_GetInterface(aNotificationCallbacks));            nsCOMPtr<nsIAuthPrompt> smtpAuthPrompt(do_GetInterface(aNotificationCallbacks));            if (!smtpPrompt || !smtpAuthPrompt)            {                nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));                if (wwatch) {                    if (!smtpPrompt)                        wwatch->GetNewPrompter(0, getter_AddRefs(smtpPrompt));                    if (!smtpAuthPrompt)                        wwatch->GetNewAuthPrompter(0, getter_AddRefs(smtpAuthPrompt));                }            }            smtpUrl->SetPrompt(smtpPrompt);                        smtpUrl->SetAuthPrompt(smtpAuthPrompt);            url->RegisterListener(aUrlListener);            if (aStatusFeedback)                url->SetStatusFeedback(aStatusFeedback);        }        rv = smtpUrl->QueryInterface(NS_GET_IID(nsIURI), (void **) aUrl);    }    return rv;}