prompt service moved to external component

import/tags/KMELEON_0_4
doozan 22 years ago
parent 91aec92391
commit e796040599
  1. 130
      k-meleon/BrowserFrameGlue.cpp
  2. 15
      k-meleon/BrowserImpl.cpp
  3. 2
      k-meleon/BrowserImpl.h
  4. 4
      k-meleon/BrowserImplContentLstnr.cpp
  5. 254
      k-meleon/BrowserImplPrompt.cpp
  6. 2
      k-meleon/BrowserView.cpp
  7. 228
      k-meleon/Dialogs.cpp
  8. 97
      k-meleon/Dialogs.h
  9. 24
      k-meleon/IBrowserFrameGlue.h
  10. 32
      k-meleon/KMeleon.dsp
  11. 12
      k-meleon/KMeleon.dsw
  12. 2
      k-meleon/MenuParser.cpp
  13. 57
      k-meleon/MfcEmbed.cpp
  14. 1
      k-meleon/MfcEmbed.h
  15. 61
      k-meleon/MfcEmbed.rc
  16. 4
      k-meleon/Preferences.cpp
  17. 163
      k-meleon/bmp_menu/bmp_menu.cpp
  18. 6
      k-meleon/bmp_menu/bmp_menu.dsp
  19. 242
      k-meleon/components/Dialogs.cpp
  20. 126
      k-meleon/components/Dialogs.h
  21. 136
      k-meleon/components/Dialogs.rc
  22. 389
      k-meleon/components/PromptService.cpp
  23. 44
      k-meleon/components/PromptService.h
  24. 150
      k-meleon/components/components.dsp
  25. 26
      k-meleon/components/resource.h
  26. 45
      k-meleon/components/stdafx.h
  27. 8
      k-meleon/fullscreen/fullscreen.dsp
  28. 10
      k-meleon/history/history.dsp
  29. 9
      k-meleon/ie_favorites/ie_favorites.dsp
  30. 8
      k-meleon/kmeleon_winamp/kmeleon_winamp.dsp
  31. 6
      k-meleon/macros/macros.cpp
  32. 8
      k-meleon/macros/macros.dsp
  33. 2
      k-meleon/ns_bookmarks/ns_bookmarks.cpp
  34. 13
      k-meleon/ns_bookmarks/ns_bookmarks.dsp
  35. 80
      k-meleon/rebar_menu/rebar_menu.cpp
  36. 4
      k-meleon/rebar_menu/rebar_menu.dsp
  37. BIN
      k-meleon/res/on.ico
  38. BIN
      k-meleon/res/oncheck.ico
  39. 6
      k-meleon/version.h

@ -411,134 +411,8 @@ void CBrowserFrame::BrowserFrameGlueObj::ShowContextMenu(PRUint32 aContextFlags,
}
void CBrowserFrame::BrowserFrameGlueObj::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
HWND CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameNativeWnd()
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_OK | MB_ICONEXCLAMATION);
}
void CBrowserFrame::BrowserFrameGlueObj::Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
int iChoice = pThis->MessageBox(W2T(text), W2T(dialogTitle), MB_YESNO | MB_ICONEXCLAMATION);
*retval = (iChoice == IDYES) ? PR_TRUE : PR_FALSE;
}
void CBrowserFrame::BrowserFrameGlueObj::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **promptText,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CPromptDialog dlg(pThis, W2T(dialogTitle), W2T(text),
(promptText && *promptText) ? W2T(*promptText) : nsnull,
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
if(dlg.DoModal() == IDOK)
{
// Get the value entered in the editbox of the PromptDlg
if (promptText && *promptText) {
nsMemory::Free(*promptText);
*promptText = nsnull;
}
nsString csPromptEditValue;
csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0));
*promptText = csPromptEditValue.ToNewUnicode();
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
}
void CBrowserFrame::BrowserFrameGlueObj::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CPromptPasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
(password && *password) ? W2T(*password) : nsnull,
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
if(dlg.DoModal() == IDOK)
{
// Get the password entered
if (password && *password) {
nsMemory::Free(*password);
*password = nsnull;
}
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
if(checkboxState)
*checkboxState = dlg.m_bCheckBoxValue;
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
}
void CBrowserFrame::BrowserFrameGlueObj::PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval)
{
METHOD_PROLOGUE(CBrowserFrame, BrowserFrameGlueObj)
USES_CONVERSION;
CPromptUsernamePasswordDialog dlg(pThis, W2T(dialogTitle), W2T(text),
(username && *username) ? W2T(*username) : nsnull,
(password && *password) ? W2T(*password) : nsnull,
(checkboxState != nsnull), W2T(checkboxMsg), checkboxState ? *checkboxState : 0);
if(dlg.DoModal() == IDOK)
{
// Get the username entered
if (username && *username) {
nsMemory::Free(*username);
*username = nsnull;
}
nsString csUserName;
csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0));
*username = csUserName.ToNewUnicode();
// Get the password entered
if (password && *password) {
nsMemory::Free(*password);
*password = nsnull;
}
nsString csPassword;
csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0));
*password = csPassword.ToNewUnicode();
if(checkboxState)
*checkboxState = dlg.m_bCheckBoxValue;
*retval = PR_TRUE;
}
else
{
*retval = PR_FALSE;
}
return pThis->m_hWnd;
}

