Repository: kylin
Updated Branches:
  refs/heads/2.x-staging 957dd42e7 -> 9b19b69f1


KYLIN-1232 ODBC - Refine connection and configuration dialog UI


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/9b19b69f
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/9b19b69f
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/9b19b69f

Branch: refs/heads/2.x-staging
Commit: 9b19b69f1776a5fa6edcdcdaa64bdde88af9837a
Parents: 957dd42
Author: lidongsjtu <lid...@apache.org>
Authored: Mon Feb 1 15:29:46 2016 +0800
Committer: lidongsjtu <lid...@apache.org>
Committed: Mon Feb 1 15:29:46 2016 +0800

----------------------------------------------------------------------
 odbc/Driver/GODBC.RC               | 205 +++++++++++++++++++-------------
 odbc/Driver/KO_CONN.CPP            |  47 +++++++-
 odbc/Driver/KO_Config.cpp          |  90 +++++++++++---
 odbc/Driver/banner.bmp             | Bin 0 -> 93654 bytes
 odbc/Driver/driver.vcxproj         |   5 +-
 odbc/Driver/driver.vcxproj.filters |   7 +-
 odbc/Driver/resource.h             |  10 +-
 7 files changed, 255 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/GODBC.RC
----------------------------------------------------------------------
diff --git a/odbc/Driver/GODBC.RC b/odbc/Driver/GODBC.RC
index dd2cb3f..9e0f4c3 100644
--- a/odbc/Driver/GODBC.RC
+++ b/odbc/Driver/GODBC.RC
@@ -31,6 +31,23 @@
 #undef APSTUDIO_READONLY_SYMBOLS
 
 /////////////////////////////////////////////////////////////////////////////
+// Chinese (Simplified, PRC) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+#pragma code_page(936)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_BITMAP1             BITMAP                  "banner.bmp"
+#endif    // Chinese (Simplified, PRC) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
 // English (United States) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
@@ -43,21 +60,21 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
 // TEXTINCLUDE
 //
 
-1 TEXTINCLUDE
+1 TEXTINCLUDE 
 BEGIN
-"resource.h\0"
+    "resource.h\0"
 END
 
-2 TEXTINCLUDE
+2 TEXTINCLUDE 
 BEGIN
-"#include ""afxres.h""\r\n"
-"\0"
+    "#include ""afxres.h""\r\n"
+    "\0"
 END
 
-3 TEXTINCLUDE
+3 TEXTINCLUDE 
 BEGIN
-"\r\n"
-"\0"
+    "\r\n"
+    "\0"
 END
 
 #endif    // APSTUDIO_INVOKED
@@ -69,36 +86,36 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
-FILEVERSION 1, 0, 0, 1
-PRODUCTVERSION 1, 0, 0, 1
-FILEFLAGSMASK 0x3fL
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
-FILEFLAGS 0x1L
+ FILEFLAGS 0x1L
 #else
-FILEFLAGS 0x0L
+ FILEFLAGS 0x0L
 #endif
-FILEOS 0x40004L
-FILETYPE 0x2L
-FILESUBTYPE 0x0L
-BEGIN
-BLOCK "StringFileInfo"
-BEGIN
-BLOCK "040904b0"
-BEGIN
-VALUE "CompanyName", "kylinolap"
-VALUE "FileDescription", "Kylin ODBC Driver"
-VALUE "FileVersion", "1, 0, 0, 1"
-VALUE "InternalName", "KylinODBC"
-VALUE "LegalCopyright", "Copyright ?2014"
-VALUE "OriginalFilename", "driver.dll"
-VALUE "ProductName", "Kylin ODBC Driver"
-VALUE "ProductVersion", "1, 0, 0, 1"
-END
-END
-BLOCK "VarFileInfo"
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
 BEGIN
-VALUE "Translation", 0x409, 1200
-END
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "kylinolap"
+            VALUE "FileDescription", "Kylin ODBC Driver"
+            VALUE "FileVersion", "1, 0, 0, 1"
+            VALUE "InternalName", "KylinODBC"
+            VALUE "LegalCopyright", "Copyright ?2014"
+            VALUE "OriginalFilename", "driver.dll"
+            VALUE "ProductName", "Kylin ODBC Driver"
+            VALUE "ProductVersion", "1, 0, 0, 1"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
 END
 
 
@@ -107,48 +124,52 @@ END
 // Dialog
 //
 
-IDD_DSN_CFG1 DIALOGEX 0, 0, 263, 162
+IDD_DSN_CFG1 DIALOGEX 0, 0, 265, 210
 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
-CAPTION "Kylin Driver Connect Dialog"
+CAPTION "Apache Kylin Driver Connection"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-PUSHBUTTON      "Cancel", IDCANCEL, 152, 138, 50, 14
-LTEXT           "Server Host", IDC_STATIC, 49, 16, 38, 8
-LTEXT           "Port", IDC_STATIC, 69, 32, 14, 8
-EDITTEXT        IDC_SERVER, 92, 14, 110, 12, ES_AUTOHSCROLL
-EDITTEXT        IDC_PORT, 92, 31, 30, 12, ES_AUTOHSCROLL
-LTEXT           "(only https service permitted)", IDC_STATIC, 93, 45, 90, 8
-LTEXT           "Username", IDC_STATIC, 52, 60, 33, 8
-LTEXT           "Password", IDC_STATIC, 54, 79, 32, 8
-EDITTEXT        IDC_UID, 92, 59, 111, 12, ES_AUTOHSCROLL
-EDITTEXT        IDC_PWD, 92, 76, 111, 13, ES_PASSWORD | ES_AUTOHSCROLL
-PUSHBUTTON      "Connect", IDC_CONNECT, 91, 95, 111, 14
-LTEXT           "Project", IDC_STATIC, 61, 119, 23, 8
-COMBOBOX        IDC_COMBO1, 92, 117, 112, 30, CBS_DROPDOWN | CBS_SORT | 
WS_DISABLED | WS_VSCROLL | WS_TABSTOP
-DEFPUSHBUTTON   "Done", IDOK, 91, 138, 50, 14, WS_DISABLED
+    PUSHBUTTON      "Cancel",IDCANCEL,137,182,50,14
+    LTEXT           "Server Host",IDC_STATIC,44,74,38,8
+    LTEXT           "Port",IDC_STATIC,68,90,14,8
+    EDITTEXT        IDC_SERVER,91,72,110,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PORT,91,89,30,12,ES_AUTOHSCROLL
+    LTEXT           "Username",IDC_STATIC,49,106,33,8
+    LTEXT           "Password",IDC_STATIC,50,125,32,8
+    EDITTEXT        IDC_UID,91,105,111,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PWD,91,122,111,12,ES_PASSWORD | ES_AUTOHSCROLL
+    PUSHBUTTON      "Connect",IDC_CONNECT,91,140,73,15
+    LTEXT           "Project",IDC_STATIC,59,165,23,8
+    COMBOBOX        IDC_COMBO1,91,163,104,30,CBS_DROPDOWN | CBS_SORT | 
WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+    DEFPUSHBUTTON   "Done",IDOK,79,182,50,14,WS_DISABLED
+    CONTROL         108,IDC_STATIC,"Static",SS_BITMAP,0,0,266,48
+    LTEXT           "Protocol",IDC_STATIC,55,57,27,8
+    COMBOBOX        IDC_PROTOCOL,91,55,48,30,CBS_DROPDOWNLIST | WS_VSCROLL | 
WS_TABSTOP
 END
 
-IDD_DSN_CFG2 DIALOGEX 0, 0, 263, 204
+IDD_DSN_CFG2 DIALOGEX 0, 0, 265, 242
 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION
-CAPTION "Kylin DSN Configuration Dialog"
+CAPTION "Apache Kylin DSN Configuration"
 FONT 8, "MS Sans Serif", 0, 0, 0x0
 BEGIN
-PUSHBUTTON      "Cancel", IDCANCEL, 145, 167, 50, 14
-LTEXT           "&DSN Name", IDC_STATIC, 49, 17, 37, 8
-LTEXT           "Server Host", IDC_STATIC, 48, 35, 38, 8
-LTEXT           "Port", IDC_STATIC, 72, 52, 14, 8
-EDITTEXT        IDC_DSNNAME, 93, 14, 102, 12, ES_AUTOHSCROLL
-EDITTEXT        IDC_SERVER, 93, 33, 102, 12, ES_AUTOHSCROLL
-EDITTEXT        IDC_PORT, 93, 50, 30, 12, ES_AUTOHSCROLL
-LTEXT           "(only https service permitted)", IDC_STATIC, 94, 66, 90, 8
-LTEXT           "Username", IDC_STATIC, 53, 82, 33, 8
-LTEXT           "Password", IDC_STATIC, 55, 102, 32, 8
-EDITTEXT        IDC_UID, 93, 79, 102, 12, ES_AUTOHSCROLL
-EDITTEXT        IDC_PWD, 93, 97, 102, 13, ES_PASSWORD | ES_AUTOHSCROLL
-PUSHBUTTON      "Connect", IDC_BTEST, 94, 117, 102, 14
-LTEXT           "Project", IDC_STATIC, 63, 145, 23, 8
-COMBOBOX        IDC_COMBO1, 94, 143, 101, 30, CBS_DROPDOWN | CBS_SORT | 
WS_DISABLED | WS_VSCROLL | WS_TABSTOP
-DEFPUSHBUTTON   "Done", IDOK, 84, 167, 50, 14, WS_DISABLED
+    PUSHBUTTON      "Cancel",IDCANCEL,138,214,50,14
+    LTEXT           "&DSN Name",IDC_STATIC,60,61,37,8
+    LTEXT           "Server Host",IDC_STATIC,59,97,38,8
+    LTEXT           "Port",IDC_STATIC,83,113,14,8
+    EDITTEXT        IDC_DSNNAME,104,59,102,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_SERVER,104,94,102,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PORT,104,111,48,12,ES_AUTOHSCROLL
+    LTEXT           "Username",IDC_STATIC,64,131,33,8
+    LTEXT           "Password",IDC_STATIC,65,149,32,8
+    EDITTEXT        IDC_UID,104,129,102,12,ES_AUTOHSCROLL
+    EDITTEXT        IDC_PWD,104,147,102,12,ES_PASSWORD | ES_AUTOHSCROLL
+    PUSHBUTTON      "Connect",IDC_BTEST,104,165,60,16
+    LTEXT           "Project",IDC_STATIC,74,188,23,8
+    COMBOBOX        IDC_COMBO1,104,186,101,30,CBS_DROPDOWN | CBS_SORT | 
WS_DISABLED | WS_VSCROLL | WS_TABSTOP
+    DEFPUSHBUTTON   "Done",IDOK,77,214,50,14,WS_DISABLED
+    CONTROL         108,IDC_STATIC,"Static",SS_BITMAP,0,0,266,48
+    LTEXT           "Protocol",IDC_STATIC,70,78,27,8
+    COMBOBOX        IDC_PROTOCOL,104,76,48,30,CBS_DROPDOWNLIST | WS_VSCROLL | 
WS_TABSTOP
 END
 
 
@@ -160,23 +181,47 @@ END
 #ifdef APSTUDIO_INVOKED
 GUIDELINES DESIGNINFO
 BEGIN
-IDD_DSN_CFG1, DIALOG
-BEGIN
-LEFTMARGIN, 7
-RIGHTMARGIN, 256
-TOPMARGIN, 7
-BOTTOMMARGIN, 155
+    IDD_DSN_CFG1, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 258
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 203
+    END
+
+    IDD_DSN_CFG2, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 258
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 235
+    END
 END
+#endif    // APSTUDIO_INVOKED
+
 
-IDD_DSN_CFG2, DIALOG
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_DSN_CFG1 DLGINIT
 BEGIN
-LEFTMARGIN, 7
-RIGHTMARGIN, 256
-TOPMARGIN, 7
-BOTTOMMARGIN, 197
+    IDC_PROTOCOL, 0x403, 5, 0
+0x7468, 0x7074, "\000" 
+    IDC_PROTOCOL, 0x403, 6, 0
+0x7468, 0x7074, 0x0073, 
+    0
 END
+
+IDD_DSN_CFG2 DLGINIT
+BEGIN
+    IDC_PROTOCOL, 0x403, 6, 0
+0x7468, 0x7074, 0x0073, 
+    IDC_PROTOCOL, 0x403, 5, 0
+0x7468, 0x7074, "\000" 
+    0
 END
-#endif    // APSTUDIO_INVOKED
 
 #endif    // English (United States) resources
 /////////////////////////////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/KO_CONN.CPP
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_CONN.CPP b/odbc/Driver/KO_CONN.CPP
index 9d31df0..28642b1 100644
--- a/odbc/Driver/KO_CONN.CPP
+++ b/odbc/Driver/KO_CONN.CPP
@@ -48,6 +48,12 @@
 #define MAX_CONN_STR_LEN       2048                 // arbitray for building 
key-values from DSN
 #define KV_BLOCK_SIZE          5                    // arbitray size for a set 
of key-value pairs
 
+#define PROTOCOL_HTTPS                 "https"
+#define PROTOCOL_HTTP                  "http"
+#define PROTOCOL_SEP                   "://"
+#define PORT_HTTPS_DEFAULT             "443"
+#define PORT_HTTP_DEFAULT              "80"
+
 // ------------------------ local callback functions  -------------------------
 INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM 
lParam );
 
@@ -67,7 +73,8 @@ static bool         AddKVToConnStr ( StrPtr pKey, StrPtr 
pValue, Word* iPos, Str
 static bool         BuildConnStr ( char* pStrConn, Word pMaxLen, pODBCConn 
pConn, struct ODBCKV* KVInput,
                                    Word iKVInputPairs, struct ODBCKV* 
KVFileDSN, Word iKVFileDSNPairs );
 
-
+static const char *supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
+static const char *defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
 
 // -----------------------------------------------------------------------
 // to set a specified property in the connection structure
@@ -288,8 +295,17 @@ static eGoodBad GetDataFromDlgDSNCfg1 ( HWND hDlg, 
pODBCConn pConn ) {
     x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
     
     if ( x > 0 ) {
-        n = make_unique_str ( x );                              // allocate 
space for holding the text
-        GetDlgItemText ( hDlg, IDC_SERVER, n.get(), x + 1 );      // get text 
from dialog
+        n = make_unique_str ( x + 8 );                                         
                // allocate space for holding the text
+
+               char serverStrBuf[256];                                         
  
+        GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, x + 1 );      // get 
text from dialog
+
+               HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+               int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, 
( WPARAM ) 0, ( LPARAM ) 0 );
+               
+               strcpy ( n.get(), supportedProtocols[ItemIndex] );
+               strcat ( n.get(), PROTOCOL_SEP );
+               strcat ( n.get(), serverStrBuf );
     }
     
     else
