Esempio n. 1
0
LPCTSTR CMessageFrame::GetWindowMenuTitle()
{
	static CString cs;
	CString csTitle = szLoadString( IDS_TITLE_NOSUBJECT );
	cs = m_bNews ? szLoadString( IDS_TITLE_ARTICLE ) : szLoadString( IDS_TITLE_MESSAGE );
	
	MWContext *pXPCX = GetMainContext()->GetContext();
	if ( pXPCX && pXPCX->title) {
		csTitle = fe_MiddleCutString(pXPCX->title, 40);
	}
	cs += csTitle;

	return cs;
}
Esempio n. 2
0
int CProfileNamePage::DoFinish()
{
    char path[BUFSZ],name[BUFSZ];
	int ret;
	XP_StatStruct statinfo; 

    if (!GetDlgItemText(IDC_PROFILE_NAME, name, BUFSZ)) {
		AfxMessageBox(szLoadString(IDS_INVALID_PROFILE_NAME),MB_OK);
		return FALSE;
	}

    if (GetDlgItemText(IDC_PROFILE_DIR, path, BUFSZ)) { 
		if (path[strlen(path)-1] == '\\') path[strlen(path)-1] = NULL;  // remove last slash...

		ret = _stat((char *) path, &statinfo);
		if (!ret) {
			// Directory already exists!
			if (AfxMessageBox(szLoadString(IDS_PROFDIR_EXISTS),MB_OKCANCEL) == IDCANCEL)
				return FALSE;
			else 
				m_pParent->m_bExistingDir = TRUE;
		}
		if(ret == -1) {
			// see if we can just create it
			char * slash = strchr(path,'\\');
			while (slash) {
				slash[0] = NULL;
				ret = CreateDirectory(path,NULL);
				slash[0] = '\\';
				if (slash+1) slash = strchr(slash+1,'\\');
			}
			ret = CreateDirectory(path,NULL);
			if (!ret) {
				AfxMessageBox(szLoadString(IDS_UNABLE_CREATE_DIR),MB_OK);
				return FALSE;
			}
		}
	} else {
		AfxMessageBox(szLoadString(IDS_INVALID_PROFILE_NAME),MB_OK);
		return FALSE;
	}

    if (GetDlgItemText(IDC_PROFILE_NAME, name, BUFSZ)) 
		login_CreateNewUserKey(name,path);
	m_pParent->m_pProfileName = name;
	m_pParent->m_pProfilePath = path;
	return TRUE;
}
Esempio n. 3
0
void CFE_AllConnectionsComplete(MWContext *pContext)	{

	if(ABSTRACTCX(pContext)->IsDestroyed())	{
		//	Don't allow this to happen if the context has been destroyed...
		TRACE("Context %p Destroyed :: AllConnectionsComplete Blocking\n", pContext);
		return;
	}

#ifdef MOZ_MAIL_NEWS
    if (IS_MESSAGE_COMPOSE(pContext)) {
		MSG_Pane *pPane = MSG_FindPane( pContext, MSG_COMPOSITIONPANE );
		ASSERT( pPane );
        MSG_MailCompositionAllConnectionsComplete ( pPane );
	}

	if (NET_IsOffline()) {
		FE_Progress(pContext, szLoadString(IDS_STATUS_OFFLINE));
	} else 
#endif   
    {
		//	Set the progress to be complete.
		FE_Progress(pContext, szLoadString(IDS_DOC_DONE));
	}

    ABSTRACTCX(pContext)->AllConnectionsComplete(pContext);
	FE_DeleteDNSList(pContext);

#ifdef EDITOR
#ifdef XP_WIN16    
    if( EDT_IS_EDITOR(pContext) ){
        // For some bizzare reason, we don't get proper focus 
        //   when starting an Edit frame+View in Win16
        // This fixes that
        ::SetFocus(PANECX(pContext)->GetPane());
    }
#endif
#endif

#ifdef DEBUG_WHITEBOX
	// AfxMessageBox("cfe.cpp: Try Again?");
	if (IS_MAIL_READER(pContext)) {
		if (QATestCaseStarted == FALSE) {
			QADoDeleteMessageEventHandler();
		}
	}
#endif
}
Esempio n. 4
0
// Called from mkhelp.c to get the standard location of the NetHelp folder as a URL
char * FE_GetNetHelpDir()
{
	CString		nethelpDirectory;
	
#ifdef XP_WIN32
	CString	regKey = FEU_GetCurrentRegistry(szLoadString(IDS_NETHELP_REGISTRY));
    CString installDirectory = FEU_GetInstallationDirectory(regKey, szLoadString(IDS_NETHELP_DIRECTORY)) + "\\";
#else ifdef XP_WIN16
	CString installDirectory = FEU_GetInstallationDirectory(szLoadString(IDS_NETSCAPE_REGISTRY), szLoadString(IDS_NETHELP_DIRECTORY)) + "\\";
#endif 

	WFE_ConvertFile2Url(nethelpDirectory, installDirectory);
	
	if (nethelpDirectory.IsEmpty()) {
		return NULL;
	} else {
		return XP_STRDUP(nethelpDirectory);
	}
}
Esempio n. 5
0
/*  Free the object
**  ---------------
**
*/
extern "C"  void 
disk_stream_complete (NET_StreamClass *stream)
{
    DataObject * data = (DataObject *)stream->data_object;	

    if(!data)
        return;

    if(data->fp) {
        fclose(data->fp);
        data->fp = NULL;
    }

    FE_Progress(data->context, szLoadString(IDS_DOC_LOAD_COMPLETE));

    if(FEU_Execute(data->context, data->command, data->params)) {
        FE_Progress(data->context, szLoadString(IDS_SPAWNING_EXTERNAL_VIEWER));
    }

    if(data->address) {
        XP_FREE(data->address);
        data->address = NULL;
    }

    if(data->filename) {
        XP_FREE(data->filename);
        data->filename = NULL;
    }

    if(data->params) {
        XP_FREE(data->params);
        data->params = NULL;
    }

    delete data;
    return;
}
Esempio n. 6
0
BOOL CProfileNamePage::UpdateData(BOOL bValidate) 
{
    char path[BUFSZ];

	if (bValidate) {
	    if (GetDlgItemText(IDC_PROFILE_DIR, path, BUFSZ)) {
			if (!path || !path[0]) {
				AfxMessageBox(szLoadString(IDS_PROFILE_EMPTY));
				return FALSE;
			}
		}
		else return FALSE;
	}
	return TRUE;
}
BOOL CChooseFolderDialog::OnInitDialog()
{
	BOOL ret = CDialog::OnInitDialog();

	if (m_nTypeID == TYPE_SENTNEWS)
		SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_NEWS_MSG));
	else if (m_nTypeID == TYPE_DRAFT)
		SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_DRAFTS));
	else if (m_nTypeID == TYPE_TEMPLATE)
		SetDlgItemText(IDC_STATIC_TITLE, szLoadString(IDS_COPY_TEMPLATES));

	CString formatString, defaultTitle;
	formatString.LoadString(IDS_SPECIAL_FOLDER);
	defaultTitle.Format(LPCTSTR(formatString), XP_GetString(m_nDefaultID));
	SetDlgItemText(IDC_RADIO_SENT, LPCTSTR(defaultTitle));

	if ( ret ) {
		// Subclass Server combo
		m_ServerCombo.SubclassDlgItem( IDC_COMBO_SERVERS, this );
		m_ServerCombo.NoPrettyName();
		m_ServerCombo.PopulateMailServer( WFE_MSGGetMaster() );
		if (SetServerComboCurSel(m_ServerCombo.GetSafeHwnd(), 
			m_pFolderPath, m_nDefaultID))
			CheckDlgButton(IDC_RADIO_SENT, TRUE);
		else
			CheckDlgButton(IDC_RADIO_OTHER, TRUE);

		// Subclass folder combo
		m_FolderCombo.SubclassDlgItem( IDC_COMBO_FOLDERS, this );
		m_FolderCombo.PopulateMail( WFE_MSGGetMaster() );
		SetFolderComboCurSel(m_FolderCombo.GetSafeHwnd(), 
			m_pFolderPath, m_nDefaultID);
	}
	
	return ret;
}
Esempio n. 8
0
void CBigIcon::DisplayCopyright(void)
{
	CClientDC	dc(this);
	CFont*		pOldFont = dc.SelectObject(&m_copyrightFont);
	CRect		rect;
	LPCSTR lpszCopyright = szLoadString(IDS_COPYRIGHT);
	// The splash screen background is black, use light grey text
    dc.SetBkColor(RGB(0,0,0));
    dc.SetTextColor(RGB(192, 192, 192));

	CenterText(dc, lpszCopyright, 237);

	// Clean up
	dc.SetBkColor(RGB(255,255,255));
    dc.SetTextColor(RGB(0,0,0));
	dc.SelectObject(pOldFont);
}
Esempio n. 9
0
int CMessageFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	int res = CMailNewsFrame::OnCreate(lpCreateStruct);

	// Set up toolbar
	m_pChrome->SetWindowTitle(XP_AppName);

	//I'm hardcoding string since I don't want it translated.
	m_pChrome->CreateCustomizableToolbar("Messages"/*ID_MESSAGES*/, 3, TRUE);
	CButtonToolbarWindow *pWindow;
	BOOL bOpen, bShowing;

	int32 nPos;

	//I'm hardcoding because I don't want this translated
	m_pChrome->LoadToolbarConfiguration(ID_NAVIGATION_TOOLBAR, CString("Navigation_Toolbar"), nPos, bOpen, bShowing);

	LPNSTOOLBAR pIToolBar;
	m_pChrome->QueryInterface( IID_INSToolBar, (LPVOID *) &pIToolBar );
	if ( pIToolBar ) {
		pIToolBar->Create( this, WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|CBRS_TOP );
		pIToolBar->SetToolbarStyle( theApp.m_pToolbarStyle);
		SwitchUI();
		pWindow = new CButtonToolbarWindow(CWnd::FromHandlePermanent(pIToolBar->GetHWnd()), theApp.m_pToolbarStyle, 43, 27, eLARGE_HTAB);
		m_pChrome->GetCustomizableToolbar()->AddNewWindow(ID_NAVIGATION_TOOLBAR, pWindow,nPos, 50, 37, 0, CString(szLoadString(ID_NAVIGATION_TOOLBAR)),theApp.m_pToolbarStyle, bOpen, FALSE);
		m_pChrome->ShowToolbar(ID_NAVIGATION_TOOLBAR, bShowing);

		pIToolBar->Release();
	}

	m_pInfoBar = new CMessageInfoBar;
	m_pInfoBar->Create( this, m_pPane );

	//I'm hardcoding because I don't want this translated
	m_pChrome->LoadToolbarConfiguration(ID_LOCATION_TOOLBAR, CString("Location_Toolbar"), nPos, bOpen, bShowing);

	CToolbarWindow *pToolWindow = new CToolbarWindow(m_pInfoBar, theApp.m_pToolbarStyle, 27, 27, eSMALL_HTAB);
	m_pChrome->GetCustomizableToolbar()->AddNewWindow(ID_LOCATION_TOOLBAR, pToolWindow,nPos, 27, 27, 0, CString(szLoadString(ID_LOCATION_TOOLBAR)),theApp.m_pToolbarStyle, bOpen, FALSE);
	m_pChrome->ShowToolbar(ID_LOCATION_TOOLBAR, bShowing);

	m_barStatus.Create(this, TRUE, TRUE);
	m_barStatus.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
	LPNSSTATUSBAR pIStatusBar = NULL;
	m_pChrome->QueryInterface( IID_INSStatusBar, (LPVOID *) &pIStatusBar );
	if ( pIStatusBar ) {
		pIStatusBar->Attach(&m_barStatus);
		pIStatusBar->Release();
	}

	return res;
}
Esempio n. 10
0
/* this is the main converter for external viewers.
 * it returns the stream object as well
 * as a data object that it can reference 
 * internally to save the state of the document
 */