@ -35,8 +35,8 @@
// This file currently has the implementation for all the interfaces
// which are required of an app embedding Gecko
// Implementation of other optional interfaces are in separate files
// so as to avoid cluttering this one. For ex, implementation of
// nsIPrompt is in BrowserImplPrompt.cpp etc.
// to avoid cluttering this one and to demonstrate other embedding
// principles. For example, nsIPrompt is implemented in a separate DLL.
//
// nsIWebBrowserChrome - This is a required interface to be implemented
// by embeddors
@ -105,7 +105,6 @@ NS_INTERFACE_MAP_BEGIN(CBrowserImpl)
NS_INTERFACE_MAP_ENTRY(nsIEmbeddingSiteWindow)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsIContextMenuListener)
NS_INTERFACE_MAP_ENTRY(nsIPrompt)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_INTERFACE_MAP_END
@ -325,7 +324,15 @@ NS_IMETHODIMP CBrowserImpl::GetDimensions(PRUint32 aFlags, PRInt32 *x, PRInt32 *
NS_IMETHODIMP CBrowserImpl::GetSiteWindow(void** aSiteWindow)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (!aSiteWindow)
return NS_ERROR_NULL_POINTER;
*aSiteWindow = 0;
if (m_pBrowserFrameGlue) {
HWND w = m_pBrowserFrameGlue->GetBrowserFrameNativeWnd();
*aSiteWindow = NS_REINTERPRET_CAST(void *, w);
}
return NS_OK;
}
NS_IMETHODIMP CBrowserImpl::SetFocus()

@ -31,7 +31,6 @@ class CBrowserImpl : public nsIInterfaceRequestor,
public nsIEmbeddingSiteWindow,
public nsIWebProgressListener,
public nsIContextMenuListener,
public nsIPrompt,
public nsSupportsWeakReference,
public nsIURIContentListener
{
@ -47,7 +46,6 @@ public:
NS_DECL_NSIEMBEDDINGSITEWINDOW
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSICONTEXTMENULISTENER
NS_DECL_NSIPROMPT
NS_DECL_NSIURICONTENTLISTENER
protected:

@ -78,6 +78,10 @@ CBrowserImpl::IsPreferred(const char * aContentType,
NS_ENSURE_ARG_POINTER(aDesiredContentType);
NS_ENSURE_ARG_POINTER(aCanHandleContent);
*aDesiredContentType = nsnull;
// nsCOMPtr<nsIURI> currentURI;
// rv = mWebBrowser->GetCurrentURI(getter_AddRefs(currentURI));
// claim that we can handle everything
*aCanHandleContent = PR_TRUE;
return NS_OK;

@ -1,254 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Chak Nanga <chak@netscape.com>
*/
// File overview.....
//
// The nsIPrompt interface is mainly used to convey/get information
// from a user via Alerts, Prompts etc.
//
#include "stdafx.h"
#include "BrowserImpl.h"
#include "IBrowserFrameGlue.h"
//*****************************************************************************
// CBrowserImpl::nsIPrompt Implementation
//*****************************************************************************
// Needed for JavaScript and other cases where a msg needs to be
// shown to the user. For ex, when a page has some JS such as
// "Alert("Hello")" this method will be invoked
NS_IMETHODIMP
CBrowserImpl::Alert(const PRUnichar *dialogTitle, const PRUnichar *text)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Alert(dialogTitle, text);
return NS_OK;
}
// Invoked in the case of a JS confirm() method invocation
NS_IMETHODIMP
CBrowserImpl::Confirm(const PRUnichar *dialogTitle,
const PRUnichar *text, PRBool *retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Confirm(dialogTitle, text, retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **promptText,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->Prompt(dialogTitle, text, promptText, checkMsg, checkValue, _retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, password,
checkMsg, checkValue, _retval);
return NS_OK;
}
NS_IMETHODIMP
CBrowserImpl::PromptUsernameAndPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkMsg, PRBool *checkValue,
PRBool *_retval)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
username, password,
checkMsg, checkValue,
_retval);
return NS_OK;
}
// This method is evil/painful. It will be gone when bug 46859 is done
//
// So far these are the cases in which UniversalDialog seems to be
// getting called when we wrap our nsIPrompt with nsISingleSignOnPrompt
// (There are other cases in which this method may be called,
// but, i'm covering the most frequent cases for now - assuming that
// we'll do away with this method soon)
//
// - JavaScript's Prompt() method - Should be calling nsIPrompt::Prompt()
// instead
//
// - To get UserName/Password while accessing a password protected site via
// HTTP - They should be calling nsIPrompt::PromptUserNameAndPassword() instead
// (However, the current nsIPrompt::PromptUserNameAndPassword() is inadequate
// in the sense that it does not have a way to specify the CheckBox text
// and the CheckState return value. So this issue also needs to be addressed
// before getting rid of the Universal Dialog)
//
// - To get just a password in the case the username's already known/specified
// i.e. in cases like ftp://chak@server.domain.com
// (Note that the user name "chak" is specified but the password is not
// They should be calling our nsIPrompt::PromptPassword() instead
// (However, the current nsIPrompt::PromptPassword() is inadequate
// in the sense that it does not have a way to specify the CheckBox text
// and the CheckState return value. So this issue also needs to be addressed
// before getting rid of the Universal Dialog)
//
// Since this method might go away here's how i'm currently using it:
//
// Identify if this method is called on behalf of a JS Prompt() etc. and if so
// delegate it to our appropriate implementations
// When this method's axed the correct IPrompt methods will be called and
// we can just get rid of this one
//
NS_IMETHODIMP
CBrowserImpl::UniversalDialog(const PRUnichar *titleMessage,
const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkboxMsg,
const PRUnichar *button0Text,
const PRUnichar *button1Text,
const PRUnichar *button2Text,
const PRUnichar *button3Text,
const PRUnichar *editfield1Msg,
const PRUnichar *editfield2Msg,
PRUnichar **editfield1Value,
PRUnichar **editfield2Value,
const PRUnichar *iconURL,
PRBool *checkboxState,
PRInt32 numberButtons,
PRInt32 numberEditfields,
PRInt32 editField1Password,
PRInt32 *buttonPressed)
{
if(! m_pBrowserFrameGlue)
return NS_ERROR_FAILURE;
PRBool confirmed;
if(numberEditfields == 1 && checkboxMsg == NULL && editField1Password == 0)
{
// This is a Prompt()
m_pBrowserFrameGlue->Prompt(dialogTitle, text, editfield1Value, NULL, NULL, &confirmed);
// The Prompt() methods return PR_TRUE/PR_FALSE depending on whether
// the OK/CANCEL was pressed. However, UniversalDialog checks
// for the index of the button pressed i.e. "0" for the "OK" button and
// "1" for the CANCEL button.
// So, now let's translate to what the UniversalDlg expects
if(confirmed) //Will be TRUE i.e. 1 if the user chose OK
*buttonPressed = 0; //Set it to the OK button index i.e. to "0"
else
*buttonPressed = 1; //Set it to the Cancel button index i.e. to "1"
return NS_OK;
}
else if(numberEditfields == 1 && checkboxMsg != NULL && editField1Password == 1)
{
// This is a PromptPassword()
m_pBrowserFrameGlue->PromptPassword(dialogTitle, text, editfield1Value,
checkboxMsg, checkboxState, &confirmed);
//See comments above on why we're doing this...
if(confirmed)
*buttonPressed = 0;
else
*buttonPressed = 1;
return NS_OK;
}
else if(numberEditfields == 2 && checkboxMsg != NULL && editField1Password == 0)
{
// This is a username/password dialog
m_pBrowserFrameGlue->PromptUserNamePassword(dialogTitle, text,
editfield1Value, editfield2Value,
checkboxMsg, checkboxState,
&confirmed);
//See comments above on why we're doing this...
if(confirmed)
*buttonPressed = 0;
else
*buttonPressed = 1;
return NS_OK;
}
else
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::AlertCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::ConfirmCheck(const PRUnichar *dialogTitle,
const PRUnichar *text,
const PRUnichar *checkMsg,
PRBool *checkValue, PRBool *retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
CBrowserImpl::Select(const PRUnichar *dialogTitle,
const PRUnichar *text, PRUint32 count,
const PRUnichar **selectList,
PRInt32 *outSelection, PRBool *retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

@ -254,13 +254,11 @@ HRESULT CBrowserView::CreateBrowser()
*/
/*
// Set up the content listeners
nsCOMPtr<nsIURIContentListener> uriListener;
uriListener = do_QueryInterface(NS_STATIC_CAST(nsIURIContentListener*, mpBrowserImpl));
NS_ENSURE_TRUE(uriListener, NS_ERROR_FAILURE);
mWebBrowser->SetParentURIContentListener(uriListener);
*/
// Register the BrowserImpl object to receive progress messages

@ -27,235 +27,9 @@
// File overview....
//
// Mainly contains dialog box code to support Alerts, Prompts such as
// Password prompt and username/password prompts
// Contains find dialog stuff
//
//--------------------------------------------------------------------------//
// CPromptDialog Stuff
//--------------------------------------------------------------------------//
CPromptDialog::CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPromptText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitPromptText)
m_csPromptAnswer = pInitPromptText;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptDialog)
DDX_Text(pDX, IDC_PROMPT_ANSWER, m_csPromptAnswer);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptDialog, CDialog)
//{{AFX_MSG_MAP(CPromptDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if (m_bHasCheckBox)
{
if(!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
// Hide the check box control if there's no label text
// This will be the case when we're not using single sign-on
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PROMPT_ANSWER);
if(pEdit)
{
pEdit->SetWindowText(m_csPromptAnswer);
pEdit->SetFocus();
pEdit->SetSel(0, -1);
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}
//--------------------------------------------------------------------------//
// CPromptPasswordDialog Stuff
//--------------------------------------------------------------------------//
CPromptPasswordDialog::CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPasswordText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptPasswordDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitPasswordText)
m_csPassword = pInitPasswordText;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptPasswordDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptPasswordDialog)
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptPasswordDialog, CDialog)
//{{AFX_MSG_MAP(CPromptPasswordDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptPasswordDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if (m_bHasCheckBox)
{
if(!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
// Hide the check box control if there's no label text
// This will be the case when we're not using single sign-on
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
if(pEdit)
{
pEdit->SetFocus();
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}
//--------------------------------------------------------------------------//
// CPromptUsernamePasswordDialog Stuff
//--------------------------------------------------------------------------//
CPromptUsernamePasswordDialog::CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitUsername, const char* pInitPassword,
BOOL bHasCheck, const char* pCheckText, int initCheckVal)
: CDialog(CPromptUsernamePasswordDialog::IDD, pParent),
m_bHasCheckBox(bHasCheck), m_bCheckBoxValue(initCheckVal)
{
if(pTitle)
m_csDialogTitle = pTitle;
if(pText)
m_csPromptText = pText;
if(pInitUsername)
m_csUserName = pInitUsername;
if(pInitPassword)
m_csPassword = pInitPassword;
if(pCheckText)
m_csCheckBoxText = pCheckText;
}
void CPromptUsernamePasswordDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPromptUsernamePasswordDialog)
DDX_Text(pDX, IDC_USERNAME, m_csUserName);
DDX_Text(pDX, IDC_PASSWORD, m_csPassword);
DDX_Check(pDX, IDC_CHECK_SAVE_PASSWORD, m_bCheckBoxValue);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPromptUsernamePasswordDialog, CDialog)
//{{AFX_MSG_MAP(CPromptUsernamePasswordDialog)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
int CPromptUsernamePasswordDialog::OnInitDialog()
{
SetWindowText(m_csDialogTitle);
CWnd *pWnd = GetDlgItem(IDC_PROMPT_TEXT);
if(pWnd)
pWnd->SetWindowText(m_csPromptText);
CButton *pChk = (CButton *)GetDlgItem(IDC_CHECK_SAVE_PASSWORD);
if(pChk)
{
if(m_bHasCheckBox)
{
if (!m_csCheckBoxText.IsEmpty())
pChk->SetWindowText(m_csCheckBoxText);
pChk->SetCheck(m_bCheckBoxValue ? BST_CHECKED : BST_UNCHECKED);
}
else
{
pChk->ShowWindow(SW_HIDE);
}
}
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_PASSWORD);
if(pEdit)
{
pEdit->SetWindowText(m_csPassword);
}
pEdit = (CEdit *)GetDlgItem(IDC_USERNAME);
if(pEdit)
{
pEdit->SetWindowText(m_csUserName);
pEdit->SetSel(0, -1);
pEdit->SetFocus();
return 0; // Returning "0" since we're explicitly setting focus
}
return TRUE;
}
//--------------------------------------------------------------------------//
// CFindDialog Stuff
//--------------------------------------------------------------------------//

@ -26,103 +26,6 @@
#include "resource.h"
class CPromptDialog : public CDialog
{
public:
CPromptDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPromptText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptDialog)
enum { IDD = IDD_PROMPT_DIALOG };
CString m_csPromptAnswer;
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CPromptPasswordDialog : public CDialog
{
public:
CPromptPasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitPasswordText,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptPasswordDialog)
enum { IDD = IDD_PROMPT_PASSWORD_DIALOG };
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
CString m_csPassword;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptPasswordDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptPasswordDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CPromptUsernamePasswordDialog : public CDialog
{
public:
CPromptUsernamePasswordDialog(CWnd* pParent, const char* pTitle, const char* pText,
const char* pInitUsername, const char* pInitPassword,
BOOL bHasCheck, const char* pCheckText, int initCheckVal);
// Dialog Data
//{{AFX_DATA(CPromptUsernamePasswordDialog)
enum { IDD = IDD_PROMPT_USERPASS_DIALOG };
//}}AFX_DATA
CString m_csDialogTitle;
CString m_csPromptText;
CString m_csUserNameLabel;
CString m_csPasswordLabel;
CString m_csPassword;
CString m_csUserName;
BOOL m_bHasCheckBox;
CString m_csCheckBoxText;
int m_bCheckBoxValue;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPromptUsernamePasswordDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG(CPromptUsernamePasswordDialog)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CBrowserView;
class CFindDialog : public CFindReplaceDialog

@ -66,21 +66,7 @@ struct IBrowserFrameGlue {
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode) = 0;
//Prompt Related Methods
virtual void Alert(const PRUnichar *dialogTitle, const PRUnichar *text) = 0;
virtual void Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval) = 0;
virtual void Prompt(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **promptText,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval) = 0;
virtual void PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **password,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval) = 0;
virtual void PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text,
PRUnichar **username, PRUnichar **password,
const PRUnichar *checkboxMsg, PRBool *checkboxState,
PRBool *retval) = 0;
virtual HWND GetBrowserFrameNativeWnd() = 0;
};
#define NS_DECL_BROWSERFRAMEGLUE \
@ -103,12 +89,8 @@ struct IBrowserFrameGlue {
virtual void SetFocus(); \
virtual void FocusAvailable(PRBool *aFocusAvail); \
virtual void GetBrowserFrameVisibility(PRBool *aVisible); \
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual void Alert(const PRUnichar *dialogTitle, const PRUnichar *text); \
virtual void Confirm(const PRUnichar *dialogTitle, const PRUnichar *text, PRBool *_retval); \
virtual void Prompt(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **promptText, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval); \
virtual void PromptPassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **password, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval); \
virtual void PromptUserNamePassword(const PRUnichar *dialogTitle, const PRUnichar *text, PRUnichar **username, PRUnichar **password, const PRUnichar *checkboxMsg, PRBool *checkboxState, PRBool *retval);
virtual void ShowContextMenu(PRUint32 aContextFlags, nsIDOMNode *aNode); \
virtual HWND GetBrowserFrameNativeWnd();
typedef IBrowserFrameGlue *PBROWSERFRAMEGLUE;

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\mozilla\mozilla\nsprpub\pr\include" /I "..\mozilla\mozilla\nsprpub\_o.obj\include" /I "..\mozilla\mozilla\include" /I "..\mozilla\mozilla\xpcom\components" /I "..\mozilla\mozilla\dist\include" /I "..\mozilla\mozilla\dist\WIN32_O.OBJ\include" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "HW_THREADS" /D "XP_PC" /D "XP_WIN" /D "XP_WIN32" /D WINVER=0x400 /D _WIN32_IE=0x0500 /Fr /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\mozilla\mozilla\nsprpub\pr\include" /I "..\mozilla\mozilla\nsprpub\_o.obj\include" /I "..\mozilla\mozilla\include" /I "..\mozilla\mozilla\xpcom\components" /I "..\mozilla\mozilla\dist\include" /I "..\mozilla\mozilla\dist\WIN32_O.OBJ\include" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HW_THREADS" /D "XP_PC" /D "XP_WIN" /D "XP_WIN32" /D WINVER=0x400 /D _WIN32_IE=0x0500 /D "_AFXDLL" /Fr /Yu"stdafx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
@ -75,7 +75,7 @@ PostBuild_Cmds=version BUILD_NUMBER version.h
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\mozilla\mozilla\nsprpub\pr\include" /I "..\mozilla\mozilla\nsprpub\_o.obj\include" /I "..\mozilla\mozilla\include" /I "..\mozilla\mozilla\xpcom\components" /I "..\mozilla\mozilla\dist\include" /I "..\mozilla\mozilla\dist\WIN32_o.OBJ\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /D "HW_THREADS" /D "XP_PC" /D "XP_WIN" /D "XP_WIN32" /D WINVER=0x400 /FR /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "\projects\mozilla\mozilla\dist\include" /I "\projects\mozilla\mozilla\dist\WIN32_O.OBJ\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "HW_THREADS" /D "XP_PC" /D "XP_WIN" /D "XP_WIN32" /D WINVER=0x400 /D "_AFXDLL" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
@ -133,11 +133,11 @@ SOURCE=.\BrowserImpl.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImplCtxMenuLstnr.cpp
SOURCE=.\BrowserImplContentLstnr.cpp
# End Source File
# Begin Source File
SOURCE=.\BrowserImplPrompt.cpp
SOURCE=.\BrowserImplCtxMenuLstnr.cpp
# End Source File
# Begin Source File
@ -257,11 +257,11 @@ SOURCE=.\kmeleon_plugin.h
# End Source File
# Begin Source File
SOURCE=.\Log.h
SOURCE=.\KmeleonConst.h
# End Source File
# Begin Source File
SOURCE=.\KmeleonConst.h
SOURCE=.\Log.h
# End Source File
# Begin Source File
@ -389,6 +389,10 @@ SOURCE=.\res\icon2.ico
# End Source File
# Begin Source File
SOURCE=.\res\icon3.ico
# End Source File
# Begin Source File
SOURCE=.\res\KmeleonDocument.ico
# End Source File
# Begin Source File
@ -397,6 +401,22 @@ SOURCE=.\res\MozillaBrowser.ico
# End Source File
# Begin Source File
SOURCE=.\res\off.ico
# End Source File
# Begin Source File
SOURCE=.\res\offcheck.ico
# End Source File
# Begin Source File
SOURCE=.\res\on.ico
# End Source File
# Begin Source File
SOURCE=.\res\oncheck.ico
# End Source File
# Begin Source File
SOURCE=.\res\temp.bmp
# End Source File
# Begin Source File

