2005-07-23 17:31:21 +02:00
|
|
|
/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */
|
|
|
|
/*
|
2006-01-08 02:25:02 +01:00
|
|
|
* Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved.
|
2005-07-23 17:31:21 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
|
|
|
|
|
|
|
#include "cecondlg.h"
|
|
|
|
#include "ceutil.h"
|
2006-01-28 20:03:10 +01:00
|
|
|
#include "debhacks.h"
|
2005-07-23 17:31:21 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
ceControlsToAddrRec( HWND hDlg, CeConnDlgState* cState )
|
|
|
|
{
|
|
|
|
XP_U16 len;
|
|
|
|
|
|
|
|
len = sizeof(cState->addrRec.u.ip_relay.hostName);
|
|
|
|
ceGetDlgItemText( hDlg, RELAYNAME_EDIT,
|
|
|
|
cState->addrRec.u.ip_relay.hostName, &len );
|
|
|
|
cState->addrRec.u.ip_relay.port =
|
|
|
|
(XP_U16)ceGetDlgItemNum( hDlg, RELAYPORT_EDIT );
|
|
|
|
len = sizeof(cState->addrRec.u.ip_relay.cookie);
|
|
|
|
ceGetDlgItemText( hDlg, COOKIE_EDIT, cState->addrRec.u.ip_relay.cookie,
|
|
|
|
&len );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ceControlsFromAddrRec( HWND hDlg, const CeConnDlgState* cState )
|
|
|
|
{
|
2006-01-31 15:40:49 +01:00
|
|
|
wchar_t* str;
|
2005-07-23 17:31:21 +02:00
|
|
|
|
|
|
|
switch( cState->addrRec.conType ) {
|
|
|
|
case COMMS_CONN_RELAY:
|
|
|
|
str = L"WiFi/Cellular data";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
XP_LOGF( "conType is %d", cState->addrRec.conType );
|
|
|
|
XP_ASSERT( 0 );
|
|
|
|
str = L"bad conType";
|
|
|
|
break;
|
|
|
|
}
|
2006-01-31 15:40:49 +01:00
|
|
|
SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO, CB_ADDSTRING, 0, (LPARAM)str );
|
2005-07-23 17:31:21 +02:00
|
|
|
SendDlgItemMessage( hDlg, IDC_CONNECTCOMBO, CB_SETCURSEL, 0, 0L );
|
|
|
|
|
|
|
|
ceSetDlgItemText( hDlg, RELAYNAME_EDIT, cState->addrRec.u.ip_relay.hostName );
|
|
|
|
ceSetDlgItemNum( hDlg, RELAYPORT_EDIT, cState->addrRec.u.ip_relay.port );
|
|
|
|
ceSetDlgItemText( hDlg, COOKIE_EDIT, cState->addrRec.u.ip_relay.cookie );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK
|
|
|
|
ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
LRESULT result = FALSE;
|
|
|
|
|
|
|
|
CeConnDlgState* cState;
|
|
|
|
CEAppGlobals* globals;
|
|
|
|
|
|
|
|
if ( message == WM_INITDIALOG ) {
|
|
|
|
SetWindowLong( hDlg, GWL_USERDATA, lParam );
|
|
|
|
cState = (CeConnDlgState*)lParam;
|
|
|
|
globals = cState->globals;
|
|
|
|
|
|
|
|
ceControlsFromAddrRec( hDlg, cState );
|
2006-05-25 05:41:32 +02:00
|
|
|
|
2006-05-27 19:18:42 +02:00
|
|
|
ceStackButtonsRight( globals, hDlg );
|
2006-05-25 05:41:32 +02:00
|
|
|
|
2005-07-23 17:31:21 +02:00
|
|
|
result = TRUE;
|
|
|
|
} else {
|
|
|
|
cState = (CeConnDlgState*)GetWindowLong( hDlg, GWL_USERDATA );
|
|
|
|
if ( !!cState ) {
|
|
|
|
globals = cState->globals;
|
|
|
|
|
|
|
|
if ( message == WM_COMMAND ) {
|
|
|
|
XP_U16 id = LOWORD(wParam);
|
|
|
|
|
|
|
|
switch( id ) {
|
|
|
|
case IDOK:
|
|
|
|
ceControlsToAddrRec( hDlg, cState );
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg, id);
|
|
|
|
cState->userCancelled = id == IDCANCEL;
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
} /* ConnsDlg */
|
|
|
|
|
|
|
|
XP_Bool
|
|
|
|
WrapConnsDlg( HWND hDlg, CEAppGlobals* globals, const CommsAddrRec* addrRec,
|
|
|
|
CeConnDlgState* state )
|
|
|
|
{
|
|
|
|
XP_Bool result;
|
|
|
|
XP_MEMSET( state, 0, sizeof( *state ) );
|
|
|
|
|
|
|
|
XP_LOGF( "WrapConnsDlg" );
|
|
|
|
|
|
|
|
state->globals = globals;
|
|
|
|
|
|
|
|
XP_MEMCPY( &state->addrRec, addrRec, sizeof(state->addrRec) );
|
|
|
|
|
2006-03-20 05:13:40 +01:00
|
|
|
DialogBoxParam( globals->hInst, (LPCTSTR)IDD_CONNSSDLG, hDlg,
|
2006-01-28 20:03:10 +01:00
|
|
|
(DLGPROC)ConnsDlg, (long)state );
|
2005-07-23 17:31:21 +02:00
|
|
|
|
|
|
|
result = !state->userCancelled;
|
|
|
|
return result;
|
|
|
|
} /* WrapConnsDlg */
|
|
|
|
|
|
|
|
#endif
|