📄 general.cpp
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/Intrface/General.cpp,v $
* $Date: 2003/05/13 18:42:06 $
*
Description:
\*____________________________________________________________________________*/
//$SourceTop:$
#include <iostream.h>
#include <stdio.h>
#include <windowsx.h>
#include "IFaceBse.h"
#include "PIStrStr.h"
#include "StrToken.h"
#include "QConfig.h"
#include "General.hrc"
/*
** #define D { cerr << __FILE__ << ": " << __LINE__ << endl; }
*/
#define D
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
#define C_RESOURCENAME "GeneralPage"
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
#if 0
/*
** HTML documentation for this handler
*/
/*___+++HTMLDOC_BEGIN+++___*/
Name:
GeneralPage
Description:
Creates the eponymous property page and is used by the PropSheet object.
Notes:
The changes you make in this won't partial immediately affect the behaviour of
the server but only after restart. This applies to the connection parameters.
Changes may lead to a configuration, which is inapplicable for remote administration
or requires corresponding changes in the configuration of the remote interface
application, particular of the PropSheet object.
Example:
<PRE>
<Object>
Name GeneralPage
Class GeneralPageClass
PropertyPage GeneralPage
</Object>
</PRE>
/*___+++HTMLDOC_END+++___*/
#endif
/*____________________________________________________________________________*\
*
Description:
\*____________________________________________________________________________*/
static BOOL CALLBACK fnDialogProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam);
/*____________________________________________________________________________*\
*
Class:
Description:
\*____________________________________________________________________________*/
class GeneralPage : public IFaceBase
{
private:
QConfig *pConfig;
PROPSHEETPAGE tPsp;
Interface *pInterface;
/*
** window private values
*/
HWND hWndHost;
HWND hWndIP;
HWND hWndLocal;
HWND hWndEdit;
HWND hWndPort;
HWND hWndURL;
HWND hWndAdmin;
HWND hWndSsl;
HWND hWndRemote;
HWND hWndVerbose;
PIString pHost;
PIString pIP;
PIString pLocal;
int __iCurrentRadioButton;
int Parameter( const char *pVariable, const char *pValue,
const char *pWhere )
{
assert( pVariable && pValue );
PIOStrStream os;
os << pWhere << "GeneralPage: ";
if ( 0 )
{
}
else
{
os << "Unknown directive '" << pVariable <<
"'" << ends;
CONFIG_ERR( Object(), os.str() );
return 0;
};
return 1;
};
public:
GeneralPage( PIObject *pObject, int iArgc, const char *ppArgv[] )
: IFaceBase( pObject ),
pConfig( FindParentQConfig( PIObject_getDB( pObject ) ) ),
pInterface( 0 ),
hWndHost( 0 ),
hWndIP( 0 ),
hWndLocal( 0 ),
hWndEdit( 0 ),
hWndPort( 0 ),
hWndURL( 0 ),
hWndAdmin( 0 ),
pHost( "localhost" ),
pIP( "127.0.0.1" ),
pLocal ( "localhost" ),
__iCurrentRadioButton( 0 )
{
ReadParameters( iArgc, ppArgv );
if ( !IsOK() )
{ return; };
/*
** Setup the PROPSHEETPAGE
*/
memset( &tPsp, 0, sizeof( PROPSHEETPAGE ) );
tPsp.dwSize = sizeof( PROPSHEETPAGE );
tPsp.dwFlags = PSP_DEFAULT;
tPsp.hInstance = (HINSTANCE)PIDLL_getSystemHandle( PIClass_getLibrary(
PIObject_getClass( Object() ) ) );
/* Status page */
tPsp.pszTemplate = C_RESOURCENAME;
tPsp.pfnDlgProc = (DLGPROC)fnDialogProc;
tPsp.lParam = (LPARAM)this;
/*
** Set the data DB of this object
*/
PIDB *pDB = PIObject_getDB( Object() );
PIDB_add( pDB, PIDBTYPE_OPAQUE, INTRFACE_WINDOWTYPE,
(void *)INTRFACE_PROPPAGE, 0 );
assert(!PIDB_lookup( pDB, PIDBTYPE_OPAQUE, INTRFACE_PROPSHEETPAGE, 0));
PIDB_add( pDB, PIDBTYPE_OPAQUE, INTRFACE_PROPSHEETPAGE,
(void *)&tPsp, 0 );
/*
** Done
*/
};
~GeneralPage()
{
};
virtual int Handle( Interface &tWindow )
{
switch( tWindow.iMessage )
{
case INTRFACE_MSG_INIT:
pInterface = &tWindow;
break;
case INTRFACE_MSG_WIN32CREATE:
return PIAPI_ABORT;
case INTRFACE_MSG_LOAD:
return PIAPI_ABORT;
case INTRFACE_MSG_DEFAULTS:
M_AddValue( pConfig, "Internal", "URLProtocol", "http://" );
M_AddValue( pConfig, "Internal", "DefaultPort", "80" );
M_AddValue( pConfig, "Internal", "ServerIOObjectLine", "\tIOObject ServerIOObject" );
M_AddValue( pConfig, "Internal", "DefaultMIMEType", "application/octet-stream" );
M_AddValue( pConfig, "Internal", "HandlerLine", DEFAULT_HANDLERS );
M_AddValue( pConfig, "Identity", "Use", "local" );
M_AddValue( pConfig, "General", "Port", "80" );
M_AddValue( pConfig, "General", "Host", "localhost" );
M_AddValue( pConfig, "General", "Admin", "webmaster@yourhost.dom" );
M_AddValue( pConfig, "General", "ErrorMessages", "Short" );
break;
default:
assert( 0 );
return PIAPI_ABORT;
};
return PIAPI_COMPLETED;
};
PIString *Internal_stringFromRadioButton( int iId )
{
switch( iId )
{
case IDC_REMOTEHOST: return &pHost;
case IDC_REMOTEIP: return &pIP;
case IDC_LOCAL: return &pLocal;
default:
assert( 0 );
};
return 0;
};
void Internal_radioButtonChange( int iNewId )
{
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
/* --- Get current value --- */
*szBuf = '\0';
SendMessage( hWndEdit, WM_GETTEXT, BUF_SIZE, (LPARAM)szBuf );
*(Internal_stringFromRadioButton( __iCurrentRadioButton )) = szBuf;
__iCurrentRadioButton = iNewId;
SendMessage( hWndEdit, WM_SETTEXT, 0, (LPARAM)(const char *)
*(Internal_stringFromRadioButton( __iCurrentRadioButton )) );
};
void Internal_updateURL( HWND hDlg )
{
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
/* --- Get current value --- */
assert( M_LookupValue( pConfig, "Internal", "URLProtocol" ) );
strcpy( szBuf, M_LookupValue( pConfig, "Internal", "URLProtocol" ) );
int iLen = strlen( szBuf );
SendMessage( hWndEdit, WM_GETTEXT, BUF_SIZE-7, (LPARAM)&(szBuf[iLen]) );
iLen = strlen( szBuf );
szBuf[iLen++] = ':';
SendMessage( hWndPort, WM_GETTEXT, BUF_SIZE-iLen, (LPARAM)&(szBuf[iLen]) );
assert( M_LookupValue( pConfig, "Internal", "DefaultPort" ) );
if ( atoi( &(szBuf[iLen]) )==atoi(M_LookupValue( pConfig, "Internal",
"DefaultPort" )) )
{ szBuf[--iLen] = '\0'; };
/* --- now update the URL --- */
SendMessage( hWndURL, WM_SETTEXT, 0, (LPARAM)szBuf );
/* --- mark property sheet as modified --- */
Changed( hDlg );
};
BOOL DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
enum { BUF_SIZE=1023 };
char szBuf[BUF_SIZE+1];
switch (uMsg)
{
case WM_INITDIALOG:
{
const char *pA = M_LookupValue( pConfig, "General", "Admin" );
hWndHost = GetDlgItem( hDlg, IDC_REMOTEHOST );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -