示例#1
1
BOOL CCpDialog::OnInitDialog()
{
	CString strAppRootFolder = GetHomeFolder() + String(GetFolderId());

	CString strContentRootFolder;
	CRegKey regkey;
	if (regkey.Open(HKEY_CURRENT_USER, REGKEY_APP) == ERROR_SUCCESS)
	{
		ULONG nLen = 255;
		char* pszValue = new char[nLen+1];

		*pszValue = 0;
		nLen = 256;
		if (regkey.QueryStringValue(REGVAL_CONTENT_FOLDER, pszValue, &nLen) == ERROR_SUCCESS)
		{
			pszValue[nLen] = 0;
			strContentRootFolder = CString(pszValue);
		}

		delete [] pszValue;
	}

	if (strContentRootFolder.IsEmpty())
		strContentRootFolder = GetHomeFolder() + String(IDS_CONTENT_FOLDER);

	DWORD dwCount = CheckForUiUpdates(strAppRootFolder);
	CheckForNewContent(strContentRootFolder, strAppRootFolder, (dwCount > 0)/*bForceCreate*/);

	// Update the variables.xsl and linelist.xml files
	SaveAppVariablesFile(strContentRootFolder, strAppRootFolder);
	SaveContentVariablesFile(strContentRootFolder, strAppRootFolder);

	CString strCaption;
	strCaption.LoadString(GetTitleId());
	SetWindowText(strCaption);

	// Initialize the url prior to calling CDHtmlDialog::OnInitDialog()
	if (m_strCurrentUrl.IsEmpty())
		m_strCurrentUrl = "about:blank";

	CDHtmlDialog::OnInitDialog();

	// This magically makes the scroll bars appear and dis-allows text selection
	DWORD dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_THEME | DOCHOSTUIFLAG_DIALOG; // DOCHOSTUIFLAG_NO3DOUTERBORDER;
	SetHostFlags(dwFlags);

	// Add "About..." menu item to system menu.
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(false);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icons for this dialog
	SetIcon(m_hIcon, true);		// Set big icon
	SetIcon(m_hIcon, false);	// Set small icon

	// Set the window size and position
	CRect rect;
	rect.SetRect(0, 0, 800, 600);
	if (0) // Restore the saved window size and position
	{
		DWORD dwSize = sizeof(rect);
		regkey.QueryBinaryValue(REGVAL_LOCATION, &rect, &dwSize);

		//j Someday, clip the rect to the display
		SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
	}
	else
	{
		SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
		CenterWindow();
	}

	CString strHomePage = strAppRootFolder + String(IDS_HOME_PAGE);
	if (FileExists(strHomePage))
		Navigate(strHomePage);

	ShowWindow(SW_NORMAL);

	DragAcceptFiles(false);

	return true;  // return TRUE  unless you set the focus to a control
}
示例#2
0
HRESULT CCpDialog::WindowOpen(IHTMLElement* pElement, int l, int t, int w, int h, LPCSTR pstrName)
{
	if (!pElement)
		return E_FAIL;

	CComBSTR bstrURL;
	pElement->get_className(&bstrURL);
	CString strURL(bstrURL);
	int iProtocol = strURL.Find(':');
	if (iProtocol < 0 || iProtocol > 5)
	{
		CString strAppRootFolder = GetHomeFolder() + String(GetFolderId());
		strURL = strAppRootFolder + strURL;
	}

	// Get the desired window size and location
	if (l < 0) l = (::GetSystemMetrics(SM_CXSCREEN) - w) / 2;
	if (l < 0) l = 0;
	if (t < 0) t = (::GetSystemMetrics(SM_CYSCREEN) - h) / 2;
	if (t < 0) t = 0;

	RECT Rect = {l, t, l+w, t+h};
	CWorkspaceDialog* pWorkspace = CWorkspaceDialog::CreateModeless(GetDesktopWindow()/*pParent*/, strURL, &Rect, pstrName);
	if (pWorkspace)
		m_WorkspaceArray.Add(pWorkspace);
	
	return S_OK;
}
示例#3
0
bstr_t GetProgramFilesPath()
{
	PWSTR path;

	SHGetKnownFolderPath(GetFolderId(), 0, nullptr, &path);

	bstr_t ret = path;
	CoTaskMemFree(path);

	return ret;
}
// <qmail>
// -----------------------------------------------------------------------------
// CFSMailMessage::AddNewAttachmentL
// -----------------------------------------------------------------------------
EXPORT_C TInt CFSMailMessage::AddNewAttachmentL( const TDesC& aFilePath,
                                                 MFSMailRequestObserver& aOperationObserver)
{
    NM_FUNCTION;
    
    TFSPendingRequest request;
  
    if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
        {
        // init asynchronous request
        request = iRequestHandler->InitAsyncRequestL( GetMessageId().PluginId(),
                                                      aOperationObserver );
        
        MFSMailRequestObserver* observer = request.iObserver;
        
        // use recognizer to find out ContentType 
        RApaLsSession apaSession;
        TDataRecognitionResult dataType;
        TBufC8<KMaxDataTypeLength> buf;
        User::LeaveIfError(apaSession.Connect());
        User::LeaveIfError(apaSession.RecognizeData(aFilePath, buf, dataType));
        apaSession.Close();

        // Create new message part with correct Content-Type
        TBuf<KMaxDataTypeLength> contentType;
        contentType.Copy(dataType.iDataType.Des());

        TRAPD( err, plugin->NewChildPartFromFileL( 
            GetMailBoxId(),
            GetFolderId(),
            GetMessageId(),
            GetPartId(),
            contentType,
            aFilePath,
            *observer,
            request.iRequestId) );

        if( err != KErrNone )
            {
            iRequestHandler->CompleteRequest( request.iRequestId );
            User::Leave( err );
            }
        }    
    else
        {
        User::Leave( KErrNotFound );
        }

    return request.iRequestId;
}
// -----------------------------------------------------------------------------
// CFSMailMessage::AddNewAttachmentL
// -----------------------------------------------------------------------------
EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL( RFile& aFile,
                                                                const TDesC8& aMimeType )
    {
    NM_FUNCTION;
    CFSMailMessagePart* newPart(NULL);
    if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
        {
        TBuf<KMaxDataTypeLength> contentType;
        if(aMimeType.Length() > 0)
            {
            // use user given content type
            contentType.Copy(aMimeType);
            }
        else
            {
            // try to find out content type using recognizers
            RApaLsSession apaSession;
            TDataRecognitionResult dataType;
            User::LeaveIfError(apaSession.Connect());
            User::LeaveIfError(apaSession.RecognizeData(aFile, dataType));
            apaSession.Close();
            contentType.Copy(dataType.iDataType.Des());
            }
        // get file name
        TFileName fileName;
        aFile.FullName( fileName );
        // get new part from plugin
        newPart = plugin->NewChildPartFromFileL(    GetMailBoxId(),
                                                    GetFolderId(),
                                                    GetMessageId(),
                                                    GetPartId(),
                                                    contentType,
                                                    aFile );
        if (newPart)
            {
            CleanupStack::PushL(newPart);
            // set attachment name
            newPart->SetAttachmentNameL(fileName);
            // store new message part
            newPart->SaveL();
            // set flag
            SetFlag(EFSMsgFlag_Attachments);
            CleanupStack::Pop(newPart);
            }
        }
    return newPart;
    }