NET_StreamClass *external_viewer_disk_stream(int iFormatOut, void *pDataObj, URL_Struct *pUrl, MWContext *pContext)	
{
    ASSERT(pUrl);
    ASSERT(pUrl->address);

	//	Lookup the helper app, if one exists.
	//	If not found, create one on the fly.
	CNetscapeApp *pNetscape = (CNetscapeApp *)AfxGetApp();
	CHelperApp *pHelper;
	XP_Bool isNewHelper = FALSE;

	if(0 == pNetscape->m_HelperListByType.Lookup(pUrl->content_type, (CObject *&)pHelper))	{
		//	couldn't find one.
		//	create the new mime type.
		CString csText = pUrl->content_type;

		//	If there's no slash, just send the type as the file type
		//		(this usually only happens on server error, but we
		//		should still behave ourselves).
		int iSlash = csText.Find('/');
		if(iSlash != -1)	{
			// this mess splits the string into the stuff before the slash and
			//   the stuff after the slash
			pHelper = fe_AddNewFileFormatType(csText.Left(iSlash),
				csText.Right(csText.GetLength() - iSlash - 1));
			isNewHelper = TRUE;
		}
		else	{
			pHelper = fe_AddNewFileFormatType(csText, "");
			isNewHelper = TRUE;
		}
	}

	//	The helper app is now defined for the mime type in any case.
	//	See how it is to be handled.
	BOOL bExternal = FALSE;
	BOOL bSave = FALSE;
	BOOL bMoreInfo = FALSE;

	switch(pHelper->how_handle)	{
	case HANDLE_UNKNOWN:	{
		//	See what this is supposed to do via user input.
		CUnknownTypeDlg dlgUnknown(GetFrame(pContext)->GetFrameWnd(), pUrl->content_type, pHelper);
		int iDlg = dlgUnknown.DoModal();
		if(iDlg == IDCANCEL)	{
			//	User hit cancel.  Abort the load.
			if (pHelper && pHelper->cd_item && isNewHelper) {
				if (XP_ListRemoveObject(cinfo_MasterListPointer(), pHelper->cd_item)) {
					if (pHelper->cd_item) {
						if (pHelper->cd_item->ci.type) {
							theApp.m_HelperListByType.RemoveKey(pHelper->cd_item->ci.type);
							XP_FREE( pHelper->cd_item->ci.type );
						}
						XP_FREE (pHelper->cd_item);
					}
					delete pHelper;
				}
			}
			return(NULL);
		}
		else if(iDlg == HANDLE_EXTERNAL)	{
            char buf[256];

			bExternal = TRUE;

			// We need to indicate that this is a user-defined MIME type. If we
			// don't, then we won't remember it the next time the Navigator is run
            sprintf(buf,"TYPE%d",theApp.m_iNumTypesInINIFile);
            theApp.m_iNumTypesInINIFile++;
            theApp.WriteProfileString("Viewers", buf, pUrl->content_type);
            pHelper->bNewType = FALSE;

		}
		else if(iDlg == HANDLE_SAVE)	{
			bSave = TRUE;
		}
		else if(iDlg == HANDLE_MOREINFO)	{
			bMoreInfo = TRUE;
		}
		break;
	}
	case HANDLE_EXTERNAL:	
	case HANDLE_BY_OLE: {
		bExternal = TRUE;
		break;
	}
	case HANDLE_SHELLEXECUTE:	{
		bExternal = TRUE;
		break;
	}
	case HANDLE_SAVE:	{
		bSave = TRUE;
		break;
	}
	default:	{
		//	Shouldn't ever be other than the above types at this
		//		point!
		ASSERT(0);
		return(NULL);
	}
	}

	//	We know that we are either saving or spawning an external
	//		viewer at this point.
	NET_StreamClass *pRetval = NULL;
	if (bSave == TRUE)	{
		return ExternalFileSave(iFormatOut, pUrl, pContext);
	} else if (bExternal == TRUE)	{
		//	Prompt the user for a file name.
		//  Security rist to let path information in externally provided
		//      filename (content disposition, filename =)
		// XXX This code could be cleaned up -- eliminate aFileName 
		// and just use what was allocated by WH_TempFileName.

		char aFileName[_MAX_PATH];
		char *pSuggestedName = NULL;
		BOOL bUseContentName = FALSE;
        if (pUrl->content_name != NULL &&
            strstr(pUrl->content_name, "../") == NULL &&
            strstr(pUrl->content_name, "..\\") == NULL) {
			bUseContentName = TRUE;
		}
		else {
			pSuggestedName = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
		}
		char *pDestination;

		ASSERT(pNetscape->m_pTempDir);
		if(pNetscape->m_pTempDir != NULL && pSuggestedName != NULL)	{
			sprintf(aFileName, "%s\\%s", pNetscape->m_pTempDir, pSuggestedName);
			XP_FREE(pSuggestedName);
			pSuggestedName = NULL;
			pDestination = aFileName;
		}
		else	{
            char aExt[_MAX_EXT];
            size_t stExt = 0;
            DWORD dwFlags = 0;
            const char *pName = pUrl->address;
            
            if(bUseContentName) {
                pName = pUrl->content_name;
            }
#ifdef XP_WIN16
            dwFlags |= EXT_DOT_THREE;
#endif
            aExt[0] = '\0';
            stExt = EXT_Invent(aExt, sizeof(aExt), dwFlags, pName, pUrl->content_type);
            char *pTemp = WH_TempFileName(xpTemporary, "M", aExt);
            if(pTemp) {
                strcpy(aFileName, pTemp);
                XP_FREE(pTemp);
                pTemp = NULL;
            }
            else {
                aFileName[0] = '\0';
            }
		}
		pDestination = aFileName;


		//	Figure out the application that we'll be spawning.
		//	Strip off odd things at the right hand side.
		CString csCommand;
        if(pHelper->how_handle == HANDLE_EXTERNAL)  {
            csCommand = pHelper->csCmd;
		    int iStrip = csCommand.ReverseFind('%');
		    if(iStrip > 0)	{
			    csCommand = csCommand.Left(iStrip - 1);
		    }
        }

		//	See if it's actually OK to spawn this application.
        CString csSpawn = csCommand;
        BOOL bShellExecute = FALSE;
        if(pHelper->how_handle == HANDLE_SHELLEXECUTE ||
			pHelper->how_handle == HANDLE_BY_OLE) {
            //  Shell execute type, figure out the exe.
            char aExe[_MAX_PATH];
            memset(aExe, 0, sizeof(aExe));
            if(FEU_FindExecutable(pDestination, aExe, FALSE)) {
                csSpawn = aExe;
                if(pHelper->how_handle == HANDLE_SHELLEXECUTE) {
                    bShellExecute = TRUE;
                }
            }
            else     {
                csSpawn.Empty();
            }
        }

		// See whether the user wants to be prompted before we open the file
		if (pContext->type != MWContextPrint && theApp.m_pSpawn->PromptBeforeOpening((LPCSTR)csSpawn)) {
			BOOL	bFree = FALSE;
			LPCSTR	lpszFilename = NULL;

			if (pUrl->content_name != NULL &&
				strstr(pUrl->content_name, "../") == NULL &&
				strstr(pUrl->content_name, "..\\") == NULL) {
				lpszFilename = pUrl->content_name;
			}

			if (!lpszFilename) {
				lpszFilename = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
				bFree = TRUE;
			}
			char* docExt[1];
			const char * ptr1 = lpszFilename;
			int type = NET_URL_Type(pUrl->address);
			BOOL canHandleOLE = FALSE;

			if ((type != MAILBOX_TYPE_URL) && (type !=NEWS_TYPE_URL) && (type != IMAP_TYPE_URL) ) {
				docExt[0] = FE_FindFileExt((char*)ptr1);
				if (docExt[0])
					canHandleOLE = fe_CanHandleByOLE(docExt, 1);
			}
			CLaunchHelper	dlg(lpszFilename, (LPCSTR)csSpawn, canHandleOLE, GetFrame(pContext)->GetFrameWnd());
	
			if (bFree)
				XP_FREE((LPVOID)lpszFilename);

			// Initialize the dialog to some defaults.
			dlg.m_bAlwaysAsk = TRUE;
			//dlg.m_nAction = HELPER_SAVE_TO_DISK; //Old statement CRN_MIME
			dlg.m_nAction = (pHelper->how_handle == HANDLE_SHELLEXECUTE) ? HELPER_OPEN_IT : HELPER_SAVE_TO_DISK; //New Statement. Set m_nAction based on pHelper->how_handle... CRN_MIME
			dlg.m_bHandleByOLE = fe_IsHandleByOLE(pUrl->content_type);
	
			// Ask the user
			if (dlg.DoModal() == IDCANCEL)
				return NULL;
	
			// See if they no longer want to be asked
			if (!dlg.m_bAlwaysAsk) {
				if (dlg.m_nAction == HELPER_SAVE_TO_DISK) {
					// User wants to just save to disk
					pHelper->how_handle = HANDLE_SAVE;
					pHelper->csCmd = MIME_SAVE;
					pHelper->bChanged = TRUE;
				
				} else {
					ASSERT(dlg.m_nAction == HELPER_OPEN_IT);
					theApp.m_pSpawn->SetPromptBeforeOpening((LPCSTR)csSpawn, FALSE);
				}
			}

			// Check whether the user wants to launch the application or save it
			// do disk
			if (dlg.m_nAction == HELPER_SAVE_TO_DISK)
				return ExternalFileSave(iFormatOut, pUrl, pContext);
			else { // open it case.
				// user want to handle this by OLE.
				if (dlg.m_bHandleByOLE) {
					fe_SetHandleByOLE(pUrl->content_type, pHelper, TRUE);
				}
				// Since mail and new will not be able launch using OLE inplace server, so we should not try to change helper app
				// how_handle here.
				else if (pHelper->how_handle == HANDLE_BY_OLE) {
					fe_SetHandleByOLE(pUrl->content_type, pHelper, FALSE);
				}
			}
		}
		// MWH -- see could we handle this via OLE.
		if ((iFormatOut == FO_PRESENT || iFormatOut == FO_PRINT)  &&
			(pHelper->how_handle == HANDLE_BY_OLE) &&
				FE_FileType(pUrl->address, pUrl->content_type, pUrl->content_encoding)) {

			// can be handle by OLE.
				return OLE_ViewStream(iFormatOut, pDataObj, pUrl,pContext);
		}

		//	It's OK to spawn this application.
		//	Attempt to split it off into a seperate context.
		if(bShellExecute) {
		    pRetval = CSaveCX::ViewUrlObject(pUrl, NULL);
		}
		else {
		    pRetval = CSaveCX::ViewUrlObject(pUrl, csSpawn);
		}
		if(pRetval != NULL)	{
			return(pRetval);
		}
		//	Couldn't split off into a new context.
		//	Handle as was handled before.

		//	We have a destination file name.
		FILE *pSink = XP_FileOpen(pDestination, xpTemporary, "wb");
		if(pSink == NULL)	{
			FE_Alert(pContext, szLoadString(IDS_FAILED_CREATE_TEMP_FILE));
			XP_FREE(pDestination);
			return(NULL);
		}

		//	Create the data object that will be passed along down
		//		the stream.
		DataObject *pMe = new DataObject;
        if(!pMe)
            return(NULL);

		memset(pMe, 0, sizeof(DataObject));
		pMe->how_handle = pHelper->how_handle;
		pMe->fp = pSink;
		pMe->context = pContext;
		pMe->format_out = iFormatOut;
		pMe->filename = pDestination;
		pMe->content_length = pUrl->content_length < 0 ? 0 : pUrl->content_length;
		pMe->cur_loc = 0;
		StrAllocCopy(pMe->address, pUrl->address);
		StrAllocCopy(pMe->format_in, pUrl->content_type);

		//	The spawn command.
        if(pMe->how_handle == HANDLE_EXTERNAL)  {
            pMe->params = XP_STRDUP(pDestination);
        }
        else if(pMe->how_handle == HANDLE_SHELLEXECUTE)    {
		    csCommand += pDestination;
        }
        else if(pMe->how_handle == HANDLE_BY_OLE)    {
		    csCommand += pDestination;
        }
		pMe->command = XP_STRDUP(csCommand);

		//	Progress.
		FE_SetProgressBarPercent(pContext, 0);

		//	Delete the file on exit.
		FE_DeleteFileOnExit(pDestination, pUrl->address);

		//	Set the waiting mode???
		FE_EnableClicking(pContext);

		//	Create the stream.
		pRetval = NET_NewStream("ServeAndView",
                    			disk_stream_write,
                    			disk_stream_complete,
                    			disk_stream_abort,
                    			write_ready,
                    			pMe,
                    			pContext);

	}
	if(bMoreInfo == TRUE)	{
		char * url = NULL;
		PREF_CopyConfigString("internal_url.more_info_plugin.url",&url);
		if (url) {
			CString csUrlAddress = url;
			csUrlAddress += "?";
			csUrlAddress += pUrl->content_type;
			(ABSTRACTCX(pContext))->NormalGetUrl(csUrlAddress, pUrl->address, csUrlAddress);
			XP_FREE(url);
		}
    }

	//	Return the stream that was created.
	return(pRetval);
}
Esempio n. 11
0
static NET_StreamClass *
ExternalFileSave(int iFormatOut, URL_Struct *pUrl, MWContext *pContext)
{
	//
	// While we have a pointer to the original frame window query
	//   for a filename
	//
	char 			*pDestination;
	char 			*pSuggested = NULL;
	NET_StreamClass *pRetval = NULL;

	//	Prompt the user for a file name.
	//  Security rist to let path information in externally provided
	//      filename (content disposition, filename =)
	if (pUrl->content_name != NULL &&
		strstr(pUrl->content_name, "../") == NULL &&
		strstr(pUrl->content_name, "..\\") == NULL) {
		// Make a copy of the name, because that's what fe_URLtoLocalName() does
		// and the code below is going to XP_FREE pSuggested
		pSuggested = XP_STRDUP(pUrl->content_name);
	}
	if (!pSuggested)
		pSuggested = fe_URLtoLocalName(pUrl->address, pUrl->content_type);
#ifdef XP_WIN16
	char dosName[13];
	FE_LongNameToDosName(dosName, pSuggested);
	pDestination = wfe_GetSaveFileName(GetFrame(pContext)->GetFrameWnd()->m_hWnd, szLoadString(IDS_SAVE_AS), dosName, NULL);
#else
	pDestination = wfe_GetSaveFileName(GetFrame(pContext)->GetFrameWnd()->m_hWnd, szLoadString(IDS_SAVE_AS), pSuggested, NULL);
#endif
	if(pSuggested != NULL)	{
		XP_FREE(pSuggested);
	}
	if(pDestination == NULL)	{
		return(NULL);
	}

	//	We're going to be saving this stream.
	//	Check to see if we should attempt to save the file in the
	//		old fashion, or in the new external contexts.
	if(NET_IsSafeForNewContext(pUrl) != FALSE)	{
		//	Attempt to split it off into a new context.
		pRetval = CSaveCX::SaveUrlObject(pUrl, NULL, pDestination);

	} else {
		//	We need to continue to use the old method of saving.

		//	We have a destination file name.
		FILE *pSink = XP_FileOpen(pDestination, xpTemporary, "wb");
		if(pSink == NULL)	{
			FE_Alert(pContext, szLoadString(IDS_FAILED_CREATE_TEMP_FILE));
			XP_FREE(pDestination);
			return(NULL);
		}

		//	Create the data object that will be passed along down
		//		the stream.
		DataObject *pMe = new DataObject;
		if(!pMe)
			return(NULL);

		memset(pMe, 0, sizeof(DataObject));
		pMe->how_handle = HANDLE_SAVE;
		pMe->fp = pSink;
		pMe->context = pContext;
		pMe->format_out = iFormatOut;
		pMe->filename = pDestination;
		pMe->content_length = pUrl->content_length < 0 ? 0 : pUrl->content_length;
		pMe->cur_loc = 0;
		StrAllocCopy(pMe->address, pUrl->address);
		StrAllocCopy(pMe->format_in, pUrl->content_type);

		//	Progress.
		FE_SetProgressBarPercent(pContext, 0);

		//	Set the waiting mode???
		FE_EnableClicking(pContext);

		//	Create the stream.
		pRetval = NET_NewStream("ServeAndSave",
								disk_stream_write,
								disk_stream_complete,
								disk_stream_abort,
								write_ready,
								pMe,
								pContext);

		if(!pRetval)
			return(NULL);
	}

	return pRetval;
}