@@ -358,16 +374,37 @@ INT_PTR CALLBACK DlgDSNCfg1Proc ( HWND hDlg, UINT uMsg, 
WPARAM wParam, LPARAM lP
     RETCODE ret = SQL_SUCCESS;
     
     switch ( uMsg ) {
-        case WM_INITDIALOG:
+        case WM_INITDIALOG: {
+                       // init protocol list
+                       HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+            SendMessage(hwndCombo, CB_ADDSTRING, 0, 
reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[0]));
+                       SendMessage(hwndCombo, CB_ADDSTRING, 0, 
reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[1]));
+                       SendMessage(hwndCombo, CB_SETCURSEL, 0, 0 );
+
             // store the structure for future use
             SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
             // initialize the dialog with data from conn struct
             PutDataToDlgDSNCfg1 ( ( pODBCConn ) lParam, hDlg );
             // set focus automatically
             return TRUE;
-            
+               }
         case WM_COMMAND:
             switch ( LOWORD ( wParam ) ) {
+                               case IDC_PROTOCOL: {
+                                       switch ( HIWORD ( wParam ) ) {
+                                               case CBN_SELCHANGE: {
+                                                       HWND hwndCombo = 
GetDlgItem ( hDlg, IDC_PROTOCOL );
+                                                       int portIndex = 
SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+                                                       if ( SetDlgItemText ( 
hDlg, IDC_PORT, defaultPorts[portIndex] ) ) { return TRUE; }
+
+                                                       return FALSE;
+                                               }
+                                               default:
+                                                       break;
+                                       }
+                                       break;
+                               }
+
                 case IDC_CONNECT: {
                         HWND hwndCombo = GetDlgItem ( hDlg, IDC_COMBO1 );
                         HWND hwndOK = GetDlgItem ( hDlg, IDOK );

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/KO_Config.cpp
----------------------------------------------------------------------
diff --git a/odbc/Driver/KO_Config.cpp b/odbc/Driver/KO_Config.cpp
index bb27fb4..d4ebae3 100644
--- a/odbc/Driver/KO_Config.cpp
+++ b/odbc/Driver/KO_Config.cpp
@@ -39,8 +39,17 @@
 #define DRIVER_NAME "KylinODBCDriver"
 #define DRIVER_DEFAULT_LOCATION "C:\\Program Files 
(x86)\\kylinolap\\KylinODBCDriver\\driver.dll"
 
+#define PROTOCOL_HTTPS "https"
+#define PROTOCOL_HTTP "http"
+#define PROTOCOL_SEP "://"
+#define PORT_HTTPS_DEFAULT "443"
+#define PORT_HTTP_DEFAULT "80"
+
 static char currentDSN[BUFFERSIZE];
 
+static const char *supportedProtocols[] = { PROTOCOL_HTTPS, PROTOCOL_HTTP };
+static const char *defaultPorts[] = { PORT_HTTPS_DEFAULT, PORT_HTTP_DEFAULT };
+
 static int GetValueFromODBCINI ( char* section, char* key, char* defaultValue, 
char* buffer, int bufferSize,
                                  char* initFileName ) {
     return SQLGetPrivateProfileString ( section, key, defaultValue, buffer, 
bufferSize, initFileName );
@@ -101,18 +110,40 @@ static eGoodBad LoadODBCINIDataToDlgDSNCfg2 ( HWND hDlg ) 
{
     
     if ( !x )  { return BAD; }
     
-    // server name/IP
+    // server name/IP and protocol
     GetValueFromODBCINI ( currentDSN, SERVERKEY, "", buffer, BUFFERSIZE, 
INITFILE );
+
+       int protocol = 0;
+       int hostOffset = 0;
+       if (buffer[0] == 'h' && buffer[1] == 't' && buffer[2] == 't' && 
buffer[3] == 'p')
+       {
+               if (buffer[4] == ':' && buffer[5] == '/' && buffer[6] == '/')
+               {
+                       protocol = 1;
+                       hostOffset = 7;
+               } 
+               else if (buffer[4] == 's' && buffer[5] == ':' && buffer[6] == 
'/' && buffer[7] == '/')
+               {
+                       hostOffset = 8;
+               }
+       }
+       HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+       SendMessage ( hwndCombo, CB_SETCURSEL, protocol, 0 );
+       
+       strcpy(buffer, buffer + hostOffset);
     x = SetDlgItemText ( hDlg, IDC_SERVER, buffer );
-    
     if ( !x )  { return BAD; }
     
     // server port
-    GetValueFromODBCINI ( currentDSN, PORTKEY, "443", buffer, BUFFERSIZE, 
INITFILE );
+       char* defaultPort = PORT_HTTPS_DEFAULT;
+       if (protocol == 1)
+       {
+               defaultPort = PORT_HTTP_DEFAULT;
+       }
+    GetValueFromODBCINI ( currentDSN, PORTKEY, defaultPort, buffer, 
BUFFERSIZE, INITFILE );
+
     int portTemp = atoi ( buffer );
-    
-    if ( portTemp == 0 )
-    { portTemp = 443; }
+    if ( portTemp == 0 ) { portTemp = atoi(defaultPort); }
     
     x = SetDlgItemInt ( hDlg, IDC_PORT, portTemp, FALSE );
     
@@ -138,7 +169,7 @@ static eGoodBad RetriveDlgData ( HWND hDlg, char* newDSN, 
char* serverStr, char*
     Long x;
     
     if ( !hDlg ) {
-        __ODBCPOPMSG ( _ODBCPopMsg ( "RetriveDlgData - Bad params: hDlg is 
NULL" ) );
+        __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "RetriveDlgData - Bad 
params: hDlg is NULL" ) );
         return BAD;
     }
     
@@ -154,19 +185,25 @@ static eGoodBad RetriveDlgData ( HWND hDlg, char* newDSN, 
char* serverStr, char*
     
     ////// server name/IP
     // get length of input text
+
     x = SendDlgItemMessage ( hDlg, IDC_SERVER, EM_LINELENGTH, 0, 0 );
-    
     if ( x > 0 ) {
-        GetDlgItemText ( hDlg, IDC_SERVER, serverStr, BUFFERSIZE );        // 
get text from dialog
+               char serverStrBuf[BUFFERSIZE - 8];
+        GetDlgItemText ( hDlg, IDC_SERVER, serverStrBuf, BUFFERSIZE );        
// get text from dialog
+
+               HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+               int ItemIndex = SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, 
( WPARAM ) 0, ( LPARAM ) 0 );
+               strcpy ( serverStr, supportedProtocols[ItemIndex] );
+               strcat ( serverStr, PROTOCOL_SEP );
+               strcat ( serverStr, serverStrBuf );
     }
-    
     else {
         serverStr[0] = '\0';
     }
-    
     /////  Port
     // get value
     *port = GetDlgItemInt ( hDlg, IDC_PORT, NULL, FALSE );
+
     ////// User name
     // get length
     x = SendDlgItemMessage ( hDlg, IDC_UID, EM_LINELENGTH, 0, 0 );
@@ -335,7 +372,7 @@ static eGoodBad RetriveDlgDataToODBCINI ( HWND hDlg, bool 
onlyTest ) {
     char portStrBuffer[BUFFERSIZE];
     
     if ( !hDlg ) {
-        __ODBCPOPMSG ( _ODBCPopMsg ( "RetriveDlgDataToODBCINI - Bad params: 
hDlg is NULL" ) );
+        __ODBCLOG ( _ODBCLogMsg ( LogLevel_DEBUG, "RetriveDlgDataToODBCINI - 
Bad params: hDlg is NULL" ) );
         return BAD;
     }
     
@@ -566,7 +603,14 @@ INT_PTR CALLBACK DlgDSNCfg2Proc ( HWND hDlg, UINT uMsg, 
WPARAM wParam, LPARAM lP
     char        pwdStr[BUFFERSIZE];
     
     switch ( uMsg ) {
-        case WM_INITDIALOG:
+        case WM_INITDIALOG: {
+                       // init protocol list
+                       
+                       HWND hwndCombo = GetDlgItem ( hDlg, IDC_PROTOCOL );
+            SendMessage(hwndCombo, CB_ADDSTRING, 0, 
reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[0]));
+                       SendMessage(hwndCombo, CB_ADDSTRING, 0, 
reinterpret_cast<LPARAM>((LPCTSTR)supportedProtocols[1]));
+                       SendMessage(hwndCombo, CB_SETCURSEL, 0, 0 );
+
             SetCurrentDSN ( attributes, "DlgDSNCfg2Proc" );
             // store the structure for future use
             SetWindowLongPtr ( hDlg, DWLP_USER, lParam );
@@ -577,9 +621,23 @@ INT_PTR CALLBACK DlgDSNCfg2Proc ( HWND hDlg, UINT uMsg, 
WPARAM wParam, LPARAM lP
             
             // set focus automatically
             return TRUE;
-            
+               }
         case WM_COMMAND:
             switch ( LOWORD ( wParam ) ) {
+                               case IDC_PROTOCOL: {
+                                       switch ( HIWORD ( wParam ) ) {
+                                               case CBN_SELCHANGE: {
+                                                       HWND hwndCombo = 
GetDlgItem ( hDlg, IDC_PROTOCOL );
+                                                       int portIndex = 
SendMessage ( hwndCombo, ( UINT ) CB_GETCURSEL, ( WPARAM ) 0, ( LPARAM ) 0 );
+                                                       if ( SetDlgItemText ( 
hDlg, IDC_PORT, defaultPorts[portIndex] ) ) { return TRUE; }
+
+                                                       return FALSE;
+                                               }
+                                               default:
+                                                       break;
+                                       }
+                                       break;
+                               }
                 case IDC_BTEST: {
                         if ( RetriveDlgData ( hDlg, newDSN, serverStr, uidStr, 
pwdStr, &port ) == GOOD ) {
                             if ( testConnection ( serverStr, uidStr, pwdStr, 
port ) == GOOD ) {
@@ -613,12 +671,12 @@ INT_PTR CALLBACK DlgDSNCfg2Proc ( HWND hDlg, UINT uMsg, 
WPARAM wParam, LPARAM lP
                             }
                             
                             else {
-                                __ODBCPopMsg ( "testConnection failed." );
+                                __ODBCPopMsg ( "Connection failed." );
                             }
                         }
                         
                         else {
-                            __ODBCPopMsg ( "RetriveDlgData failed." );
+                            __ODBCLOG ( _ODBCLogMsg ( LogLevel_INFO, 
"RetriveDlgData failed." ));
                         }
                         
                         return FALSE;

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/banner.bmp
----------------------------------------------------------------------
diff --git a/odbc/Driver/banner.bmp b/odbc/Driver/banner.bmp
new file mode 100644
index 0000000..936cd2f
Binary files /dev/null and b/odbc/Driver/banner.bmp differ

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/driver.vcxproj
----------------------------------------------------------------------
diff --git a/odbc/Driver/driver.vcxproj b/odbc/Driver/driver.vcxproj
index 0e60c0c..415030d 100644
--- a/odbc/Driver/driver.vcxproj
+++ b/odbc/Driver/driver.vcxproj
@@ -16,8 +16,6 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -->
-
-
 <Project DefaultTargets="Build" ToolsVersion="4.0" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
   <ItemGroup Label="ProjectConfigurations">
     <ProjectConfiguration Include="Debug|Win32">
@@ -388,6 +386,9 @@
   <ItemGroup>
     <ResourceCompile Include="GODBC.RC" />
   </ItemGroup>
+  <ItemGroup>
+    <Image Include="banner.bmp" />
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/driver.vcxproj.filters
----------------------------------------------------------------------
diff --git a/odbc/Driver/driver.vcxproj.filters 
b/odbc/Driver/driver.vcxproj.filters
index a60e5e1..aafa067 100644
--- a/odbc/Driver/driver.vcxproj.filters
+++ b/odbc/Driver/driver.vcxproj.filters
@@ -16,8 +16,6 @@
  See the License for the specific language governing permissions and
  limitations under the License.
 -->
-
-
 <Project ToolsVersion="4.0" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003";>
   <ItemGroup>
     <Filter Include="Source Files">
@@ -101,4 +99,9 @@
       <Filter>Source Files</Filter>
     </CustomBuild>
   </ItemGroup>
+  <ItemGroup>
+    <Image Include="banner.bmp">
+      <Filter>Resource Files</Filter>
+    </Image>
+  </ItemGroup>
 </Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/kylin/blob/9b19b69f/odbc/Driver/resource.h
----------------------------------------------------------------------
diff --git a/odbc/Driver/resource.h b/odbc/Driver/resource.h
index eb0d30b..fa30988 100644
--- a/odbc/Driver/resource.h
+++ b/odbc/Driver/resource.h
@@ -23,6 +23,7 @@
 #define IDOK2                           3
 #define IDD_DSN_CFG1                    101
 #define IDD_DSN_CFG2                    102
+#define IDB_BITMAP1                     108
 #define IDC_DSNNAME                     1000
 #define IDC_SERVER                      1001
 #define IDC_PORT                        1002
@@ -31,20 +32,21 @@
 #define IDC_BTEST                       1005
 #define IDC_CONNECT                     1006
 #define IDC_COMBO1                      1007
-
 #define IDC_COMPANY                     1008
+#define IDC_PROTOCOL                    1008
 #define IDC_PREV                        1009
 #define IDC_DATABASE                    1010
 #define IDC_SERVER2                     1011
 #define IDC_BUTTON1                     1012
+#define IDC_COMBO2                      1015
 
 // Next default values for new objects
-//
+// 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        108
+#define _APS_NEXT_RESOURCE_VALUE        111
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1015
+#define _APS_NEXT_CONTROL_VALUE         1016
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Reply via email to