// -----------------------------------------------------------------------------
// CFSMailMessage::AddNewAttachmentL
// -----------------------------------------------------------------------------
EXPORT_C CFSMailMessagePart* CFSMailMessage::AddNewAttachmentL(	const TDesC& aFilePath,
																const TFSMailMsgId /*aInsertBefore*/ )
    {
    NM_FUNCTION;

    CFSMailMessagePart* newPart(NULL);
  
    if(CFSMailPlugin* plugin = iRequestHandler->GetPluginByUid(GetMessageId()))
        {
        // use recognizer to find out ContentType 
        RApaLsSession apaSession;
        TDataRecognitionResult dataType;
        TBufC8<KMaxDataTypeLength> buf;
        User::LeaveIfError(apaSession.Connect());
        User::LeaveIfError(apaSession.RecognizeData(aFilePath, buf, dataType));
        apaSession.Close();

        // Create new message part with correct Content-Type
        TBuf<KMaxDataTypeLength> contentType;
        contentType.Copy(dataType.iDataType.Des());
        newPart = plugin->NewChildPartFromFileL(  GetMailBoxId(),
                            GetFolderId(),
                            GetMessageId(),
                            GetPartId(),
                            contentType,
                            aFilePath );
        if (newPart)
            {
            CleanupStack::PushL(newPart);
            // set attachment name
            newPart->SetAttachmentNameL(aFilePath);
            // store new message part
            newPart->SaveL();
            // set flag
            SetFlag(EFSMsgFlag_Attachments);
            CleanupStack::Pop(newPart);
            }
        }
    return newPart;
}