@ -15,6 +15,18 @@ Package=<4>
###############################################################################
Project: "components"=".\components\components.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "fullscreen"=".\fullscreen\fullscreen.dsp" - Package Owner=<4>
Package=<5>

@ -98,7 +98,7 @@ int CMenuParser::Load(CString &filename){
else if (strnicmp(p+1, "ifplugin", 8) == 0) {
char *plugin = p+9;
kmeleonPlugin * kPlugin = theApp.plugins.Load(plugin);
if (!kPlugin->loaded) {
if (!kPlugin || !kPlugin->loaded) {
pauseParsing = 1;
}
}

@ -58,6 +58,13 @@ static char THIS_FILE[] = __FILE__;
#define MENU_CONFIG_FILE "menus.cfg"
#define ACCEL_CONFIG_FILE "accel.cfg"
// this is for overriding the Mozilla default PromptService component
#include "components\PromptService.h"
#define kComponentsLibname "kmeleonComponents.dll"
#define NS_PROMPTSERVICE_CID \
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
BEGIN_MESSAGE_MAP(CMfcEmbedApp, CWinApp)
//{{AFX_MSG_MAP(CMfcEmbedApp)
ON_COMMAND(ID_NEW_BROWSER, OnNewBrowser)
@ -78,6 +85,50 @@ CMfcEmbedApp::CMfcEmbedApp() :
CMfcEmbedApp theApp;
/* Some Gecko interfaces are implemented as components, automatically
registered at application initialization. nsIPrompt is an example:
the default implementation uses XUL, not native windows. Embedding
apps can override the default implementation by implementing the
nsIPromptService interface and registering a factory for it with
the same CID and Contract ID as the default's.
Note that this example implements the service in a separate DLL,
replacing the default if the override DLL is present. This could
also have been done in the same module, without a separate DLL.
See the PowerPlant example for, well, an example.
*/
nsresult CMfcEmbedApp::OverrideComponents()
{
nsresult rv = NS_OK;
// replace Mozilla's default PromptService with our own, if the
// expected override DLL is present
HMODULE overlib = ::LoadLibrary(kComponentsLibname);
if (overlib) {
InitPromptServiceType InitLib;
MakeFactoryType MakeFactory;
InitLib = reinterpret_cast<InitPromptServiceType>(::GetProcAddress(overlib, kPromptServiceInitFuncName));
MakeFactory = reinterpret_cast<MakeFactoryType>(::GetProcAddress(overlib, kPromptServiceFactoryFuncName));
if (InitLib && MakeFactory) {
InitLib(overlib);
nsCOMPtr<nsIFactory> promptFactory;
rv = MakeFactory(getter_AddRefs(promptFactory));
if (NS_SUCCEEDED(rv))
nsComponentManager::RegisterFactory(kPromptServiceCID,
"Prompt Service",
"@mozilla.org/embedcomp/prompt-service;1",
promptFactory,
PR_TRUE); // replace existing
} else
::FreeLibrary(overlib);
}
return rv;
}
// Initialize our MFC application and also init
// the Gecko embedding APIs
// Note that we're also init'ng the profile switching
@ -107,6 +158,12 @@ BOOL CMfcEmbedApp::InitInstance()
return FALSE;
}
rv = OverrideComponents();
if(NS_FAILED(rv)) {
ASSERT(FALSE);
return FALSE;
}
rv = InitializeWindowCreator();
if (NS_FAILED(rv)) {
ASSERT(FALSE);

@ -71,6 +71,7 @@ public:
PRInt32 cx = -1, PRInt32 cy = -1,
PRBool bShowWindow = PR_TRUE);
void RemoveFrameFromList(CBrowserFrame* pFrm, BOOL bCloseAppOnLastFrame = TRUE);
nsresult OverrideComponents();
// Overrides
// ClassWizard generated virtual function overrides

@ -227,48 +227,6 @@ BEGIN
PUSHBUTTON "K-Meleon &Forums",IDC_KMELEON_FORUM,160,168,61,16
END
IDD_PROMPT_DIALOG DIALOG DISCARDABLE 0, 0, 249, 82
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Prompt Dialog"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,130,61,50,14
PUSHBUTTON "Cancel",IDCANCEL,189,61,50,14
LTEXT "Please enter something....",IDC_PROMPT_TEXT,10,7,229,29
EDITTEXT IDC_PROMPT_ANSWER,10,39,229,14,ES_AUTOHSCROLL
END
IDD_PROMPT_PASSWORD_DIALOG DIALOG DISCARDABLE 0, 0, 248, 93
STYLE DS_SYSMODAL | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
CAPTION "Password Entry Dialog"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Please enter your password:",IDC_PROMPT_TEXT,5,7,232,20
DEFPUSHBUTTON "OK",IDOK,129,75,50,14
PUSHBUTTON "Cancel",IDCANCEL,188,75,50,14
EDITTEXT IDC_PASSWORD,5,37,233,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Check1",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,57,229,10
END
IDD_PROMPT_USERPASS_DIALOG DIALOG DISCARDABLE 0, 0, 214, 123
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Username and Password Required"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "This operation requires authentication. Please enter your user name and password:",
IDC_PROMPT_TEXT,6,9,171,25
LTEXT "User Name:",IDC_USERNAME_LABEL,6,39,39,9
EDITTEXT IDC_USERNAME,49,39,153,12,ES_AUTOHSCROLL
LTEXT "Password:",IDC_PASSWORD_LABEL,6,58,36,8
EDITTEXT IDC_PASSWORD,49,56,153,12,ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Check1",IDC_CHECK_SAVE_PASSWORD,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,6,78,201,10
DEFPUSHBUTTON "OK",IDOK,40,101,50,14
PUSHBUTTON "Cancel",IDCANCEL,95,101,50,14
END
IDD_PROFILES DIALOG DISCARDABLE 0, 0, 196, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Manage Profiles"
@ -327,12 +285,13 @@ END
IDD_PREFERENCES_DISPLAY DIALOGEX 0, 0, 233, 154
STYLE WS_CHILD
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT
FONT 8, "MS Sans Serif", 0, 0, 0x1
FONT 8, "MS Sans Serif"
BEGIN
EDITTEXT IDC_EDIT_TOOLBAR_BACKGROUND,84,6,93,14,ES_AUTOHSCROLL
CONTROL "Toolbar Background",IDC_CHECK_TOOLBAR_BACKGROUND,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,4,8,80,10
PUSHBUTTON "Browse...",IDC_BUTTON_BROWSE,179,6,50,14
EDITTEXT IDC_EDIT_TOOLBAR_BACKGROUND,11,22,169,14,ES_AUTOHSCROLL
CONTROL "Show Toolbar Background",IDC_CHECK_TOOLBAR_BACKGROUND,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,41,137,10
PUSHBUTTON "Browse...",IDC_BUTTON_BROWSE,182,22,39,14
GROUPBOX "Toolbar Background Image",IDC_STATIC,4,7,226,52
END
IDD_PREFERENCES_PROXY DIALOGEX 0, 0, 233, 154
@ -387,9 +346,11 @@ FONT 8, "MS Sans Serif"
BEGIN
CONTROL "List1",IDC_LIST_PLUGINS,"SysListView32",LVS_LIST |
LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT |
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,4,4,225,130
PUSHBUTTON "&Configure",IDC_BUTTON_CONFIG,4,136,57,14
PUSHBUTTON "&Enable/Disable",IDC_BUTTON_ENABLE,63,136,57,14
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,4,4,225,113
PUSHBUTTON "&Configure",IDC_BUTTON_CONFIG,4,120,57,14
PUSHBUTTON "&Enable/Disable",IDC_BUTTON_ENABLE,63,120,57,14
LTEXT "Disabled plugins will not be loaded the next time K-Meleon is started.",
IDC_STATIC,4,138,225,12
END
IDD_PREFERENCES_ADVANCED DIALOGEX 0, 0, 233, 154

@ -68,7 +68,7 @@ void CPreferences::Load() {
if (NS_FAILED(rv) || !inited) {
// Set up prefs for first run
rv = prefs->SetBoolPref(_T("kmeleon.prefs_inited"), PR_TRUE);
rv = prefs->SavePrefFile(nsnull);
rv = prefs->SavePrefFile();
}
@ -252,7 +252,7 @@ void CPreferences::Save() {
else
rv = prefs->SetCharPref(_T("image.animation_mode"), _T("none"));
rv = prefs->SavePrefFile(nsnull);
rv = prefs->SavePrefFile();
}
else
NS_ASSERTION(PR_FALSE, "Could not get preferences service");

@ -38,6 +38,8 @@ int refCount;
char szPath[MAX_PATH];
/*
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
@ -66,18 +68,18 @@ void DoMenu(HMENU menu, char *param);
void DoRebar(HWND rebarWnd);
pluginFunctions pFunc = {
Init,
Create,
Config,
Quit,
DoMenu,
DoRebar
Init,
Create,
Config,
Quit,
DoMenu,
DoRebar
};
kmeleonPlugin kPlugin = {
KMEL_PLUGIN_VER,
"Bitmapped Menus",
&pFunc
KMEL_PLUGIN_VER,
"Bitmapped Menus",
&pFunc
};
/*
@ -103,7 +105,7 @@ BmpMapT bmpMap;
typedef std::map<std::string, int> DefineMapT;
void ParseConfig(char *buffer) {
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR8, 32, 256);
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR8, 32, 256);
DefineMapT defineMap;
#define DEFINEMAP_ADD(entry) defineMap[std::string(#entry)] = entry;
@ -114,11 +116,14 @@ void ParseConfig(char *buffer) {
int index = 0;
char *p;
while ((p = strtok(NULL, "\n")) != NULL){
while ((p = strtok(NULL, "\n")) != NULL) {
// ignore the comments
if (*p == '#') {
continue;
}
else if (!currentBitmap){
else if (!currentBitmap) {
char *b = strchr(p, '{');
if (b) {
*b = 0;
@ -135,17 +140,18 @@ void ParseConfig(char *buffer) {
strcat(bmpPath, p);
bitmap = (HBITMAP)LoadImage(NULL, bmpPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
}
ImageList_AddMasked(hImageList, bitmap, RGB(192, 192, 192));
ImageList_AddMasked(hImageList, bitmap, RGB(192, 192, 192));
DeleteObject(bitmap);
DeleteObject(bitmap);
currentBitmap = true;
currentBitmap = true;
}
}
else {
if ( strchr( p, '}' )) {
currentBitmap = false;
index = ImageList_GetImageCount(hImageList);
currentBitmap = false;
index = ImageList_GetImageCount(hImageList);
continue;
}
@ -153,48 +159,44 @@ void ParseConfig(char *buffer) {
p = SkipWhiteSpace(p);
int id;
defineMapIt = defineMap.find(std::string(p));
if ( defineMapIt != defineMap.end() ) {
if ( defineMapIt != defineMap.end() )
id = defineMapIt->second;
}
else {
else
id = 0;
}
bmpMap[id] = index;
index++;
}
}
}
int Init(){
refCount = 0;
kPlugin.kf->GetPreference(PREF_STRING, _T("kmeleon.general.settingsDir"), szPath, "");
int Init() {
refCount = 0;
char cfgPath[MAX_PATH];
strcpy(cfgPath, szPath);
strcat(cfgPath, "menuicons.cfg");
kPlugin.kf->GetPreference(PREF_STRING, _T("kmeleon.general.settingsDir"), szPath, "");
FILE *cfgFile = fopen(cfgPath, "r");
if (cfgFile){
fseek(cfgFile, 0, SEEK_END);
long cfgFileSize = ftell(cfgFile);
fseek(cfgFile, 0, SEEK_SET);
char cfgPath[MAX_PATH];
strcpy(cfgPath, szPath);
strcat(cfgPath, "menuicons.cfg");
char *cfgFileBuffer = new char[cfgFileSize];
if (cfgFileBuffer){
fread(cfgFileBuffer, sizeof(char), cfgFileSize, cfgFile);
FILE *cfgFile = fopen(cfgPath, "r");
if (cfgFile){
fseek(cfgFile, 0, SEEK_END);
long cfgFileSize = ftell(cfgFile);
fseek(cfgFile, 0, SEEK_SET);
strtok(cfgFileBuffer, "\n");
ParseConfig(cfgFileBuffer);
char *cfgFileBuffer = new char[cfgFileSize];
if (cfgFileBuffer) {
fread(cfgFileBuffer, sizeof(char), cfgFileSize, cfgFile);
delete [] cfgFileBuffer;
}
fclose(cfgFile);
}
strtok(cfgFileBuffer, "\n");
ParseConfig(cfgFileBuffer);
return true;
delete [] cfgFileBuffer;
}
fclose(cfgFile);
}
return true;
}
WNDPROC KMeleonWndProc;
@ -205,23 +207,23 @@ void Create(HWND parent){
KMeleonWndProc = (WNDPROC) GetWindowLong(parent, GWL_WNDPROC);
SetWindowLong(parent, GWL_WNDPROC, (LONG)WndProc);
refCount++;
refCount++;
}
void Config(HWND parent){
char cfgPath[MAX_PATH];
strcpy(cfgPath, szPath);
strcat(cfgPath, "menuicons.cfg");
char cfgPath[MAX_PATH];
strcpy(cfgPath, szPath)