summaryrefslogtreecommitdiff
path: root/storage/ndb/src/cw
diff options
context:
space:
mode:
Diffstat (limited to 'storage/ndb/src/cw')
-rw-r--r--storage/ndb/src/cw/Makefile.am4
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp215
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp216
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw29
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h40
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.icobin0 -> 1078 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc193
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln21
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suobin0 -> 8704 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj240
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/Closed.ICObin0 -> 1078 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp436
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/Open.ICObin0 -> 1078 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp24
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h69
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp19
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/TreeView.h19
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmpbin0 -> 622 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/resource.h90
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/small.icobin0 -> 318 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmpbin0 -> 622 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/App.icobin0 -> 1078 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs1400
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs256
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs242
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs228
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICObin0 -> 1078 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/Database.cs162
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj240
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user48
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncbbin0 -> 19456 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln21
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs1883
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/Process.cs144
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs435
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs41
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs360
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs207
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs26
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs251
-rw-r--r--storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs408
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Computer.cls20
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Database.cls18
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 110.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 231.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 237.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 241.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 242.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 270.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 271.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 273.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 31.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 337.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 338.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Icon 339.icobin0 -> 766 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/MSSCCPRJ.SCC5
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Module1.bas233
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbp49
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbw13
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/Process.cls22
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/closed folder.icobin0 -> 10134 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/computer.icobin0 -> 10134 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmAbout.frm245
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmLogin.frm119
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmMain.frm1207
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frm124
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frxbin0 -> 4 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase.frxbin0 -> 12 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase1.frm187
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.frm136
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.log1
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase3.frm88
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmOptions.frm231
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/frmSplash.frxbin0 -> 70450 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/networking.icobin0 -> 10134 bytes
-rw-r--r--storage/ndb/src/cw/cpcc-win32/vb6/open folder.icobin0 -> 10134 bytes
-rw-r--r--storage/ndb/src/cw/cpcd/APIService.cpp386
-rw-r--r--storage/ndb/src/cw/cpcd/APIService.hpp64
-rw-r--r--storage/ndb/src/cw/cpcd/CPCD.cpp435
-rw-r--r--storage/ndb/src/cw/cpcd/CPCD.hpp382
-rw-r--r--storage/ndb/src/cw/cpcd/Makefile.am20
-rw-r--r--storage/ndb/src/cw/cpcd/Monitor.cpp79
-rw-r--r--storage/ndb/src/cw/cpcd/Process.cpp479
-rw-r--r--storage/ndb/src/cw/cpcd/common.cpp98
-rw-r--r--storage/ndb/src/cw/cpcd/common.hpp36
-rw-r--r--storage/ndb/src/cw/cpcd/main.cpp187
-rw-r--r--storage/ndb/src/cw/test/socketclient/Makefile24
-rw-r--r--storage/ndb/src/cw/test/socketclient/socketClientTest.cpp64
-rw-r--r--storage/ndb/src/cw/util/ClientInterface.cpp185
-rw-r--r--storage/ndb/src/cw/util/ClientInterface.hpp49
-rw-r--r--storage/ndb/src/cw/util/Makefile10
-rw-r--r--storage/ndb/src/cw/util/SocketRegistry.cpp213
-rw-r--r--storage/ndb/src/cw/util/SocketRegistry.hpp290
-rw-r--r--storage/ndb/src/cw/util/SocketService.cpp60
-rw-r--r--storage/ndb/src/cw/util/SocketService.hpp46
95 files changed, 13772 insertions, 0 deletions
diff --git a/storage/ndb/src/cw/Makefile.am b/storage/ndb/src/cw/Makefile.am
new file mode 100644
index 00000000000..7348fc9eab6
--- /dev/null
+++ b/storage/ndb/src/cw/Makefile.am
@@ -0,0 +1,4 @@
+SUBDIRS = cpcd
+
+windoze-dsp:
+
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp
new file mode 100644
index 00000000000..59ee3e90451
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.cpp
@@ -0,0 +1,215 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include "stdafx.h"
+
+HINSTANCE hInst ;
+TCHAR szTitle[MAX_LOADSTRING] ;
+TCHAR szWindowClass[MAX_LOADSTRING] ;
+
+static CNdbControls controls ;
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow){
+ MSG msg;
+ HACCEL hAccelTable;
+
+ LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING) ;
+ LoadString(hInstance, IDC_CPC_GUI, szWindowClass, MAX_LOADSTRING) ;
+ NdbRegisterClass(hInstance);
+
+ if (!InitInstance (hInstance, nCmdShow)) {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_CPC_GUI);
+
+ while (GetMessage(&msg, NULL, 0, 0)){
+
+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)){
+
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+
+ }
+
+ }
+
+ return msg.wParam;
+}
+
+
+ATOM NdbRegisterClass(HINSTANCE hInstance){
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW ;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_CPC_GUI);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW);
+ wcex.lpszMenuName = (LPCSTR)IDC_CPC_GUI;
+ wcex.lpszClassName = szWindowClass;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassEx(&wcex);
+}
+
+
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){
+
+ HWND hWnd;
+
+ hInst = hInstance;
+
+ hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ InitCommonControls();
+
+ if (!hWnd) return FALSE ;
+
+ ShowWindow(hWnd, nCmdShow) ;
+ UpdateWindow(hWnd) ;
+
+ return TRUE;
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
+
+ int wmId, wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ int c = 0 ;
+
+ switch (message)
+ {
+
+ case WM_CREATE:
+ _assert(controls.Create(hInst, hWnd)) ;
+ return 0 ;
+
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+
+ switch (wmId){
+ case IDM_ABOUT:
+ DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
+ break;
+ case IDM_EXIT:
+ DestroyWindow(hWnd);
+ break;
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR) lParam)->code) {
+ case TTN_GETDISPINFO: {
+
+ LPTOOLTIPTEXT lpttt;
+ lpttt = (LPTOOLTIPTEXT) lParam;
+ lpttt->hinst = hInst;
+
+ int idButton = lpttt->hdr.idFrom;
+
+ switch (idButton){
+ case IDM_NEW:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_NEW);
+ break;
+ case IDM_DELETE:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_DELETE);
+ break;
+ case IDM_PROPS:
+ lpttt->lpszText = MAKEINTRESOURCE(IDS_TIP_PROPS);
+ break;
+ }
+ break;
+ }
+ case TVN_SELCHANGED: {
+ LPNMTREEVIEW pnmtv ;
+
+ pnmtv = (LPNMTREEVIEW) lParam ;
+ controls.ToggleListViews(pnmtv) ;
+
+ break ;
+ }
+
+ case NM_RCLICK: {
+ LPNMHDR lpnmh ;
+ lpnmh = (LPNMHDR) lParam ;
+ switch(lpnmh->idFrom){
+ case ID_TREEVIEW:
+ break;
+ default:
+ break ;
+ }
+ }
+
+ default:
+ break;
+ }
+
+
+ case WM_PAINT:
+ hdc = BeginPaint(hWnd, &ps) ;
+ EndPaint(hWnd, &ps);
+ break;
+
+ case WM_SIZE:
+ controls.Resize() ;
+ return 0 ;
+
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ return 0;
+}
+
+
+LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){
+
+ switch (message){
+
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL){
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+
+
+
+
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp
new file mode 100644
index 00000000000..91007b0a47e
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsp
@@ -0,0 +1,216 @@
+# Microsoft Developer Studio Project File - Name="CPC_GUI" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=CPC_GUI - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "CPC_GUI.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "CPC_GUI.mak" CFG="CPC_GUI - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "CPC_GUI - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "CPC_GUI - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "CPC_GUI - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /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"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib mfc42.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF "$(CFG)" == "CPC_GUI - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /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"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib comctl32.lib mfc42d.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "CPC_GUI - Win32 Release"
+# Name "CPC_GUI - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\CPC_GUI.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CPC_GUI.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\NdbControls.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\CPC_GUI.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\NdbControls.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\bitmap1.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\bmp00001.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\C.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Closed.BMP
+# End Source File
+# Begin Source File
+
+SOURCE=.\Closed.ICO
+# End Source File
+# Begin Source File
+
+SOURCE=.\Closed24.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Computer24.BMP
+# End Source File
+# Begin Source File
+
+SOURCE=.\CPC_GUI.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\Db.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\icon1.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\O.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Open.BMP
+# End Source File
+# Begin Source File
+
+SOURCE=.\Open.ICO
+# End Source File
+# Begin Source File
+
+SOURCE=.\Open24.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\small.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\toolbar.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\toolbar1.bmp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Tower2.ICO
+# End Source File
+# Begin Source File
+
+SOURCE=.\TowerIC1.BMP
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw
new file mode 100644
index 00000000000..1f163a31662
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "CPC_GUI"=.\CPC_GUI.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h
new file mode 100644
index 00000000000..cf7670948a7
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+#if !defined(AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_)
+#define AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+
+#define MAX_LOADSTRING 100
+
+
+
+#define TV_ROOT_ITEMS 2
+
+
+// Global Variables
+
+ATOM NdbRegisterClass(HINSTANCE) ;
+BOOL InitInstance(HINSTANCE, int) ;
+LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM) ;
+LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
+
+#endif // !defined(AFX_CPC_GUI_H__EA01C861_C56D_48F1_856F_4935E20620B1__INCLUDED_)
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico
new file mode 100644
index 00000000000..386883523bc
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc
new file mode 100644
index 00000000000..41d75b2b282
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.rc
@@ -0,0 +1,193 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_CPC_GUI ICON DISCARDABLE "CPC_GUI.ICO"
+IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDM_CPC_GUI MENU DISCARDABLE
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "E&xit", IDM_EXIT
+ END
+ POPUP "&Actions"
+ BEGIN
+ MENUITEM "&Insert...", ID_ACTIONS_INSERT
+ MENUITEM "&Delete", ID_ACTIONS_DELETE
+ MENUITEM "&Properties", ID_ACTIONS_PROPERTIES
+ END
+ POPUP "&Help"
+ BEGIN
+ MENUITEM "&About ...", IDM_ABOUT
+ END
+END
+
+IDM_TREEVIEW MENU DISCARDABLE
+BEGIN
+ MENUITEM "&Insert", ID_TREEVIEW1
+ MENUITEM "&Delete", ID_DELETE
+ MENUITEM "&Properties", ID_PROPERTIES
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Accelerator
+//
+
+IDC_CPC_GUI ACCELERATORS MOVEABLE PURE
+BEGIN
+ "?", IDM_ABOUT, ASCII, ALT
+ "/", IDM_ABOUT, ASCII, ALT
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
+STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
+CAPTION "About"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "NDB Cluster Process Control Applet v1.0",IDC_STATIC,7,8,
+ 213,8,SS_NOPREFIX
+ LTEXT "Copyright (C) 2003 MySQL AB",
+ IDC_STATIC,7,20,213,20
+ DEFPUSHBUTTON "OK",IDOK,185,55,41,16,WS_GROUP
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+2 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""resource.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+1 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "resource.h\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDR_TOOLBAR BITMAP MOVEABLE PURE "toolbar.bmp"
+IDB_TOOLBAR BITMAP MOVEABLE PURE "bitmap1.bmp"
+IDB_COMPUTER BITMAP MOVEABLE PURE "TowerIC1.BMP"
+IDB_OPEN BITMAP MOVEABLE PURE "Open.BMP"
+IDB_CLOSED BITMAP MOVEABLE PURE "Closed.BMP"
+IDB_DATABASE BITMAP MOVEABLE PURE "DB.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Toolbar
+//
+
+IDR_TOOLBAR TOOLBAR MOVEABLE PURE 18, 18
+BEGIN
+ BUTTON ID_BUTTON32773
+ BUTTON ID_BUTTON32783
+ BUTTON ID_BUTTON32784
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_APP_TITLE "NDB Cluster Process Control Applet"
+ IDS_TV_ROOT_COMPUTERS "Computers"
+ IDS_TV_ROOT_DATABASES "Databases"
+ IDS_LV_COMPUTER_HEADER_1 "Computer"
+ IDS_LV_COMPUTER_HEADER_2 "Hostname"
+ IDS_LV_PROCESS_HEADER_1 "Process"
+ IDC_CPC_GUI "CPC_GUI"
+ IDS_TIP_NEW "Add new computer or database"
+ IDS_TIP_DELETE "Delete selected computer or database"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_TIP_PROPS "Display properties for selected computer or database"
+ IDS_LV_PROCESS_HEADER_2 "Name"
+ IDS_LV_PROCESS_HEADER_3 "Owner"
+ IDS_LV_PROCESS_HEADER_4 "Status"
+ IDS_LV_COMPUTER_HEADER_3 "Status"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln
new file mode 100644
index 00000000000..86b574d851d
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPC_GUI", "CPC_GUI.vcproj", "{F5FADD9D-4353-4A73-88DC-474A4D17B485}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Debug.ActiveCfg = Debug|Win32
+ {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Debug.Build.0 = Debug|Win32
+ {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Release.ActiveCfg = Release|Win32
+ {F5FADD9D-4353-4A73-88DC-474A4D17B485}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo
new file mode 100644
index 00000000000..e7d178f04c3
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.suo
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj
new file mode 100644
index 00000000000..56f9f3a8511
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/CPC_GUI.vcproj
@@ -0,0 +1,240 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="CPC_GUI"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Release/CPC_GUI.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="mfc42.lib"
+ OutputFile=".\Release/CPC_GUI.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ ProgramDatabaseFile=".\Release/CPC_GUI.pdb"
+ SubSystem="2"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/CPC_GUI.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="3"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/CPC_GUI.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="comctl32.lib mfc70d.lib"
+ OutputFile=".\Debug/CPC_GUI.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/CPC_GUI.pdb"
+ SubSystem="2"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/CPC_GUI.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath=".\CPC_GUI.cpp">
+ </File>
+ <File
+ RelativePath=".\CPC_GUI.rc">
+ </File>
+ <File
+ RelativePath=".\NdbControls.cpp">
+ </File>
+ <File
+ RelativePath=".\StdAfx.cpp">
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\CPC_GUI.h">
+ </File>
+ <File
+ RelativePath=".\NdbControls.h">
+ </File>
+ <File
+ RelativePath=".\StdAfx.h">
+ </File>
+ <File
+ RelativePath=".\resource.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ <File
+ RelativePath=".\C.bmp">
+ </File>
+ <File
+ RelativePath=".\CPC_GUI.ico">
+ </File>
+ <File
+ RelativePath=".\Closed.BMP">
+ </File>
+ <File
+ RelativePath=".\Closed.ICO">
+ </File>
+ <File
+ RelativePath=".\Closed24.bmp">
+ </File>
+ <File
+ RelativePath=".\Computer24.BMP">
+ </File>
+ <File
+ RelativePath=".\Db.bmp">
+ </File>
+ <File
+ RelativePath=".\O.bmp">
+ </File>
+ <File
+ RelativePath=".\Open.BMP">
+ </File>
+ <File
+ RelativePath=".\Open.ICO">
+ </File>
+ <File
+ RelativePath=".\Open24.bmp">
+ </File>
+ <File
+ RelativePath=".\Tower2.ICO">
+ </File>
+ <File
+ RelativePath=".\TowerIC1.BMP">
+ </File>
+ <File
+ RelativePath=".\bitmap1.bmp">
+ </File>
+ <File
+ RelativePath=".\bmp00001.bmp">
+ </File>
+ <File
+ RelativePath=".\icon1.ico">
+ </File>
+ <File
+ RelativePath=".\small.ico">
+ </File>
+ <File
+ RelativePath=".\toolbar.bmp">
+ </File>
+ <File
+ RelativePath=".\toolbar1.bmp">
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO b/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO
new file mode 100644
index 00000000000..044042b42fb
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/Closed.ICO
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp
new file mode 100644
index 00000000000..6bbc9a9859b
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/NdbControls.cpp
@@ -0,0 +1,436 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include "stdafx.h"
+#include "NdbControls.h"
+
+
+/**
+* CNdbControl implementation
+*/
+
+BOOL CNdbControl::GetRect(LPRECT lprc) const {
+
+ _ASSERT(this) ;
+
+ return GetClientRect(m_hControl, lprc) ;
+
+}
+
+BOOL CNdbControl::Resize(LONG x, LONG y, LONG w, LONG h) const {
+
+ _ASSERT(this) ;
+
+ if(!MoveWindow(m_hControl, x, y, w, h, TRUE))
+ return FALSE ;
+ if(m_bVisible){
+ ShowWindow(m_hControl, SW_SHOW) ;
+ UpdateWindow(m_hControl) ;
+ }
+ return TRUE ;
+
+}
+
+BOOL CNdbControl::Show(BOOL bShow) {
+
+ _ASSERT(this) ;
+
+ if(bShow){
+ ShowWindow(m_hControl, SW_SHOW);
+ m_bVisible = TRUE ;
+ }else{
+ ShowWindow(m_hControl, SW_HIDE);
+ m_bVisible = FALSE ;
+ }
+ EnableWindow(m_hControl, bShow) ;
+ UpdateWindow(m_hControl) ;
+
+ return TRUE ;
+}
+
+
+
+CNdbControl::~CNdbControl(){
+
+ DestroyWindow(m_hControl) ;
+ if(m_hMenu)
+ DestroyMenu(m_hMenu) ;
+
+}
+
+
+/**
+* CNdbListView implementation
+*/
+
+BOOL CNdbListView::Create(HINSTANCE hInst, HWND hParent, DWORD dwId, NDB_ITEM_TYPE enType, PNDB_LV pstH, DWORD dwWidth) {
+
+ if(!pstH)
+ return FALSE ;
+
+ LV_COLUMN lvC ;
+ m_hInstance = hInst ;
+ m_hParent = hParent ;
+ m_dwId = dwId ;
+ m_dwWidth = dwWidth ;
+ m_dwWidth = 100 ;
+ m_enType = enType;
+ char* szLabels[MAX_LV_HEADERS] ;
+ int count = 0 ;
+
+ m_hControl = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, WC_LISTVIEW, TEXT(""),
+ WS_VISIBLE | WS_CHILD | WS_BORDER | LVS_REPORT,
+ 0, 0, 0, 0, m_hParent, (HMENU)m_dwId, hInst, NULL );
+
+ if(!m_hControl)
+ return FALSE ;
+
+ lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvC.fmt = LVCFMT_LEFT;
+
+ switch(enType){
+ case ITEM_COMPR_ROOT:
+ szLabels[0] = pstH->szComputer ;
+ szLabels[1] = pstH->szHostname ;
+ szLabels[2] = pstH->szStatus ;
+ count = 3 ;
+ break ;
+ case ITEM_DB_ROOT:
+ szLabels[0] = pstH->szDatabase ;
+ szLabels[1] = pstH->szStatus ;
+ count = 2 ;
+ break ;
+ case ITEM_COMPR:
+ szLabels[0] = pstH->szProcess ;
+ szLabels[1] = pstH->szDatabase;
+ szLabels[2] = pstH->szOwner ;
+ szLabels[3] = pstH->szStatus ;
+ count = 4 ;
+ case ITEM_DB:
+ szLabels[0] = pstH->szProcess ;
+ szLabels[1] = pstH->szComputer;
+ szLabels[2] = pstH->szOwner ;
+ szLabels[3] = pstH->szStatus ;
+ count = 4 ;
+ break ;
+ NDB_DEFAULT_UNREACHABLE ;
+ }
+
+ for(int j = 0 ; j < count ; ++j){
+ lvC.iSubItem = j ;
+ lvC.cx = m_dwWidth ;
+ lvC.pszText = szLabels[j] ;
+ if(0xFFFFFFFF == ListView_InsertColumn(m_hControl, j, &lvC))
+ return FALSE ;
+ }
+
+ SendMessage(m_hControl, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT,
+ LVS_EX_FULLROWSELECT );
+
+ ShowWindow(m_hControl, SW_SHOW) ;
+
+ return TRUE ;
+
+}
+
+
+
+/**
+* CNdbToolBar implementation
+*/
+
+
+
+/**
+* CNdbTreeView implementation
+*/
+
+BOOL CNdbTreeView::Create(HINSTANCE hInst, HWND hParent, DWORD dwMenuId, DWORD dwId){
+
+ if(!CreateTreeView(hInst, hParent, dwId))
+ return FALSE ;
+
+ m_hMenu = LoadMenu(m_hInstance,MAKEINTRESOURCE(dwMenuId)) ;
+ if(!m_hMenu)
+ return FALSE ;
+
+ return TRUE ;
+}
+
+
+BOOL CNdbTreeView::CreateTreeView(HINSTANCE hInst, HWND hParent, DWORD dwId){
+
+
+ m_hInstance = hInst ;
+ m_hParent = hParent ;
+ m_dwId = dwId ;
+ HIMAGELIST himl ;
+ HBITMAP hbmp ;
+ DWORD dwCount = 0 ;
+
+ m_hControl = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, WC_TREEVIEW, "Tree View",
+ WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES |
+ TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SINGLEEXPAND,
+ 0, 0, 0, 0, m_hParent, (HMENU)m_dwId, m_hInstance, NULL) ;
+
+ if(!m_hControl)
+ return FALSE ;
+
+ if((himl = ImageList_Create(nX, nY, ILC_MASK | ILC_COLOR8, 4, 0)) == NULL)
+ return FALSE ;
+
+ hbmp = LoadBitmap(m_hInstance, MAKEINTRESOURCE(IDI_OPEN));
+ hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_OPEN), IMAGE_BITMAP, nX, 0, LR_DEFAULTSIZE);
+ m_nOpen = ImageList_AddMasked(himl, hbmp, clr);
+ DeleteObject(hbmp);
+ hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_CLOSED), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
+ m_nClosed = ImageList_AddMasked(himl, hbmp, clr);
+ DeleteObject(hbmp);
+ hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_COMPUTER),IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
+ m_nComputer = ImageList_AddMasked(himl, hbmp, clr);
+ DeleteObject(hbmp);
+ hbmp = (HBITMAP)LoadImage(m_hInstance, MAKEINTRESOURCE(IDB_DATABASE), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);
+ m_nDatabase = ImageList_AddMasked(himl, hbmp, clr);
+ DeleteObject(hbmp);
+
+ if(ImageList_GetImageCount(himl) < 4)
+ return FALSE ;
+
+ TreeView_SetImageList(m_hControl, himl, TVSIL_NORMAL);
+
+ ShowWindow(m_hControl, SW_SHOW) ;
+
+ return TRUE ;
+
+}
+
+
+
+HTREEITEM CNdbTreeView::AddItem(LPSTR szText, NDB_ITEM_TYPE enType, DWORD dwLVId){
+
+ TVITEM tvi ;
+ TVINSERTSTRUCT tvins ;
+ HTREEITEM hti ;
+ HTREEITEM hTemp ;
+ int nImage = m_nClosed ;
+
+ tvi.mask = TVIF_TEXT | TVIF_IMAGE
+ | TVIF_SELECTEDIMAGE | TVIF_PARAM;
+
+ tvi.pszText = szText;
+ tvi.cchTextMax = lstrlen(szText);
+
+ switch(enType){
+
+ case ITEM_COMPR_ROOT:
+ nImage = m_nClosed ;
+ if(!m_hPrevRoot)
+ tvins.hParent = TVI_ROOT;
+ else
+ tvins.hInsertAfter = m_hPrevRoot ;
+ break ;
+
+ case ITEM_DB_ROOT:
+ if(!m_hPrevRoot)
+ tvins.hParent = TVI_ROOT;
+ else
+ tvins.hInsertAfter = m_hPrevRoot ;
+ break ;
+
+ case ITEM_COMPR:
+ nImage = m_nComputer ;
+ if(!m_hPrevComputersChild || !m_hComputersRoot)
+ return 0 ;
+ else
+ tvins.hInsertAfter = m_hPrevComputersChild ;
+ tvins.hParent = m_hComputersRoot ;
+ break ;
+
+ case ITEM_DB:
+ nImage = m_nDatabase ;
+ if(!m_hPrevComputersChild || !m_hComputersRoot)
+ return 0 ;
+ else
+ tvins.hInsertAfter = m_hPrevDatabasesChild ;
+ tvins.hParent = m_hDatabasesRoot ;
+ break ;
+
+ NDB_DEFAULT_UNREACHABLE ;
+
+ }
+
+ tvi.iImage = nImage ;
+ tvi.iSelectedImage = nImage ;
+ tvi.lParam = (LPARAM) dwLVId ;
+ tvins.item = tvi ;
+
+ hTemp = TreeView_InsertItem(m_hControl, &tvins);
+ if(!hTemp)
+ return NULL ;
+
+ switch(enType){
+
+ case ITEM_COMPR_ROOT:
+ m_hComputersRoot = hTemp ;
+ break ;
+
+ case ITEM_DB_ROOT:
+ m_hDatabasesRoot = hTemp ;
+ break ;
+
+ case ITEM_COMPR:
+ m_hPrevComputersChild = hTemp ;
+ break ;
+
+ case ITEM_DB:
+ m_hPrevComputersChild = hTemp ;
+ break ;
+
+ NDB_DEFAULT_UNREACHABLE ;
+
+ }
+
+ if (ITEM_COMPR_ROOT != enType && ITEM_DB_ROOT != enType) {
+
+ hti = TreeView_GetParent(m_hControl, hTemp);
+ tvi.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvi.hItem = hti;
+ tvi.iImage = m_nClosed;
+ tvi.iSelectedImage = m_nClosed;
+ TreeView_SetItem(m_hControl, &tvi);
+
+ }
+
+ return hTemp ;
+}
+
+
+BOOL CNdbControls::Create(HINSTANCE hInst, HWND hParent){
+
+ m_hInstance = hInst ;
+ m_hParent = hParent ;
+ m_tb.Create(m_hInstance, m_hParent, ID_TOOLBAR, IDB_TOOLBAR) ;
+ m_sb.Create(m_hInstance, m_hParent, ID_STATUSBAR) ;
+ m_tv.Create(m_hInstance, m_hParent, IDM_TREEVIEW, ID_TREEVIEW) ;
+ _assert(AddView("Computers", ITEM_COMPR_ROOT)) ;
+ _assert(AddView("Databases", ITEM_DB_ROOT)) ;
+
+ return TRUE ;
+}
+
+BOOL CNdbControls::AddListView(NDB_ITEM_TYPE enType, DWORD dwId){
+
+ int count ;
+ CNdbListView* plv ;
+ PNDB_LV pst ;
+
+ plv = new CNdbListView ;
+
+ if(!plv)
+ return FALSE ;
+
+ count = m_map_lvc.GetCount() + m_dwFirstId_lv ;
+
+ switch(enType){
+ case ITEM_COMPR_ROOT:
+ pst = &m_stlvcRoot ;
+ break ;
+ case ITEM_DB_ROOT:
+ pst = &m_stlvdRoot ;
+ break ;
+ case ITEM_COMPR:
+ pst = &m_stlvc ;
+ break ;
+ case ITEM_DB:
+ pst = &m_stlvd ;
+ break ;
+ NDB_DEFAULT_UNREACHABLE ;
+ }
+
+ plv->Create(m_hInstance, m_hParent, dwId, enType, pst, LV_HEADER_WIDTH) ;
+
+ m_map_lvc[count] = plv ;
+
+ return TRUE ;
+}
+
+BOOL CNdbControls::AddView(LPSTR szText, NDB_ITEM_TYPE enType){
+
+ DWORD dwId_lv = m_dwNextId_lv ;
+
+ if(AddListView(enType, dwId_lv) && m_tv.AddItem(szText, enType, dwId_lv))
+ m_dwNextId_lv++ ;
+ else
+ return FALSE ;
+
+ return TRUE ;
+};
+
+
+VOID CNdbControls::ToggleListViews(LPNMTREEVIEW pnmtv){
+
+ CNdbListView* plv ;
+ int count = m_map_lvc.GetCount() + m_dwFirstId_lv ;
+
+ for(int c = FIRST_ID_LV ; c < count; ++c){
+ _assert(m_map_lvc.Lookup(c, plv)) ;
+ if(pnmtv->itemNew.lParam == (c))
+ plv->Show(TRUE) ;
+ else
+ plv->Show(FALSE) ;
+ }
+}
+
+
+
+VOID CNdbControls::Resize(){
+
+ RECT rc, rcTB, rcSB ;
+ LONG tw, sw, lx, ly, lw, lh, tvw, tvh ;
+ CNdbListView* plv ;
+ int count ; //, id ;
+
+ GetClientRect(m_hParent, &rc) ;
+ m_tb.GetRect(&rcTB) ;
+ m_sb.GetRect(&rcSB) ;
+
+ sw = rcSB.bottom ;
+ tw = rcTB.bottom ;
+
+ m_tb.Resize(0, 0, rc.right, tw) ;
+
+ tvw = rc.right / 4 ;
+ tvh = rc.bottom - sw - tw - BORDER ;
+
+ m_tv.Resize(0, tw + BORDER, tvw, tvh) ;
+
+ m_sb.Resize(0, tvh, rc.left, sw) ;
+
+ lx = tvw + BORDER - 2 ;
+ ly = tw + BORDER ;
+ lw = rc.right - tvw - BORDER + 1 ;
+ lh = tvh ;
+
+ count = m_map_lvc.GetCount() + FIRST_ID_LV ;
+
+ for(int c = FIRST_ID_LV ; c < count; ++c){
+ _assert(m_map_lvc.Lookup(c, plv)) ;
+ plv->Resize(lx, ly, lw, lh) ;
+ }
+
+ return ;
+
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO b/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO
new file mode 100644
index 00000000000..ab7b05d9df7
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/Open.ICO
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp
new file mode 100644
index 00000000000..8fcdb4ce158
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.cpp
@@ -0,0 +1,24 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+// stdafx.cpp : source file that includes just the standard includes
+// CPC_GUI.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h
new file mode 100644
index 00000000000..370d04fb466
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/StdAfx.h
@@ -0,0 +1,69 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#ifdef _DEBUG
+#define NDB_DEFAULT_UNREACHABLE default: _ASSERT(0); break
+#elif _MSC_VER >= 1200
+#define NDB_DEFAULT_UNREACHABLE default: __assume(0); break
+#else
+#define NDB_DEFAULT_UNREACHABLE default: break
+#endif;
+
+
+#ifdef _DEBUG
+#define _assert _ASSERT
+#else
+#define _assert(expr) expr
+#endif
+
+
+#include <afx.h>
+#include <afxtempl.h>
+
+// C RunTime Header Files
+#include <ndb_global.h>
+#include <memory.h>
+#include <tchar.h>
+#include <commctrl.h>
+#include <shlwapi.h>
+#include <crtdbg.h>
+
+// Local Header Files
+#include "resource.h"
+#include "NdbControls.h"
+#include "CPC_GUI.h"
+
+
+// TODO: reference additional headers your program requires here
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp
new file mode 100644
index 00000000000..db5c62f14bb
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.cpp
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include "StdAfx.h"
+#include "resource.h"
+#include "CPC_GUI.h"
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h
new file mode 100644
index 00000000000..595f9bd6cdc
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/TreeView.h
@@ -0,0 +1,19 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+
+
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp b/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp
new file mode 100644
index 00000000000..e50af403eda
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/bmp00001.bmp
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/resource.h b/storage/ndb/src/cw/cpcc-win32/C++/resource.h
new file mode 100644
index 00000000000..0bec552edf6
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/resource.h
@@ -0,0 +1,90 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by CPC_GUI.rc
+//
+#define IDC_MYICON 2
+#define IDD_CPC_GUI_DIALOG 102
+#define IDD_ABOUTBOX 103
+#define IDS_APP_TITLE 103
+#define IDM_ABOUT 104
+#define IDS_LV_ROOT_COMPUTERS 104
+#define IDS_TV_ROOT_COMPUTERS 104
+#define IDM_EXIT 105
+#define IDS_LV_ROOT_DATABASES 105
+#define IDS_TV_ROOT_DATABASES 105
+#define IDS_HELLO 106
+#define IDS_LV_COMPUTER_HEADER_1 106
+#define IDI_CPC_GUI 107
+#define IDS_LV_COMPUTER_HEADER_2 107
+#define IDI_SMALL 108
+#define IDS_LV_PROCESS_HEADER_1 108
+#define IDC_CPC_GUI 109
+#define IDM_CPC_GUI 109
+#define IDS_TIP_NEW 110
+#define IDS_TIP_DELETE 111
+#define IDS_TIP_PROPS 112
+#define IDS_LV_PROCESS_HEADER_2 113
+#define IDS_LV_PROCESS_HEADER_3 114
+#define IDS_LV_PROCESS_HEADER_4 115
+#define IDS_LV_COMPUTER_HEADER_3 116
+#define IDR_MAINFRAME 128
+#define ID_TREEVIEW 130
+#define IDM_TREEVIEW 130
+#define IDB_TOOLBAR 137
+#define ID_TOOLBAR 158
+#define IDB_COMPUTER 168
+#define IDB_CLOSED 169
+#define IDB_OPEN 170
+#define IDI_DATABASE 172
+#define IDI_CLOSED 175
+#define IDI_OPEN 176
+#define IDI_COMPUTER 177
+#define IDB_MASK 178
+#define IDB_DATABASE 182
+#define IDM_TV 183
+#define ID_TREEVIEW1 32771
+#define ID_BUTTON32773 32773
+#define IDM_NEW 32774
+#define IDM_DELETE 32775
+#define IDM_PROPS 32776
+#define ID_LIST_C 32777
+#define ID_ACTIONS_INSERT 32778
+#define ID_ACTIONS_DELETE 32779
+#define ID_DELETE 32780
+#define ID_PROPERTIES 32781
+#define ID_ACTIONS_PROPERTIES 32782
+#define ID_BUTTON32783 32783
+#define ID_BUTTON32784 32784
+#define ID_LIST_P 32785
+#define ID_STATUSBAR 32786
+#define ID_LIST_C_ROOT 32787
+#define ID_LIST_D_ROOT 32788
+#define IDM_ADDNEW 32793
+#define IDC_STATIC -1
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 184
+#define _APS_NEXT_COMMAND_VALUE 32796
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 110
+#endif
+#endif
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/small.ico b/storage/ndb/src/cw/cpcc-win32/C++/small.ico
new file mode 100644
index 00000000000..8f94d9aa828
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/small.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp b/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp
new file mode 100644
index 00000000000..a1059352c66
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/C++/toolbar.bmp
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/App.ico b/storage/ndb/src/cw/cpcc-win32/csharp/App.ico
new file mode 100644
index 00000000000..3a5525fd794
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/App.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs
new file mode 100644
index 00000000000..ea1798c8c67
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/CPC_Form.cs
@@ -0,0 +1,1400 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+using System.Threading;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for Form1.
+ /// </summary>
+ public class CPC : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.TreeView tvComputerCluster;
+ private System.Windows.Forms.ContextMenu ctxTreeViewMenu;
+ private System.Windows.Forms.ColumnHeader chComputer;
+ private System.Windows.Forms.ColumnHeader chProcessName;
+ private System.Windows.Forms.ContextMenu ctxListViewMenu;
+ private System.Windows.Forms.MenuItem mainMenuItem;
+ private System.Windows.Forms.ColumnHeader chProcesses;
+ private System.Windows.Forms.MainMenu mainMenu;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.MenuItem menuItem7;
+ private System.Windows.Forms.MenuItem menuItem10;
+ private System.Windows.Forms.MenuItem mainMenuFile;
+ private System.Windows.Forms.MenuItem mainMenuComputer;
+ private System.Windows.Forms.MenuItem subMenuComputerAdd;
+ private System.Windows.Forms.MenuItem subMenuComputerRemove;
+ private System.Windows.Forms.MenuItem subMenuComputerDisconnect;
+ private System.Windows.Forms.MenuItem subMenuComputerProperties;
+ private System.ComponentModel.IContainer components;
+
+ private System.Windows.Forms.MenuItem menuItem3;
+ private System.Windows.Forms.MenuItem computerMenuAdd;
+ private System.Windows.Forms.MenuItem computerMenuRemove;
+ private System.Windows.Forms.MenuItem menuItem5;
+ private System.Windows.Forms.MenuItem computerMenuDisconnect;
+ private System.Windows.Forms.MenuItem computerMenuConnect;
+ private System.Windows.Forms.MenuItem computerMenuProperties;
+ private System.Windows.Forms.MenuItem menuItem11;
+ private System.Windows.Forms.MenuItem tvCtxMenuComputerAdd;
+ private System.Windows.Forms.MenuItem tvCtxMenuComputerRemove;
+ private System.Windows.Forms.MenuItem tvCtxMenuComputerConnect;
+ private System.Windows.Forms.MenuItem tvCtxMenuComputerDisconnect;
+ private System.Windows.Forms.MenuItem tvCtxMenuComputerDefine;
+ private System.Windows.Forms.MenuItem tvCtxMenuDatabaseNew;
+ private System.Windows.Forms.MenuItem menuItem1;
+ private System.Windows.Forms.MenuItem menuItem2;
+ private System.Windows.Forms.MenuItem mainMenuDatabase;
+ private System.Windows.Forms.MenuItem subMenuDatabaseCreate;
+ private System.Windows.Forms.MenuItem menuItem8;
+ private System.Windows.Forms.MenuItem tvCtxMenuProperties;
+ private System.Windows.Forms.ImageList imageTV;
+
+ private ComputerMgmt computerMgmt;
+ private System.Windows.Forms.MenuItem computerMenuRefresh;
+ private System.Windows.Forms.ListView listView;
+ private System.Windows.Forms.ColumnHeader chComputerIP;
+ private System.Windows.Forms.ColumnHeader chDatabase;
+ private System.Windows.Forms.ColumnHeader chName;
+ private System.Windows.Forms.ColumnHeader chOwner;
+ private System.Windows.Forms.ColumnHeader chStatus;
+ private System.Windows.Forms.Splitter splitter2;
+ private System.Windows.Forms.Splitter splitterVertical;
+ private System.Windows.Forms.Splitter splitterHorizont;
+ private Thread guiThread;
+ private float resizeWidthRatio;
+ private System.Windows.Forms.MenuItem menuItem6;
+ private System.Windows.Forms.MenuItem menuGetStatus;
+ private System.Windows.Forms.MenuItem menuStartProcess;
+ private System.Windows.Forms.MenuItem menuRestartProcess;
+ private System.Windows.Forms.MenuItem menuStopProcess;
+ private System.Windows.Forms.MenuItem menuRemoveProcess;
+ private System.Windows.Forms.MenuItem menuRefresh;
+ private System.Windows.Forms.OpenFileDialog openHostFileDialog;
+ private System.Windows.Forms.SaveFileDialog saveHostFileDialog;
+ private float resizeHeightRatio;
+ private System.Windows.Forms.TextBox mgmConsole;
+ int i;
+ public CPC()
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ computerMgmt = new ComputerMgmt();
+ guiThread = new Thread(new ThreadStart(updateGuiThread));
+
+ // guiThread.Start();
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ //guiThread.Abort();
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CPC));
+ this.tvComputerCluster = new System.Windows.Forms.TreeView();
+ this.ctxTreeViewMenu = new System.Windows.Forms.ContextMenu();
+ this.tvCtxMenuComputerAdd = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuComputerRemove = new System.Windows.Forms.MenuItem();
+ this.menuGetStatus = new System.Windows.Forms.MenuItem();
+ this.menuItem6 = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuComputerConnect = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuComputerDisconnect = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuDatabaseNew = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuComputerDefine = new System.Windows.Forms.MenuItem();
+ this.menuItem8 = new System.Windows.Forms.MenuItem();
+ this.tvCtxMenuProperties = new System.Windows.Forms.MenuItem();
+ this.imageTV = new System.Windows.Forms.ImageList(this.components);
+ this.ctxListViewMenu = new System.Windows.Forms.ContextMenu();
+ this.menuStartProcess = new System.Windows.Forms.MenuItem();
+ this.menuRestartProcess = new System.Windows.Forms.MenuItem();
+ this.menuStopProcess = new System.Windows.Forms.MenuItem();
+ this.menuRemoveProcess = new System.Windows.Forms.MenuItem();
+ this.menuRefresh = new System.Windows.Forms.MenuItem();
+ this.computerMenuAdd = new System.Windows.Forms.MenuItem();
+ this.menuItem3 = new System.Windows.Forms.MenuItem();
+ this.computerMenuRemove = new System.Windows.Forms.MenuItem();
+ this.menuItem5 = new System.Windows.Forms.MenuItem();
+ this.computerMenuDisconnect = new System.Windows.Forms.MenuItem();
+ this.computerMenuConnect = new System.Windows.Forms.MenuItem();
+ this.menuItem11 = new System.Windows.Forms.MenuItem();
+ this.computerMenuProperties = new System.Windows.Forms.MenuItem();
+ this.computerMenuRefresh = new System.Windows.Forms.MenuItem();
+ this.chComputer = new System.Windows.Forms.ColumnHeader();
+ this.chProcessName = new System.Windows.Forms.ColumnHeader();
+ this.mainMenuItem = new System.Windows.Forms.MenuItem();
+ this.chProcesses = new System.Windows.Forms.ColumnHeader();
+ this.mainMenu = new System.Windows.Forms.MainMenu();
+ this.mainMenuFile = new System.Windows.Forms.MenuItem();
+ this.menuItem2 = new System.Windows.Forms.MenuItem();
+ this.menuItem1 = new System.Windows.Forms.MenuItem();
+ this.mainMenuComputer = new System.Windows.Forms.MenuItem();
+ this.subMenuComputerAdd = new System.Windows.Forms.MenuItem();
+ this.menuItem7 = new System.Windows.Forms.MenuItem();
+ this.subMenuComputerDisconnect = new System.Windows.Forms.MenuItem();
+ this.subMenuComputerRemove = new System.Windows.Forms.MenuItem();
+ this.menuItem10 = new System.Windows.Forms.MenuItem();
+ this.subMenuComputerProperties = new System.Windows.Forms.MenuItem();
+ this.mainMenuDatabase = new System.Windows.Forms.MenuItem();
+ this.subMenuDatabaseCreate = new System.Windows.Forms.MenuItem();
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.mgmConsole = new System.Windows.Forms.TextBox();
+ this.splitterHorizont = new System.Windows.Forms.Splitter();
+ this.splitter2 = new System.Windows.Forms.Splitter();
+ this.listView = new System.Windows.Forms.ListView();
+ this.chComputerIP = new System.Windows.Forms.ColumnHeader();
+ this.chStatus = new System.Windows.Forms.ColumnHeader();
+ this.chDatabase = new System.Windows.Forms.ColumnHeader();
+ this.chName = new System.Windows.Forms.ColumnHeader();
+ this.chOwner = new System.Windows.Forms.ColumnHeader();
+ this.splitterVertical = new System.Windows.Forms.Splitter();
+ this.openHostFileDialog = new System.Windows.Forms.OpenFileDialog();
+ this.saveHostFileDialog = new System.Windows.Forms.SaveFileDialog();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // tvComputerCluster
+ //
+ this.tvComputerCluster.CausesValidation = false;
+ this.tvComputerCluster.ContextMenu = this.ctxTreeViewMenu;
+ this.tvComputerCluster.Dock = System.Windows.Forms.DockStyle.Left;
+ this.tvComputerCluster.ImageList = this.imageTV;
+ this.tvComputerCluster.Name = "tvComputerCluster";
+ this.tvComputerCluster.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
+ new System.Windows.Forms.TreeNode("Computer", 0, 0),
+ new System.Windows.Forms.TreeNode("Database", 5, 5)});
+ this.tvComputerCluster.Size = new System.Drawing.Size(104, 333);
+ this.tvComputerCluster.TabIndex = 5;
+ this.tvComputerCluster.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvComputerCluster_MouseDown);
+ this.tvComputerCluster.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvComputerCluster_AfterSelect);
+ this.tvComputerCluster.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeCollapse);
+ this.tvComputerCluster.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeExpand);
+ //
+ // ctxTreeViewMenu
+ //
+ this.ctxTreeViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.tvCtxMenuComputerAdd,
+ this.tvCtxMenuComputerRemove,
+ this.menuGetStatus,
+ this.menuItem6,
+ this.tvCtxMenuComputerConnect,
+ this.tvCtxMenuComputerDisconnect,
+ this.tvCtxMenuDatabaseNew,
+ this.tvCtxMenuComputerDefine,
+ this.menuItem8,
+ this.tvCtxMenuProperties});
+ this.ctxTreeViewMenu.Popup += new System.EventHandler(this.ctxTreeViewMenu_Popup);
+ //
+ // tvCtxMenuComputerAdd
+ //
+ this.tvCtxMenuComputerAdd.Index = 0;
+ this.tvCtxMenuComputerAdd.Text = "Add computer";
+ this.tvCtxMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
+ //
+ // tvCtxMenuComputerRemove
+ //
+ this.tvCtxMenuComputerRemove.Index = 1;
+ this.tvCtxMenuComputerRemove.Text = "Remove computer";
+ this.tvCtxMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
+ //
+ // menuGetStatus
+ //
+ this.menuGetStatus.Index = 2;
+ this.menuGetStatus.Text = "Get Status";
+ this.menuGetStatus.Click += new System.EventHandler(this.menuGetStatus_Click);
+ //
+ // menuItem6
+ //
+ this.menuItem6.Index = 3;
+ this.menuItem6.Text = "-";
+ //
+ // tvCtxMenuComputerConnect
+ //
+ this.tvCtxMenuComputerConnect.Index = 4;
+ this.tvCtxMenuComputerConnect.Text = "Connect";
+ //
+ // tvCtxMenuComputerDisconnect
+ //
+ this.tvCtxMenuComputerDisconnect.Index = 5;
+ this.tvCtxMenuComputerDisconnect.Text = "Disconnect";
+ //
+ // tvCtxMenuDatabaseNew
+ //
+ this.tvCtxMenuDatabaseNew.Index = 6;
+ this.tvCtxMenuDatabaseNew.Text = "Create database...";
+ this.tvCtxMenuDatabaseNew.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
+ //
+ // tvCtxMenuComputerDefine
+ //
+ this.tvCtxMenuComputerDefine.Index = 7;
+ this.tvCtxMenuComputerDefine.Text = "Define process...";
+ this.tvCtxMenuComputerDefine.Click += new System.EventHandler(this.tvCtxMenuComputerDefine_Click);
+ //
+ // menuItem8
+ //
+ this.menuItem8.Index = 8;
+ this.menuItem8.Text = "-";
+ //
+ // tvCtxMenuProperties
+ //
+ this.tvCtxMenuProperties.Index = 9;
+ this.tvCtxMenuProperties.Text = "Properties";
+ //
+ // imageTV
+ //
+ this.imageTV.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.imageTV.ImageSize = new System.Drawing.Size(16, 16);
+ this.imageTV.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageTV.ImageStream")));
+ this.imageTV.TransparentColor = System.Drawing.Color.Transparent;
+ //
+ // ctxListViewMenu
+ //
+ this.ctxListViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuStartProcess,
+ this.menuRestartProcess,
+ this.menuStopProcess,
+ this.menuRemoveProcess,
+ this.menuRefresh});
+ this.ctxListViewMenu.Popup += new System.EventHandler(this.ctxListViewMenu_Popup);
+ //
+ // menuStartProcess
+ //
+ this.menuStartProcess.Index = 0;
+ this.menuStartProcess.Text = "Start process";
+ this.menuStartProcess.Click += new System.EventHandler(this.startProcess);
+ //
+ // menuRestartProcess
+ //
+ this.menuRestartProcess.Index = 1;
+ this.menuRestartProcess.Text = "Restart process";
+ this.menuRestartProcess.Click += new System.EventHandler(this.restartProcess);
+ //
+ // menuStopProcess
+ //
+ this.menuStopProcess.Index = 2;
+ this.menuStopProcess.Text = "Stop process";
+ this.menuStopProcess.Click += new System.EventHandler(this.stopProcess);
+ //
+ // menuRemoveProcess
+ //
+ this.menuRemoveProcess.Index = 3;
+ this.menuRemoveProcess.Text = "Remove process";
+ this.menuRemoveProcess.Click += new System.EventHandler(this.removeProcess);
+ //
+ // menuRefresh
+ //
+ this.menuRefresh.Index = 4;
+ this.menuRefresh.Text = "Refresh";
+ this.menuRefresh.Click += new System.EventHandler(this.menuRefresh_Click);
+ //
+ // computerMenuAdd
+ //
+ this.computerMenuAdd.Index = -1;
+ this.computerMenuAdd.Text = "Add";
+ this.computerMenuAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
+ //
+ // menuItem3
+ //
+ this.menuItem3.Index = -1;
+ this.menuItem3.Text = "-";
+ //
+ // computerMenuRemove
+ //
+ this.computerMenuRemove.Index = -1;
+ this.computerMenuRemove.Text = "Remove";
+ this.computerMenuRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
+ //
+ // menuItem5
+ //
+ this.menuItem5.Index = -1;
+ this.menuItem5.Text = "-";
+ //
+ // computerMenuDisconnect
+ //
+ this.computerMenuDisconnect.Index = -1;
+ this.computerMenuDisconnect.Text = "Disconnect";
+ //
+ // computerMenuConnect
+ //
+ this.computerMenuConnect.Index = -1;
+ this.computerMenuConnect.Text = "Connect";
+ //
+ // menuItem11
+ //
+ this.menuItem11.Index = -1;
+ this.menuItem11.Text = "-";
+ //
+ // computerMenuProperties
+ //
+ this.computerMenuProperties.Index = -1;
+ this.computerMenuProperties.Text = "Properties";
+ //
+ // computerMenuRefresh
+ //
+ this.computerMenuRefresh.Index = -1;
+ this.computerMenuRefresh.Text = "Refresh";
+ this.computerMenuRefresh.Click += new System.EventHandler(this.computerMenuRefresh_Click);
+ //
+ // chComputer
+ //
+ this.chComputer.Text = "Computer";
+ //
+ // chProcessName
+ //
+ this.chProcessName.Text = "Name";
+ //
+ // mainMenuItem
+ //
+ this.mainMenuItem.Index = -1;
+ this.mainMenuItem.Text = "File";
+ //
+ // chProcesses
+ //
+ this.chProcesses.Text = "Id";
+ //
+ // mainMenu
+ //
+ this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.mainMenuFile,
+ this.mainMenuComputer,
+ this.mainMenuDatabase});
+ //
+ // mainMenuFile
+ //
+ this.mainMenuFile.Index = 0;
+ this.mainMenuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.menuItem2,
+ this.menuItem1});
+ this.mainMenuFile.Text = "&File";
+ //
+ // menuItem2
+ //
+ this.menuItem2.Index = 0;
+ this.menuItem2.Text = "&Import...";
+ this.menuItem2.Click += new System.EventHandler(this.importHostFile);
+ //
+ // menuItem1
+ //
+ this.menuItem1.Index = 1;
+ this.menuItem1.Text = "&Export...";
+ this.menuItem1.Click += new System.EventHandler(this.exportHostFile);
+ //
+ // mainMenuComputer
+ //
+ this.mainMenuComputer.Index = 1;
+ this.mainMenuComputer.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.subMenuComputerAdd,
+ this.menuItem7,
+ this.subMenuComputerDisconnect,
+ this.subMenuComputerRemove,
+ this.menuItem10,
+ this.subMenuComputerProperties});
+ this.mainMenuComputer.Text = "&Computer";
+ //
+ // subMenuComputerAdd
+ //
+ this.subMenuComputerAdd.Index = 0;
+ this.subMenuComputerAdd.Text = "&Add Computer";
+ this.subMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
+ //
+ // menuItem7
+ //
+ this.menuItem7.Index = 1;
+ this.menuItem7.Text = "-";
+ //
+ // subMenuComputerDisconnect
+ //
+ this.subMenuComputerDisconnect.Index = 2;
+ this.subMenuComputerDisconnect.Text = "&Disconnect";
+ //
+ // subMenuComputerRemove
+ //
+ this.subMenuComputerRemove.Index = 3;
+ this.subMenuComputerRemove.Text = "&Remove Computer";
+ this.subMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
+ //
+ // menuItem10
+ //
+ this.menuItem10.Index = 4;
+ this.menuItem10.Text = "-";
+ //
+ // subMenuComputerProperties
+ //
+ this.subMenuComputerProperties.Index = 5;
+ this.subMenuComputerProperties.Text = "&Properties";
+ //
+ // mainMenuDatabase
+ //
+ this.mainMenuDatabase.Index = 2;
+ this.mainMenuDatabase.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
+ this.subMenuDatabaseCreate});
+ this.mainMenuDatabase.Text = "&Database";
+ this.mainMenuDatabase.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
+ //
+ // subMenuDatabaseCreate
+ //
+ this.subMenuDatabaseCreate.Index = 0;
+ this.subMenuDatabaseCreate.Text = "&Create database...";
+ this.subMenuDatabaseCreate.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
+ //
+ // panel1
+ //
+ this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.mgmConsole,
+ this.splitterHorizont,
+ this.splitter2,
+ this.listView});
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(104, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(384, 333);
+ this.panel1.TabIndex = 6;
+ //
+ // mgmConsole
+ //
+ this.mgmConsole.AccessibleRole = System.Windows.Forms.AccessibleRole.StaticText;
+ this.mgmConsole.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.mgmConsole.Location = new System.Drawing.Point(0, 231);
+ this.mgmConsole.Multiline = true;
+ this.mgmConsole.Name = "mgmConsole";
+ this.mgmConsole.Size = new System.Drawing.Size(384, 96);
+ this.mgmConsole.TabIndex = 5;
+ this.mgmConsole.Text = "textBox1";
+ this.mgmConsole.TextChanged += new System.EventHandler(this.mgmConsole_TextChanged);
+ this.mgmConsole.Enter += new System.EventHandler(this.mgmConsole_Enter);
+ //
+ // splitterHorizont
+ //
+ this.splitterHorizont.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.splitterHorizont.Location = new System.Drawing.Point(0, 327);
+ this.splitterHorizont.MinExtra = 100;
+ this.splitterHorizont.MinSize = 100;
+ this.splitterHorizont.Name = "splitterHorizont";
+ this.splitterHorizont.Size = new System.Drawing.Size(384, 3);
+ this.splitterHorizont.TabIndex = 4;
+ this.splitterHorizont.TabStop = false;
+ //
+ // splitter2
+ //
+ this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.splitter2.Location = new System.Drawing.Point(0, 330);
+ this.splitter2.Name = "splitter2";
+ this.splitter2.Size = new System.Drawing.Size(384, 3);
+ this.splitter2.TabIndex = 2;
+ this.splitter2.TabStop = false;
+ //
+ // listView
+ //
+ this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.chComputerIP,
+ this.chStatus,
+ this.chDatabase,
+ this.chName,
+ this.chOwner});
+ this.listView.ContextMenu = this.ctxListViewMenu;
+ this.listView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listView.FullRowSelect = true;
+ this.listView.Name = "listView";
+ this.listView.Size = new System.Drawing.Size(384, 333);
+ this.listView.TabIndex = 0;
+ this.listView.View = System.Windows.Forms.View.Details;
+ this.listView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView_ColumnClick_1);
+ this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
+ //
+ // chComputerIP
+ //
+ this.chComputerIP.Text = "IP Adress";
+ //
+ // chStatus
+ //
+ this.chStatus.Text = "Status";
+ //
+ // chDatabase
+ //
+ this.chDatabase.Text = "Database";
+ //
+ // chName
+ //
+ this.chName.Text = "Name";
+ //
+ // chOwner
+ //
+ this.chOwner.Text = "Owner";
+ //
+ // splitterVertical
+ //
+ this.splitterVertical.Location = new System.Drawing.Point(104, 0);
+ this.splitterVertical.MinSize = 100;
+ this.splitterVertical.Name = "splitterVertical";
+ this.splitterVertical.Size = new System.Drawing.Size(3, 333);
+ this.splitterVertical.TabIndex = 7;
+ this.splitterVertical.TabStop = false;
+ this.splitterVertical.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitterVertical_SplitterMoved);
+ //
+ // openHostFileDialog
+ //
+ this.openHostFileDialog.DefaultExt = "cpc";
+ this.openHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*";
+ this.openHostFileDialog.Title = "Import a CPCd configuration file";
+ this.openHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openHostFileDialog_FileOk);
+ //
+ // saveHostFileDialog
+ //
+ this.saveHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*";
+ this.saveHostFileDialog.Title = "Export a CPCd configuration file";
+ this.saveHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.saveHostFileDialog_FileOk);
+ //
+ // CPC
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(488, 333);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.splitterVertical,
+ this.panel1,
+ this.tvComputerCluster});
+ this.Menu = this.mainMenu;
+ this.Name = "CPC";
+ this.Text = "CPC";
+ this.Resize += new System.EventHandler(this.CPC_Resize);
+ this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CPC_MouseDown);
+ this.Closing += new System.ComponentModel.CancelEventHandler(this.CPC_Closing);
+ this.Load += new System.EventHandler(this.CPC_Load);
+ this.Activated += new System.EventHandler(this.CPC_Activated);
+ this.Paint += new System.Windows.Forms.PaintEventHandler(this.CPC_Paint);
+ this.panel1.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.Run(new CPC());
+
+ }
+
+ private void tvComputerCluster_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
+ {
+ if(e.Node.Text.ToString().Equals("Database"))
+ {
+ updateListViews("Database");
+
+ return;
+ }
+ if(e.Node.Text.ToString().Equals("Computer"))
+ {
+ //updateListViews();
+
+ updateListViews("Computer");
+ return;
+ }
+ if(e.Node.Parent.Text.ToString().Equals("Database"))
+ {
+ //updateListViews();
+ listView.Columns.Clear();
+ listView.Columns.Add(this.chName);
+ listView.Columns.Add(this.chDatabase);
+ listView.Columns.Add(this.chStatus);
+ listView.Columns.Add(this.chOwner);
+ updateDatabaseView(e.Node.Text.ToString());
+ }
+
+ if(e.Node.Parent.Text=="Computer")
+ {
+ //updateListViews();
+
+ Computer c=computerMgmt.getComputer(e.Node.Text.ToString());
+ string [] processcols= new string[5];
+ ArrayList processes;
+ processes = c.getProcesses();
+ listView.Items.Clear();
+ listView.Columns.Clear();
+ listView.Columns.Add(this.chComputer);
+ listView.Columns.Add(this.chDatabase);
+ listView.Columns.Add(this.chName);
+ listView.Columns.Add(this.chStatus);
+ listView.Columns.Add(this.chOwner);
+ if(processes != null )
+ {
+
+ listView.BeginUpdate();
+ foreach(Process p in processes)
+ {
+ processcols[0]=p.getComputer().getName();
+ processcols[1]=p.getDatabase();
+ processcols[2]=p.getName();
+ processcols[3]=p.getStatusString();
+ processcols[4]=p.getOwner();
+ ListViewItem lvp= new ListViewItem(processcols);
+ listView.Items.Add(lvp);
+ }
+
+ listView.EndUpdate();
+ }
+
+
+ listView.Show();
+ }
+
+ }
+
+
+
+ private void ctxTreeViewMenu_Popup(object sender, System.EventArgs e)
+ {
+ tvCtxMenuComputerAdd.Enabled=true;
+ tvCtxMenuComputerRemove.Enabled=true;
+ tvCtxMenuComputerConnect.Enabled=true;
+ tvCtxMenuComputerDisconnect.Enabled=true;
+ tvCtxMenuComputerDefine.Enabled=true;
+ menuGetStatus.Enabled=true;
+ tvCtxMenuDatabaseNew.Enabled=true;
+ tvCtxMenuComputerAdd.Visible=true;
+ tvCtxMenuComputerRemove.Visible=true;
+ tvCtxMenuComputerConnect.Visible=true;
+ tvCtxMenuComputerDisconnect.Visible=true;
+ tvCtxMenuComputerDefine.Visible=true;
+ tvCtxMenuDatabaseNew.Visible=true;
+ tvCtxMenuProperties.Visible=true;
+ menuGetStatus.Visible=true;
+
+ if(tvComputerCluster.SelectedNode.Text.Equals("Computer"))
+ {
+ tvCtxMenuComputerAdd.Enabled=true;
+ tvCtxMenuComputerRemove.Enabled=false;
+ tvCtxMenuComputerConnect.Enabled=false;
+ tvCtxMenuComputerDisconnect.Enabled=false;
+ tvCtxMenuComputerDefine.Enabled=false;
+ tvCtxMenuDatabaseNew.Visible=false;
+ menuGetStatus.Visible=false;
+ return;
+ }
+
+ if(tvComputerCluster.SelectedNode.Text.Equals("Database"))
+ {
+ // ctxTreeViewMenu.MenuItems.Add(menuDatabaseItem1);
+ tvCtxMenuComputerAdd.Visible=false;
+ tvCtxMenuComputerRemove.Visible=false;
+ tvCtxMenuComputerConnect.Visible=false;
+ tvCtxMenuComputerDisconnect.Visible=false;
+ tvCtxMenuComputerDefine.Visible=false;
+ tvCtxMenuDatabaseNew.Visible=true;
+ tvCtxMenuDatabaseNew.Enabled=true;
+ menuGetStatus.Visible=false;
+ menuItem6.Visible=false;
+ return;
+ }
+ if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Computer"))
+ {
+
+ Computer c= computerMgmt.getComputer(tvComputerCluster.SelectedNode.Text.ToString());
+ if(c.getStatus().Equals(Computer.Status.Disconnected))
+ {
+ tvCtxMenuComputerConnect.Enabled=true;
+ tvCtxMenuComputerDisconnect.Enabled=false;
+ }
+ else
+ {
+ tvCtxMenuComputerDisconnect.Enabled=true;
+ tvCtxMenuComputerConnect.Enabled=false;
+ }
+
+ tvCtxMenuComputerAdd.Enabled=false;
+ tvCtxMenuComputerRemove.Enabled=true;
+ menuGetStatus.Visible=false;
+
+ tvCtxMenuComputerDefine.Enabled=true;
+ tvCtxMenuDatabaseNew.Visible=false;
+ return;
+ }
+
+ if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Database"))
+ {
+ tvCtxMenuComputerAdd.Enabled=true;
+ tvCtxMenuComputerRemove.Enabled=false;
+ tvCtxMenuComputerConnect.Enabled=false;
+ tvCtxMenuComputerDisconnect.Enabled=false;
+ tvCtxMenuComputerDefine.Enabled=false;
+ tvCtxMenuDatabaseNew.Visible=true;
+ menuGetStatus.Visible=true;
+ return;
+ }
+
+
+ }
+
+
+ private void listView_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ //MessageBox.Show(listView.SelectedItems[0].Text);
+ }
+
+
+ private void tvComputerCluster_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
+ { /*
+ TreeNode node = tvComputerCluster.GetNodeAt(e.X,e.Y);
+ if(node==null)
+ {
+ return;
+ }
+ tvComputerCluster.SelectedNode=node;
+// updateListViews();
+ tvComputerCluster.SelectedNode.Expand();
+ */
+ }
+
+
+ private void subMenuComputerRemove_Click(object sender, System.EventArgs e)
+ {
+ //ComputerRemoveDialog crd=new ComputerRemoveDialog(computerMgmt);
+ //crd.Show();
+ //updateListViews();
+/* string computer = tvComputerCluster.SelectedNode.Text.ToString();
+ if(MessageBox.Show(this,"Are you sure you want to remove: " +computer+ "?","Remove computer",MessageBoxButtons.YesNo)==DialogResult.Yes)
+ {
+ computerMgmt.RemoveComputer(computer);
+ }
+*/
+ }
+
+ private void subMenuComputerAdd_Click(object sender, System.EventArgs e)
+ {
+ ComputerAddDialog cad=new ComputerAddDialog(computerMgmt);
+ cad.ShowDialog();
+ cad.Dispose();
+/// updateListViews(tvComputerCluster.SelectedNode.Text.ToString());
+ }
+
+
+
+ private void updateListViews(string node)
+ {
+ if(node.Equals("Computer"))
+ {
+ listView.Columns.Clear();
+ listView.Items.Clear();
+ ArrayList list= computerMgmt.getComputerCollection();
+ string [] computercols= new string[2];
+
+
+ listView.BeginUpdate();
+ listView.Columns.Add(this.chComputer);
+ listView.Columns.Add(this.chStatus);
+ foreach (Computer computer in list)
+ {
+ computercols[0]=computer.getName();
+ computercols[1]=computer.getStatusString();
+
+ ListViewItem lvc= new ListViewItem(computercols);
+
+ listView.Items.Add(lvc);
+
+ }
+ listView.EndUpdate();
+ listView.Show();
+ }
+
+ if(node.Equals("Database"))
+ {
+
+ ArrayList databases= computerMgmt.getDatabaseCollection();
+ string [] dbcols= new string[3];
+
+
+ listView.BeginUpdate();
+ listView.Items.Clear();
+ listView.Columns.Clear();
+ listView.Columns.Add(this.chDatabase);
+ listView.Columns.Add(this.chStatus);
+ listView.Columns.Add(this.chOwner);
+ foreach (Database db in databases)
+ {
+ dbcols[0]=db.getName();
+ dbcols[1]=db.getStatusString();
+ dbcols[2]=db.getOwner();
+
+ ListViewItem lvc= new ListViewItem(dbcols);
+
+ listView.Items.Add(lvc);
+
+ }
+ listView.EndUpdate();
+
+ listView.Show();
+ }
+
+ }
+
+ public void updateDatabaseView(string database)
+ {
+ Database d=computerMgmt.getDatabase(database);
+ string [] processcols= new string[5];
+ ArrayList processes = d.getProcesses();
+ listView.Items.Clear();
+ if(processes != null )
+ {
+
+ listView.BeginUpdate();
+ listView.Columns.Clear();
+ listView.Columns.Add(this.chComputer);
+ listView.Columns.Add(this.chDatabase);
+ listView.Columns.Add(this.chName);
+ listView.Columns.Add(this.chStatus);
+ listView.Columns.Add(this.chOwner);
+
+ foreach(Process p in processes)
+ {
+ processcols[0]=p.getComputer().getName();
+ processcols[1]=p.getDatabase();
+ processcols[2]=p.getName();
+ processcols[3]=p.getStatusString();
+ processcols[4]=p.getOwner();
+ ListViewItem lvp= new ListViewItem(processcols);
+ listView.Items.Add(lvp);
+ }
+
+ listView.EndUpdate();
+ }
+
+ listView.Show();
+ }
+
+ private void updateTreeViews()
+ {
+ //tvComputerCluster.Nodes.Clear();
+ ArrayList computers= computerMgmt.getComputerCollection();
+
+ ArrayList databases= computerMgmt.getDatabaseCollection();
+
+ tvComputerCluster.BeginUpdate();
+ tvComputerCluster.Nodes[0].Nodes.Clear();
+ tvComputerCluster.Nodes[1].Nodes.Clear();
+ if(computers != null)
+ {
+ foreach (Computer computer in computers)
+ {
+ tvComputerCluster.Nodes[0].Nodes.Add(new TreeNode(computer.getName().ToString()));
+ }
+ }
+ if(databases != null)
+ {
+ foreach (Database db in databases)
+ {
+ tvComputerCluster.Nodes[1].Nodes.Add(new TreeNode(db.getName().ToString()));
+ }
+ }
+
+ tvComputerCluster.EndUpdate();
+ }
+
+
+ private void CPC_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ //updateListViews();
+ //updateTreeViews();
+
+ }
+
+ private void CPC_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+ if(tvComputerCluster.SelectedNode!=null)
+ {
+ if(tvComputerCluster.SelectedNode.Text.ToString().Equals("Computer"))
+ updateListViews("Computer");
+ }
+
+ //updateListViews();
+ //updateTreeViews();
+ }
+
+ private void CPC_Activated(object sender, System.EventArgs e)
+ {
+ updateListViews(tvComputerCluster.SelectedNode.Text.ToString());
+ //updateListViews();
+ updateTreeViews();
+ }
+
+
+ private void computerMenuAdd_Click(object sender, System.EventArgs e)
+ {
+ ComputerAddDialog cad=new ComputerAddDialog(computerMgmt);
+ cad.ShowDialog();
+ cad.Dispose();
+
+ }
+
+ private void computerMenuRemove_Click(object sender, System.EventArgs e)
+ {
+
+ string computer = tvComputerCluster.SelectedNode.Text.ToString();
+ if(MessageBox.Show("Are you sure you want to remove: " + computer +"?\n" + "This will remove all processes on the computer!" ,"Remove selected computer",MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
+ {
+ removeComputer(computer);
+ }
+ }
+
+ private void removeComputer(string computer)
+ {
+ ArrayList processes;
+ Computer c=computerMgmt.getComputer(computer);
+ processes = c.getProcesses();
+
+ /*foreach(Process p in processes)
+ {
+ removeProcess(computer,p.getName());
+ processes=c.getProcesses();
+ }
+*/
+ if(computerMgmt.RemoveComputer(computer))
+ {
+ tvComputerCluster.SelectedNode=tvComputerCluster.SelectedNode.PrevVisibleNode;
+ this.updateTreeViews();
+ this.updateListViews("Computer");
+
+ if(tvComputerCluster.SelectedNode!=null)
+ this.updateListViews(tvComputerCluster.SelectedNode.Text.ToString());
+ //updateListViews();
+ }
+ }
+
+ private void listView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
+ {
+
+ if(listView.Sorting.Equals(SortOrder.Ascending))
+ listView.Sorting=SortOrder.Descending;
+ else
+ listView.Sorting=SortOrder.Ascending;
+
+ }
+
+
+ private void subMenuDatabaseCreate_Click(object sender, System.EventArgs e)
+ {
+ PanelWizard p = new PanelWizard(this.computerMgmt);
+ p.ShowDialog();
+ }
+
+ private void tvCtxMenuComputerDefine_Click(object sender, System.EventArgs e)
+ {
+ ProcessDefineDialog pdd = new ProcessDefineDialog(this.computerMgmt,
+ tvComputerCluster.SelectedNode.Text.ToString());
+ pdd.Show();
+ }
+
+ private void listView_ItemActivate(object sender, System.EventArgs e)
+ {
+ updateDatabaseView(listView.SelectedItems[0].Text.ToString());
+ for(int i=0;i<tvComputerCluster.Nodes[1].Nodes.Count;i++)
+ {
+ if(tvComputerCluster.Nodes[1].Nodes[i].Text.ToString().Equals(listView.SelectedItems[0].Text.ToString()))
+ {
+ tvComputerCluster.SelectedNode=tvComputerCluster.Nodes[1].Nodes[i];
+ break;
+ }
+ }
+
+
+ }
+
+ private void CPC_Resize(object sender, System.EventArgs e)
+ {
+ if(this.Width < 200) this.Width=200;
+ if(this.Height <200) this.Height=200;
+ this.tvComputerCluster.Width=(int)(this.Width*this.resizeWidthRatio);
+ this.listView.Height=(int)(this.Height*this.resizeHeightRatio);
+
+ //this.Size=new System.Drawing.Size((int)(this.Size.Width*this.tvComputerCluster.Width
+
+ }
+
+
+
+ private void updateGuiThread()
+ {
+ while(true) {
+ if(tvComputerCluster.SelectedNode!=null)
+ {
+ if(tvComputerCluster.SelectedNode.Text.ToString().Equals("Computer"))
+ updateListViews("Computer");
+ }
+ Thread.Sleep(1000);
+ }
+ }
+
+ private void computerMenuRefresh_Click(object sender, System.EventArgs e)
+ {
+ updateListViews("Computer");
+ }
+
+ private void CPC_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ /*clean up*/
+ ArrayList comp = this.computerMgmt.getComputerCollection();
+ foreach(Computer c in comp)
+ {
+ c.disconnect();
+ }
+ }
+
+ private void CPC_Load(object sender, System.EventArgs e)
+ {
+ this.tvComputerCluster.Width=104;
+ resizeWidthRatio =(float) ((float)(this.tvComputerCluster.Width)/(float)(this.Width));
+ resizeHeightRatio = (float) ((float)(this.listView.Height)/(float)(this.Height));
+ listView.Columns.Clear();
+ listView.Columns.Add(this.chComputer);
+ listView.Columns.Add(this.chStatus);
+
+ }
+
+ private void splitterVertical_SplitterMoved(object sender, System.Windows.Forms.SplitterEventArgs e)
+ {
+ if(this.Width < 500)
+ this.Width=500;
+ }
+
+ private void menuGetStatus_Click(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void tvComputerCluster_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
+ {
+ if (e.Node.Parent!=null && e.Node.Nodes.Count !=0)
+ e.Cancel=true;
+ if(e.Node.IsExpanded)
+ e.Cancel=true;
+ }
+
+ private void tvComputerCluster_BeforeCollapse(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
+ {
+ e.Cancel=true;
+ if (e.Node.Parent!=null && e.Node.Nodes.Count !=0)
+ e.Cancel=true;
+ if(e.Node.IsExpanded)
+ e.Cancel=false;
+ }
+
+
+
+ private void ctxListViewMenu_Popup(object sender, System.EventArgs e)
+ {
+
+ menuStartProcess.Visible=false;
+ menuStopProcess.Visible=false;
+ menuRestartProcess.Visible=false;
+ menuRemoveProcess.Visible=false;
+ menuRefresh.Visible=false;
+
+
+ if(this.tvComputerCluster.SelectedNode.Text.Equals("Computer"))
+ {
+ return;
+ }
+
+ if(this.tvComputerCluster.SelectedNode.Text.Equals("Database"))
+ {
+ return;
+ }
+
+ if(this.tvComputerCluster.SelectedNode.Parent.Text.Equals("Computer"))
+ {
+ if(listView.SelectedItems==null)
+ return;
+ menuRefresh.Visible=true;
+ }
+ if(this.tvComputerCluster.SelectedNode.Parent.Text.Equals("Database"))
+ {
+ if(listView.SelectedItems==null)
+ return;
+ menuStartProcess.Visible=true;
+ menuStopProcess.Visible=true;
+ menuRestartProcess.Visible=true;
+ menuRemoveProcess.Visible=true;
+ menuRefresh.Visible=true;
+ menuStopProcess.Enabled=true;
+ menuStartProcess.Enabled=true;
+ menuRestartProcess.Enabled=true;
+ menuRemoveProcess.Enabled=true;
+ menuRefresh.Enabled=true;
+ }
+
+
+ computerMenuRemove.Enabled=true;
+ computerMenuConnect.Enabled=true;
+ computerMenuDisconnect.Enabled=true;
+ computerMenuRefresh.Enabled=true;
+ string selectedItem="";
+ if(listView.SelectedItems.Count>0)
+ selectedItem=listView.FocusedItem.Text.ToString();
+
+
+ if(selectedItem.Equals(""))
+ {
+ computerMenuAdd.Enabled=true;
+ computerMenuRemove.Enabled=false;
+ computerMenuConnect.Enabled=false;
+ computerMenuDisconnect.Enabled=false;
+ return;
+ }
+ else
+ {
+ computerMenuAdd.Enabled=false;
+ if(computerMgmt.getStatus(selectedItem).Equals(Computer.Status.Connected))
+ {
+ computerMenuConnect.Enabled=false;
+ computerMenuRemove.Enabled=true;
+ }
+ if(computerMgmt.getStatus(selectedItem).Equals(Computer.Status.Disconnected))
+ computerMenuDisconnect.Enabled=false;
+ }
+
+
+ }
+
+ private void startProcess(object sender, System.EventArgs e)
+ {
+ if(listView.SelectedItems.Count==0)
+ return;
+
+ string computer = listView.SelectedItems[0].SubItems[0].Text.ToString();
+ string process = listView.SelectedItems[0].SubItems[2].Text.ToString();
+
+ if(computerMgmt.getComputer(computer).getProcessByName(process).getStatus()==Process.Status.Running)
+ {
+ MessageBox.Show(this,"The process is already started!" ,"Process failed to start",MessageBoxButtons.OK);
+ return;
+ }
+
+ int status = startProcess(listView.SelectedItems[0].SubItems[0].Text.ToString(),listView.SelectedItems[0].SubItems[2].Text.ToString());
+
+
+ if(status < 0)
+ MessageBox.Show(this,"Either the link is not OK, or the process is misconfigured! Status : " + status,"Process failed to start",MessageBoxButtons.OK);
+ else
+ MessageBox.Show(this,"The process was sucessfully started!","Process started",MessageBoxButtons.OK);
+
+ }
+
+ private int startProcess(string computer, string process)
+ {
+ Computer c=computerMgmt.getComputer(computer);
+ int status = c.startProcess(c.getProcessByName(process));
+ return status;
+ }
+
+ private void listView_ColumnClick_1(object sender, System.Windows.Forms.ColumnClickEventArgs e)
+ {
+ // if(listView.Columns[e.Column].Text.Equals("Computer"))
+ // {
+ if(listView.Sorting.Equals(SortOrder.Ascending))
+ {
+ listView.Sorting=SortOrder.Descending;
+ }
+ else
+ {
+ listView.Sorting=SortOrder.Ascending;
+ }
+ // }
+ }
+
+ private void removeProcess(object sender, System.EventArgs e)
+ {
+ if(listView.SelectedItems.Count==0)
+ return;
+ string process = listView.SelectedItems[0].SubItems[2].Text.ToString();
+ string computer = listView.SelectedItems[0].SubItems[0].Text.ToString();
+
+ if(MessageBox.Show("Are you sure that you want to remove " + process + " permanently?","Remove process",MessageBoxButtons.YesNo) == DialogResult.No)
+ return;
+ removeProcess(computer,process);
+ MessageBox.Show(this,"The process was sucessfully removed!","Remove process",MessageBoxButtons.OK);
+ }
+
+ private void removeProcess(string computer, string process)
+ {
+
+ Computer c=computerMgmt.getComputer(computer);
+ stopProcess(computer,process);
+ int status = c.undefineProcess(c.getProcessByName(process));
+ //if(status < 0)
+ // MessageBox.Show(this,"The process could not be removed!","Failed to remove process",MessageBoxButtons.OK);
+ // else
+ // {
+ Database db = computerMgmt.getDatabase((c.getProcessByName(process).getDatabase()));
+ db.removeProcess(process);
+ c.removeProcess(process,db.getName());
+ updateListViews("Database");
+ // }
+ }
+
+ private void stopProcess(object sender, System.EventArgs e)
+ {
+ if(listView.SelectedItems.Count==0)
+ return;
+ string computer = listView.SelectedItems[0].SubItems[0].Text.ToString();
+ string process = listView.SelectedItems[0].SubItems[2].Text.ToString();
+ if(computerMgmt.getComputer(computer).getProcessByName(process).getStatus()==Process.Status.Stopped)
+ {
+ MessageBox.Show(this,"The process is already stopped!" ,"Process failed to stop",MessageBoxButtons.OK);
+ return;
+ }
+
+ if(DialogResult.No==MessageBox.Show(this,"Are you sure you want to stop the " + process + " process?","Stop process!", MessageBoxButtons.YesNo))
+ return;
+
+ int status = stopProcess(computer, process);
+ if(status < 0)
+ MessageBox.Show(this,"The process could not be stopped. Status: " + status ,"Process failed to stop",MessageBoxButtons.OK);
+ else
+ MessageBox.Show(this,"The process was sucessfully stopped!","Process stopped",MessageBoxButtons.OK);
+ }
+
+ private int stopProcess(string computer, string process)
+ {
+ Computer c=computerMgmt.getComputer(computer);
+ int status = c.stopProcess(c.getProcessByName(process));
+ return status;
+ }
+
+ private void restartProcess(object sender, System.EventArgs e)
+ {
+ if(listView.SelectedItems.Count==0)
+ return;
+ string computer = listView.SelectedItems[0].SubItems[0].Text.ToString();
+ string process = listView.SelectedItems[0].SubItems[2].Text.ToString();
+ if(stopProcess(computer, process)<0)
+ {
+ MessageBox.Show("Restart process failed!!!", "Restart process");
+ return;
+ }
+ if(startProcess(computer, process)<0)
+ {
+ MessageBox.Show("Restart process failed!!!", "Restart process");
+ return;
+ }
+ MessageBox.Show("Succesfully restarted the process!","Restart process");
+ }
+
+ private void menuRefresh_Click(object sender, System.EventArgs e)
+ {
+ //string computer = tvComputerCluster.SelectedNode.Text;
+
+ this.listProcesses();
+ }
+
+ private void importHostFile(object sender, System.EventArgs e)
+ {
+ openHostFileDialog.ShowDialog();
+ }
+
+ private void exportHostFile(object sender, System.EventArgs e)
+ {
+ saveHostFileDialog.ShowDialog();
+ }
+
+ private void listProcesses()
+ {
+ /* add process in computer list*/
+ ArrayList computers = computerMgmt.getComputerCollection();
+ foreach(Computer c in computers)
+ {
+ c.listProcesses();
+ ArrayList processes = c.getProcesses();
+ if(processes!=null)
+ {
+ foreach(Process p in processes)
+ {
+ Database db = computerMgmt.getDatabase(p.getDatabase());
+ if(db!=null)
+ {
+ p.setDefined(true);
+ db.addProcessCheck(p);
+ }
+ }
+ }
+ }
+ updateListViews("Computer");
+ updateListViews("Database");
+ }
+
+ private void openHostFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ computerMgmt.importHostFile(openHostFileDialog.FileName);
+ this.updateTreeViews();
+ openHostFileDialog.Dispose();
+ listProcesses();
+ }
+
+ private void saveHostFileDialog_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ computerMgmt.exportHostFile(saveHostFileDialog.FileName);
+ saveHostFileDialog.Dispose();
+ }
+
+ private void mgmConsole_Enter(object sender, System.EventArgs e)
+ {/*
+ //telnetclient.telnetClient tc= new telnetclient.telnetClient("10.0.13.1",10000,mgmConsole);
+ socketcomm.SocketComm sc = new socketcomm.SocketComm("10.0.13.1",10000);
+ sc.doConnect();
+ while(!sc.isConnected())
+ {
+ Thread.Sleep(100);
+ }
+ sc.writeMessage("get status\r");
+ string line = sc.readLine();
+ while(!line.Equals(""))
+ {
+ MessageBox.Show(line);
+ line=sc.readLine();
+ }
+*/
+ }
+
+ private void mgmConsole_TextChanged(object sender, System.EventArgs e)
+ {
+
+ }
+
+
+
+
+
+
+
+
+
+ }
+
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs
new file mode 100644
index 00000000000..9763fac5622
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/Computer.cs
@@ -0,0 +1,256 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+using System.IO;
+using NDB_CPC.socketcomm;
+using NDB_CPC.simpleparser;
+
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for Computer.
+ /// </summary>
+ public class Computer
+ {
+ public enum Status {Disconnected=1,Connected=2, Unknown=3}
+ private string m_ip;
+ private int m_cpcdPort;
+ private string m_name;
+ private Status m_status;
+ private ArrayList m_processes;
+ private SocketComm m_socket;
+ public Computer(string name, int port)
+ {
+ m_name = name;
+ m_status = Status.Disconnected;
+ m_processes = new ArrayList();
+ m_cpcdPort=port;
+ m_socket = new SocketComm(m_name,m_cpcdPort);
+ }
+
+ public Computer(string name, string ip)
+ {
+ m_ip = ip;
+ m_name = name;
+ m_status = Status.Disconnected;
+ m_processes = new ArrayList();
+ m_cpcdPort=1234; //default port
+ m_socket = new SocketComm(m_ip,m_cpcdPort);
+ }
+
+ public void connectToCpcd()
+ {
+ m_socket.doConnect();
+ }
+
+ private bool sendMessage(string str)
+ {
+ return m_socket.writeMessage(str);
+
+ }
+
+ public string getName() {return m_name;}
+ public string getIp() {return m_ip;}
+ public ArrayList getProcesses()
+ {
+ if(m_processes.Count>0)
+ return m_processes;
+ else
+ return null;
+ }
+ public string getStatusString()
+ {
+ try
+ {
+ if(m_socket.isConnected())
+ return "Connected";
+ else
+ return "Disconnected";
+ }
+ catch(Exception e)
+ {
+ return "Unknown";
+ }
+ }
+
+
+ public bool isConnected()
+ {
+ if(m_socket.isConnected())
+ return true;
+ return false;
+ }
+
+ public Status getStatus()
+ {
+ try
+ {
+ if(m_socket.isConnected())
+ return Status.Connected;
+ else
+ return Status.Disconnected;
+ }
+ catch(Exception e)
+ {
+ return Status.Unknown;
+ }
+ }
+
+ public void setStatus(Status status)
+ {
+ m_status=status;
+ }
+
+ public void addProcess(Process process)
+ {
+ m_processes.Add(process);
+ }
+
+ public Process getProcessByName(string name)
+ {
+ foreach(Process process in m_processes)
+ {
+ if(process.getName().Equals(name))
+ return process;
+ }
+ return null;
+ }
+
+
+ public bool removeProcess(string name, string database)
+ {
+ foreach(Process p in m_processes)
+ {
+ if(p.getName().Equals(name) && p.getDatabase().Equals(database))
+ {
+ m_processes.Remove(p);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void disconnect()
+ {
+ m_socket.disconnect();
+ }
+ public Process getProcess(string id)
+ {
+ foreach(Process process in m_processes)
+ {
+ if(process.getId().Equals(id))
+ return process;
+ }
+ return null;
+ }
+
+ public int listProcesses()
+ {
+ string list = "list processes\n\n";
+
+ if(!sendMessage(list))
+ return -2;
+
+ SimpleCPCParser.parse(m_processes, this, m_socket);
+ return 1;
+ }
+
+ public int defineProcess(Process p)
+ {
+ string define = "define process \n";
+ define = define + "name:" + p.getName() + "\n";
+ define = define + "group:" + p.getDatabase() + "\n";
+ define = define + "env:" + "NDB_CONNECTSTRING="+p.getConnectString() ;
+ if(p.getEnv().Equals(""))
+ define = define + "\n";
+ else
+ define = define + " " + p.getEnv() + "\n";
+
+ //if(p.getPath().EndsWith("\\"))
+ // define = define + "path:" + p.getPath()+ "ndb" + "\n";
+ //else
+ define = define + "path:" + p.getPath() + "\n";
+ define = define + "args:" + p.getArgs() + "\n";
+ define = define + "type:" + "permanent" + "\n";
+ define = define + "cwd:" + p.getCwd() + "\n";
+ define = define + "owner:" + "ejohson" + "\n\n";
+
+ if(!sendMessage(define))
+ return -2;
+
+ SimpleCPCParser.parse(p, m_socket);
+ if(p.isDefined())
+ return 1;
+ else
+ return -1;
+
+ }
+
+ public int startProcess(Process p)
+ {
+ if(!p.isDefined())
+ {
+ this.defineProcess(p);
+ if(!p.isDefined())
+ return -4; //process misconfigured
+
+ }
+ string start= "start process \n";
+ start = start + "id:" + p.getId() + "\n\n";
+ if(!sendMessage(start))
+ return -2;
+ SimpleCPCParser.parse(p, m_socket);
+ if(p.getStatus().Equals(Process.Status.Running))
+ return 1;
+ else
+ return -1;
+ }
+
+ public int stopProcess(Process p)
+ {
+ if(!p.isDefined())
+ {
+ return -4; //process not defined
+ }
+ string stop= "stop process \n";
+ stop = stop + "id:" + p.getId() + "\n\n";
+ if(!sendMessage(stop))
+ return -2;
+ SimpleCPCParser.parse(p, m_socket);
+
+ if(p.getStatus().Equals(Process.Status.Stopped))
+ return 1;
+ else
+ return -1;
+ }
+
+ public int undefineProcess(Process p)
+ {
+ if(!p.isDefined())
+ {
+ return -4; //process not defined
+ }
+ string undefine= "undefine process \n";
+ undefine = undefine + "id:" + p.getId() + "\n\n";
+ if(!sendMessage(undefine))
+ return -2;
+ SimpleCPCParser.parse(p, m_socket);
+ if(!p.isDefined())
+ {
+ return 1;
+
+ }
+ return -1;
+ }
+
+ public int getCpcdPort()
+ {
+ return this.m_cpcdPort;
+ }
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs
new file mode 100644
index 00000000000..c01e41f3e60
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerAddDialog.cs
@@ -0,0 +1,242 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for ComputerAddDialog.
+ /// </summary>
+ public class ComputerAddDialog : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox textboxComputerName;
+ private System.Windows.Forms.Button btnAdd;
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.Label label2;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.CheckBox checkBoxDefault;
+ private System.Windows.Forms.TextBox textBoxPort;
+
+ private ComputerMgmt mgmt;
+ public ComputerAddDialog(ComputerMgmt mgmt)
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ this.mgmt=mgmt;
+ }
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.textboxComputerName = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.btnAdd = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.textBoxPort = new System.Windows.Forms.TextBox();
+ this.checkBoxDefault = new System.Windows.Forms.CheckBox();
+ this.SuspendLayout();
+ //
+ // textboxComputerName
+ //
+ this.textboxComputerName.Location = new System.Drawing.Point(128, 16);
+ this.textboxComputerName.Name = "textboxComputerName";
+ this.textboxComputerName.Size = new System.Drawing.Size(136, 20);
+ this.textboxComputerName.TabIndex = 0;
+ this.textboxComputerName.Text = "";
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(40, 16);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(88, 23);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "Computer name:";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // btnAdd
+ //
+ this.btnAdd.Location = new System.Drawing.Point(112, 128);
+ this.btnAdd.Name = "btnAdd";
+ this.btnAdd.Size = new System.Drawing.Size(80, 24);
+ this.btnAdd.TabIndex = 4;
+ this.btnAdd.Text = "Add";
+ this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
+ //
+ // btnCancel
+ //
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.Location = new System.Drawing.Point(200, 128);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(80, 24);
+ this.btnCancel.TabIndex = 5;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(128, 40);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(136, 16);
+ this.label2.TabIndex = 4;
+ this.label2.Text = "(e.g. Ndb01 or 10.0.1.1)";
+ //
+ // label6
+ //
+ this.label6.Location = new System.Drawing.Point(48, 64);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(80, 24);
+ this.label6.TabIndex = 9;
+ this.label6.Text = "CPCd port:";
+ this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // textBoxPort
+ //
+ this.textBoxPort.Enabled = false;
+ this.textBoxPort.Location = new System.Drawing.Point(128, 64);
+ this.textBoxPort.Name = "textBoxPort";
+ this.textBoxPort.Size = new System.Drawing.Size(136, 20);
+ this.textBoxPort.TabIndex = 2;
+ this.textBoxPort.TabStop = false;
+ this.textBoxPort.Text = "";
+ //
+ // checkBoxDefault
+ //
+ this.checkBoxDefault.Checked = true;
+ this.checkBoxDefault.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.checkBoxDefault.Location = new System.Drawing.Point(96, 96);
+ this.checkBoxDefault.Name = "checkBoxDefault";
+ this.checkBoxDefault.Size = new System.Drawing.Size(168, 16);
+ this.checkBoxDefault.TabIndex = 3;
+ this.checkBoxDefault.Text = "Use default port (1234)?";
+ this.checkBoxDefault.CheckedChanged += new System.EventHandler(this.checkBoxDefault_CheckedChanged);
+ //
+ // ComputerAddDialog
+ //
+ this.AcceptButton = this.btnAdd;
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.CancelButton = this.btnCancel;
+ this.ClientSize = new System.Drawing.Size(298, 159);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.checkBoxDefault,
+ this.label6,
+ this.textBoxPort,
+ this.label2,
+ this.btnCancel,
+ this.btnAdd,
+ this.label1,
+ this.textboxComputerName});
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ComputerAddDialog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Add a computer";
+ this.Load += new System.EventHandler(this.ComputerAddDialog_Load);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void btnCancel_Click(object sender, System.EventArgs e)
+ {
+ this.Close();
+ this.Dispose();
+ }
+
+ private void btnAdd_Click(object sender, System.EventArgs e)
+ {
+ int port;
+ if(this.textboxComputerName.Text.Equals(""))
+ {
+ MessageBox.Show(this,"A computer must have an IP address or a host name","Warning!",MessageBoxButtons.OK);
+ return;
+ }
+ if(this.checkBoxDefault.Checked)
+ {
+ port=1234;
+ }
+ else
+ {
+ if(this.textBoxPort.Text.Equals(""))
+ {
+ MessageBox.Show(this,"You must specify a port number!!!","Warning!",MessageBoxButtons.OK);
+ return;
+ }
+ else
+ {
+ try
+ {
+ port=Convert.ToInt32(this.textBoxPort.Text.ToString());
+
+ }
+ catch (Exception exception)
+ {
+ MessageBox.Show(this,"Port number must be numeric!!!","Warning!",MessageBoxButtons.OK);
+ return;
+ }
+ }
+ }
+
+ if(mgmt.getComputer(this.textboxComputerName.Text)==null)
+ {
+ mgmt.AddComputer(this.textboxComputerName.Text.ToString(),port);}
+ else
+ {
+ MessageBox.Show("This computer does already exist!", "Add computer");
+ return;
+ }
+
+ this.Dispose();
+ }
+
+ private void ComputerAddDialog_Load(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void checkBoxDefault_CheckedChanged(object sender, System.EventArgs e)
+ {
+ if(checkBoxDefault.Checked)
+ textBoxPort.Enabled=false;
+ else
+ textBoxPort.Enabled=true;
+ }
+
+
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs
new file mode 100644
index 00000000000..5b4d1b56df7
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/ComputerRemoveDialog.cs
@@ -0,0 +1,228 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for ComputerRemoveDialog.
+ /// </summary>
+ public class ComputerRemoveDialog : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ComboBox comboComputer;
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.Button btnRemove;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+ private ComputerMgmt mgmt;
+
+ public ComputerRemoveDialog(ComputerMgmt mgmt)
+ {
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ this.mgmt=mgmt;
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(ComputerRemoveDialog));
+ this.label1 = new System.Windows.Forms.Label();
+ this.comboComputer = new System.Windows.Forms.ComboBox();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.btnRemove = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AccessibleDescription = ((string)(resources.GetObject("label1.AccessibleDescription")));
+ this.label1.AccessibleName = ((string)(resources.GetObject("label1.AccessibleName")));
+ this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor")));
+ this.label1.AutoSize = ((bool)(resources.GetObject("label1.AutoSize")));
+ this.label1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label1.Dock")));
+ this.label1.Enabled = ((bool)(resources.GetObject("label1.Enabled")));
+ this.label1.Font = ((System.Drawing.Font)(resources.GetObject("label1.Font")));
+ this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
+ this.label1.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.ImageAlign")));
+ this.label1.ImageIndex = ((int)(resources.GetObject("label1.ImageIndex")));
+ this.label1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label1.ImeMode")));
+ this.label1.Location = ((System.Drawing.Point)(resources.GetObject("label1.Location")));
+ this.label1.Name = "label1";
+ this.label1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label1.RightToLeft")));
+ this.label1.Size = ((System.Drawing.Size)(resources.GetObject("label1.Size")));
+ this.label1.TabIndex = ((int)(resources.GetObject("label1.TabIndex")));
+ this.label1.Text = resources.GetString("label1.Text");
+ this.label1.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.TextAlign")));
+ this.label1.Visible = ((bool)(resources.GetObject("label1.Visible")));
+ //
+ // comboComputer
+ //
+ this.comboComputer.AccessibleDescription = ((string)(resources.GetObject("comboComputer.AccessibleDescription")));
+ this.comboComputer.AccessibleName = ((string)(resources.GetObject("comboComputer.AccessibleName")));
+ this.comboComputer.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("comboComputer.Anchor")));
+ this.comboComputer.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("comboComputer.BackgroundImage")));
+ this.comboComputer.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("comboComputer.Dock")));
+ this.comboComputer.Enabled = ((bool)(resources.GetObject("comboComputer.Enabled")));
+ this.comboComputer.Font = ((System.Drawing.Font)(resources.GetObject("comboComputer.Font")));
+ this.comboComputer.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("comboComputer.ImeMode")));
+ this.comboComputer.IntegralHeight = ((bool)(resources.GetObject("comboComputer.IntegralHeight")));
+ this.comboComputer.ItemHeight = ((int)(resources.GetObject("comboComputer.ItemHeight")));
+ this.comboComputer.Location = ((System.Drawing.Point)(resources.GetObject("comboComputer.Location")));
+ this.comboComputer.MaxDropDownItems = ((int)(resources.GetObject("comboComputer.MaxDropDownItems")));
+ this.comboComputer.MaxLength = ((int)(resources.GetObject("comboComputer.MaxLength")));
+ this.comboComputer.Name = "comboComputer";
+ this.comboComputer.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("comboComputer.RightToLeft")));
+ this.comboComputer.Size = ((System.Drawing.Size)(resources.GetObject("comboComputer.Size")));
+ this.comboComputer.Sorted = true;
+ this.comboComputer.TabIndex = ((int)(resources.GetObject("comboComputer.TabIndex")));
+ this.comboComputer.Text = resources.GetString("comboComputer.Text");
+ this.comboComputer.Visible = ((bool)(resources.GetObject("comboComputer.Visible")));
+ this.comboComputer.SelectedIndexChanged += new System.EventHandler(this.comboComputer_SelectedIndexChanged);
+ //
+ // btnCancel
+ //
+ this.btnCancel.AccessibleDescription = ((string)(resources.GetObject("btnCancel.AccessibleDescription")));
+ this.btnCancel.AccessibleName = ((string)(resources.GetObject("btnCancel.AccessibleName")));
+ this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnCancel.Anchor")));
+ this.btnCancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCancel.BackgroundImage")));
+ this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnCancel.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnCancel.Dock")));
+ this.btnCancel.Enabled = ((bool)(resources.GetObject("btnCancel.Enabled")));
+ this.btnCancel.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnCancel.FlatStyle")));
+ this.btnCancel.Font = ((System.Drawing.Font)(resources.GetObject("btnCancel.Font")));
+ this.btnCancel.Image = ((System.Drawing.Image)(resources.GetObject("btnCancel.Image")));
+ this.btnCancel.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCancel.ImageAlign")));
+ this.btnCancel.ImageIndex = ((int)(resources.GetObject("btnCancel.ImageIndex")));
+ this.btnCancel.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnCancel.ImeMode")));
+ this.btnCancel.Location = ((System.Drawing.Point)(resources.GetObject("btnCancel.Location")));
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnCancel.RightToLeft")));
+ this.btnCancel.Size = ((System.Drawing.Size)(resources.GetObject("btnCancel.Size")));
+ this.btnCancel.TabIndex = ((int)(resources.GetObject("btnCancel.TabIndex")));
+ this.btnCancel.Text = resources.GetString("btnCancel.Text");
+ this.btnCancel.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnCancel.TextAlign")));
+ this.btnCancel.Visible = ((bool)(resources.GetObject("btnCancel.Visible")));
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // btnRemove
+ //
+ this.btnRemove.AccessibleDescription = ((string)(resources.GetObject("btnRemove.AccessibleDescription")));
+ this.btnRemove.AccessibleName = ((string)(resources.GetObject("btnRemove.AccessibleName")));
+ this.btnRemove.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("btnRemove.Anchor")));
+ this.btnRemove.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnRemove.BackgroundImage")));
+ this.btnRemove.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("btnRemove.Dock")));
+ this.btnRemove.Enabled = ((bool)(resources.GetObject("btnRemove.Enabled")));
+ this.btnRemove.FlatStyle = ((System.Windows.Forms.FlatStyle)(resources.GetObject("btnRemove.FlatStyle")));
+ this.btnRemove.Font = ((System.Drawing.Font)(resources.GetObject("btnRemove.Font")));
+ this.btnRemove.Image = ((System.Drawing.Image)(resources.GetObject("btnRemove.Image")));
+ this.btnRemove.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnRemove.ImageAlign")));
+ this.btnRemove.ImageIndex = ((int)(resources.GetObject("btnRemove.ImageIndex")));
+ this.btnRemove.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("btnRemove.ImeMode")));
+ this.btnRemove.Location = ((System.Drawing.Point)(resources.GetObject("btnRemove.Location")));
+ this.btnRemove.Name = "btnRemove";
+ this.btnRemove.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("btnRemove.RightToLeft")));
+ this.btnRemove.Size = ((System.Drawing.Size)(resources.GetObject("btnRemove.Size")));
+ this.btnRemove.TabIndex = ((int)(resources.GetObject("btnRemove.TabIndex")));
+ this.btnRemove.Text = resources.GetString("btnRemove.Text");
+ this.btnRemove.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("btnRemove.TextAlign")));
+ this.btnRemove.Visible = ((bool)(resources.GetObject("btnRemove.Visible")));
+ this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
+ //
+ // ComputerRemoveDialog
+ //
+ this.AcceptButton = this.btnRemove;
+ this.AccessibleDescription = ((string)(resources.GetObject("$this.AccessibleDescription")));
+ this.AccessibleName = ((string)(resources.GetObject("$this.AccessibleName")));
+ this.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("$this.Anchor")));
+ this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
+ this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
+ this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
+ this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
+ this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
+ this.CancelButton = this.btnCancel;
+ this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.btnRemove,
+ this.btnCancel,
+ this.comboComputer,
+ this.label1});
+ this.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("$this.Dock")));
+ this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
+ this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+ this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
+ this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
+ this.MaximizeBox = false;
+ this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
+ this.MinimizeBox = false;
+ this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
+ this.Name = "ComputerRemoveDialog";
+ this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
+ this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
+ this.Text = resources.GetString("$this.Text");
+ this.Visible = ((bool)(resources.GetObject("$this.Visible")));
+ this.Load += new System.EventHandler(this.ComputerRemoveDialog_Load);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void btnRemove_Click(object sender, System.EventArgs e)
+ {
+ mgmt.RemoveComputer(comboComputer.SelectedItem.ToString());
+ this.Dispose();
+ }
+
+ private void ComputerRemoveDialog_Load(object sender, System.EventArgs e)
+ {
+ ArrayList list = mgmt.getComputerCollection();
+ foreach (Computer computer in list)
+ {
+ comboComputer.Items.Add(computer.getName());
+ }
+ }
+
+ private void btnCancel_Click(object sender, System.EventArgs e)
+ {
+ this.Close();
+ this.Dispose();
+ }
+
+ private void comboComputer_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ }
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO b/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO
new file mode 100644
index 00000000000..9689aa88361
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/DATABASE.ICO
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs
new file mode 100644
index 00000000000..39b8c160159
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/Database.cs
@@ -0,0 +1,162 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for Database.
+ /// </summary>
+ public class Database
+ {
+ public enum Status {Disconnected=1,Connected=2, Unknown=3}
+ private string m_name;
+ private string m_owner;
+ private int m_mgmtPort;
+ private Status m_status;
+ private ArrayList m_processes;
+ public Database(string name)
+ {
+ m_name=name;
+ m_processes = new ArrayList();
+ }
+ public Database(string name, string owner)
+ {
+ m_name=name;
+ m_owner=owner;
+ m_processes = new ArrayList();
+ }
+ public Database()
+ {
+ m_processes = new ArrayList();
+ }
+
+ public string getName()
+ {
+ return m_name;
+ }
+
+ public void setName(string name)
+ {
+ m_name=name;
+ }
+
+ public void setMgmtPort(int port)
+ {
+ m_mgmtPort=port;
+ }
+
+ public string getOwner()
+ {
+ return m_owner;
+ }
+
+ public void setOwner(string name)
+ {
+ m_owner=name;
+ }
+
+
+ public Status getStatus()
+ {
+ return m_status;
+ }
+
+ public string getStatusString()
+ {
+ if(m_status.Equals(Status.Connected))
+ return "Connected";
+ if(m_status.Equals(Status.Disconnected))
+ return "Disconnected";
+ if(m_status.Equals(Status.Unknown))
+ return "Unknown";
+ return "Unknown";
+ }
+ public void setStatus(Status status)
+ {
+ m_status=status;
+ }
+
+ public void addProcess(Process process)
+ {
+ /*if(check)
+ {
+ if(m_processes==null)
+ return;
+ if(m_processes.Count>0)
+ {
+ foreach (Process p in m_processes)
+ {
+ if(process.getId().Equals(p.getId()))
+ return;
+ }
+ }
+ }
+ */
+ m_processes.Add(process);
+ }
+ public void addProcessCheck(Process process)
+ {
+
+ if(m_processes==null)
+ return;
+ if(m_processes.Count>0)
+ {
+ foreach (Process p in m_processes)
+ {
+ if(process.getId().Equals(p.getId()))
+ return;
+ }
+ }
+ m_processes.Add(process);
+ }
+
+ public Process getProcess(string id)
+ {
+ foreach(Process process in m_processes)
+ {
+ if(process.getId().Equals(id))
+ return process;
+ }
+ return null;
+ }
+
+ public Process getProcessByName(string name)
+ {
+ foreach(Process process in m_processes)
+ {
+ if(process.getName().Equals(name))
+ return process;
+ }
+ return null;
+ }
+
+ public void removeProcess( string processName)
+ {
+ Process p = this.getProcessByName(processName);
+ m_processes.Remove(p);
+ }
+
+ public void removeAllProcesses()
+ {
+ Computer c;
+ foreach(Process p in m_processes)
+ {
+ c=p.getComputer();
+ if(c.removeProcess(p.getName(),m_name).Equals(false))
+ {
+
+ }
+ }
+ m_processes.Clear();
+ }
+
+ public ArrayList getProcesses()
+ {
+ return m_processes;
+ }
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj
new file mode 100644
index 00000000000..6384eff8329
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj
@@ -0,0 +1,240 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.0.9466"
+ SchemaVersion = "1.0"
+ ProjectGuid = "{B78F6720-D36C-43DD-B442-F583718D0286}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = "App.ico"
+ AssemblyKeyContainerName = ""
+ AssemblyName = "NDB_CPC"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "WinExe"
+ RootNamespace = "NDB_CPC"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "DEBUG;TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "true"
+ FileAlignment = "4096"
+ IncrementalBuild = "true"
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ <Config
+ Name = "Release"
+ AllowUnsafeBlocks = "false"
+ BaseAddress = "285212672"
+ CheckForOverflowUnderflow = "false"
+ ConfigurationOverrideFile = ""
+ DefineConstants = "TRACE"
+ DocumentationFile = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ Optimize = "true"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ RemoveIntegerChecks = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "4"
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "System.Data"
+ AssemblyName = "System.Data"
+ HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
+ />
+ <Reference
+ Name = "System.Drawing"
+ AssemblyName = "System.Drawing"
+ HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Drawing.dll"
+ />
+ <Reference
+ Name = "System.Windows.Forms"
+ AssemblyName = "System.Windows.Forms"
+ HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Windows.Forms.dll"
+ />
+ <Reference
+ Name = "System.XML"
+ AssemblyName = "System.Xml"
+ HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
+ />
+ <Reference
+ Name = "System"
+ AssemblyName = "System"
+ HintPath = "..\..\..\..\..\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
+ />
+ <Reference
+ Name = "VBIDE"
+ Guid = "{0002E157-0000-0000-C000-000000000046}"
+ VersionMajor = "5"
+ VersionMinor = "3"
+ Lcid = "0"
+ WrapperTool = "tlbimp"
+ />
+ <Reference
+ Name = "stdole"
+ Guid = "{00020430-0000-0000-C000-000000000046}"
+ VersionMajor = "2"
+ VersionMinor = "0"
+ Lcid = "0"
+ WrapperTool = "primary"
+ />
+ <Reference
+ Name = "Microsoft.Office.Core"
+ Guid = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}"
+ VersionMajor = "2"
+ VersionMinor = "2"
+ Lcid = "0"
+ WrapperTool = "tlbimp"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "app.config"
+ BuildAction = "None"
+ />
+ <File
+ RelPath = "App.ico"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "Computer.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComputerAddDialog.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComputerAddDialog.resx"
+ DependentUpon = "ComputerAddDialog.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "ComputerMgmt.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComputerRemoveDialog.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ComputerRemoveDialog.af.resx"
+ DependentUpon = "ComputerRemoveDialog.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "ComputerRemoveDialog.resx"
+ DependentUpon = "ComputerRemoveDialog.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "CPC_Form.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "CPC_Form.resx"
+ DependentUpon = "CPC_Form.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "Database.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "PanelWizard.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "PanelWizard.resx"
+ DependentUpon = "PanelWizard.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "Process.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ProcessDefineDialog.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ProcessDefineDialog.resx"
+ DependentUpon = "ProcessDefineDialog.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "startDatabaseDlg.cs"
+ SubType = "Form"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "startDatabaseDlg.resx"
+ DependentUpon = "startDatabaseDlg.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
+ RelPath = "fileaccess\FileMgmt.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "simpleparser\SimpleCPCParser.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "socketcomm\myTcpClient.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "socketcomm\SocketComm.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "telnetclient\telnetClient.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user
new file mode 100644
index 00000000000..68937906d93
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.csproj.user
@@ -0,0 +1,48 @@
+<VisualStudioProject>
+ <CSHARP>
+ <Build>
+ <Settings ReferencePath = "" >
+ <Config
+ Name = "Debug"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "false"
+ />
+ <Config
+ Name = "Release"
+ EnableASPDebugging = "false"
+ EnableASPXDebugging = "false"
+ EnableUnmanagedDebugging = "false"
+ EnableSQLServerDebugging = "false"
+ RemoteDebugEnabled = "false"
+ RemoteDebugMachine = ""
+ StartAction = "Project"
+ StartArguments = ""
+ StartPage = ""
+ StartProgram = ""
+ StartURL = ""
+ StartWorkingDirectory = ""
+ StartWithIE = "true"
+ />
+ </Settings>
+ </Build>
+ <OtherProjectSettings
+ CopyProjectDestinationFolder = ""
+ CopyProjectUncPath = ""
+ CopyProjectOption = "0"
+ ProjectView = "ProjectFiles"
+ ProjectTrust = "0"
+ />
+ </CSHARP>
+</VisualStudioProject>
+
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb
new file mode 100644
index 00000000000..ed3460476b0
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.ncb
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln
new file mode 100644
index 00000000000..ef18b5e94ce
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/NDB_CPC.sln
@@ -0,0 +1,21 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NDB_CPC", "NDB_CPC.csproj", "{B78F6720-D36C-43DD-B442-F583718D0286}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {B78F6720-D36C-43DD-B442-F583718D0286}.Debug.ActiveCfg = Debug|.NET
+ {B78F6720-D36C-43DD-B442-F583718D0286}.Debug.Build.0 = Debug|.NET
+ {B78F6720-D36C-43DD-B442-F583718D0286}.Release.ActiveCfg = Release|.NET
+ {B78F6720-D36C-43DD-B442-F583718D0286}.Release.Build.0 = Release|.NET
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs
new file mode 100644
index 00000000000..f492aa64c60
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/PanelWizard.cs
@@ -0,0 +1,1883 @@
+//author:Arun
+//date:Nov 13,2002
+//Wizard using panel
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for MDXQueryBuilderWizard.
+ /// </summary>
+ public class PanelWizard : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.Button btnCancel;
+ private System.Windows.Forms.Button btnback;
+ private System.Windows.Forms.Button btnNext;
+ private System.Windows.Forms.Button btnFinish;
+
+ //---enabling and disabling the buttons
+ private bool cancelEnabled;
+ private bool backEnabled;
+ private bool nextEnabled;
+ private bool finishEnabled;
+ //--------
+ //--set the next and back panel
+ private Panel nextPanel;
+ private Panel backPanel;
+ private Panel presentPanel;
+ //
+ private Panel[] arrayPanel;
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.Panel panel2;
+ private System.Windows.Forms.Panel panel3;
+ private System.Windows.Forms.RadioButton radioBtnYes;
+ private System.Windows.Forms.RadioButton radioBtnNo;
+ private System.Windows.Forms.ListBox listBoxComputers;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label1;
+ private System.ComponentModel.IContainer components;
+ private System.Windows.Forms.Button buttonComputerAdd;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.ComboBox comboNDB;
+ private System.Windows.Forms.ComboBox comboAPI;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.ComboBox comboMGM;
+ private System.Windows.Forms.Button btnTransferNodeToComp;
+ private System.Windows.Forms.TreeView tvComputer;
+ private System.Windows.Forms.ListView lvNode;
+ private System.Windows.Forms.Button btnTransferCompToNode;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.Label label10;
+ private int m_nMGM;
+ private ComputerMgmt mgmt;
+ private int m_nNDB;
+ private int m_nAPI;
+ private Database m_db;
+ private System.Windows.Forms.Label label11;
+ private System.Windows.Forms.TextBox textDbName;
+ private System.Windows.Forms.Label label31;
+ private System.Windows.Forms.Label label32;
+ private System.Windows.Forms.Label label33;
+ private System.Windows.Forms.Label label18;
+ private System.Windows.Forms.Label labelTitle;
+ private System.Windows.Forms.Label labelCwd;
+ private System.Windows.Forms.Label labelArgs;
+ private System.Windows.Forms.Label labelOther;
+ private System.Windows.Forms.Label labelPath;
+ private int m_noOfConfiguredNodes;
+ private int m_noOfConfiguredMgmt;
+ private int m_noOfConfiguredNdb;
+ private string m_mgmHost;
+ private string m_mgmPort;
+ private System.Windows.Forms.TextBox textCwd;
+ private System.Windows.Forms.TextBox textArgs;
+ private System.Windows.Forms.TextBox textOther;
+ private System.Windows.Forms.TextBox textPath;
+ private System.Windows.Forms.TextBox textComputer;
+ private System.Windows.Forms.TextBox textDatabase;
+ private System.Windows.Forms.TextBox textName;
+ private int m_noOfConfiguredApi;
+ private bool m_bMgmt;
+ private System.Windows.Forms.Button buttonSave;
+ private System.Windows.Forms.CheckBox checkBoxReuse;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Panel panel4;
+ private System.Windows.Forms.CheckBox checkBoxLater;
+ private System.Windows.Forms.RadioButton radioYes;
+ private System.Windows.Forms.RadioButton radioNo;
+ private System.Windows.Forms.Panel panel6;
+ private System.Windows.Forms.Panel panel5;
+ private System.Windows.Forms.RadioButton radioStartNo;
+ private System.Windows.Forms.RadioButton radioStartYes;
+ private System.Windows.Forms.ImageList imageListComp;
+ private System.Windows.Forms.Label label12;
+ private System.Windows.Forms.TextBox textOwner;
+ private System.Windows.Forms.Label label13;
+ private System.Windows.Forms.TextBox textEnv;
+ private bool m_bNdb;
+ public PanelWizard(ComputerMgmt comp)
+ {
+ mgmt=comp;
+ m_noOfConfiguredNodes=0;
+ m_noOfConfiguredMgmt=0;
+ m_noOfConfiguredNdb=0;
+ m_noOfConfiguredApi=0;
+ Size panelSize= new Size(350,300);
+ Size s= new Size(355,360);
+ Point cancel= new Point(8,310);
+ Point back= new Point(96,310);
+ Point next = new Point(184,310);
+ Point finish= new Point(272,310);
+ InitializeComponent();
+ this.Size=s;
+ this.btnCancel.Location=cancel;
+
+ this.btnback.Location=back;
+ this.btnNext.Location=next;
+ this.btnFinish.Location=finish;
+
+ arrayPanel=new Panel[]{panel1,panel2,panel3,panel4,panel5,panel6};//,panel5, panel6};
+ panel1.Size=panelSize;
+
+ comboNDB.SelectedIndex=0;
+ comboAPI.SelectedIndex=0;
+ comboMGM.SelectedIndex=0;
+ m_bMgmt=false;
+ m_bNdb=false;
+
+ m_db = new Database();
+ if(listBoxComputers.Items.Count.Equals(0))
+ btnNext.Enabled=false;
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PanelWizard));
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.buttonComputerAdd = new System.Windows.Forms.Button();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.listBoxComputers = new System.Windows.Forms.ListBox();
+ this.radioBtnNo = new System.Windows.Forms.RadioButton();
+ this.radioBtnYes = new System.Windows.Forms.RadioButton();
+ this.panel2 = new System.Windows.Forms.Panel();
+ this.label12 = new System.Windows.Forms.Label();
+ this.textOwner = new System.Windows.Forms.TextBox();
+ this.label11 = new System.Windows.Forms.Label();
+ this.textDbName = new System.Windows.Forms.TextBox();
+ this.label8 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.comboMGM = new System.Windows.Forms.ComboBox();
+ this.comboAPI = new System.Windows.Forms.ComboBox();
+ this.comboNDB = new System.Windows.Forms.ComboBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.panel3 = new System.Windows.Forms.Panel();
+ this.checkBoxLater = new System.Windows.Forms.CheckBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.btnTransferCompToNode = new System.Windows.Forms.Button();
+ this.btnTransferNodeToComp = new System.Windows.Forms.Button();
+ this.lvNode = new System.Windows.Forms.ListView();
+ this.tvComputer = new System.Windows.Forms.TreeView();
+ this.imageListComp = new System.Windows.Forms.ImageList(this.components);
+ this.panel6 = new System.Windows.Forms.Panel();
+ this.radioStartNo = new System.Windows.Forms.RadioButton();
+ this.radioStartYes = new System.Windows.Forms.RadioButton();
+ this.label18 = new System.Windows.Forms.Label();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.btnback = new System.Windows.Forms.Button();
+ this.btnNext = new System.Windows.Forms.Button();
+ this.btnFinish = new System.Windows.Forms.Button();
+ this.panel4 = new System.Windows.Forms.Panel();
+ this.textEnv = new System.Windows.Forms.TextBox();
+ this.label13 = new System.Windows.Forms.Label();
+ this.checkBoxReuse = new System.Windows.Forms.CheckBox();
+ this.buttonSave = new System.Windows.Forms.Button();
+ this.labelTitle = new System.Windows.Forms.Label();
+ this.textComputer = new System.Windows.Forms.TextBox();
+ this.textCwd = new System.Windows.Forms.TextBox();
+ this.textArgs = new System.Windows.Forms.TextBox();
+ this.textOther = new System.Windows.Forms.TextBox();
+ this.textPath = new System.Windows.Forms.TextBox();
+ this.textDatabase = new System.Windows.Forms.TextBox();
+ this.textName = new System.Windows.Forms.TextBox();
+ this.labelCwd = new System.Windows.Forms.Label();
+ this.labelArgs = new System.Windows.Forms.Label();
+ this.labelOther = new System.Windows.Forms.Label();
+ this.labelPath = new System.Windows.Forms.Label();
+ this.label31 = new System.Windows.Forms.Label();
+ this.label32 = new System.Windows.Forms.Label();
+ this.label33 = new System.Windows.Forms.Label();
+ this.panel5 = new System.Windows.Forms.Panel();
+ this.radioNo = new System.Windows.Forms.RadioButton();
+ this.radioYes = new System.Windows.Forms.RadioButton();
+ this.label4 = new System.Windows.Forms.Label();
+ this.panel1.SuspendLayout();
+ this.panel2.SuspendLayout();
+ this.panel3.SuspendLayout();
+ this.panel6.SuspendLayout();
+ this.panel4.SuspendLayout();
+ this.panel5.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.buttonComputerAdd,
+ this.label1,
+ this.label5,
+ this.listBoxComputers,
+ this.radioBtnNo,
+ this.radioBtnYes});
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(344, 312);
+ this.panel1.TabIndex = 0;
+ this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
+ //
+ // buttonComputerAdd
+ //
+ this.buttonComputerAdd.Enabled = false;
+ this.buttonComputerAdd.Location = new System.Drawing.Point(192, 232);
+ this.buttonComputerAdd.Name = "buttonComputerAdd";
+ this.buttonComputerAdd.Size = new System.Drawing.Size(96, 24);
+ this.buttonComputerAdd.TabIndex = 3;
+ this.buttonComputerAdd.Text = "Add computer...";
+ this.buttonComputerAdd.Click += new System.EventHandler(this.buttonComputerAdd_Click);
+ //
+ // label1
+ //
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.label1.Location = new System.Drawing.Point(80, 8);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(200, 23);
+ this.label1.TabIndex = 5;
+ this.label1.Text = "Configure computers";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // label5
+ //
+ this.label5.Location = new System.Drawing.Point(24, 40);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(128, 23);
+ this.label5.TabIndex = 4;
+ this.label5.Text = "Available computers:";
+ this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // listBoxComputers
+ //
+ this.listBoxComputers.Location = new System.Drawing.Point(24, 64);
+ this.listBoxComputers.Name = "listBoxComputers";
+ this.listBoxComputers.Size = new System.Drawing.Size(128, 212);
+ this.listBoxComputers.TabIndex = 3;
+ this.listBoxComputers.SelectedIndexChanged += new System.EventHandler(this.listBoxComputers_SelectedIndexChanged);
+ //
+ // radioBtnNo
+ //
+ this.radioBtnNo.AutoCheck = false;
+ this.radioBtnNo.Location = new System.Drawing.Point(168, 168);
+ this.radioBtnNo.Name = "radioBtnNo";
+ this.radioBtnNo.Size = new System.Drawing.Size(152, 64);
+ this.radioBtnNo.TabIndex = 2;
+ this.radioBtnNo.Text = "No, I have to add more computers in order to deploy NDB Cluster. ";
+ this.radioBtnNo.Click += new System.EventHandler(this.radioBtnNo_Click);
+ //
+ // radioBtnYes
+ //
+ this.radioBtnYes.AutoCheck = false;
+ this.radioBtnYes.Location = new System.Drawing.Point(168, 72);
+ this.radioBtnYes.Name = "radioBtnYes";
+ this.radioBtnYes.Size = new System.Drawing.Size(152, 80);
+ this.radioBtnYes.TabIndex = 1;
+ this.radioBtnYes.Text = "Yes, all the computers that I need to deploy NDB Cluster exists in the list \"Avai" +
+ "lable computers\"";
+ this.radioBtnYes.Click += new System.EventHandler(this.radioBtnYes_Click);
+ //
+ // panel2
+ //
+ this.panel2.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.label12,
+ this.textOwner,
+ this.label11,
+ this.textDbName,
+ this.label8,
+ this.label7,
+ this.label6,
+ this.comboMGM,
+ this.comboAPI,
+ this.comboNDB,
+ this.label2});
+ this.panel2.Location = new System.Drawing.Point(0, 320);
+ this.panel2.Name = "panel2";
+ this.panel2.Size = new System.Drawing.Size(344, 312);
+ this.panel2.TabIndex = 1;
+ this.panel2.Validating += new System.ComponentModel.CancelEventHandler(this.panel2_Validating);
+ this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint);
+ //
+ // label12
+ //
+ this.label12.Location = new System.Drawing.Point(72, 216);
+ this.label12.Name = "label12";
+ this.label12.Size = new System.Drawing.Size(112, 24);
+ this.label12.TabIndex = 16;
+ this.label12.Text = "Database owner:";
+ this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // textOwner
+ //
+ this.textOwner.Location = new System.Drawing.Point(192, 216);
+ this.textOwner.Name = "textOwner";
+ this.textOwner.TabIndex = 5;
+ this.textOwner.Text = "";
+ this.textOwner.TextChanged += new System.EventHandler(this.textOwner_TextChanged);
+ //
+ // label11
+ //
+ this.label11.Location = new System.Drawing.Point(72, 184);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(112, 24);
+ this.label11.TabIndex = 14;
+ this.label11.Text = "Database name:";
+ this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ this.label11.Click += new System.EventHandler(this.label11_Click);
+ //
+ // textDbName
+ //
+ this.textDbName.Location = new System.Drawing.Point(192, 184);
+ this.textDbName.Name = "textDbName";
+ this.textDbName.TabIndex = 4;
+ this.textDbName.Text = "";
+
+ this.textDbName.TextChanged += new System.EventHandler(this.textDbName_TextChanged);
+ //
+ // label8
+ //
+ this.label8.Location = new System.Drawing.Point(16, 120);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(176, 24);
+ this.label8.TabIndex = 12;
+ this.label8.Text = "Number of management servers:";
+ this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label7
+ //
+ this.label7.Location = new System.Drawing.Point(16, 88);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(120, 24);
+ this.label7.TabIndex = 11;
+ this.label7.Text = "Number of API nodes:";
+ this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label6
+ //
+ this.label6.Location = new System.Drawing.Point(16, 56);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(144, 24);
+ this.label6.TabIndex = 10;
+ this.label6.Text = "Number of database nodes:";
+ this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // comboMGM
+ //
+ this.comboMGM.DisplayMember = "0";
+ this.comboMGM.Items.AddRange(new object[] {
+ "1"});
+ this.comboMGM.Location = new System.Drawing.Point(192, 120);
+ this.comboMGM.Name = "comboMGM";
+ this.comboMGM.Size = new System.Drawing.Size(104, 21);
+ this.comboMGM.TabIndex = 3;
+ this.comboMGM.Text = "comboBox3";
+ //
+ // comboAPI
+ //
+ this.comboAPI.DisplayMember = "0";
+ this.comboAPI.Items.AddRange(new object[] {
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10"});
+ this.comboAPI.Location = new System.Drawing.Point(192, 88);
+ this.comboAPI.Name = "comboAPI";
+ this.comboAPI.Size = new System.Drawing.Size(104, 21);
+ this.comboAPI.TabIndex = 2;
+ this.comboAPI.Text = "comboBox2";
+ //
+ // comboNDB
+ //
+ this.comboNDB.DisplayMember = "0";
+ this.comboNDB.Items.AddRange(new object[] {
+ "1",
+ "2",
+ "4",
+ "8"});
+ this.comboNDB.Location = new System.Drawing.Point(192, 56);
+ this.comboNDB.Name = "comboNDB";
+ this.comboNDB.Size = new System.Drawing.Size(104, 21);
+ this.comboNDB.TabIndex = 1;
+ this.comboNDB.Text = "comboBox1";
+ //
+ // label2
+ //
+ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.label2.Location = new System.Drawing.Point(80, 8);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(208, 23);
+ this.label2.TabIndex = 6;
+ this.label2.Text = "Setup NDB Cluster nodes";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // panel3
+ //
+ this.panel3.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.checkBoxLater,
+ this.label10,
+ this.label9,
+ this.label3,
+ this.btnTransferCompToNode,
+ this.btnTransferNodeToComp,
+ this.lvNode,
+ this.tvComputer});
+ this.panel3.Location = new System.Drawing.Point(360, 8);
+ this.panel3.Name = "panel3";
+ this.panel3.Size = new System.Drawing.Size(320, 312);
+ this.panel3.TabIndex = 2;
+ //
+ // checkBoxLater
+ //
+ this.checkBoxLater.Location = new System.Drawing.Point(40, 256);
+ this.checkBoxLater.Name = "checkBoxLater";
+ this.checkBoxLater.Size = new System.Drawing.Size(240, 16);
+ this.checkBoxLater.TabIndex = 9;
+ this.checkBoxLater.Text = "I will configure these nodes manually, later.";
+ //
+ // label10
+ //
+ this.label10.Location = new System.Drawing.Point(16, 40);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(104, 16);
+ this.label10.TabIndex = 8;
+ this.label10.Text = "NDB Cluster nodes:";
+ this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label9
+ //
+ this.label9.Location = new System.Drawing.Point(192, 40);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(100, 16);
+ this.label9.TabIndex = 7;
+ this.label9.Text = "Computers:";
+ this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
+ //
+ // label3
+ //
+ this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.label3.Location = new System.Drawing.Point(40, 8);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(280, 23);
+ this.label3.TabIndex = 6;
+ this.label3.Text = "Assign NDB nodes to computers";
+ this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // btnTransferCompToNode
+ //
+ this.btnTransferCompToNode.Location = new System.Drawing.Point(144, 160);
+ this.btnTransferCompToNode.Name = "btnTransferCompToNode";
+ this.btnTransferCompToNode.Size = new System.Drawing.Size(40, 24);
+ this.btnTransferCompToNode.TabIndex = 4;
+ this.btnTransferCompToNode.Text = "<---";
+ //
+ // btnTransferNodeToComp
+ //
+ this.btnTransferNodeToComp.Location = new System.Drawing.Point(144, 128);
+ this.btnTransferNodeToComp.Name = "btnTransferNodeToComp";
+ this.btnTransferNodeToComp.Size = new System.Drawing.Size(40, 24);
+ this.btnTransferNodeToComp.TabIndex = 3;
+ this.btnTransferNodeToComp.Text = "--->";
+ this.btnTransferNodeToComp.Click += new System.EventHandler(this.btnTransferNodeToComp_Click);
+ //
+ // lvNode
+ //
+ this.lvNode.HideSelection = false;
+ this.lvNode.Location = new System.Drawing.Point(16, 56);
+ this.lvNode.Name = "lvNode";
+ this.lvNode.Size = new System.Drawing.Size(112, 192);
+ this.lvNode.TabIndex = 2;
+ this.lvNode.View = System.Windows.Forms.View.List;
+ this.lvNode.SelectedIndexChanged += new System.EventHandler(this.lvNode_SelectedIndexChanged);
+ //
+ // tvComputer
+ //
+ this.tvComputer.HideSelection = false;
+ this.tvComputer.ImageList = this.imageListComp;
+ this.tvComputer.Location = new System.Drawing.Point(192, 56);
+ this.tvComputer.Name = "tvComputer";
+ this.tvComputer.Size = new System.Drawing.Size(120, 192);
+ this.tvComputer.TabIndex = 1;
+ this.tvComputer.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvComputer_MouseDown);
+ this.tvComputer.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvComputer_AfterSelect);
+ this.tvComputer.MouseLeave += new System.EventHandler(this.tvComputer_MouseLeave);
+ this.tvComputer.DragDrop += new System.Windows.Forms.DragEventHandler(this.tvComputer_DragDrop);
+ //
+ // imageListComp
+ //
+ this.imageListComp.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
+ this.imageListComp.ImageSize = new System.Drawing.Size(16, 16);
+ this.imageListComp.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListComp.ImageStream")));
+ this.imageListComp.TransparentColor = System.Drawing.Color.Transparent;
+ //
+ // panel6
+ //
+ this.panel6.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.radioStartNo,
+ this.radioStartYes,
+ this.label18});
+ this.panel6.Location = new System.Drawing.Point(344, 336);
+ this.panel6.Name = "panel6";
+ this.panel6.Size = new System.Drawing.Size(344, 312);
+ this.panel6.TabIndex = 3;
+ this.panel6.Paint += new System.Windows.Forms.PaintEventHandler(this.panel4_Paint);
+ //
+ // radioStartNo
+ //
+ this.radioStartNo.Location = new System.Drawing.Point(40, 144);
+ this.radioStartNo.Name = "radioStartNo";
+ this.radioStartNo.Size = new System.Drawing.Size(272, 48);
+ this.radioStartNo.TabIndex = 81;
+ this.radioStartNo.Text = "Manually start NDB Cluster. The Magician will exit and you must start NDB Cluster" +
+ " manually.";
+ this.radioStartNo.CheckedChanged += new System.EventHandler(this.radioStartNo_CheckedChanged);
+ //
+ // radioStartYes
+ //
+ this.radioStartYes.Location = new System.Drawing.Point(40, 40);
+ this.radioStartYes.Name = "radioStartYes";
+ this.radioStartYes.Size = new System.Drawing.Size(272, 88);
+ this.radioStartYes.TabIndex = 80;
+ this.radioStartYes.Text = "Start NDB Cluster now. The Magician will start NDB Cluster and exit. MAKE SURE YO" +
+ "U HAVE STARTED THE MGMTSRVR WITH THE CORRECT CONFIGURATION FILE!!!";
+ this.radioStartYes.CheckedChanged += new System.EventHandler(this.radioStartYes_CheckedChanged);
+ //
+ // label18
+ //
+ this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.label18.Location = new System.Drawing.Point(56, 8);
+ this.label18.Name = "label18";
+ this.label18.Size = new System.Drawing.Size(224, 24);
+ this.label18.TabIndex = 79;
+ this.label18.Text = "Start NDB Cluster and finish";
+ //
+ // btnCancel
+ //
+ this.btnCancel.Location = new System.Drawing.Point(8, 656);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.Size = new System.Drawing.Size(70, 23);
+ this.btnCancel.TabIndex = 10;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // btnback
+ //
+ this.btnback.Location = new System.Drawing.Point(96, 656);
+ this.btnback.Name = "btnback";
+ this.btnback.Size = new System.Drawing.Size(70, 23);
+ this.btnback.TabIndex = 11;
+ this.btnback.Text = "< Back";
+ this.btnback.Click += new System.EventHandler(this.btnback_Click);
+ //
+ // btnNext
+ //
+ this.btnNext.Location = new System.Drawing.Point(184, 656);
+ this.btnNext.Name = "btnNext";
+ this.btnNext.Size = new System.Drawing.Size(70, 23);
+ this.btnNext.TabIndex = 12;
+ this.btnNext.Text = "Next >";
+ this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
+ //
+ // btnFinish
+ //
+ this.btnFinish.Location = new System.Drawing.Point(272, 656);
+ this.btnFinish.Name = "btnFinish";
+ this.btnFinish.Size = new System.Drawing.Size(70, 23);
+ this.btnFinish.TabIndex = 13;
+ this.btnFinish.Text = "Finish";
+ this.btnFinish.Click += new System.EventHandler(this.btnFinish_Click);
+ //
+ // panel4
+ //
+ this.panel4.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.textEnv,
+ this.label13,
+ this.checkBoxReuse,
+ this.buttonSave,
+ this.labelTitle,
+ this.textComputer,
+ this.textCwd,
+ this.textArgs,
+ this.textOther,
+ this.textPath,
+ this.textDatabase,
+ this.textName,
+ this.labelCwd,
+ this.labelArgs,
+ this.labelOther,
+ this.labelPath,
+ this.label31,
+ this.label32,
+ this.label33});
+ this.panel4.Location = new System.Drawing.Point(672, 8);
+ this.panel4.Name = "panel4";
+ this.panel4.Size = new System.Drawing.Size(344, 312);
+ this.panel4.TabIndex = 62;
+ this.panel4.Paint += new System.Windows.Forms.PaintEventHandler(this.panel5_Paint);
+ //
+ // textEnv
+ //
+ this.textEnv.Location = new System.Drawing.Point(136, 136);
+ this.textEnv.Name = "textEnv";
+ this.textEnv.Size = new System.Drawing.Size(184, 20);
+ this.textEnv.TabIndex = 2;
+ this.textEnv.TabStop = false;
+ this.textEnv.Text = "";
+ //
+ // label13
+ //
+ this.label13.Location = new System.Drawing.Point(8, 136);
+ this.label13.Name = "label13";
+ this.label13.Size = new System.Drawing.Size(136, 24);
+ this.label13.TabIndex = 81;
+ this.label13.Text = "Environment variables:";
+ //
+ // checkBoxReuse
+ //
+ this.checkBoxReuse.Location = new System.Drawing.Point(88, 232);
+ this.checkBoxReuse.Name = "checkBoxReuse";
+ this.checkBoxReuse.Size = new System.Drawing.Size(240, 32);
+ this.checkBoxReuse.TabIndex = 5;
+ this.checkBoxReuse.TabStop = false;
+ this.checkBoxReuse.Text = "Use the same configuration for ALL NDB nodes?";
+ //
+ // buttonSave
+ //
+ this.buttonSave.Location = new System.Drawing.Point(184, 264);
+ this.buttonSave.Name = "buttonSave";
+ this.buttonSave.Size = new System.Drawing.Size(88, 24);
+ this.buttonSave.TabIndex = 6;
+ this.buttonSave.Text = "Save";
+ this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
+ //
+ // labelTitle
+ //
+ this.labelTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.labelTitle.Location = new System.Drawing.Point(80, 16);
+ this.labelTitle.Name = "labelTitle";
+ this.labelTitle.Size = new System.Drawing.Size(192, 23);
+ this.labelTitle.TabIndex = 79;
+ this.labelTitle.Text = "Mgmtsrvr configuration";
+ //
+ // textComputer
+ //
+ this.textComputer.Location = new System.Drawing.Point(136, 40);
+ this.textComputer.Name = "textComputer";
+ this.textComputer.ReadOnly = true;
+ this.textComputer.Size = new System.Drawing.Size(184, 20);
+ this.textComputer.TabIndex = 77;
+ this.textComputer.TabStop = false;
+ this.textComputer.Text = "";
+ //
+ // textCwd
+ //
+ this.textCwd.Location = new System.Drawing.Point(136, 208);
+ this.textCwd.Name = "textCwd";
+ this.textCwd.Size = new System.Drawing.Size(184, 20);
+ this.textCwd.TabIndex = 5;
+ this.textCwd.TabStop = false;
+ this.textCwd.Text = "";
+ //
+ // textArgs
+ //
+ this.textArgs.Location = new System.Drawing.Point(136, 184);
+ this.textArgs.Name = "textArgs";
+ this.textArgs.Size = new System.Drawing.Size(184, 20);
+ this.textArgs.TabIndex = 4;
+ this.textArgs.TabStop = false;
+ this.textArgs.Text = "";
+ //
+ // textOther
+ //
+ this.textOther.Location = new System.Drawing.Point(136, 160);
+ this.textOther.Name = "textOther";
+ this.textOther.Size = new System.Drawing.Size(184, 20);
+ this.textOther.TabIndex = 3;
+ this.textOther.TabStop = false;
+ this.textOther.Text = "";
+ //
+ // textPath
+ //
+ this.textPath.Location = new System.Drawing.Point(136, 112);
+ this.textPath.Name = "textPath";
+ this.textPath.Size = new System.Drawing.Size(184, 20);
+ this.textPath.TabIndex = 1;
+ this.textPath.TabStop = false;
+ this.textPath.Text = "";
+ this.textPath.TextChanged += new System.EventHandler(this.textPath_TextChanged);
+ //
+ // textDatabase
+ //
+ this.textDatabase.Location = new System.Drawing.Point(136, 88);
+ this.textDatabase.Name = "textDatabase";
+ this.textDatabase.ReadOnly = true;
+ this.textDatabase.Size = new System.Drawing.Size(184, 20);
+ this.textDatabase.TabIndex = 62;
+ this.textDatabase.TabStop = false;
+ this.textDatabase.Text = "";
+ //
+ // textName
+ //
+ this.textName.Location = new System.Drawing.Point(136, 64);
+ this.textName.Name = "textName";
+ this.textName.ReadOnly = true;
+ this.textName.Size = new System.Drawing.Size(184, 20);
+ this.textName.TabIndex = 60;
+ this.textName.TabStop = false;
+ this.textName.Text = "";
+ //
+ // labelCwd
+ //
+ this.labelCwd.Location = new System.Drawing.Point(8, 208);
+ this.labelCwd.Name = "labelCwd";
+ this.labelCwd.Size = new System.Drawing.Size(112, 24);
+ this.labelCwd.TabIndex = 72;
+ this.labelCwd.Text = "Current working dir.:";
+ //
+ // labelArgs
+ //
+ this.labelArgs.Location = new System.Drawing.Point(8, 184);
+ this.labelArgs.Name = "labelArgs";
+ this.labelArgs.Size = new System.Drawing.Size(128, 24);
+ this.labelArgs.TabIndex = 70;
+ this.labelArgs.Text = "Arguments to mgmtsrvr:";
+ //
+ // labelOther
+ //
+ this.labelOther.Location = new System.Drawing.Point(8, 160);
+ this.labelOther.Name = "labelOther";
+ this.labelOther.Size = new System.Drawing.Size(136, 24);
+ this.labelOther.TabIndex = 69;
+ this.labelOther.Text = "Mgmtsrvr port:";
+ //
+ // labelPath
+ //
+ this.labelPath.Location = new System.Drawing.Point(8, 112);
+ this.labelPath.Name = "labelPath";
+ this.labelPath.Size = new System.Drawing.Size(128, 24);
+ this.labelPath.TabIndex = 67;
+ this.labelPath.Text = "Path to mgmtsrvr binary:";
+ //
+ // label31
+ //
+ this.label31.Location = new System.Drawing.Point(8, 88);
+ this.label31.Name = "label31";
+ this.label31.Size = new System.Drawing.Size(88, 24);
+ this.label31.TabIndex = 65;
+ this.label31.Text = "Database:";
+ //
+ // label32
+ //
+ this.label32.Location = new System.Drawing.Point(8, 64);
+ this.label32.Name = "label32";
+ this.label32.Size = new System.Drawing.Size(88, 24);
+ this.label32.TabIndex = 63;
+ this.label32.Text = "Process name:";
+ //
+ // label33
+ //
+ this.label33.Location = new System.Drawing.Point(8, 40);
+ this.label33.Name = "label33";
+ this.label33.Size = new System.Drawing.Size(64, 24);
+ this.label33.TabIndex = 61;
+ this.label33.Text = "Computer:";
+ //
+ // panel5
+ //
+ this.panel5.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.radioNo,
+ this.radioYes,
+ this.label4});
+ this.panel5.Location = new System.Drawing.Point(672, 328);
+ this.panel5.Name = "panel5";
+ this.panel5.Size = new System.Drawing.Size(344, 312);
+ this.panel5.TabIndex = 63;
+ //
+ // radioNo
+ //
+ this.radioNo.Location = new System.Drawing.Point(72, 160);
+ this.radioNo.Name = "radioNo";
+ this.radioNo.Size = new System.Drawing.Size(240, 48);
+ this.radioNo.TabIndex = 1;
+ this.radioNo.Text = "I already have a configuration file that I want to use for this configuration.";
+ this.radioNo.CheckedChanged += new System.EventHandler(this.radioNo_CheckedChanged);
+ //
+ // radioYes
+ //
+ this.radioYes.Checked = true;
+ this.radioYes.Location = new System.Drawing.Point(72, 56);
+ this.radioYes.Name = "radioYes";
+ this.radioYes.Size = new System.Drawing.Size(240, 88);
+ this.radioYes.TabIndex = 0;
+ this.radioYes.TabStop = true;
+ this.radioYes.Text = "Generate a configuration file template (initconfig.txt) for the mgmtsrvr based on" +
+ " the specified configuration? Notepad will be started with a template that you m" +
+ "ust complete and save in the cwd of the mgmtsrvr.";
+ this.radioYes.CheckedChanged += new System.EventHandler(this.radioYes_CheckedChanged);
+ //
+ // label4
+ //
+ this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
+ this.label4.Location = new System.Drawing.Point(88, 8);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(192, 40);
+ this.label4.TabIndex = 79;
+ this.label4.Text = "Tying up the configuration";
+ this.label4.TextAlign = System.Drawing.ContentAlignment.TopCenter;
+ //
+ // PanelWizard
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(1030, 755);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.panel5,
+ this.panel4,
+ this.panel1,
+ this.btnFinish,
+ this.btnNext,
+ this.btnback,
+ this.btnCancel,
+ this.panel6,
+ this.panel3,
+ this.panel2});
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "PanelWizard";
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+ this.Text = "Create Database Magician";
+ this.Load += new System.EventHandler(this.MDXQueryBuilderWizard_Load);
+ this.Activated += new System.EventHandler(this.PanelWizard_Activated);
+ this.panel1.ResumeLayout(false);
+ this.panel2.ResumeLayout(false);
+ this.panel3.ResumeLayout(false);
+ this.panel6.ResumeLayout(false);
+ this.panel4.ResumeLayout(false);
+ this.panel5.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void MDXQueryBuilderWizard_Load(object sender, System.EventArgs e)
+ {
+
+ foreach(Control ct in this.Controls)
+ {
+ if(ct.GetType().Name=="Panel")
+ {
+ ct.Left=0;
+ ct.Top=0;
+ ct.Visible=false;
+ }
+
+ }
+ presentPanel=arrayPanel[0];
+ //--set the properties
+ setBtnPanProperty(getPosition(presentPanel));
+ //------
+ refreshLook();
+ }
+
+ //-set the buttons and panel
+ private void refreshLook()
+ {
+ if(cancelEnabled)
+ btnCancel.Enabled=true;
+ else
+ btnCancel.Enabled=false;
+
+ if(backEnabled)
+ btnback.Enabled=true;
+ else
+ btnback.Enabled=false;
+
+ if(nextEnabled)
+ btnNext.Enabled=true;
+ else
+ btnNext.Enabled=false;
+
+ if(finishEnabled)
+ btnFinish.Enabled=true;
+ else
+ btnFinish.Enabled=false;
+
+ if(presentPanel!=null)
+ {
+ presentPanel.Show();
+ presentPanel.BringToFront();
+ }
+ }
+ //--------
+ private int getPosition(Panel p)
+ {
+ int result=-1;
+ for(int i=0;i<arrayPanel.Length;i++)
+ {
+ if(arrayPanel[i]==p)
+ {
+ result=i;
+ break;
+ }
+ }
+ return result ;
+ }
+ //----
+
+ private void setBtnPanProperty(int presentPanelPosition )
+ {
+ int panelLength=arrayPanel.Length-1;
+ if(presentPanelPosition==0)
+ {
+ //first panel...no back ,no finish
+ cancelEnabled=true;
+ backEnabled=false;
+ nextEnabled=false;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=arrayPanel[presentPanelPosition+1];
+ backPanel=null;
+
+ }
+ else if(presentPanelPosition==1)
+ {
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=false;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=arrayPanel[presentPanelPosition+1];
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+
+ else if(presentPanelPosition==2)
+ {
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=false;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=arrayPanel[presentPanelPosition+1];
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+
+ else if(presentPanelPosition==3)
+ {
+ //last panel...no next,finish
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=true;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=arrayPanel[presentPanelPosition+1];
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+ else if(presentPanelPosition==4)
+ {
+ //last panel...no next,finish
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=true;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=presentPanel;
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+
+ else if(presentPanelPosition==5)
+ {
+ //last panel...no next,finish yes
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=false;
+ finishEnabled=false;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=null;
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+
+ else
+ {
+ //no finish,next and back
+ cancelEnabled=true;
+ backEnabled=true;
+ nextEnabled=false;
+ finishEnabled=true;
+ presentPanel=arrayPanel[presentPanelPosition];
+ nextPanel=null;
+ backPanel=arrayPanel[presentPanelPosition-1];
+ }
+ }
+
+ private void btnNext_Click(object sender, System.EventArgs e)
+ {
+
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel1))
+ {
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ refreshLook();
+ return;
+ }
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel2))
+ {
+ m_db.setName(textDbName.Text.ToString());
+ m_db.setOwner(textOwner.Text.ToString());
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ //presentPanel
+ setBtnPanProperty(getPosition(presentPanel));
+ prepareNodeAssignmentPanel();
+ refreshLook();
+
+ return;
+ }
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel3))
+ {
+ prepareNodeConfigurationPanel();
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ refreshLook();
+ return;
+ }
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel4))
+ {
+ nextEnabled=true;
+ finishEnabled=true;
+ backEnabled=true;
+ cancelEnabled=true;
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ refreshLook();
+ return;
+ }
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel5))
+ {
+ generateInitConfig();
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ refreshLook();
+ return;
+ }
+
+ if(arrayPanel[getPosition(presentPanel)].Equals(panel6))
+ {
+ // presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ refreshLook();
+ return;
+ }
+ /*else
+ {
+ presentPanel=arrayPanel[getPosition(presentPanel)+1];
+ setBtnPanProperty(getPosition(presentPanel));
+ updateListViews();
+ refreshLook();
+ }*/
+ }
+
+
+ private void btnback_Click(object sender, System.EventArgs e)
+ {
+ presentPanel=arrayPanel[getPosition(presentPanel)-1];
+ setBtnPanProperty(getPosition(presentPanel));
+ m_noOfConfiguredNodes=0;
+ m_noOfConfiguredNodes=0;
+ m_noOfConfiguredMgmt=0;
+ m_noOfConfiguredNdb=0;
+ m_noOfConfiguredApi=0;
+ m_bNdb=false;
+ m_bMgmt=false;
+ refreshLook();
+ }
+
+
+ private void btnCancel_Click(object sender, System.EventArgs e)
+ {
+ m_db.removeAllProcesses();
+ this.Dispose(true);
+ }
+
+
+
+
+ private void radioBtnYes_Click(object sender, System.EventArgs e)
+ {
+ if(radioBtnNo.Checked.Equals(false))
+ {
+ if(radioBtnYes.Checked.Equals(true))
+ radioBtnYes.Checked=false;
+ else
+ {
+ radioBtnYes.Checked=true;
+ this.btnNext.Enabled=true;
+ }
+
+ }
+ if(radioBtnNo.Checked.Equals(true))
+ {
+ radioBtnNo.Checked=false;
+ radioBtnYes.Checked=true;
+ buttonComputerAdd.Enabled=false;
+ this.btnNext.Enabled=true;
+ }
+
+ }
+
+ private void radioBtnNo_Click(object sender, System.EventArgs e)
+ {
+ if(radioBtnYes.Checked.Equals(false))
+ {
+ if(radioBtnNo.Checked.Equals(true))
+ {
+ radioBtnNo.Checked=false;
+ buttonComputerAdd.Enabled=false;
+ }
+ else
+ {
+ radioBtnNo.Checked=true;
+ buttonComputerAdd.Enabled=true;
+ this.btnNext.Enabled=false;
+ }
+
+ }
+ if(radioBtnYes.Checked.Equals(true))
+ {
+ radioBtnYes.Checked=false;
+ radioBtnNo.Checked=true;
+ buttonComputerAdd.Enabled=true;
+ this.btnNext.Enabled=false;
+ }
+ }
+
+ private void buttonComputerAdd_Click(object sender, System.EventArgs e)
+ {
+ if(getPosition(presentPanel)==0)
+ {
+ if(radioBtnNo.Checked.Equals(true))
+ {
+ ComputerAddDialog cad = new ComputerAddDialog(mgmt);
+ cad.ShowDialog();
+ }
+ }
+ }
+
+ private void PanelWizard_Activated(object sender, System.EventArgs e)
+ {
+ updateComputers();
+ }
+
+ private void updateComputers()
+ {
+ ArrayList list = mgmt.getComputerCollection();
+ this.listBoxComputers.BeginUpdate();
+ this.listBoxComputers.Items.Clear();
+ foreach(Computer c in list)
+ {
+ this.listBoxComputers.Items.Add(c.getName());
+ }
+ if(listBoxComputers.Items.Count > 0)
+ {
+ btnNext.Enabled=true;
+ }
+ this.listBoxComputers.EndUpdate();
+ this.listBoxComputers.Refresh();
+ }
+
+
+ private void tvComputer_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
+ {
+ tvComputer.SelectedNode.Expand();
+
+ }
+
+ private void tvComputer_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
+ {
+
+ }
+
+ private void tvComputer_MouseLeave(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void tvComputer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
+ {
+ TreeNode prevNode = tvComputer.SelectedNode;
+ if(prevNode!=null)
+ {
+ prevNode.BackColor=Color.White;
+ }
+ TreeNode node = tvComputer.GetNodeAt(e.X,e.Y);
+ if(node==null)
+ {
+ return;
+ }
+
+ tvComputer.SelectedNode=node;
+ tvComputer.SelectedNode.BackColor=Color.LightGray;
+
+ }
+
+ private void btnTransferNodeToComp_Click(object sender, System.EventArgs e)
+ {
+
+ if(tvComputer.SelectedNode==null)
+ return;
+ if(lvNode.SelectedItems.Equals(null))
+ return;
+ int itemCount=lvNode.SelectedItems.Count;
+ lvNode.BeginUpdate();
+ tvComputer.BeginUpdate();
+ for(int i=0;i < itemCount;i++)
+ {
+ tvComputer.SelectedNode.Nodes.Add(lvNode.SelectedItems[i].Text.ToString());
+ }
+
+ for(int i=0;i < itemCount;i++)
+ {
+ lvNode.Items.RemoveAt(lvNode.SelectedIndices[0]);
+
+ }
+ if(lvNode.Items.Count.Equals(0))
+ btnNext.Enabled=true;
+ else
+ btnNext.Enabled=false;
+ tvComputer.SelectedNode.Expand();
+ lvNode.EndUpdate();
+ tvComputer.EndUpdate();
+ }
+
+ private void lvNode_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ }
+
+ private void prepareNodeAssignmentPanel()
+ {
+ ArrayList computers = mgmt.getComputerCollection();
+ m_nNDB=Convert.ToInt32(comboNDB.SelectedItem.ToString());
+ m_nAPI=Convert.ToInt32(comboAPI.SelectedItem.ToString());
+ m_nMGM=Convert.ToInt32(comboMGM.SelectedItem.ToString());
+
+ lvNode.Items.Clear();
+ tvComputer.Nodes.Clear();
+ for (int i=1;i<=m_nMGM;i++)
+ lvNode.Items.Add("mgm."+i);
+
+ for (int i=m_nMGM+1;i<=(m_nNDB+m_nMGM);i++)
+ lvNode.Items.Add("ndb."+i);
+
+ for (int i=m_nMGM+m_nNDB+1;i<=(m_nNDB+m_nMGM+m_nAPI);i++)
+ lvNode.Items.Add("api."+i);
+
+ foreach(Computer c in computers)
+ {
+ if(c.getStatus() == Computer.Status.Connected)
+ tvComputer.Nodes.Add(c.getName());
+ }
+
+ }
+ private void prepareNodeConfigurationPanel()
+ {
+ Computer c;
+ for(int i=0;i<tvComputer.Nodes.Count;i++)
+ {
+ c=mgmt.getComputer(tvComputer.Nodes[i].Text.ToString());
+ for(int j=0; j < tvComputer.Nodes[i].Nodes.Count;j++)
+ {
+ m_db.addProcess(new Process(tvComputer.Nodes[i].Nodes[j].Text.ToString(),m_db.getOwner(),m_db.getName(),c));
+ c.addProcess(m_db.getProcessByName(tvComputer.Nodes[i].Nodes[j].Text.ToString()));
+ }
+ }
+ }
+
+ private void updateListViews()
+ {/*
+ lvConfig.Items.Clear();
+ ArrayList processes = m_db.getProcesses();
+ string [] processcols= new string[5];
+ foreach (Process process in processes)
+ {
+ processcols[0]=process.getName();
+ processcols[1]=process.getComputer().getName();
+ processcols[2]=process.getPath();
+ processcols[3]="";
+ processcols[4]="";
+
+ ListViewItem lvc= new ListViewItem(processcols);
+
+
+ lvConfig.Items.Add(lvc);
+ }
+ lvConfig.EndUpdate();
+ */
+ }
+
+ private void btnConfigure_Click(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void textDbName_TextChanged(object sender, System.EventArgs e)
+ {
+ if(textOwner.TextLength>0 && textDbName.TextLength > 0)
+ nextEnabled=true;
+ else
+ nextEnabled=false;
+
+ refreshLook();
+
+ }
+
+ private void checkBoxLater_CheckedChanged(object sender, System.EventArgs e)
+ {
+ if(checkBoxLater.Checked.Equals(true))
+ {
+ this.finishEnabled=true;
+ this.nextEnabled=false;
+ }
+ else
+ {
+ this.finishEnabled=false;
+ this.nextEnabled=true;
+ }
+ this.refreshLook();
+ }
+
+ private void btnFinish_Click(object sender, System.EventArgs e)
+ {
+ mgmt.AddDatabase(this.m_db);
+
+ if(radioStartYes.Checked==true)
+ startDatabase();
+ this.Dispose();
+ }
+
+ private void panel4_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+
+ // Point location= new Point(8,40);
+ // Size s= new Size(panel4.Size.Width-8,panel4.Size.Height-120);
+ // lvConfig.Location=location;
+ // lvConfig.Size=s;
+
+
+ }
+
+ private void configureMgmt()
+ {
+ //clear old
+ textOther.Text="";
+ textArgs.Text="";
+ textCwd.Text="";
+ textPath.Text="";
+
+ textPath.Clear();
+ textEnv.Clear();
+ textOther.Clear();
+ textCwd.Clear();
+ textArgs.Clear();
+
+ textPath.ClearUndo();
+ textEnv.ClearUndo();
+ textOther.ClearUndo();
+ textCwd.ClearUndo();
+ textArgs.ClearUndo();
+
+
+ textOther.Enabled=true;
+ textArgs.Enabled=true;
+ textCwd.Enabled=true;
+ textPath.Enabled=true;
+
+ textPath.TabStop=true;
+ textOther.TabStop=true;
+ textArgs.TabStop=true;
+ textCwd.TabStop=true;
+ textEnv.TabStop=true;
+
+ labelTitle.Text="Mgmtsrvr configuration";
+ labelPath.Text="Path to mgmtsrvr binary:";
+ labelArgs.Text="Arguments to mgmtsrvr:";
+ labelOther.Text="Mgmtsrvr port (-p X):";
+
+ //get new
+ String process="mgm." + Convert.ToString(m_noOfConfiguredMgmt+1);
+ Process mgmt=m_db.getProcessByName(process);
+ textComputer.Text=mgmt.getComputer().getName();
+ textName.Text=mgmt.getName().ToString();
+ textDatabase.Text=mgmt.getDatabase().ToString();
+ m_mgmHost=mgmt.getComputer().getName();
+ textPath.Focus();
+ }
+ private void configureApi()
+ {
+ checkBoxReuse.Text="Use the same configuration for ALL API nodes?";
+ if(m_nAPI > 1)
+ {
+ checkBoxReuse.Visible=true;
+ checkBoxReuse.Enabled=true;
+
+ }
+ else
+ {
+ checkBoxReuse.Enabled=false;
+ checkBoxReuse.Visible=true;
+ }
+
+ // clear previous and get a new api
+
+ textOther.Text="";
+ textArgs.Text="";
+ //textCwd.Text="";
+ //textPath.Text="";
+ //get new api
+ textOther.Enabled=false;
+ textArgs.Enabled=true;
+ labelTitle.Text="API node configuration";
+ labelPath.Text="Path to api binary:";
+ labelArgs.Text="Arguments to api:";
+ labelOther.Text="NDB_CONNECTSTRING";
+ String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1);
+ Process api=m_db.getProcessByName(process);
+ textComputer.Text=api.getComputer().getName();
+ textName.Text=api.getName().ToString();
+ textOther.Text="nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1) + ";host="+this.m_mgmHost + ":" + this.m_mgmPort;
+ textDatabase.Text=api.getDatabase().ToString();
+ textPath.Focus();
+ }
+
+ private void configureNdb()
+ {
+
+
+ checkBoxReuse.Text="Use the same configuration for ALL NDB nodes?";
+
+
+ if(this.m_nNDB > 1)
+ {
+ checkBoxReuse.Visible=true;
+ checkBoxReuse.Enabled=true;
+
+ }
+ else
+ {
+ checkBoxReuse.Enabled=false;
+ checkBoxReuse.Visible=true;
+ }
+
+
+
+ labelPath.Text="Path to ndb binary:";
+ labelArgs.Text="Arguments to ndb:";
+
+ // clear previous and get a new ndb
+
+ labelOther.Text="NDB_CONNECTSTRING";
+ textArgs.Text="-i";
+ textOther.Enabled=false;
+ textArgs.Enabled=false;
+
+ textPath.TabStop=true;
+ textEnv.TabStop=true;
+ textOther.TabStop=false;
+ textArgs.TabStop=false;
+ textCwd.TabStop=true;
+
+ //textCwd.Text="";
+ //textPath.Text="";
+ //get new
+
+ String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1);
+ textOther.Text="nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1) + ";host="+this.m_mgmHost + ":" + this.m_mgmPort;
+ Process ndb=m_db.getProcessByName(process);
+ textComputer.Text=ndb.getComputer().getName();
+ textName.Text=ndb.getName().ToString();
+ textDatabase.Text=ndb.getDatabase().ToString();
+ textPath.Focus();
+ }
+
+
+ public void saveMgm()
+ {
+ String process="mgm." + Convert.ToString(m_noOfConfiguredMgmt+1);
+ Process mgmt=m_db.getProcessByName(process);
+ mgmt.setOther(textOther.Text.ToString());
+ mgmt.setEnv(textEnv.Text.ToString());
+ m_mgmPort = textOther.Text.ToString();
+ try
+ {
+ m_db.setMgmtPort(Convert.ToInt32(m_mgmPort));
+ }
+ catch(Exception e)
+ {
+ MessageBox.Show("Port number must be numeric!!!", "Error",MessageBoxButtons.OK);
+ this.configureMgmt();
+ return;
+ }
+ mgmt.setPath(textPath.Text.ToString());
+ mgmt.setCwd(textCwd.Text.ToString());
+ mgmt.setProcessType("permanent");
+ mgmt.setArgs("-i initconfig.txt");
+ mgmt.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredMgmt+1)+";host="+m_mgmHost+":" + m_mgmPort);
+ this.m_noOfConfiguredMgmt++;
+ }
+
+ public void saveApi()
+ {
+ if(checkBoxReuse.Checked)
+ {
+ for(;m_noOfConfiguredApi<m_nAPI;m_noOfConfiguredApi++)
+ {
+ String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1);
+ Process api=m_db.getProcessByName(process);
+ textName.Text=process;
+ api.setPath(textPath.Text.ToString());
+ api.setArgs(textArgs.Text.ToString());
+ api.setCwd(textCwd.Text.ToString());
+ api.setEnv(textEnv.Text.ToString());
+ api.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nNDB+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort);
+ api.setProcessType("permanent");
+ }
+
+ }
+ else
+ {
+ String process="api." + Convert.ToString(m_noOfConfiguredApi+m_nMGM+m_nNDB+1);
+ Process api=m_db.getProcessByName(process);
+ api.setPath(textPath.Text.ToString());
+ api.setCwd(textCwd.Text.ToString());
+ api.setEnv(textEnv.Text.ToString());
+ api.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredApi+m_nNDB+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort);
+ api.setArgs(textArgs.Text.ToString());
+ api.setProcessType("permanent");
+ this.m_noOfConfiguredApi++;
+ }
+ }
+
+ public void saveNdb()
+ {
+
+ if(checkBoxReuse.Checked)
+ {
+ for(;m_noOfConfiguredNdb<m_nNDB;m_noOfConfiguredNdb++)
+ {
+ String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1);
+ Process ndb=m_db.getProcessByName(process);
+ ndb.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort);
+ ndb.setPath(textPath.Text.ToString());
+ ndb.setArgs(textArgs.Text.ToString());
+ ndb.setEnv(textEnv.Text.ToString());
+ ndb.setCwd(textCwd.Text.ToString());
+ ndb.setProcessType("permanent");
+ }
+ checkBoxReuse.Checked=false;
+ return;
+ }
+ else
+ {
+ String process="ndb." + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1);
+ Process ndb=m_db.getProcessByName(process);
+ ndb.setConnectString("nodeid=" + Convert.ToString(m_noOfConfiguredNdb+m_nMGM+1)+";host="+m_mgmHost+":" + m_mgmPort);
+ ndb.setPath(textPath.Text.ToString());
+ ndb.setCwd(textCwd.Text.ToString());
+ ndb.setArgs(textArgs.Text.ToString());
+ ndb.setEnv(textEnv.Text.ToString());
+ ndb.setProcessType("permanent");
+ m_noOfConfiguredNdb++;
+ }
+
+ }
+
+
+ private void panel5_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+ nextEnabled=false;
+ buttonSave.Enabled=true;
+ checkBoxReuse.Visible=false;
+ refreshLook();
+ configureMgmt();
+ }
+
+ private void buttonSave_Click(object sender, System.EventArgs e)
+ {
+ Process p = m_db.getProcessByName(textName.Text.ToString());
+
+ if(textOther.Text.ToString().Equals(""))
+ {
+ if(textName.Text.StartsWith("mgm"))
+ {
+ MessageBox.Show("You have to specify a port.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+ if(textName.Text.StartsWith("ndb"))
+ {
+ MessageBox.Show("You have to specify a filesystem path.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+
+ }
+
+ if(textPath.Text.ToString().Equals(""))
+ {
+ if(textName.Text.StartsWith("mgm"))
+ {
+ MessageBox.Show("You have to specify the path to the mgmtsrvr.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+ if(textName.Text.StartsWith("ndb"))
+ {
+ MessageBox.Show("You have to specify the path to ndb.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+ }
+
+ if(textArgs.Text.ToString().Equals(""))
+ {
+ if(textName.Text.StartsWith("mgm"))
+ {
+ MessageBox.Show("You have to specify the arguments to the mgmtsrvr.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+ }
+
+ if(textCwd.Text.ToString().Equals(""))
+ {
+ if(textCwd.Text.StartsWith("mgm"))
+ {
+ MessageBox.Show("You have to specify the current working directory for the mgmtsrvr.","Warning",MessageBoxButtons.OK);
+ return;
+ }
+ }
+
+
+ /*
+ * INPUT IS FINE AT THIS POINT
+ * Everything needed for respective process is ok
+ * */
+
+ if(textName.Text.StartsWith("mgm"))
+ {
+ //MessageBox.Show(textOther.Text.ToString());
+ saveMgm();
+
+ }
+
+ if(textName.Text.StartsWith("ndb"))
+ {
+ saveNdb();
+
+ }
+
+ if(textName.Text.StartsWith("api"))
+ {
+ saveApi();
+
+ }
+
+ if(m_noOfConfiguredMgmt < m_nMGM)
+ {
+ //load another Mgmt
+ labelTitle.Text="Mgmtsrvr configuration";
+ configureMgmt();
+ }
+ else
+ {
+ m_bMgmt=true;
+ }
+
+ if(m_bMgmt)
+ {
+ labelTitle.Text="NDB node configuration";
+ if(m_noOfConfiguredNdb < m_nNDB)
+ {
+ configureNdb();
+ }
+ else
+ m_bNdb=true;
+ }
+
+ if(m_bNdb && m_bMgmt)
+ {
+ labelTitle.Text="API node configuration";
+ if(m_noOfConfiguredApi < m_nAPI)
+ configureApi();
+ else
+ {
+ nextEnabled=true;
+ buttonSave.Enabled=false;
+ refreshLook();
+ }
+ }
+
+ }
+
+ private void listBoxComputers_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+ updateComputers();
+ }
+
+ private void radioYes_CheckedChanged(object sender, System.EventArgs e)
+ {
+ if(radioYes.Checked==true)
+ {
+ radioNo.Checked=false;
+ }
+ if(radioYes.Checked==false)
+ {
+ radioNo.Checked=true;
+ }
+
+ }
+
+ private void radioNo_CheckedChanged(object sender, System.EventArgs e)
+ {
+ if(radioNo.Checked==true)
+ {
+ radioYes.Checked=false;
+ }
+ if(radioNo.Checked==false)
+ {
+ radioYes.Checked=true;
+ }
+ }
+
+ private void radioStartYes_CheckedChanged(object sender, System.EventArgs e)
+ {
+
+ if(radioStartYes.Checked==true)
+ {
+ radioStartNo.Checked=false;
+ }
+ if(radioStartYes.Checked==false)
+ {
+ radioStartNo.Checked=true;
+ }
+ finishEnabled=true;
+ refreshLook();
+ }
+
+ private void radioStartNo_CheckedChanged(object sender, System.EventArgs e)
+ {
+ if(radioStartNo.Checked==true)
+ {
+ radioStartYes.Checked=false;
+ }
+ if(radioStartNo.Checked==false)
+ {
+ radioStartYes.Checked=true;
+ }
+ finishEnabled=true;
+ refreshLook();
+ }
+
+
+
+
+ public void startDatabase()
+ {
+ startDatabaseDlg x = new startDatabaseDlg(this.m_db);
+
+
+ x.ShowDialog();
+
+
+ }
+
+
+ public void generateInitConfig()
+ {
+ MessageBox.Show("Generate initconfig.txt");
+ }
+
+ private void label11_Click(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void textOwner_TextChanged(object sender, System.EventArgs e)
+ {
+ if(textDbName.TextLength > 0 && textOwner.TextLength > 0)
+ nextEnabled=true;
+ else
+ nextEnabled=false;
+
+ refreshLook();
+ }
+
+ private void panel2_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+ textOwner.Text=System.Environment.UserName;
+ this.Validate();
+ if(textDbName.TextLength > 0 && textOwner.TextLength>0)
+ {
+ nextEnabled=true;
+ }
+ else
+ {
+ nextEnabled=false;
+ }
+ refreshLook();
+ }
+
+ private void textPath_TextChanged(object sender, System.EventArgs e)
+ {
+ try
+ {
+
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+
+ private void panel2_Validating(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ if(textOwner.TextLength>0 && textDbName.TextLength > 0)
+ nextEnabled=true;
+ else
+ nextEnabled=false;
+ }
+
+
+
+
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs
new file mode 100644
index 00000000000..c1ee1b2fe9e
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/Process.cs
@@ -0,0 +1,144 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for Process.
+ /// </summary>
+ public class Process
+ {
+ public enum Status {Running, Stopped, Unknown}
+ private string m_id;
+ protected string m_name;
+ private Status m_status;
+ private Computer m_computer;
+ private string m_owner;
+ private string m_cwd;
+ private string m_type;
+ private string m_path;
+ private string m_other;
+ private string m_args;
+ private string m_env;
+ private string m_database;
+ private string m_connectString;
+ private bool m_defined;
+ public Process( string name,
+ string owner, string database,
+ Computer computer)
+ {
+ m_name=name;
+ m_owner=owner;
+ m_computer=computer;
+ m_status=Status.Unknown;
+ m_database=database;
+ m_defined=false;
+ m_path="";
+ m_cwd="";
+ m_args="";
+ m_other="";
+ }
+ public Process()
+ {
+
+ }
+ public Process(string id)
+ {
+ m_id=id;
+ }
+
+ public Process( string name,
+ string database,
+ Computer computer)
+ {
+ m_name=name;
+ m_computer=computer;
+ m_status=Status.Unknown;
+ m_database=database;
+ m_defined=false;
+ }
+
+ public Process( string name,
+ Computer computer)
+ {
+ m_name=name;
+ m_computer=computer;
+ m_status=Status.Unknown;
+ m_defined=false;
+ }
+
+
+ public string getStatusString()
+ {
+ if(m_status.Equals(Status.Running))
+ return "Running";
+ if(m_status.Equals(Status.Stopped))
+ return "Stopped";
+ return "Unknown";
+ }
+
+ public Computer getComputer() {return m_computer;}
+ public string getName() {return m_name;}
+ public string getDatabase() {return m_database;}
+ public string getOwner() {return m_owner;}
+ public string getId() {return m_id;}
+ public void setId(string id) {m_id=id;}
+
+ public void setCwd(string cwd) {m_cwd=cwd;}
+ public void setPath(string path) {m_path=path;}
+ public void setArgs(string args) {m_args=args;}
+ public void setOther(string other) {m_other=other;}
+ public void setEnv(string env) {m_env=env;}
+ public void setName(string name) {m_name=name;}
+ public void setOwner(string owner) {m_owner=owner;}
+ public void setDatabase(string db) {m_database=db;}
+ public void setComputer(Computer c) {m_computer=c;}
+
+
+ public string getCwd() {return m_cwd;}
+ public string getPath() {return m_path;}
+ public string getArgs() {return m_args;}
+ public string getOther() {return m_other;}
+ public string getEnv() {return m_env;}
+
+ public bool isDefined() {return m_defined;}
+ public void setDefined(bool defined)
+ {
+ m_defined=defined;
+ }
+
+ public Status getStatus()
+ {
+ return m_status;
+ }
+
+ public void setConnectString(string cs)
+ {
+ m_connectString=cs;
+ }
+
+ public string getConnectString()
+ {
+ return m_connectString;
+ }
+ public void setStatus(Status status)
+ {
+ m_status=status;
+ }
+
+
+ public void setProcessType(string type)
+ {
+ m_type=type;
+ }
+ public string getProcessType()
+ {
+ return m_type;
+ }
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs
new file mode 100644
index 00000000000..581b8383e7c
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/ProcessDefineDialog.cs
@@ -0,0 +1,435 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for ProcessDefineDialog.
+ /// </summary>
+ public class ProcessDefineDialog : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.ComboBox comboComputer;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.Label label8;
+ private System.Windows.Forms.Label label9;
+ private System.Windows.Forms.TextBox textProcessName;
+ private System.Windows.Forms.TextBox textProcessGroup;
+ private System.Windows.Forms.TextBox textProcessEnv;
+ private System.Windows.Forms.TextBox textProcessPath;
+ private System.Windows.Forms.TextBox textProcessArgs;
+ private System.Windows.Forms.TextBox textProcessCWD;
+ private System.Windows.Forms.TextBox textProcessOwner;
+ private System.Windows.Forms.ComboBox comboType;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Label label11;
+ private System.Windows.Forms.Label label12;
+ private System.Windows.Forms.Label label13;
+ private System.Windows.Forms.Label label15;
+ private System.Windows.Forms.Label label16;
+ private System.Windows.Forms.Label label14;
+ private System.Windows.Forms.Label label17;
+ private System.Windows.Forms.Label label18;
+ private System.Windows.Forms.Button btnAdd;
+ private System.Windows.Forms.Button btnCancel;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+ private ComputerMgmt c_mgmt;
+ private string m_selComputer;
+ public ProcessDefineDialog(ComputerMgmt mgmt, string computer)
+ {
+
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ m_selComputer =computer; //the selected computer in the TreeView
+ c_mgmt=mgmt;
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.comboComputer = new System.Windows.Forms.ComboBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label6 = new System.Windows.Forms.Label();
+ this.label7 = new System.Windows.Forms.Label();
+ this.label8 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.textProcessName = new System.Windows.Forms.TextBox();
+ this.textProcessGroup = new System.Windows.Forms.TextBox();
+ this.textProcessEnv = new System.Windows.Forms.TextBox();
+ this.textProcessPath = new System.Windows.Forms.TextBox();
+ this.textProcessArgs = new System.Windows.Forms.TextBox();
+ this.textProcessCWD = new System.Windows.Forms.TextBox();
+ this.textProcessOwner = new System.Windows.Forms.TextBox();
+ this.comboType = new System.Windows.Forms.ComboBox();
+ this.label10 = new System.Windows.Forms.Label();
+ this.label11 = new System.Windows.Forms.Label();
+ this.label12 = new System.Windows.Forms.Label();
+ this.label13 = new System.Windows.Forms.Label();
+ this.label15 = new System.Windows.Forms.Label();
+ this.label16 = new System.Windows.Forms.Label();
+ this.label14 = new System.Windows.Forms.Label();
+ this.label17 = new System.Windows.Forms.Label();
+ this.label18 = new System.Windows.Forms.Label();
+ this.btnAdd = new System.Windows.Forms.Button();
+ this.btnCancel = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // comboComputer
+ //
+ this.comboComputer.ItemHeight = 13;
+ this.comboComputer.Location = new System.Drawing.Point(152, 24);
+ this.comboComputer.Name = "comboComputer";
+ this.comboComputer.Size = new System.Drawing.Size(112, 21);
+ this.comboComputer.TabIndex = 0;
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(24, 24);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(64, 24);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "Computer:";
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(24, 48);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(88, 24);
+ this.label2.TabIndex = 2;
+ this.label2.Text = "Process name:";
+ //
+ // label3
+ //
+ this.label3.Location = new System.Drawing.Point(24, 72);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(88, 24);
+ this.label3.TabIndex = 3;
+ this.label3.Text = "Group:";
+ //
+ // label4
+ //
+ this.label4.Location = new System.Drawing.Point(24, 96);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(88, 24);
+ this.label4.TabIndex = 4;
+ this.label4.Text = "Env. variables:";
+ //
+ // label5
+ //
+ this.label5.Location = new System.Drawing.Point(24, 120);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(88, 24);
+ this.label5.TabIndex = 5;
+ this.label5.Text = "Path to binary:";
+ //
+ // label6
+ //
+ this.label6.Location = new System.Drawing.Point(24, 144);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(112, 24);
+ this.label6.TabIndex = 6;
+ this.label6.Text = "Arguments to binary:";
+ //
+ // label7
+ //
+ this.label7.Location = new System.Drawing.Point(24, 168);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(112, 24);
+ this.label7.TabIndex = 7;
+ this.label7.Text = "Type of process:";
+ //
+ // label8
+ //
+ this.label8.Location = new System.Drawing.Point(24, 192);
+ this.label8.Name = "label8";
+ this.label8.Size = new System.Drawing.Size(112, 24);
+ this.label8.TabIndex = 8;
+ this.label8.Text = "Current working dir.:";
+ //
+ // label9
+ //
+ this.label9.Location = new System.Drawing.Point(24, 216);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(112, 24);
+ this.label9.TabIndex = 9;
+ this.label9.Text = "Owner:";
+ //
+ // textProcessName
+ //
+ this.textProcessName.Location = new System.Drawing.Point(152, 48);
+ this.textProcessName.Name = "textProcessName";
+ this.textProcessName.Size = new System.Drawing.Size(112, 20);
+ this.textProcessName.TabIndex = 1;
+ this.textProcessName.Text = "";
+ //
+ // textProcessGroup
+ //
+ this.textProcessGroup.Location = new System.Drawing.Point(152, 72);
+ this.textProcessGroup.Name = "textProcessGroup";
+ this.textProcessGroup.Size = new System.Drawing.Size(112, 20);
+ this.textProcessGroup.TabIndex = 2;
+ this.textProcessGroup.Text = "";
+ //
+ // textProcessEnv
+ //
+ this.textProcessEnv.Location = new System.Drawing.Point(152, 96);
+ this.textProcessEnv.Name = "textProcessEnv";
+ this.textProcessEnv.Size = new System.Drawing.Size(112, 20);
+ this.textProcessEnv.TabIndex = 3;
+ this.textProcessEnv.Text = "";
+ //
+ // textProcessPath
+ //
+ this.textProcessPath.Location = new System.Drawing.Point(152, 120);
+ this.textProcessPath.Name = "textProcessPath";
+ this.textProcessPath.Size = new System.Drawing.Size(112, 20);
+ this.textProcessPath.TabIndex = 4;
+ this.textProcessPath.Text = "";
+ //
+ // textProcessArgs
+ //
+ this.textProcessArgs.Location = new System.Drawing.Point(152, 144);
+ this.textProcessArgs.Name = "textProcessArgs";
+ this.textProcessArgs.Size = new System.Drawing.Size(112, 20);
+ this.textProcessArgs.TabIndex = 5;
+ this.textProcessArgs.Text = "";
+ //
+ // textProcessCWD
+ //
+ this.textProcessCWD.Location = new System.Drawing.Point(152, 192);
+ this.textProcessCWD.Name = "textProcessCWD";
+ this.textProcessCWD.Size = new System.Drawing.Size(112, 20);
+ this.textProcessCWD.TabIndex = 7;
+ this.textProcessCWD.Text = "";
+ //
+ // textProcessOwner
+ //
+ this.textProcessOwner.Location = new System.Drawing.Point(152, 216);
+ this.textProcessOwner.Name = "textProcessOwner";
+ this.textProcessOwner.Size = new System.Drawing.Size(112, 20);
+ this.textProcessOwner.TabIndex = 8;
+ this.textProcessOwner.Text = "";
+ //
+ // comboType
+ //
+ this.comboType.ItemHeight = 13;
+ this.comboType.Items.AddRange(new object[] {
+ "Permanent",
+ "Interactive"});
+ this.comboType.Location = new System.Drawing.Point(152, 168);
+ this.comboType.Name = "comboType";
+ this.comboType.Size = new System.Drawing.Size(112, 21);
+ this.comboType.TabIndex = 6;
+ //
+ // label10
+ //
+ this.label10.Location = new System.Drawing.Point(272, 32);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(88, 16);
+ this.label10.TabIndex = 19;
+ this.label10.Text = "(Mandatory)";
+ //
+ // label11
+ //
+ this.label11.Location = new System.Drawing.Point(272, 56);
+ this.label11.Name = "label11";
+ this.label11.Size = new System.Drawing.Size(88, 16);
+ this.label11.TabIndex = 20;
+ this.label11.Text = "(Mandatory)";
+ //
+ // label12
+ //
+ this.label12.Location = new System.Drawing.Point(272, 80);
+ this.label12.Name = "label12";
+ this.label12.Size = new System.Drawing.Size(88, 16);
+ this.label12.TabIndex = 21;
+ this.label12.Text = "(Mandatory)";
+ //
+ // label13
+ //
+ this.label13.Location = new System.Drawing.Point(272, 127);
+ this.label13.Name = "label13";
+ this.label13.Size = new System.Drawing.Size(88, 16);
+ this.label13.TabIndex = 22;
+ this.label13.Text = "(Mandatory)";
+ //
+ // label15
+ //
+ this.label15.Location = new System.Drawing.Point(272, 176);
+ this.label15.Name = "label15";
+ this.label15.Size = new System.Drawing.Size(88, 16);
+ this.label15.TabIndex = 24;
+ this.label15.Text = "(Mandatory)";
+ //
+ // label16
+ //
+ this.label16.Location = new System.Drawing.Point(272, 200);
+ this.label16.Name = "label16";
+ this.label16.Size = new System.Drawing.Size(88, 16);
+ this.label16.TabIndex = 25;
+ this.label16.Text = "(Mandatory)";
+ //
+ // label14
+ //
+ this.label14.Location = new System.Drawing.Point(272, 224);
+ this.label14.Name = "label14";
+ this.label14.Size = new System.Drawing.Size(88, 16);
+ this.label14.TabIndex = 26;
+ this.label14.Text = "(Mandatory)";
+ //
+ // label17
+ //
+ this.label17.Location = new System.Drawing.Point(272, 104);
+ this.label17.Name = "label17";
+ this.label17.Size = new System.Drawing.Size(88, 16);
+ this.label17.TabIndex = 27;
+ this.label17.Text = "(Optional)";
+ //
+ // label18
+ //
+ this.label18.Location = new System.Drawing.Point(272, 152);
+ this.label18.Name = "label18";
+ this.label18.Size = new System.Drawing.Size(88, 16);
+ this.label18.TabIndex = 28;
+ this.label18.Text = "(Optional)";
+ //
+ // btnAdd
+ //
+ this.btnAdd.Location = new System.Drawing.Point(288, 248);
+ this.btnAdd.Name = "btnAdd";
+ this.btnAdd.TabIndex = 9;
+ this.btnAdd.Text = "Define...";
+ this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
+ //
+ // btnCancel
+ //
+ this.btnCancel.Location = new System.Drawing.Point(152, 248);
+ this.btnCancel.Name = "btnCancel";
+ this.btnCancel.TabIndex = 10;
+ this.btnCancel.Text = "Cancel";
+ this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
+ //
+ // ProcessDefineDialog
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(370, 279);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.btnCancel,
+ this.btnAdd,
+ this.label18,
+ this.label17,
+ this.label14,
+ this.label16,
+ this.label15,
+ this.label13,
+ this.label12,
+ this.label11,
+ this.label10,
+ this.comboType,
+ this.textProcessOwner,
+ this.textProcessCWD,
+ this.textProcessArgs,
+ this.textProcessPath,
+ this.textProcessEnv,
+ this.textProcessGroup,
+ this.textProcessName,
+ this.label9,
+ this.label8,
+ this.label7,
+ this.label6,
+ this.label5,
+ this.label4,
+ this.label3,
+ this.label2,
+ this.label1,
+ this.comboComputer});
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "ProcessDefineDialog";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "Define Process";
+ this.Load += new System.EventHandler(this.ProcessDefineDialog_Load);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void btnCancel_Click(object sender, System.EventArgs e)
+ {
+ this.Dispose();
+ this.Close();
+ }
+
+ private void btnAdd_Click(object sender, System.EventArgs e)
+ {
+ //TODO: ERROR CHECK
+
+ Computer c;
+ c=c_mgmt.getComputer(this.m_selComputer);
+
+ c.addProcess(new Process(this.textProcessName.Text.ToString(),
+ this.textProcessOwner.Text.ToString(),
+ this.textProcessGroup.Text.ToString(),
+ c));
+ this.Close();
+ this.Dispose();
+ }
+
+ private void ProcessDefineDialog_Load(object sender, System.EventArgs e)
+ {
+ comboType.SelectedIndex=0;
+ ArrayList list = c_mgmt.getComputerCollection();
+ int i=0, selIndex=0;
+ foreach(Computer computer in list)
+ {
+ this.comboComputer.Items.Add(computer.getName());
+ if(computer.getName().Equals(m_selComputer))
+ selIndex=i;
+ i++;
+ }
+ comboComputer.SelectedIndex=selIndex;
+ }
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs
new file mode 100644
index 00000000000..b3a2361bcb0
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/fileaccess/FileMgmt.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Text;
+using System.Collections.Specialized;
+using System.IO;
+using System.Windows.Forms;
+namespace NDB_CPC.fileaccess
+{
+ /// <summary>
+ /// Summary description for FileMgmt.
+ /// </summary>
+ public class FileMgmt
+ {
+ public FileMgmt()
+ {
+ }
+
+ public StringCollection importHostFile(string filename)
+ {
+ StringCollection sc = new StringCollection();
+ StreamReader SR = new StreamReader(filename);
+ string line ="";
+ line = SR.ReadLine();
+ while(!line.Equals(""))
+ {
+ sc.Add(line);
+ line = SR.ReadLine();
+ }
+ return sc;
+ }
+
+ public void exportHostFile(string filename, string content)
+ {
+ StreamWriter SW = new StreamWriter(filename,false);
+ SW.Write(content);
+ SW.WriteLine("");
+ SW.WriteLine("");
+ SW.Close();
+ }
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs
new file mode 100644
index 00000000000..b8ff2844af9
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/simpleparser/SimpleCPCParser.cs
@@ -0,0 +1,360 @@
+using System;
+using System.Collections;
+using System.IO;
+using System.Windows.Forms;
+using NDB_CPC;
+using NDB_CPC.socketcomm;
+
+namespace NDB_CPC.simpleparser
+{
+ /// <summary>
+ /// Summary description for SimpleCPCParser.
+ /// </summary>
+ public class SimpleCPCParser
+ {
+ public SimpleCPCParser()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ public static void parse(Process p, SocketComm comm)
+ {
+
+ string line=comm.readLine();//reader.ReadLine();
+ while(line.Equals(""))
+ {
+ line=comm.readLine();
+ }
+ if(line.Equals("define process"))
+ {
+ defineProcess(p, comm);
+ line="";
+ return;
+ }
+ if(line.Equals("start process"))
+ {
+ startProcess(p,comm);
+ line="";
+ return;
+ }
+ if(line.Equals("stop process"))
+ {
+ stopProcess(p,comm);
+ line="";
+ return;
+ }
+ if(line.Equals("undefine process"))
+ {
+ undefineProcess(p,comm);
+ line="";
+ return;
+ }
+
+ }
+
+ public static void parse(ArrayList processes, Computer c, SocketComm comm)
+ {
+
+ string line=comm.readLine();//reader.ReadLine();
+ while(line.Equals(""))
+ {
+ line=comm.readLine();
+ }
+
+ if(line.Equals("start processes"))
+ {
+ listProcesses(processes, c, comm);
+ line="";
+ return;
+ }
+
+ }
+
+ private static void defineProcess(Process p, SocketComm comm)
+ {
+ string line=comm.readLine();//reader.ReadLine();
+ while(!line.Equals(""))
+ {
+ if(line.StartsWith("status:"))
+ {
+ line=line.Remove(0,7);
+ line=line.Trim();
+ if(line.Equals("1"))
+ {
+ p.setDefined(true);
+ p.setStatus(Process.Status.Stopped);
+ }
+ else
+ p.setDefined(false);
+ }
+ if(line.StartsWith("id:"))
+ {
+ line=line.Remove(0,3);
+ line=line.Trim();
+ p.setId(line);
+ }
+ line=comm.readLine();
+ }
+ }
+
+
+ private static void startProcess(Process p, SocketComm comm)
+ {
+ string line=comm.readLine();//reader.ReadLine();
+ while(!line.Equals(""))
+ {
+ if(line.StartsWith("status:"))
+ {
+ line=line.Remove(0,7);
+ line=line.Trim();
+ if(line.Equals("1"))
+ p.setStatus(NDB_CPC.Process.Status.Running);
+ else
+ p.setStatus(NDB_CPC.Process.Status.Unknown);
+
+ }
+ if(line.StartsWith("id:"))
+ {
+ line=line.Remove(0,3);
+ line=line.Trim();
+ if(p.getId().Equals(line))
+ {
+ ;
+ }
+ else
+ {
+ //damn something is wrong
+ p.setStatus(NDB_CPC.Process.Status.Unknown);
+ }
+
+ }
+ line=comm.readLine();
+ }
+ }
+ private static void undefineProcess(Process p, SocketComm comm)
+ {
+ string line=comm.readLine();//reader.ReadLine();
+ while(!line.Equals(""))
+ {
+ if(line.StartsWith("status:"))
+ {
+
+ line=line.Remove(0,7);
+ line=line.Trim();
+ if(line.Equals("1"))
+ p.setDefined(false);
+ else
+ p.setDefined(true);
+
+ }
+ if(line.StartsWith("id:"))
+ {
+ line=line.Remove(0,3);
+ line=line.Trim();
+ }
+ line=comm.readLine();
+ }
+ }
+
+ private static void stopProcess(Process p, SocketComm comm)
+ {
+ string line=comm.readLine();//reader.ReadLine();
+ while(!line.Equals(""))
+ {
+ if(line.StartsWith("status:"))
+ {
+ line=line.Remove(0,7);
+ line=line.Trim();
+ if(line.Equals("1"))
+ p.setStatus(NDB_CPC.Process.Status.Stopped);
+ else
+ p.setStatus(NDB_CPC.Process.Status.Unknown);
+
+ }
+ if(line.StartsWith("id:"))
+ {
+ line=line.Remove(0,3);
+ line=line.Trim();
+ if(p.getId().Equals(line))
+ {
+ ;
+ }
+ else
+ {
+ //damn something is wrong
+ p.setStatus(NDB_CPC.Process.Status.Unknown);
+ }
+
+ }
+ line=comm.readLine();
+ }
+ }
+ private static void listProcesses(ArrayList processes, Computer c, SocketComm comm)
+ {
+ bool processExist = false;
+
+ string line=comm.readLine();//reader.ReadLine();
+ while(!line.Equals("end processes"))
+ {
+ if(line.Equals("process"))
+ {
+ line=comm.readLine();
+ Process p = new Process();
+
+ while(!line.Equals(""))
+ {
+ if(line.StartsWith("id:"))
+ {
+ string pid;
+ line=line.Remove(0,3);
+ pid=line.Trim();
+ /*check if process already exist*/
+ processExist=findProcess(processes,pid);
+ if(!processExist)
+ {
+ p.setId(pid);
+ }
+ }
+
+ if(line.StartsWith("name:"))
+ {
+
+ line=line.Remove(0,5);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setName(line);
+ }
+ }
+
+ if(line.StartsWith("path:"))
+ {
+
+ line=line.Remove(0,5);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setPath(line);
+ }
+ }
+
+ if(line.StartsWith("args:"))
+ {
+
+ line=line.Remove(0,5);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setArgs(line);
+ }
+ }
+
+ if(line.StartsWith("type:"))
+ {
+
+ line=line.Remove(0,5);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+
+ }
+ }
+
+ if(line.StartsWith("cwd:"))
+ {
+
+ line=line.Remove(0,4);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setCwd(line);
+ }
+ }
+
+ if(line.StartsWith("env:"))
+ {
+
+ line=line.Remove(0,4);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setEnv(line);
+ }
+ }
+
+ if(line.StartsWith("owner:"))
+ {
+
+ line=line.Remove(0,6);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setOwner(line);
+ }
+ }
+ if(line.StartsWith("group:"))
+ {
+
+ line=line.Remove(0,6);
+ line=line.Trim();
+ /*check if process already exist*/
+ if(!processExist)
+ {
+ p.setDatabase(line);
+ }
+ }
+
+ if(line.StartsWith("status:"))
+ {
+
+ line=line.Remove(0,7);
+ line=line.Trim();
+ /*check if process already exist*/
+ //if(!processExist)
+ //{
+ if(line.Equals("0"))
+ p.setStatus(Process.Status.Stopped);
+ if(line.Equals("1"))
+ p.setStatus(Process.Status.Running);
+ if(line.Equals("2"))
+ p.setStatus(Process.Status.Unknown);
+ //}
+ }
+
+
+ line=comm.readLine();
+ }
+ if(!processExist)
+ {
+ p.setComputer(c);
+ p.setDefined(true);
+ processes.Add(p);
+ }
+ processExist=false;
+ }
+ line=comm.readLine();
+
+ }
+ }
+
+ private static bool findProcess(ArrayList processes, string pid)
+ {
+ foreach (Process p in processes)
+ {
+ if(p.getId().Equals(pid))
+ return true;
+ }
+ return false;
+
+ }
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs
new file mode 100644
index 00000000000..2cef5d34f17
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/SocketComm.cs
@@ -0,0 +1,207 @@
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Windows.Forms;
+using System.Threading;
+using System.IO;
+
+namespace NDB_CPC.socketcomm
+{
+ /// <summary>
+ /// Summary description for SocketComm.
+ /// </summary>
+ public class SocketComm
+ {
+ private myTcpClient sender;
+ private StreamWriter writer;
+ private StreamReader reader;
+ private string m_host;
+ private int m_port;
+ private bool m_connected;
+ private bool m_connecting;
+ private Thread connectThread;
+ public SocketComm(string host, int port)
+ {
+
+ m_host=host;
+ m_port=port;
+ m_connected=false;
+ m_connecting=false;
+ }
+
+
+
+ public bool isConnected()
+ {
+ return m_connected;
+ }
+
+ public void doConnect()
+ {
+ if(!m_connecting && !m_connected)
+ {
+ connectThread= new Thread(new ThreadStart(connect));
+ connectThread.Start();
+ }
+
+ }
+
+ private void connect()
+ {
+ m_connecting=true;
+ while(true)
+ {
+ if(!m_connected)
+ {
+ try
+ {
+ // Establish the remote endpoint for the socket.
+ // The name of the
+ // remote device is "host.contoso.com".
+
+ // Create a TCP/IP socket.
+ sender = new myTcpClient();
+ // Connect the socket to the remote endpoint. Catch any errors.
+ try
+ {
+ /*
+ IPAddress ipAddress = Dns.Resolve(host).AddressList[0];
+ IPEndPoint ipLocalEndPoint = new IPEndPoint(ipAddress, 11000);
+*/
+
+
+ sender.Connect(m_host,m_port);;
+
+ writer = new StreamWriter(sender.GetStream(), Encoding.ASCII);
+ reader = new StreamReader(sender.GetStream(), Encoding.ASCII);
+ m_connected=true;
+ m_connecting=false;
+ // break;
+ Console.WriteLine("Socket connected to {0}",
+ sender.ToString());
+
+ }
+ catch (ArgumentNullException ane)
+ {
+ Console.WriteLine("ArgumentNullException : {0}",ane.ToString());
+ m_connected=false;
+ }
+ catch (SocketException se)
+ {
+ Console.WriteLine("SocketException : {0}",se.ToString());
+ m_connected=false;
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unexpected exception : {0}", e.ToString());
+ m_connected=false;
+ }
+
+ }
+
+ Thread.Sleep(200);
+ }
+ }
+
+ public bool disconnect()
+ {
+ try
+ {
+ this.m_connected=false;
+ this.m_connecting=false;
+ sender.GetUnderlyingSocket().Shutdown(SocketShutdown.Both);
+ sender.GetUnderlyingSocket().Close();
+ writer.Close();
+ reader.Close();
+ sender.Close();
+
+ }
+ catch (ArgumentNullException ane)
+ {
+ Console.WriteLine("ArgumentNullException : {0}",ane.ToString());
+ connectThread.Abort();
+ return false;
+ }
+ catch (SocketException se)
+ {
+ Console.WriteLine("SocketException : {0}",se.ToString());
+ connectThread.Abort();
+ return false;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unexpected exception : {0}", e.ToString());
+ connectThread.Abort();
+ return false;
+ }
+ connectThread.Abort();
+ return true;
+ }
+
+ public bool writeMessage(string message)
+ {
+ int attempts=0;
+ while (attempts < 10)
+ {
+ try
+ {
+ writer.WriteLine(message);
+ writer.Flush();
+ message="";
+ return true;
+ }
+ catch(IOException e)
+ {
+ this.disconnect();
+ this.doConnect();
+ Thread.Sleep(200);
+ attempts++;
+ }
+ catch(System.NullReferenceException)
+ {
+ this.disconnect();
+ this.doConnect();
+
+ Thread.Sleep(200);
+ attempts++;
+ }
+ }
+ return false;
+ }
+
+ public string readLine()
+ {
+ int attempts=0;
+ string line="";
+ while (attempts < 10){
+ try
+ {
+ line = reader.ReadLine();
+ if(line==null)
+ line="";
+ return line;
+ }
+ catch(IOException e)
+ {
+ this.disconnect();
+ this.doConnect();
+ Thread.Sleep(400);
+ attempts++;
+ }
+ catch(System.NullReferenceException)
+ {
+ this.disconnect();
+ this.doConnect();
+ Thread.Sleep(400);
+ attempts++;
+ }
+ }
+ return "";
+
+ }
+
+ }
+}
+
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs
new file mode 100644
index 00000000000..9c0d82a0b27
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/socketcomm/myTcpClient.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using System.IO;
+
+
+namespace NDB_CPC.socketcomm
+{
+ public class myTcpClient : TcpClient
+ {
+ private Socket s;
+ public myTcpClient(): base()
+ {
+ if(this.Active)
+ {
+ s = this.Client;
+ }
+ }
+ public Socket GetUnderlyingSocket()
+ {
+ return s;
+ }
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs
new file mode 100644
index 00000000000..cecfcaeb0f3
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/startDatabaseDlg.cs
@@ -0,0 +1,251 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using NDB_CPC.simpleparser;
+
+namespace NDB_CPC
+{
+ /// <summary>
+ /// Summary description for startDatabase.
+ /// </summary>
+ public class startDatabaseDlg : System.Windows.Forms.Form
+ {
+ private System.Windows.Forms.TextBox textAction;
+ private System.Windows.Forms.Label label1;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+ private System.Windows.Forms.ProgressBar progressBar;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Button buttonGo;
+ private Database m_db;
+ public startDatabaseDlg(Database db)
+ {
+
+ //
+ // Required for Windows Form Designer support
+ //
+ InitializeComponent();
+
+ //
+ // TODO: Add any constructor code after InitializeComponent call
+ //
+ m_db=db;
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ #region Windows Form Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.textAction = new System.Windows.Forms.TextBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.progressBar = new System.Windows.Forms.ProgressBar();
+ this.label2 = new System.Windows.Forms.Label();
+ this.buttonGo = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // textAction
+ //
+ this.textAction.Location = new System.Drawing.Point(104, 40);
+ this.textAction.Name = "textAction";
+ this.textAction.ReadOnly = true;
+ this.textAction.Size = new System.Drawing.Size(256, 20);
+ this.textAction.TabIndex = 0;
+ this.textAction.Text = "";
+ //
+ // label1
+ //
+ this.label1.Location = new System.Drawing.Point(8, 40);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(96, 16);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "Current activity:";
+ this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
+ // progressBar
+ //
+ this.progressBar.Location = new System.Drawing.Point(104, 88);
+ this.progressBar.Name = "progressBar";
+ this.progressBar.Size = new System.Drawing.Size(152, 16);
+ this.progressBar.TabIndex = 2;
+ //
+ // label2
+ //
+ this.label2.Location = new System.Drawing.Point(8, 88);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(96, 16);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Activity progress:";
+ this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // buttonGo
+ //
+ this.buttonGo.Location = new System.Drawing.Point(152, 136);
+ this.buttonGo.Name = "buttonGo";
+ this.buttonGo.Size = new System.Drawing.Size(96, 24);
+ this.buttonGo.TabIndex = 4;
+ this.buttonGo.Text = "Go!";
+ this.buttonGo.Click += new System.EventHandler(this.buttonGo_Click);
+ //
+ // startDatabaseDlg
+ //
+ this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+ this.ClientSize = new System.Drawing.Size(378, 167);
+ this.Controls.AddRange(new System.Windows.Forms.Control[] {
+ this.buttonGo,
+ this.label2,
+ this.progressBar,
+ this.label1,
+ this.textAction});
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "startDatabaseDlg";
+ this.Text = "Starting database";
+ this.Load += new System.EventHandler(this.startDatabase_Load);
+ this.Paint += new System.Windows.Forms.PaintEventHandler(this.startDatabase_Paint);
+ this.ResumeLayout(false);
+
+ }
+ #endregion
+
+ private void startDatabase_Load(object sender, System.EventArgs e)
+ {
+
+ }
+
+ private void startDatabase_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
+ {
+
+
+
+ }
+ private void defineProcesses()
+ {
+ ArrayList processes = m_db.getProcesses();
+ progressBar.Maximum = processes.Count;
+ progressBar.Minimum = 0;
+
+ int retry=0;
+ //sc.connect("130.100.232.7");
+ foreach (Process p in processes)
+ {
+ Computer comp;
+ retry=0;
+ //if(p.getName().StartsWith("ndb") || p.getName().StartsWith("mgm"))
+ //{
+ textAction.Text="Defining process " + p.getName();
+ textAction.Refresh();
+ comp=p.getComputer();
+ while(retry<10)
+ {
+ if(!comp.isConnected())
+ {
+ comp.connectToCpcd();
+
+ }
+ else
+ {
+ if(comp.defineProcess(p)<0)
+ {
+ ;
+ }
+ else
+ break;
+ }
+ if(retry==9)
+ {
+ if(MessageBox.Show(this,"Failed to define process. Try again?","Warning!!!",MessageBoxButtons.YesNo)==DialogResult.Yes)
+ retry=0;
+ }
+ retry++;
+ //comp.undefineProcess(p);
+ }
+ //}
+ progressBar.PerformStep();
+ }
+ }
+
+ private void startProcesses()
+ {
+
+ ArrayList processes = m_db.getProcesses();
+ progressBar.Maximum = processes.Count;
+ progressBar.Minimum = 0;
+ string start = "start process \n";
+
+ int retry=0;
+ //sc.connect("130.100.232.7");
+ foreach (Process p in processes)
+ {
+ Computer comp;
+ if((p.getName().StartsWith("ndb")) || (p.getName().StartsWith("mgm")))
+ {
+ textAction.Text="Starting process " + p.getName();
+ textAction.Refresh();
+ start = start + "id:" + p.getId() + "\n\n";
+ comp=p.getComputer();
+ while(retry<10)
+ {
+ if(!comp.isConnected())
+ {
+ comp.connectToCpcd();
+ }
+ else
+ {
+ if(comp.startProcess(p)<0)
+ {
+ ;
+ }
+ else
+ break;
+ }
+ if(retry==9)
+ {
+ if(MessageBox.Show(this,"Failed to start process. Retry again?","Warning!!!",MessageBoxButtons.YesNo)==DialogResult.Yes)
+ retry=0;
+ }
+
+ retry++;
+ }
+ }
+ progressBar.PerformStep();
+
+ }
+
+ }
+
+ private void buttonGo_Click(object sender, System.EventArgs e)
+ {
+ buttonGo.Enabled=false;
+ progressBar.Step=1;
+ defineProcesses();
+ progressBar.Value=0;
+ startProcesses();
+
+ }
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs
new file mode 100644
index 00000000000..a7966947e1f
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/csharp/telnetclient/telnetClient.cs
@@ -0,0 +1,408 @@
+using System;
+using System.Drawing;
+using System.Collections;
+using System.ComponentModel;
+using System.Windows.Forms;
+using System.Data;
+using System.Net;
+using System.Net.Sockets;
+using System.Text;
+using System.IO;
+using System.Threading ;
+
+namespace NDB_CPC.telnetclient
+{
+ /// <summary>
+ /// Summary description for telnetClient.
+ /// </summary>
+ public class telnetClient
+ {
+ Char IAC = Convert.ToChar(255);
+ Char DO = Convert.ToChar(253);
+ Char DONT = Convert.ToChar(254);
+ Char WILL = Convert.ToChar(251);
+ Char WONT = Convert.ToChar(252);
+ Char SB = Convert.ToChar(250);
+ Char SE = Convert.ToChar(240);
+ const Char IS = '0';
+ const Char SEND = '1';
+ const Char INFO = '2';
+ const Char VAR = '0';
+ const Char VALUE = '1';
+ const Char ESC = '2';
+ const Char USERVAR = '3';
+ string m_strResp;
+
+ private ArrayList m_ListOptions = new ArrayList();
+ private IPEndPoint iep ;
+ private AsyncCallback callbackProc ;
+ private string address ;
+ private int port ;
+ private Socket s ;
+ private TextBox textBox1;
+ Byte[] m_byBuff = new Byte[32767];
+
+
+ public telnetClient(string ip, int p, TextBox tb)
+ {
+
+ address = ip;
+ port = p;
+ textBox1=tb;
+ IPHostEntry IPHost = Dns.Resolve(address);
+ string []aliases = IPHost.Aliases;
+ IPAddress[] addr = IPHost.AddressList;
+
+ try
+ {
+ // Create New Socket
+ s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ // Create New EndPoint
+ iep = new IPEndPoint(addr[0],port);
+ // This is a non blocking IO
+ s.Blocking = false ;
+ // Assign Callback function to read from Asyncronous Socket
+ callbackProc = new AsyncCallback(ConnectCallback);
+ // Begin Asyncronous Connection
+ s.BeginConnect(iep , callbackProc, s ) ;
+
+ }
+ catch(Exception eeeee )
+ {
+ MessageBox.Show(eeeee.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop );
+ Application.Exit();
+ }
+ }
+
+ public void ConnectCallback( IAsyncResult ar )
+ {
+ try
+ {
+ // Get The connection socket from the callback
+ Socket sock1 = (Socket)ar.AsyncState;
+ if ( sock1.Connected )
+ {
+ // Define a new Callback to read the data
+ AsyncCallback recieveData = new AsyncCallback( OnRecievedData );
+ // Begin reading data asyncronously
+ sock1.BeginReceive( m_byBuff, 0, m_byBuff.Length, SocketFlags.None, recieveData , sock1 );
+ }
+ }
+ catch( Exception ex )
+ {
+ MessageBox.Show(ex.Message, "Setup Recieve callbackProc failed!" );
+ }
+ }
+
+
+ public void OnRecievedData( IAsyncResult ar )
+ {
+ // Get The connection socket from the callback
+ Socket sock = (Socket)ar.AsyncState;
+ // Get The data , if any
+ int nBytesRec = sock.EndReceive( ar );
+ if( nBytesRec > 0 )
+ {
+ string sRecieved = Encoding.ASCII.GetString( m_byBuff, 0, nBytesRec );
+ string m_strLine="";
+ for ( int i=0; i < nBytesRec;i++)
+ {
+ Char ch = Convert.ToChar(m_byBuff[i]);
+ switch( ch )
+ {
+ case '\r':
+ m_strLine += Convert.ToString("\r\n");
+ break;
+ case '\n':
+ break;
+ default:
+ m_strLine += Convert.ToString(ch);
+ break;
+ }
+ }
+ try
+ {
+ int strLinelen = m_strLine.Length ;
+ if ( strLinelen == 0 )
+ {
+ m_strLine = Convert.ToString("\r\n");
+ }
+
+ Byte[] mToProcess = new Byte[strLinelen];
+ for ( int i=0; i < strLinelen ; i++)
+ mToProcess[i] = Convert.ToByte(m_strLine[i]);
+ // Process the incoming data
+ string mOutText = ProcessOptions(mToProcess);
+ if ( mOutText != "" )
+ textBox1.AppendText(mOutText);
+
+ // Respond to any incoming commands
+ RespondToOptions();
+ }
+ catch( Exception ex )
+ {
+ Object x = this ;
+ MessageBox.Show(ex.Message , "Information!" );
+ }
+ }
+ else
+ {
+ // If no data was recieved then the connection is probably dead
+ Console.WriteLine( "Disconnected", sock.RemoteEndPoint );
+ sock.Shutdown( SocketShutdown.Both );
+ sock.Close();
+ Application.Exit();
+ }
+ }
+
+ private string ProcessOptions(byte[] m_strLineToProcess)
+ {
+ string m_DISPLAYTEXT ="";
+ string m_strTemp ="" ;
+ string m_strOption ="";
+ string m_strNormalText ="";
+ bool bScanDone =false;
+ int ndx =0;
+ int ldx =0;
+ char ch ;
+ try
+ {
+ for ( int i=0; i < m_strLineToProcess.Length ; i++)
+ {
+ Char ss = Convert.ToChar(m_strLineToProcess[i]);
+ m_strTemp = m_strTemp + Convert.ToString(ss);
+ }
+
+ while(bScanDone != true )
+ {
+ int lensmk = m_strTemp.Length;
+ ndx = m_strTemp.IndexOf(Convert.ToString(IAC));
+ if ( ndx > lensmk )
+ ndx = m_strTemp.Length;
+
+ if(ndx != -1)
+ {
+ m_DISPLAYTEXT+= m_strTemp.Substring(0,ndx);
+ ch = m_strTemp[ndx + 1];
+ if ( ch == DO || ch == DONT || ch == WILL || ch == WONT )
+ {
+ m_strOption = m_strTemp.Substring(ndx, 3);
+ string txt = m_strTemp.Substring(ndx + 3);
+ m_DISPLAYTEXT+= m_strTemp.Substring(0,ndx);
+ m_ListOptions.Add(m_strOption);
+ m_strTemp = txt ;
+ }
+ else
+ if ( ch == IAC)
+ {
+ m_DISPLAYTEXT= m_strTemp.Substring(0,ndx);
+ m_strTemp = m_strTemp.Substring(ndx + 1);
+ }
+ else
+ if ( ch == SB )
+ {
+ m_DISPLAYTEXT= m_strTemp.Substring(0,ndx);
+ ldx = m_strTemp.IndexOf(Convert.ToString(SE));
+ m_strOption = m_strTemp.Substring(ndx, ldx);
+ m_ListOptions.Add(m_strOption);
+ m_strTemp = m_strTemp.Substring(ldx);
+ }
+ }
+ else
+ {
+ m_DISPLAYTEXT = m_DISPLAYTEXT + m_strTemp;
+ bScanDone = true ;
+ }
+ }
+ m_strNormalText = m_DISPLAYTEXT;
+ }
+ catch(Exception eP)
+ {
+ MessageBox.Show(eP.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop );
+ Application.Exit();
+ }
+ return m_strNormalText ;
+ }
+
+ void DispatchMessage(string strText)
+ {
+ try
+ {
+ Byte[] smk = new Byte[strText.Length];
+ for ( int i=0; i < strText.Length ; i++)
+ {
+ Byte ss = Convert.ToByte(strText[i]);
+ smk[i] = ss ;
+ }
+
+ IAsyncResult ar2 = s.BeginSend(smk , 0 , smk.Length , SocketFlags.None , callbackProc , s );
+ s.EndSend(ar2);
+ }
+ catch(Exception ers)
+ {
+ MessageBox.Show("ERROR IN RESPOND OPTIONS");
+ }
+ }
+
+ void RespondToOptions()
+ {
+ try
+ {
+ string strOption;
+ for ( int i=0; i < m_ListOptions.Count; i++)
+ {
+ strOption = (string)m_ListOptions[i];
+ ArrangeReply(strOption);
+ }
+ DispatchMessage(m_strResp);
+ m_strResp ="";
+ m_ListOptions.Clear();
+ }
+ catch(Exception ers)
+ {
+ MessageBox.Show("ERROR IN RESPOND OPTIONS");
+ }
+ }
+ void ArrangeReply(string strOption)
+ {
+ try
+ {
+
+ Char Verb;
+ Char Option;
+ Char Modifier;
+ Char ch;
+ bool bDefined = false;
+
+ if(strOption.Length < 3) return;
+
+ Verb = strOption[1];
+ Option = strOption[2];
+
+ if ( Option == 1 || Option == 3 )
+ {
+ // case 1: // Echo
+ // case 3: // Suppress Go-Ahead
+ bDefined = true;
+ // break;
+ }
+
+ m_strResp += IAC;
+
+ if(bDefined == true )
+ {
+ if ( Verb == DO )
+ {
+ // case DO:
+ ch = WILL;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == DONT )
+ {
+ ch = WONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == WILL )
+ {
+ ch = DO;
+ m_strResp += ch;
+ m_strResp += Option;
+ //break;
+ }
+ if ( Verb == WONT)
+ {
+ ch = DONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == SB)
+ {
+ Modifier = strOption[3];
+ if(Modifier == SEND)
+ {
+ ch = SB;
+ m_strResp += ch;
+ m_strResp += Option;
+ m_strResp += IS;
+ m_strResp += IAC;
+ m_strResp += SE;
+ }
+ // break;
+ }
+ }
+ else
+ {
+ // switch(Verb)
+ // {
+ if ( Verb == DO )
+ {
+ ch = WONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == DONT)
+ {
+ ch = WONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == WILL)
+ {
+ ch = DONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ if ( Verb == WONT)
+ {
+ ch = DONT;
+ m_strResp += ch;
+ m_strResp += Option;
+ // break;
+ }
+ }
+ }
+ catch(Exception eeeee )
+ {
+ MessageBox.Show(eeeee.Message , "Application Error!!!" , MessageBoxButtons.OK , MessageBoxIcon.Stop );
+ Application.Exit();
+ }
+
+ }
+
+ private void textBox1_KeyPress_1(object sender, System.Windows.Forms.KeyPressEventArgs e)
+ {
+ if ( e.KeyChar == 13 )
+ {
+ DispatchMessage("\r\n");
+ }
+ else
+ if ( e.KeyChar == 8 )
+ {
+ try
+ {
+// string mtmp = textBox1.Text.Substring(0,textBox1.Text.Length-1);
+// textBox1.Text = "" ;
+ }
+ catch(Exception ebs)
+ {
+ MessageBox.Show("ERROR IN BACKSPACE");
+ }
+ }
+ else
+ {
+ string str = e.KeyChar.ToString();
+ DispatchMessage(str);
+ }
+ }
+
+
+ }
+}
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Computer.cls b/storage/ndb/src/cw/cpcc-win32/vb6/Computer.cls
new file mode 100644
index 00000000000..5b42dfeadb6
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Computer.cls
@@ -0,0 +1,20 @@
+VERSION 1.0 CLASS
+BEGIN
+ MultiUse = -1 'True
+ Persistable = 0 'NotPersistable
+ DataBindingBehavior = 0 'vbNone
+ DataSourceBehavior = 0 'vbNone
+ MTSTransactionMode = 0 'NotAnMTSObject
+END
+Attribute VB_Name = "Computer"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = True
+Attribute VB_PredeclaredId = False
+Attribute VB_Exposed = False
+Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
+Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
+Public m_ip As String
+Public m_name As String
+Public m_status As String
+Public m_processes As Collection
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Database.cls b/storage/ndb/src/cw/cpcc-win32/vb6/Database.cls
new file mode 100644
index 00000000000..dfb1195d910
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Database.cls
@@ -0,0 +1,18 @@
+VERSION 1.0 CLASS
+BEGIN
+ MultiUse = -1 'True
+ Persistable = 0 'NotPersistable
+ DataBindingBehavior = 0 'vbNone
+ DataSourceBehavior = 0 'vbNone
+ MTSTransactionMode = 0 'NotAnMTSObject
+END
+Attribute VB_Name = "Database_"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = True
+Attribute VB_PredeclaredId = False
+Attribute VB_Exposed = False
+Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
+Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
+Public m_name As String
+Public m_processes As Collection
+Public m_status As String
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 110.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 110.ico
new file mode 100644
index 00000000000..34b85992394
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 110.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 231.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 231.ico
new file mode 100644
index 00000000000..fe30ff5d1e6
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 231.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 237.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 237.ico
new file mode 100644
index 00000000000..af0a1294f9e
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 237.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 241.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 241.ico
new file mode 100644
index 00000000000..e8caf6e9a73
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 241.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 242.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 242.ico
new file mode 100644
index 00000000000..2deff5472bc
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 242.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 270.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 270.ico
new file mode 100644
index 00000000000..9cab239de23
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 270.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 271.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 271.ico
new file mode 100644
index 00000000000..f05c95f74fe
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 271.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 273.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 273.ico
new file mode 100644
index 00000000000..800606eda0c
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 273.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 31.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 31.ico
new file mode 100644
index 00000000000..a2404977771
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 31.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 337.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 337.ico
new file mode 100644
index 00000000000..9dadb12cfbe
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 337.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 338.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 338.ico
new file mode 100644
index 00000000000..a13c80c81b4
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 338.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Icon 339.ico b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 339.ico
new file mode 100644
index 00000000000..5eb4c06815d
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Icon 339.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/MSSCCPRJ.SCC b/storage/ndb/src/cw/cpcc-win32/vb6/MSSCCPRJ.SCC
new file mode 100644
index 00000000000..3100640f8bd
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/MSSCCPRJ.SCC
@@ -0,0 +1,5 @@
+[SCC]
+SCC=This is a source code control file
+[NdbCPC.vbp]
+SCC_Project_Name=this project is not under source code control
+SCC_Aux_Path=<This is an empty string for the mssccprj.scc file>
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Module1.bas b/storage/ndb/src/cw/cpcc-win32/vb6/Module1.bas
new file mode 100644
index 00000000000..ae8ed444a41
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Module1.bas
@@ -0,0 +1,233 @@
+Attribute VB_Name = "Module1"
+Option Explicit
+Public fMainForm As frmMain
+Public g_computers As New Collection
+Public g_databases As New Collection
+
+Sub Main()
+ If False Then
+ Dim fLogin As New frmLogin
+ fLogin.Show vbModal
+ If Not fLogin.OK Then
+ 'Login Failed so exit app
+ End
+ End If
+ Unload fLogin
+
+ frmSplash.Show
+ frmSplash.Refresh
+ End If
+
+ init
+
+ Set fMainForm = New frmMain
+ Load fMainForm
+ Unload frmSplash
+
+ fMainForm.Show
+End Sub
+
+Private Sub init()
+ Dim c As Computer
+ Dim p As Process
+
+ ' ---
+ ' One node configuration
+ '
+ Set c = New Computer
+ With c
+ .m_ip = "130.100.232.31"
+ .m_name = "ndb-client31"
+ .m_status = "Connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set p = New Process
+ With p
+ .m_id = "1"
+ .m_name = "mgm-1"
+ .m_database = "elathal"
+ .m_status = "Running"
+ .m_owner = "elathal"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set p = New Process
+ With p
+ .m_id = "2"
+ .m_name = "ndb-2"
+ .m_database = "elathal"
+ .m_status = "Running"
+ .m_owner = "elathal"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set p = New Process
+ With p
+ .m_id = "3"
+ .m_name = "api-3"
+ .m_database = "elathal"
+ .m_status = "Running"
+ .m_owner = "elathal"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ ' ---
+ ' Two node configuration
+ '
+ Set p = New Process
+ With p
+ .m_id = "4"
+ .m_name = "mgm-1"
+ .m_database = "ejonore-2-node"
+ .m_status = "Running"
+ .m_owner = "ejonore"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set c = New Computer
+ With c
+ .m_ip = "10.0.1.1"
+ .m_name = "cluster-1"
+ .m_status = "Connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set p = New Process
+ With p
+ .m_id = "1"
+ .m_name = "ndb-2"
+ .m_database = "ejonore-2-node"
+ .m_status = "Running"
+ .m_owner = "ejonore"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set c = New Computer
+ With c
+ .m_ip = "10.0.2.1"
+ .m_name = "cluster-2"
+ .m_status = "Connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set p = New Process
+ With p
+ .m_id = "1"
+ .m_name = "ndb-3"
+ .m_database = "ejonore-2-node"
+ .m_status = "Running"
+ .m_owner = "ejonore"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set c = New Computer
+ With c
+ .m_ip = "10.0.3.1"
+ .m_name = "cluster-3"
+ .m_status = "Connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set p = New Process
+ With p
+ .m_id = "1"
+ .m_name = "api-4"
+ .m_database = "ejonore-2-node"
+ .m_status = "Running"
+ .m_owner = "ejonore"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set c = New Computer
+ With c
+ .m_ip = "10.0.4.1"
+ .m_name = "cluster-4"
+ .m_status = "Connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set p = New Process
+ With p
+ .m_id = "1"
+ .m_name = "api-5"
+ .m_database = "ejonore-2-node"
+ .m_status = "Running"
+ .m_owner = "ejonore"
+ Set .m_computer = c
+ End With
+ addProcess c, p
+
+ Set c = New Computer
+ With c
+ .m_ip = "130.100.232.5"
+ .m_name = "ndbs05"
+ .m_status = "Not connected"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+ Set c = New Computer
+ With c
+ .m_ip = "130.100.232.7"
+ .m_name = "ndb-srv7"
+ .m_status = "No contact"
+ Set .m_processes = New Collection
+ End With
+ addComputer c
+
+End Sub
+
+Public Sub addComputer(ByRef c As Computer)
+ g_computers.Add c, "_" & c.m_name
+End Sub
+
+Private Sub addProcess(ByRef c As Computer, ByRef p As Process)
+ c.m_processes.Add p, "_" & p.m_id
+
+ Dim cl As Database_
+ If Not Exists(g_databases, "_" & p.m_database) Then
+ Set cl = New Database_
+ With cl
+ .m_name = p.m_database
+ .m_status = "Unknown"
+ Set .m_processes = New Collection
+ End With
+ g_databases.Add cl, "_" & p.m_database
+ Else
+ Set cl = g_databases("_" & p.m_database)
+ End If
+ cl.m_processes.Add p, "_" & p.m_computer.m_name & "_" & p.m_id
+End Sub
+
+Public Function Exists(ByRef c As Collection, ByVal k As String) As Boolean
+ Dim r As Boolean
+ Dim o As Object
+
+ r = True
+
+ On Error GoTo NotFound
+ Set o = c.Item(k)
+ GoTo Continue
+NotFound:
+ If Err.Number <> 5 Then
+ Err.Raise Err.Number, Err.Source, Err.Description
+ End If
+
+ r = False
+Continue:
+ Exists = r
+End Function
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbp b/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbp
new file mode 100644
index 00000000000..dc8f3780a74
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbp
@@ -0,0 +1,49 @@
+Type=Exe
+Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.ocx
+Module=Module1; Module1.bas
+Form=frmMain.frm
+Form=frmSplash.frm
+Form=frmLogin.frm
+Form=frmOptions.frm
+Form=frmAbout.frm
+Class=Computer; Computer.cls
+Class=Process; Process.cls
+Class=Database_; Database.cls
+Form=frmNewComputer.frm
+Form=frmNewDatabase3.frm
+Form=frmNewDatabase1.frm
+Form=frmNewDatabase2.frm
+IconForm="frmAbout"
+Startup="Sub Main"
+HelpFile=""
+Title="NdbCPC"
+ExeName32="NdbCPC.exe"
+Command32=""
+Name="NdbCPC"
+HelpContextID="0"
+CompatibleMode="0"
+MajorVer=1
+MinorVer=0
+RevisionVer=0
+AutoIncrementVer=0
+ServerSupportFiles=0
+VersionCompanyName="ctp"
+CompilationType=0
+OptimizationType=0
+FavorPentiumPro(tm)=0
+CodeViewDebugInfo=0
+NoAliasing=0
+BoundsCheck=0
+OverflowCheck=0
+FlPointCheck=0
+FDIVCheck=0
+UnroundedFP=0
+StartMode=0
+Unattended=0
+Retained=0
+ThreadPerObject=0
+MaxNumberOfThreads=1
+DebugStartupOption=0
+
+[MS Transaction Server]
+AutoRefresh=1
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbw b/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbw
new file mode 100644
index 00000000000..825abbc923a
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/NdbCPC.vbw
@@ -0,0 +1,13 @@
+Module1 = 44, 44, 577, 492,
+frmMain = 44, 44, 577, 492, , 66, 66, 599, 514, C
+frmSplash = 132, 132, 670, 576, C, 88, 88, 621, 536, C
+frmLogin = 0, 0, 538, 444, C, 110, 110, 643, 558, C
+frmOptions = 176, 176, 714, 620, C, 132, 132, 665, 580, C
+frmAbout = 132, 132, 759, 511, C, 154, 154, 687, 602, C
+Computer = 110, 110, 648, 554,
+Process = 132, 132, 670, 576, C
+Database_ = 88, 88, 626, 532, C
+frmNewComputer = 44, 44, 582, 488, , 22, 22, 390, 218, C
+frmNewDatabase3 = 0, 0, 506, 444, , 0, 0, 506, 444, C
+frmNewDatabase1 = 132, 132, 638, 550, , 154, 154, 660, 572, C
+frmNewDatabase2 = 198, 198, 704, 616, , 176, 176, 682, 594, C
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/Process.cls b/storage/ndb/src/cw/cpcc-win32/vb6/Process.cls
new file mode 100644
index 00000000000..fcb4c2cbb2c
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/Process.cls
@@ -0,0 +1,22 @@
+VERSION 1.0 CLASS
+BEGIN
+ MultiUse = -1 'True
+ Persistable = 0 'NotPersistable
+ DataBindingBehavior = 0 'vbNone
+ DataSourceBehavior = 0 'vbNone
+ MTSTransactionMode = 0 'NotAnMTSObject
+END
+Attribute VB_Name = "Process"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = True
+Attribute VB_PredeclaredId = False
+Attribute VB_Exposed = False
+Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
+Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
+Public m_computer As Computer
+Public m_id As String
+Public m_name As String
+Public m_database As String
+Public m_status As String
+Public m_owner As String
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/closed folder.ico b/storage/ndb/src/cw/cpcc-win32/vb6/closed folder.ico
new file mode 100644
index 00000000000..fe82350d376
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/closed folder.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/computer.ico b/storage/ndb/src/cw/cpcc-win32/vb6/computer.ico
new file mode 100644
index 00000000000..d73302d1cd5
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/computer.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmAbout.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmAbout.frm
new file mode 100644
index 00000000000..b842d20de21
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmAbout.frm
@@ -0,0 +1,245 @@
+VERSION 5.00
+Begin VB.Form frmAbout
+ BorderStyle = 3 'Fixed Dialog
+ Caption = "About NdbCPC"
+ ClientHeight = 3630
+ ClientLeft = 45
+ ClientTop = 330
+ ClientWidth = 5865
+ ClipControls = 0 'False
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 3630
+ ScaleWidth = 5865
+ ShowInTaskbar = 0 'False
+ StartUpPosition = 1 'CenterOwner
+ Tag = "About NdbCPC"
+ Begin VB.PictureBox picIcon
+ AutoSize = -1 'True
+ BackColor = &H00C0C0C0&
+ ClipControls = 0 'False
+ Height = 540
+ Left = 240
+ Picture = "frmAbout.frx":0000
+ ScaleHeight = 480
+ ScaleMode = 0 'User
+ ScaleWidth = 480
+ TabIndex = 2
+ TabStop = 0 'False
+ Top = 240
+ Width = 540
+ End
+ Begin VB.CommandButton cmdOK
+ Cancel = -1 'True
+ Caption = "OK"
+ Default = -1 'True
+ Height = 345
+ Left = 4245
+ TabIndex = 0
+ Tag = "OK"
+ Top = 2625
+ Width = 1467
+ End
+ Begin VB.CommandButton cmdSysInfo
+ Caption = "&System Info..."
+ Height = 345
+ Left = 4260
+ TabIndex = 1
+ Tag = "&System Info..."
+ Top = 3075
+ Width = 1452
+ End
+ Begin VB.Label lblDescription
+ Caption = "App Description"
+ ForeColor = &H00000000&
+ Height = 1170
+ Left = 1050
+ TabIndex = 6
+ Tag = "App Description"
+ Top = 1125
+ Width = 4092
+ End
+ Begin VB.Label lblTitle
+ Caption = "Application Title"
+ ForeColor = &H00000000&
+ Height = 480
+ Left = 1050
+ TabIndex = 5
+ Tag = "Application Title"
+ Top = 240
+ Width = 4092
+ End
+ Begin VB.Line Line1
+ BorderColor = &H00808080&
+ BorderStyle = 6 'Inside Solid
+ Index = 1
+ X1 = 225
+ X2 = 5657
+ Y1 = 2430
+ Y2 = 2430
+ End
+ Begin VB.Line Line1
+ BorderColor = &H00FFFFFF&
+ BorderWidth = 2
+ Index = 0
+ X1 = 240
+ X2 = 5657
+ Y1 = 2445
+ Y2 = 2445
+ End
+ Begin VB.Label lblVersion
+ Caption = "Version"
+ Height = 225
+ Left = 1050
+ TabIndex = 4
+ Tag = "Version"
+ Top = 780
+ Width = 4092
+ End
+ Begin VB.Label lblDisclaimer
+ Caption = "Warning: ..."
+ ForeColor = &H00000000&
+ Height = 825
+ Left = 255
+ TabIndex = 3
+ Tag = "Warning: ..."
+ Top = 2625
+ Width = 3870
+ End
+End
+Attribute VB_Name = "frmAbout"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+' Reg Key Security Options...
+Const KEY_ALL_ACCESS = &H2003F
+
+
+' Reg Key ROOT Types...
+Const HKEY_LOCAL_MACHINE = &H80000002
+Const ERROR_SUCCESS = 0
+Const REG_SZ = 1 ' Unicode nul terminated string
+Const REG_DWORD = 4 ' 32-bit number
+
+
+Const gREGKEYSYSINFOLOC = "SOFTWARE\Microsoft\Shared Tools Location"
+Const gREGVALSYSINFOLOC = "MSINFO"
+Const gREGKEYSYSINFO = "SOFTWARE\Microsoft\Shared Tools\MSINFO"
+Const gREGVALSYSINFO = "PATH"
+
+
+Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
+Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long
+Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
+
+Private Sub Form_Load()
+ lblVersion.Caption = "Version " & App.Major & "." & App.Minor & "." & App.Revision
+ lblTitle.Caption = App.Title
+End Sub
+
+
+
+Private Sub cmdSysInfo_Click()
+ Call StartSysInfo
+End Sub
+
+
+Private Sub cmdOK_Click()
+ Unload Me
+End Sub
+
+
+Public Sub StartSysInfo()
+ On Error GoTo SysInfoErr
+
+
+ Dim rc As Long
+ Dim SysInfoPath As String
+
+
+ ' Try To Get System Info Program Path\Name From Registry...
+ If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO, SysInfoPath) Then
+ ' Try To Get System Info Program Path Only From Registry...
+ ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC, SysInfoPath) Then
+ ' Validate Existance Of Known 32 Bit File Version
+ If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
+ SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
+
+
+ ' Error - File Can Not Be Found...
+ Else
+ GoTo SysInfoErr
+ End If
+ ' Error - Registry Entry Can Not Be Found...
+ Else
+ GoTo SysInfoErr
+ End If
+
+
+ Call Shell(SysInfoPath, vbNormalFocus)
+
+
+ Exit Sub
+SysInfoErr:
+ MsgBox "System Information Is Unavailable At This Time", vbOKOnly
+End Sub
+
+
+Public Function GetKeyValue(KeyRoot As Long, KeyName As String, SubKeyRef As String, ByRef KeyVal As String) As Boolean
+ Dim i As Long ' Loop Counter
+ Dim rc As Long ' Return Code
+ Dim hKey As Long ' Handle To An Open Registry Key
+ Dim hDepth As Long '
+ Dim KeyValType As Long ' Data Type Of A Registry Key
+ Dim tmpVal As String ' Tempory Storage For A Registry Key Value
+ Dim KeyValSize As Long ' Size Of Registry Key Variable
+ '------------------------------------------------------------
+ ' Open RegKey Under KeyRoot {HKEY_LOCAL_MACHINE...}
+ '------------------------------------------------------------
+ rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey) ' Open Registry Key
+
+
+ If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Error...
+
+
+ tmpVal = String$(1024, 0) ' Allocate Variable Space
+ KeyValSize = 1024 ' Mark Variable Size
+
+
+ '------------------------------------------------------------
+ ' Retrieve Registry Key Value...
+ '------------------------------------------------------------
+ rc = RegQueryValueEx(hKey, SubKeyRef, 0, KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value
+
+
+ If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors
+
+
+ tmpVal = VBA.Left(tmpVal, InStr(tmpVal, VBA.Chr(0)) - 1)
+ '------------------------------------------------------------
+ ' Determine Key Value Type For Conversion...
+ '------------------------------------------------------------
+ Select Case KeyValType ' Search Data Types...
+ Case REG_SZ ' String Registry Key Data Type
+ KeyVal = tmpVal ' Copy String Value
+ Case REG_DWORD ' Double Word Registry Key Data Type
+ For i = Len(tmpVal) To 1 Step -1 ' Convert Each Bit
+ KeyVal = KeyVal + Hex(Asc(Mid(tmpVal, i, 1))) ' Build Value Char. By Char.
+ Next
+ KeyVal = Format$("&h" + KeyVal) ' Convert Double Word To String
+ End Select
+
+
+ GetKeyValue = True ' Return Success
+ rc = RegCloseKey(hKey) ' Close Registry Key
+ Exit Function ' Exit
+
+
+GetKeyError: ' Cleanup After An Error Has Occured...
+ KeyVal = "" ' Set Return Val To Empty String
+ GetKeyValue = False ' Return Failure
+ rc = RegCloseKey(hKey) ' Close Registry Key
+End Function
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmLogin.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmLogin.frm
new file mode 100644
index 00000000000..d4d663c93c2
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmLogin.frm
@@ -0,0 +1,119 @@
+VERSION 5.00
+Begin VB.Form frmLogin
+ BorderStyle = 3 'Fixed Dialog
+ Caption = "Login"
+ ClientHeight = 1590
+ ClientLeft = 45
+ ClientTop = 330
+ ClientWidth = 3750
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 1590
+ ScaleWidth = 3750
+ ShowInTaskbar = 0 'False
+ StartUpPosition = 2 'CenterScreen
+ Tag = "Login"
+ Begin VB.CommandButton cmdCancel
+ Cancel = -1 'True
+ Caption = "Cancel"
+ Height = 360
+ Left = 2100
+ TabIndex = 5
+ Tag = "Cancel"
+ Top = 1020
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdOK
+ Caption = "OK"
+ Default = -1 'True
+ Height = 360
+ Left = 495
+ TabIndex = 4
+ Tag = "OK"
+ Top = 1020
+ Width = 1140
+ End
+ Begin VB.TextBox txtPassword
+ Height = 285
+ IMEMode = 3 'DISABLE
+ Left = 1305
+ PasswordChar = "*"
+ TabIndex = 1
+ Top = 525
+ Width = 2325
+ End
+ Begin VB.TextBox txtUserName
+ Height = 285
+ Left = 1305
+ TabIndex = 3
+ Top = 135
+ Width = 2325
+ End
+ Begin VB.Label lblLabels
+ Caption = "&Password:"
+ Height = 248
+ Index = 1
+ Left = 105
+ TabIndex = 0
+ Tag = "&Password:"
+ Top = 540
+ Width = 1080
+ End
+ Begin VB.Label lblLabels
+ Caption = "&User Name:"
+ Height = 248
+ Index = 0
+ Left = 105
+ TabIndex = 2
+ Tag = "&User Name:"
+ Top = 150
+ Width = 1080
+ End
+End
+Attribute VB_Name = "frmLogin"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
+
+
+Public OK As Boolean
+Private Sub Form_Load()
+ Dim sBuffer As String
+ Dim lSize As Long
+
+
+ sBuffer = Space$(255)
+ lSize = Len(sBuffer)
+ Call GetUserName(sBuffer, lSize)
+ If lSize > 0 Then
+ txtUserName.Text = Left$(sBuffer, lSize)
+ Else
+ txtUserName.Text = vbNullString
+ End If
+End Sub
+
+
+
+Private Sub cmdCancel_Click()
+ OK = False
+ Me.Hide
+End Sub
+
+
+Private Sub cmdOK_Click()
+ 'ToDo: create test for correct password
+ 'check for correct password
+ If txtPassword.Text = "" Then
+ OK = True
+ Me.Hide
+ Else
+ MsgBox "Invalid Password, try again!", , "Login"
+ txtPassword.SetFocus
+ txtPassword.SelStart = 0
+ txtPassword.SelLength = Len(txtPassword.Text)
+ End If
+End Sub
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmMain.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmMain.frm
new file mode 100644
index 00000000000..a4bf5b58941
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmMain.frm
@@ -0,0 +1,1207 @@
+VERSION 5.00
+Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
+Begin VB.Form frmMain
+ Caption = "NdbCPC"
+ ClientHeight = 5955
+ ClientLeft = 2115
+ ClientTop = 2250
+ ClientWidth = 8880
+ LinkTopic = "Form1"
+ ScaleHeight = 5955
+ ScaleWidth = 8880
+ Begin MSComctlLib.ImageList ImageList1
+ Left = 6840
+ Top = 3120
+ _ExtentX = 1005
+ _ExtentY = 1005
+ BackColor = 16777215
+ ImageWidth = 16
+ ImageHeight = 16
+ MaskColor = 12632256
+ _Version = 393216
+ BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
+ NumListImages = 11
+ BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":0000
+ Key = "close"
+ EndProperty
+ BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":27B4
+ Key = "open"
+ EndProperty
+ BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":4F68
+ Key = "computer_unknown"
+ EndProperty
+ BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":5284
+ Key = "computer_stopped"
+ EndProperty
+ BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":55A0
+ Key = "computer_started"
+ EndProperty
+ BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":58BC
+ Key = ""
+ EndProperty
+ BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":5BD8
+ Key = ""
+ EndProperty
+ BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":5EF4
+ Key = ""
+ EndProperty
+ BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":6210
+ Key = "db"
+ EndProperty
+ BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":652A
+ Key = "computer"
+ EndProperty
+ BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
+ Picture = "frmMain.frx":6844
+ Key = "properties"
+ EndProperty
+ EndProperty
+ End
+ Begin VB.PictureBox picSplitter
+ BackColor = &H00808080&
+ BorderStyle = 0 'None
+ FillColor = &H00808080&
+ Height = 4800
+ Left = 5400
+ ScaleHeight = 2090.126
+ ScaleMode = 0 'User
+ ScaleWidth = 780
+ TabIndex = 6
+ Top = 705
+ Width = 72
+ Visible = 0 'False
+ End
+ Begin MSComctlLib.TreeView tvTreeView
+ Height = 4800
+ Left = 0
+ TabIndex = 5
+ Top = 705
+ Width = 2016
+ _ExtentX = 3545
+ _ExtentY = 8467
+ _Version = 393217
+ HideSelection = 0 'False
+ Indentation = 0
+ LineStyle = 1
+ Sorted = -1 'True
+ Style = 7
+ FullRowSelect = -1 'True
+ ImageList = "ImageList1"
+ Appearance = 1
+ End
+ Begin VB.PictureBox picTitles
+ Align = 1 'Align Top
+ Appearance = 0 'Flat
+ BorderStyle = 0 'None
+ ForeColor = &H80000008&
+ Height = 300
+ Left = 0
+ ScaleHeight = 300
+ ScaleWidth = 8880
+ TabIndex = 2
+ TabStop = 0 'False
+ Top = 420
+ Width = 8880
+ Begin VB.Label lblTitle
+ BorderStyle = 1 'Fixed Single
+ Caption = " ListView:"
+ Height = 270
+ Index = 1
+ Left = 2078
+ TabIndex = 4
+ Tag = " ListView:"
+ Top = 12
+ Width = 3216
+ End
+ Begin VB.Label lblTitle
+ BorderStyle = 1 'Fixed Single
+ Caption = " TreeView:"
+ Height = 270
+ Index = 0
+ Left = 0
+ TabIndex = 3
+ Tag = " TreeView:"
+ Top = 12
+ Width = 2016
+ End
+ End
+ Begin MSComctlLib.Toolbar tbToolBar
+ Align = 1 'Align Top
+ Height = 420
+ Left = 0
+ TabIndex = 1
+ Top = 0
+ Width = 8880
+ _ExtentX = 15663
+ _ExtentY = 741
+ ButtonWidth = 609
+ ButtonHeight = 582
+ Appearance = 1
+ ImageList = "ImageList1"
+ _Version = 393216
+ BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
+ NumButtons = 5
+ BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
+ Style = 3
+ EndProperty
+ BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
+ Key = "Add computer"
+ Object.ToolTipText = "Add computer"
+ ImageKey = "computer"
+ EndProperty
+ BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
+ Key = "New database"
+ Object.ToolTipText = "New database"
+ ImageKey = "db"
+ EndProperty
+ BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
+ Style = 3
+ EndProperty
+ BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
+ Key = "Properties"
+ Object.ToolTipText = "Properties"
+ ImageKey = "properties"
+ EndProperty
+ EndProperty
+ End
+ Begin MSComctlLib.StatusBar sbStatusBar
+ Align = 2 'Align Bottom
+ Height = 270
+ Left = 0
+ TabIndex = 0
+ Top = 5685
+ Width = 8880
+ _ExtentX = 15663
+ _ExtentY = 476
+ _Version = 393216
+ BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
+ NumPanels = 3
+ BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
+ AutoSize = 1
+ Object.Width = 10028
+ Text = "Status"
+ TextSave = "Status"
+ EndProperty
+ BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628}
+ Style = 6
+ AutoSize = 2
+ TextSave = "2002-10-15"
+ EndProperty
+ BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628}
+ Style = 5
+ AutoSize = 2
+ TextSave = "09:44"
+ EndProperty
+ EndProperty
+ End
+ Begin MSComctlLib.ListView lvProcesses
+ Height = 4815
+ Left = 2040
+ TabIndex = 8
+ Top = 720
+ Width = 3255
+ _ExtentX = 5741
+ _ExtentY = 8493
+ Sorted = -1 'True
+ MultiSelect = -1 'True
+ LabelWrap = -1 'True
+ HideSelection = 0 'False
+ AllowReorder = -1 'True
+ FullRowSelect = -1 'True
+ _Version = 393217
+ ForeColor = -2147483640
+ BackColor = -2147483643
+ BorderStyle = 1
+ Appearance = 1
+ NumItems = 6
+ BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ Key = "Id"
+ Text = "Id"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 1
+ Key = "Computer"
+ Text = "Computer"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 2
+ Key = "Database"
+ Text = "Database"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 3
+ Key = "Name"
+ Text = "Name"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 4
+ Key = "Status"
+ Text = "Status"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 5
+ Key = "Owner"
+ Text = "Owner"
+ Object.Width = 2540
+ EndProperty
+ End
+ Begin MSComctlLib.ListView lvComputers
+ Height = 4815
+ Left = 2040
+ TabIndex = 7
+ Top = 720
+ Width = 3255
+ _ExtentX = 5741
+ _ExtentY = 8493
+ Sorted = -1 'True
+ MultiSelect = -1 'True
+ LabelWrap = -1 'True
+ HideSelection = -1 'True
+ AllowReorder = -1 'True
+ FullRowSelect = -1 'True
+ _Version = 393217
+ Icons = "ImageList1"
+ SmallIcons = "ImageList1"
+ ForeColor = -2147483640
+ BackColor = -2147483643
+ BorderStyle = 1
+ Appearance = 1
+ NumItems = 2
+ BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ Text = "Computer"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 1
+ Text = "Status"
+ Object.Width = 2540
+ EndProperty
+ End
+ Begin MSComctlLib.ListView lvDatabases
+ Height = 4815
+ Left = 2040
+ TabIndex = 9
+ Top = 720
+ Width = 3255
+ _ExtentX = 5741
+ _ExtentY = 8493
+ View = 3
+ Sorted = -1 'True
+ MultiSelect = -1 'True
+ LabelWrap = -1 'True
+ HideSelection = -1 'True
+ AllowReorder = -1 'True
+ FullRowSelect = -1 'True
+ _Version = 393217
+ Icons = "ImageList1"
+ SmallIcons = "ImageList1"
+ ForeColor = -2147483640
+ BackColor = -2147483643
+ BorderStyle = 1
+ Appearance = 1
+ NumItems = 2
+ BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ Key = "Database"
+ Text = "Database"
+ Object.Width = 2540
+ EndProperty
+ BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
+ SubItemIndex = 1
+ Key = "Status"
+ Text = "Status"
+ Object.Width = 2540
+ EndProperty
+ End
+ Begin VB.Image imgSplitter
+ Height = 4788
+ Left = 1965
+ MousePointer = 9 'Size W E
+ Top = 705
+ Width = 150
+ End
+ Begin VB.Menu mnuFile
+ Caption = "&File"
+ Begin VB.Menu mnuFileOpen
+ Caption = "&Open..."
+ End
+ Begin VB.Menu mnuFileFind
+ Caption = "&Find"
+ End
+ Begin VB.Menu mnuFileBar0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuFileSendTo
+ Caption = "Sen&d to"
+ End
+ Begin VB.Menu mnuFileBar1
+ Caption = "-"
+ End
+ Begin VB.Menu mnuFileNew
+ Caption = "&New"
+ Shortcut = ^N
+ End
+ Begin VB.Menu mnuFileBar2
+ Caption = "-"
+ End
+ Begin VB.Menu mnuFileDelete
+ Caption = "&Delete"
+ End
+ Begin VB.Menu mnuFileRename
+ Caption = "Rena&me"
+ End
+ Begin VB.Menu mnuFileProperties
+ Caption = "Propert&ies"
+ End
+ Begin VB.Menu mnuFileBar3
+ Caption = "-"
+ End
+ Begin VB.Menu mnuFileMRU
+ Caption = ""
+ Index = 1
+ Visible = 0 'False
+ End
+ Begin VB.Menu mnuFileMRU
+ Caption = ""
+ Index = 2
+ Visible = 0 'False
+ End
+ Begin VB.Menu mnuFileMRU
+ Caption = ""
+ Index = 3
+ Visible = 0 'False
+ End
+ Begin VB.Menu mnuFileBar4
+ Caption = "-"
+ Visible = 0 'False
+ End
+ Begin VB.Menu mnuFileBar5
+ Caption = "-"
+ End
+ Begin VB.Menu mnuFileClose
+ Caption = "&Close"
+ End
+ End
+ Begin VB.Menu mnuEdit
+ Caption = "&Edit"
+ Begin VB.Menu mnuEditUndo
+ Caption = "&Undo"
+ End
+ Begin VB.Menu mnuEditBar0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuEditCut
+ Caption = "Cu&t"
+ Shortcut = ^X
+ End
+ Begin VB.Menu mnuEditCopy
+ Caption = "&Copy"
+ Shortcut = ^C
+ End
+ Begin VB.Menu mnuEditPaste
+ Caption = "&Paste"
+ Shortcut = ^V
+ End
+ Begin VB.Menu mnuEditPasteSpecial
+ Caption = "Paste &Special..."
+ End
+ Begin VB.Menu mnuEditBar1
+ Caption = "-"
+ End
+ Begin VB.Menu mnuEditSelectAll
+ Caption = "Select &All"
+ Shortcut = ^A
+ End
+ Begin VB.Menu mnuEditInvertSelection
+ Caption = "&Invert Selection"
+ End
+ End
+ Begin VB.Menu mnuView
+ Caption = "&View"
+ Begin VB.Menu mnuViewToolbar
+ Caption = "&Toolbar"
+ Checked = -1 'True
+ End
+ Begin VB.Menu mnuViewStatusBar
+ Caption = "Status &Bar"
+ Checked = -1 'True
+ End
+ Begin VB.Menu mnuViewBar0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuListViewMode
+ Caption = "Lar&ge Icons"
+ Index = 0
+ End
+ Begin VB.Menu mnuListViewMode
+ Caption = "S&mall Icons"
+ Index = 1
+ End
+ Begin VB.Menu mnuListViewMode
+ Caption = "&List"
+ Index = 2
+ End
+ Begin VB.Menu mnuListViewMode
+ Caption = "&Details"
+ Index = 3
+ End
+ Begin VB.Menu mnuViewBar1
+ Caption = "-"
+ End
+ Begin VB.Menu mnuViewArrangeIcons
+ Caption = "Arrange &Icons"
+ End
+ Begin VB.Menu mnuViewBar2
+ Caption = "-"
+ End
+ Begin VB.Menu mnuViewRefresh
+ Caption = "&Refresh"
+ End
+ Begin VB.Menu mnuViewOptions
+ Caption = "&Options..."
+ End
+ Begin VB.Menu mnuViewWebBrowser
+ Caption = "&Web Browser"
+ End
+ End
+ Begin VB.Menu mnuHelp
+ Caption = "&Help"
+ Begin VB.Menu mnuHelpContents
+ Caption = "&Contents"
+ End
+ Begin VB.Menu mnuHelpSearchForHelpOn
+ Caption = "&Search For Help On..."
+ End
+ Begin VB.Menu mnuHelpBar0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuHelpAbout
+ Caption = "&About "
+ End
+ End
+ Begin VB.Menu mnuPopComputers
+ Caption = ""
+ Visible = 0 'False
+ Begin VB.Menu mnuPopAddComputer
+ Caption = "Add computer"
+ End
+ Begin VB.Menu mnuPop__
+ Caption = "-"
+ End
+ Begin VB.Menu mnuPopSortComputers
+ Caption = "Sorted"
+ End
+ End
+ Begin VB.Menu mnuPopDatabases
+ Caption = ""
+ Visible = 0 'False
+ Begin VB.Menu mnuPopNewDatabase
+ Caption = "New database"
+ End
+ Begin VB.Menu mnuPopSortDatabases0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuPopSortDatabases
+ Caption = "Sorted"
+ End
+ End
+ Begin VB.Menu mnuPopComputer
+ Caption = ""
+ Visible = 0 'False
+ Begin VB.Menu mnuPopComputerName
+ Caption = "ComputerName"
+ Enabled = 0 'False
+ End
+ Begin VB.Menu mnuPopComputer0
+ Caption = "-"
+ End
+ Begin VB.Menu mnuPopConnectComputer
+ Caption = "Connect"
+ End
+ Begin VB.Menu mnuPopDisconnectComputer
+ Caption = "Disconnect"
+ End
+ Begin VB.Menu mnuPopRemoveComputer
+ Caption = "Remove"
+ End
+ Begin VB.Menu mnuComputer1
+ Caption = "-"
+ End
+ Begin VB.Menu mnuPopComputerProperties
+ Caption = "Properties"
+ End
+ End
+End
+Attribute VB_Name = "frmMain"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Option Explicit
+Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hwnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
+
+Dim mbMoving As Boolean
+Const sglSplitLimit = 500
+Dim m_currentNode As MSComctlLib.Node
+Dim m_currentList As ListView
+
+Dim m_currentView As Integer
+Dim m_computerWidth As Integer
+Dim m_databaseWidth As Integer
+
+Dim m_currentComputer As Computer
+Dim m_currentDatabase As Database_
+
+Private Sub Form_Load()
+ tvTreeView.Nodes.Clear
+ lvComputers.ListItems.Clear
+ lvProcesses.ListItems.Clear
+ lvDatabases.ListItems.Clear
+
+ Me.Left = GetSetting(App.Title, "Settings", "MainLeft", 1000)
+ Me.Top = GetSetting(App.Title, "Settings", "MainTop", 1000)
+ Me.Width = GetSetting(App.Title, "Settings", "MainWidth", 6500)
+ Me.Height = GetSetting(App.Title, "Settings", "MainHeight", 6500)
+
+ tvTreeView.Nodes.Add , tvwChild, "Computers", "Computers", 1, 2
+ Dim c As Computer
+ For Each c In g_computers
+ addComputer c
+ Next
+
+ Set m_currentNode = tvTreeView.Nodes("Computers")
+ Set m_currentList = lvComputers
+
+ tvTreeView.Nodes.Add , tvwChild, "Databases", "Databases", 1, 2
+ Dim d As Database_
+ For Each d In g_databases
+ AddDatabase d
+ Next
+
+ lvComputers.Visible = True
+ lvProcesses.Visible = False
+ lvDatabases.Visible = False
+ lvComputers.View = lvwReport
+ lvProcesses.View = lvwReport
+ lvDatabases.View = lvwReport
+ m_computerWidth = lvProcesses.ColumnHeaders("Computer").Width
+ m_databaseWidth = lvProcesses.ColumnHeaders("Database").Width
+ lvProcesses.ColumnHeaders("Id").Width = 0
+End Sub
+
+Private Sub setComputer(ByVal f_ip As String)
+ Dim c As Computer
+ Set c = g_computers(f_ip)
+ If c Is Nothing Then
+ MsgBox "Unknown computer: " & f_ip
+ Exit Sub
+ End If
+
+ Set m_currentComputer = c
+
+ lblTitle(1).Caption = "Processes defined on computer: " & c.m_name
+ setProcesses c.m_processes
+
+ If lvProcesses.ColumnHeaders("Computer").Width <> 0 Then
+ m_computerWidth = lvProcesses.ColumnHeaders("Computer").Width
+ lvProcesses.ColumnHeaders("Computer").Width = 0
+ End If
+
+ If lvProcesses.ColumnHeaders("Database").Width = 0 Then
+ lvProcesses.ColumnHeaders("Database").Width = m_databaseWidth
+ End If
+End Sub
+
+Private Sub setDatabase(ByVal f_name As String)
+ Dim c As Database_
+ Set c = g_databases(f_name)
+ If c Is Nothing Then
+ MsgBox "Unknown database: " & f_name
+ Exit Sub
+ End If
+
+ Set m_currentDatabase = c
+
+ lblTitle(1).Caption = "Processes defined for database: " & c.m_name
+ setProcesses c.m_processes
+
+ If lvProcesses.ColumnHeaders("Database").Width <> 0 Then
+ m_databaseWidth = lvProcesses.ColumnHeaders("Database").Width
+ lvProcesses.ColumnHeaders("Database").Width = 0
+ End If
+
+ If lvProcesses.ColumnHeaders("Computer").Width = 0 Then
+ lvProcesses.ColumnHeaders("Computer").Width = m_computerWidth
+ End If
+
+End Sub
+
+Private Sub setProcesses(ByRef c As Collection)
+ lvProcesses.ListItems.Clear
+ Dim p As Process
+ For Each p In c
+ Dim li As ListItem
+ Set li = lvProcesses.ListItems.Add(, "_" & p.m_computer.m_name & "_" & p.m_id, p.m_id)
+ li.SubItems(1) = p.m_computer.m_name
+ li.SubItems(2) = p.m_database
+ li.SubItems(3) = p.m_name
+ li.SubItems(4) = p.m_status
+ li.SubItems(5) = p.m_owner
+ Next
+End Sub
+
+Public Sub addComputer(ByRef c As Computer)
+ Dim icon As Integer
+ Select Case c.m_status
+ Case "No contact"
+ icon = 4
+ Case "Connected"
+ icon = 5
+ Case Else
+ icon = 3
+ End Select
+
+ Dim li As ListItem
+ Set li = lvComputers.ListItems.Add(, "_" & c.m_name, c.m_name, icon, icon)
+ li.SubItems(1) = c.m_status
+
+ tvTreeView.Nodes.Add "Computers", tvwChild, "_" & c.m_name, c.m_name, icon, icon
+End Sub
+
+Public Sub removeComputer(ByRef name As String)
+ lvComputers.ListItems.Remove "_" & name
+ tvTreeView.Nodes.Remove "_" & name
+
+ '
+ ' Check if should remove database
+ Dim c As Computer
+ Set c = g_computers("_" & name)
+ Dim db As Database_
+ Dim dbs As New Collection
+ Dim p As Process
+ For Each p In c.m_processes
+ Set db = g_databases("_" & p.m_database)
+ db.m_processes.Remove "_" & p.m_computer.m_name & "_" & p.m_id
+ If Not Exists(dbs, p.m_database) Then dbs.Add db, p.m_database
+ Next
+
+ For Each db In dbs
+ If db.m_processes.Count = 0 Then
+ g_databases.Remove "_" & db.m_name
+ tvTreeView.Nodes.Remove "_" & db.m_name
+ End If
+ Next
+
+ g_computers.Remove "_" & name
+
+ '
+ ' Check if should remove database
+
+ Dim n As MSComctlLib.Node
+ Set n = tvTreeView.SelectedItem
+ selectNode n
+End Sub
+
+Private Sub AddDatabase(ByRef c As Database_)
+ Dim li As ListItem
+ Set li = lvDatabases.ListItems.Add(, "_" & c.m_name, c.m_name, 9, 9)
+ li.SubItems(1) = c.m_status
+ tvTreeView.Nodes.Add "Databases", tvwChild, "_" & c.m_name, c.m_name, 9, 9
+End Sub
+
+Private Sub Form_Unload(Cancel As Integer)
+ Dim i As Integer
+
+
+ 'close all sub forms
+ For i = Forms.Count - 1 To 1 Step -1
+ Unload Forms(i)
+ Next
+ If Me.WindowState <> vbMinimized Then
+ SaveSetting App.Title, "Settings", "MainLeft", Me.Left
+ SaveSetting App.Title, "Settings", "MainTop", Me.Top
+ SaveSetting App.Title, "Settings", "MainWidth", Me.Width
+ SaveSetting App.Title, "Settings", "MainHeight", Me.Height
+ End If
+End Sub
+
+Private Sub Form_Resize()
+ On Error Resume Next
+ If Me.Width < 3000 Then Me.Width = 3000
+ SizeControls imgSplitter.Left
+End Sub
+
+Private Sub imgSplitter_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
+ With imgSplitter
+ picSplitter.Move .Left, .Top, .Width \ 2, .Height - 20
+ End With
+ picSplitter.Visible = True
+ mbMoving = True
+End Sub
+
+Private Sub imgSplitter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
+ Dim sglPos As Single
+
+
+ If mbMoving Then
+ sglPos = X + imgSplitter.Left
+ If sglPos < sglSplitLimit Then
+ picSplitter.Left = sglSplitLimit
+ ElseIf sglPos > Me.Width - sglSplitLimit Then
+ picSplitter.Left = Me.Width - sglSplitLimit
+ Else
+ picSplitter.Left = sglPos
+ End If
+ End If
+End Sub
+
+
+Private Sub imgSplitter_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
+ SizeControls picSplitter.Left
+ picSplitter.Visible = False
+ mbMoving = False
+End Sub
+
+
+Private Sub TreeView1_DragDrop(Source As Control, X As Single, Y As Single)
+ If Source = imgSplitter Then
+ SizeControls X
+ End If
+End Sub
+
+
+Sub SizeControls(X As Single)
+ On Error Resume Next
+
+ 'set the width
+ If X < 1500 Then X = 1500
+ If X > (Me.Width - 1500) Then X = Me.Width - 1500
+ tvTreeView.Width = X
+ imgSplitter.Left = X
+
+ Dim t_left, t_width As Integer
+ t_left = X + 40
+ t_width = Me.Width - (tvTreeView.Width + 140)
+
+ lblTitle(0).Width = tvTreeView.Width
+ lblTitle(1).Left = t_left + 20
+ lblTitle(1).Width = t_width - 40
+
+
+ 'set the top
+ If tbToolBar.Visible Then
+ tvTreeView.Top = tbToolBar.Height + picTitles.Height
+ Else
+ tvTreeView.Top = picTitles.Height
+ End If
+
+
+ 'set the height
+ If sbStatusBar.Visible Then
+ tvTreeView.Height = Me.ScaleHeight - (picTitles.Top + picTitles.Height + sbStatusBar.Height)
+ Else
+ tvTreeView.Height = Me.ScaleHeight - (picTitles.Top + picTitles.Height)
+ End If
+
+
+ imgSplitter.Top = tvTreeView.Top
+ imgSplitter.Height = tvTreeView.Height
+
+ setListDimensions t_left, t_width, tvTreeView.Top, tvTreeView.Height
+End Sub
+
+Private Sub setListView(ByVal f_View As Integer)
+ lvComputers.View = f_View
+ lvProcesses.View = f_View
+End Sub
+
+Private Sub setListDimensions(ByVal f_Left As Integer, ByVal f_Width As Integer, ByVal f_Top As Integer, ByVal f_Height As Integer)
+ With lvComputers
+ .Left = f_Left
+ .Width = f_Width
+ .Top = f_Top
+ .Height = f_Height
+ End With
+ With lvProcesses
+ .Left = f_Left
+ .Width = f_Width
+ .Top = f_Top
+ .Height = f_Height
+ End With
+ With lvDatabases
+ .Left = f_Left
+ .Width = f_Width
+ .Top = f_Top
+ .Height = f_Height
+ End With
+End Sub
+
+Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)
+ On Error Resume Next
+ Select Case Button.Key
+ Case "New database"
+ 'ToDo: Add 'Back' button code.
+ mnuPopNewDatabase_Click
+ Case "Add computer"
+ 'ToDo: Add 'Forward' button code.
+ frmNewComputer.Show vbModal, Me
+ Dim c As Computer
+ For Each c In frmNewComputer.m_hosts
+ addComputer c
+ g_computers.Add c, "_" & c.m_name
+ Next
+ Case "Properties"
+ mnuFileProperties_Click
+ End Select
+End Sub
+
+Private Sub mnuHelpAbout_Click()
+ frmAbout.Show vbModal, Me
+End Sub
+
+Private Sub mnuHelpSearchForHelpOn_Click()
+ Dim nRet As Integer
+
+
+ 'if there is no helpfile for this project display a message to the user
+ 'you can set the HelpFile for your application in the
+ 'Project Properties dialog
+ If Len(App.HelpFile) = 0 Then
+ MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
+ Else
+ On Error Resume Next
+ nRet = OSWinHelp(Me.hwnd, App.HelpFile, 261, 0)
+ If Err Then
+ MsgBox Err.Description
+ End If
+ End If
+
+End Sub
+
+Private Sub mnuHelpContents_Click()
+ Dim nRet As Integer
+
+
+ 'if there is no helpfile for this project display a message to the user
+ 'you can set the HelpFile for your application in the
+ 'Project Properties dialog
+ If Len(App.HelpFile) = 0 Then
+ MsgBox "Unable to display Help Contents. There is no Help associated with this project.", vbInformation, Me.Caption
+ Else
+ On Error Resume Next
+ nRet = OSWinHelp(Me.hwnd, App.HelpFile, 3, 0)
+ If Err Then
+ MsgBox Err.Description
+ End If
+ End If
+
+End Sub
+
+
+Private Sub mnuViewWebBrowser_Click()
+ 'ToDo: Add 'mnuViewWebBrowser_Click' code.
+ MsgBox "Add 'mnuViewWebBrowser_Click' code."
+End Sub
+
+Private Sub mnuViewOptions_Click()
+ frmOptions.Show vbModal, Me
+End Sub
+
+Private Sub mnuViewRefresh_Click()
+ 'ToDo: Add 'mnuViewRefresh_Click' code.
+ MsgBox "Add 'mnuViewRefresh_Click' code."
+End Sub
+
+
+Private Sub mnuViewStatusBar_Click()
+ mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
+ sbStatusBar.Visible = mnuViewStatusBar.Checked
+ SizeControls imgSplitter.Left
+End Sub
+
+Private Sub mnuViewToolbar_Click()
+ mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
+ tbToolBar.Visible = mnuViewToolbar.Checked
+ SizeControls imgSplitter.Left
+End Sub
+
+Private Sub mnuEditInvertSelection_Click()
+ 'ToDo: Add 'mnuEditInvertSelection_Click' code.
+ MsgBox "Add 'mnuEditInvertSelection_Click' code."
+End Sub
+
+Private Sub mnuEditSelectAll_Click()
+ 'ToDo: Add 'mnuEditSelectAll_Click' code.
+ MsgBox "Add 'mnuEditSelectAll_Click' code."
+End Sub
+
+Private Sub mnuEditPasteSpecial_Click()
+ 'ToDo: Add 'mnuEditPasteSpecial_Click' code.
+ MsgBox "Add 'mnuEditPasteSpecial_Click' code."
+End Sub
+
+Private Sub mnuEditPaste_Click()
+ 'ToDo: Add 'mnuEditPaste_Click' code.
+ MsgBox "Add 'mnuEditPaste_Click' code."
+End Sub
+
+Private Sub mnuEditCopy_Click()
+ 'ToDo: Add 'mnuEditCopy_Click' code.
+ MsgBox "Add 'mnuEditCopy_Click' code."
+End Sub
+
+Private Sub mnuEditCut_Click()
+ 'ToDo: Add 'mnuEditCut_Click' code.
+ MsgBox "Add 'mnuEditCut_Click' code."
+End Sub
+
+Private Sub mnuEditUndo_Click()
+ 'ToDo: Add 'mnuEditUndo_Click' code.
+ MsgBox "Add 'mnuEditUndo_Click' code."
+End Sub
+
+Private Sub mnuFileClose_Click()
+ 'unload the form
+ Unload Me
+
+End Sub
+
+Private Sub mnuFileProperties_Click()
+ 'ToDo: Add 'mnuFileProperties_Click' code.
+ MsgBox "Add 'mnuFileProperties_Click' code."
+End Sub
+
+Private Sub mnuFileRename_Click()
+ 'ToDo: Add 'mnuFileRename_Click' code.
+ MsgBox "Add 'mnuFileRename_Click' code."
+End Sub
+
+Private Sub mnuFileDelete_Click()
+ 'ToDo: Add 'mnuFileDelete_Click' code.
+ MsgBox "Add 'mnuFileDelete_Click' code."
+End Sub
+
+Private Sub mnuFileNew_Click()
+ 'ToDo: Add 'mnuFileNew_Click' code.
+ MsgBox "Add 'mnuFileNew_Click' code."
+End Sub
+
+Private Sub mnuFileSendTo_Click()
+ 'ToDo: Add 'mnuFileSendTo_Click' code.
+ MsgBox "Add 'mnuFileSendTo_Click' code."
+End Sub
+
+Private Sub mnuFileFind_Click()
+ 'ToDo: Add 'mnuFileFind_Click' code.
+ MsgBox "Add 'mnuFileFind_Click' code."
+End Sub
+
+Private Sub mnuFileOpen_Click()
+ Dim sFile As String
+End Sub
+
+Private Sub mnuPopComputerProperties_Click()
+ mnuFileProperties_Click
+End Sub
+
+Private Sub mnuPopNewDatabase_Click()
+ frmNewDatabase1.Show vbModal, Me
+ frmNewDatabase2.Show vbModal, Me
+ frmNewDatabase3.Show vbModal, Me
+End Sub
+
+Private Sub mnuPopAddComputer_Click()
+ frmNewComputer.Show vbModal, Me
+ Dim c As Computer
+ For Each c In frmNewComputer.m_hosts
+ addComputer c
+ g_computers.Add c, "_" & c.m_name
+ Next
+End Sub
+
+Private Sub mnuPopSortComputers_Click()
+ If m_currentNode.Sorted = True Then
+ mnuPopSortComputers.Checked = False
+ m_currentNode.Sorted = False
+ Else
+ mnuPopSortComputers.Checked = True
+ m_currentNode.Sorted = True
+ End If
+End Sub
+
+Private Sub mnuPopRemoveComputer_Click()
+ Dim res As VbMsgBoxResult
+ Dim str As String
+ str = "Remove computer " & m_currentComputer.m_name
+ res = MsgBox(str, vbOKCancel, str)
+ If res = vbOK Then
+ removeComputer (m_currentComputer.m_name)
+ End If
+End Sub
+
+Private Sub mnuPopSortDatabases_Click()
+ If m_currentNode.Sorted = True Then
+ mnuPopSortDatabases.Checked = False
+ m_currentNode.Sorted = False
+ Else
+ mnuPopSortDatabases.Checked = True
+ m_currentNode.Sorted = True
+ End If
+End Sub
+
+Private Sub tvTreeView_BeforeLabelEdit(Cancel As Integer)
+ Cancel = True
+End Sub
+
+Private Sub tvTreeView_Collapse(ByVal Node As MSComctlLib.Node)
+ 'MsgBox "tvTreeView_Collapse"
+End Sub
+
+Private Sub tvTreeView_Expand(ByVal Node As MSComctlLib.Node)
+ 'MsgBox "tvTreeView_Expand"
+End Sub
+
+Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
+ selectNode Node
+End Sub
+
+Private Sub tvTreeView_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
+ 'MsgBox "tvTreeView_MouseUp Button: " & Button & " Shift: " & Shift
+ Dim Node As MSComctlLib.Node
+ Dim place As Integer
+
+ Set Node = tvTreeView.HitTest(X, Y)
+ place = selectNode(Node)
+ If Button = vbRightButton Then
+ ShowPopup place
+ End If
+End Sub
+
+Private Function selectNode(ByRef n As MSComctlLib.Node) As Integer
+ Dim list As ListView
+ Dim place As Integer
+
+ If n Is Nothing Then
+ If Not m_currentNode Is Nothing Then
+ place = 1
+ m_currentNode.Selected = False
+ Else
+ place = 2
+ End If
+ Else
+ n.Selected = True
+ If n.Text = "Computers" Then
+ place = 3
+ Set list = lvComputers
+ lblTitle(1).Caption = "Computers"
+ ElseIf n.Text = "Databases" Then
+ place = 4
+ Set list = lvDatabases
+ lblTitle(1).Caption = "Databases"
+ ElseIf n.Parent.Text = "Computers" Then
+ place = 5
+ Set list = lvProcesses
+ setComputer (n.Key)
+ ElseIf n.Parent.Text = "Databases" Then
+ place = 6
+ Set list = lvProcesses
+ setDatabase (n.Key)
+ End If
+
+ If m_currentList.hwnd <> list.hwnd Then
+ m_currentList.Visible = False
+ list.Visible = True
+ Set m_currentList = list
+ End If
+ End If
+ Set m_currentNode = n
+ selectNode = place
+End Function
+
+Private Sub lvComputers_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
+ Dim li As ListItem
+ Set li = lvComputers.HitTest(X, Y)
+ If Button = vbRightButton And Not li Is Nothing Then
+ Dim c As Computer
+ Set m_currentComputer = g_computers(li.Key)
+ ShowPopup 5
+ End If
+End Sub
+
+Private Sub ShowPopup(ByVal place As Integer)
+ Select Case place
+ Case 3
+ PopupMenu mnuPopComputers
+ Case 4
+ PopupMenu mnuPopDatabases
+ Case 5
+ mnuPopComputerName.Caption = m_currentComputer.m_name & ": " & m_currentComputer.m_status
+ Select Case m_currentComputer.m_status
+ Case "Connected"
+ mnuPopConnectComputer.Enabled = False
+ mnuPopDisconnectComputer.Enabled = True
+ Case "Connecting"
+ mnuPopConnectComputer.Enabled = False
+ mnuPopDisconnectComputer.Enabled = True
+ Case "Not connected"
+ mnuPopConnectComputer.Enabled = True
+ mnuPopDisconnectComputer.Enabled = False
+ Case "No contact"
+ mnuPopConnectComputer.Enabled = True
+ mnuPopDisconnectComputer.Enabled = False
+ Case Else
+ mnuPopConnectComputer.Enabled = False
+ mnuPopDisconnectComputer.Enabled = False
+ End Select
+
+ PopupMenu mnuPopComputer, , , , mnuPopComputerName
+ End Select
+End Sub
+
+Private Sub lvComputers_BeforeLabelEdit(Cancel As Integer)
+ Cancel = True
+End Sub
+
+Private Sub lvProcesses_BeforeLabelEdit(Cancel As Integer)
+ Cancel = True
+End Sub
+
+Private Sub lvDatabases_BeforeLabelEdit(Cancel As Integer)
+ Cancel = True
+End Sub
+
+Private Sub ColumnClick(ByRef list As ListView, i As Integer)
+ i = i - 1
+ If list.SortKey = i Then
+ list.SortOrder = 1 - list.SortOrder
+ Else
+ list.SortKey = i
+ End If
+End Sub
+
+Private Sub lvComputers_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
+ ColumnClick lvComputers, ColumnHeader.Index
+End Sub
+
+Private Sub lvProcesses_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
+ ColumnClick lvProcesses, ColumnHeader.Index
+End Sub
+
+Private Sub lvDatabases_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
+ ColumnClick lvDatabases, ColumnHeader.Index
+End Sub
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frm
new file mode 100644
index 00000000000..eae5802493c
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frm
@@ -0,0 +1,124 @@
+VERSION 5.00
+Begin VB.Form frmNewComputer
+ Caption = "Add computer"
+ ClientHeight = 1545
+ ClientLeft = 60
+ ClientTop = 345
+ ClientWidth = 4605
+ LinkTopic = "Form1"
+ ScaleHeight = 1545
+ ScaleWidth = 4605
+ StartUpPosition = 3 'Windows Default
+ Begin VB.CommandButton Command3
+ Caption = "Apply"
+ Default = -1 'True
+ Height = 360
+ Left = 3240
+ TabIndex = 4
+ Tag = "OK"
+ Top = 840
+ Width = 1140
+ End
+ Begin VB.CommandButton Command2
+ Caption = "Cancel"
+ Height = 360
+ Left = 1920
+ TabIndex = 3
+ Tag = "OK"
+ Top = 840
+ Width = 1140
+ End
+ Begin VB.CommandButton Command1
+ Caption = "OK"
+ Height = 360
+ Left = 600
+ TabIndex = 2
+ Tag = "OK"
+ Top = 840
+ Width = 1140
+ End
+ Begin VB.TextBox Text1
+ Height = 285
+ Left = 1440
+ TabIndex = 1
+ Top = 240
+ Width = 2925
+ End
+ Begin VB.Label lblLabels
+ Caption = "Computer name:"
+ Height = 255
+ Index = 1
+ Left = 120
+ TabIndex = 0
+ Tag = "&User Name:"
+ Top = 240
+ Width = 1440
+ End
+End
+Attribute VB_Name = "frmNewComputer"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Public m_hosts As New Collection
+
+Private Sub Form_Load()
+ If m_hosts.Count > 0 Then
+ For i = m_hosts.Count To 1 Step -1
+ m_hosts.Remove i
+ Next
+ End If
+End Sub
+
+Private Sub Command1_Click()
+ If Text1.Text = "" Then
+ MsgBox "Invalid hostname"
+ Exit Sub
+ End If
+
+ If Exists(g_computers, "_" & Text1.Text) Then
+ MsgBox Text1.Text & " already exists"
+ Exit Sub
+ End If
+
+ Dim c As New Computer
+ With c
+ .m_ip = ""
+ .m_name = Text1.Text
+ .m_status = "Not connected"
+ Set .m_processes = New Collection
+ End With
+
+ m_hosts.Add c
+
+ Unload Me
+End Sub
+
+Private Sub Command2_Click()
+ Unload Me
+End Sub
+
+Private Sub Command3_Click()
+ If Text1.Text = "" Then
+ MsgBox "Invalid hostname"
+ Exit Sub
+ End If
+
+ If Exists(g_computers, "_" & Text1.Text) Then
+ MsgBox Text1.Text & " already exists"
+ Exit Sub
+ End If
+
+ Dim c As New Computer
+ With c
+ .m_ip = ""
+ .m_name = Text1.Text
+ .m_status = "Not connected"
+ Set .m_processes = New Collection
+ End With
+
+ m_hosts.Add c
+
+ Text1.Text = ""
+End Sub
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frx b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frx
new file mode 100644
index 00000000000..593f4708db8
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewComputer.frx
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase.frx b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase.frx
new file mode 100644
index 00000000000..b20c2b651ae
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase.frx
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase1.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase1.frm
new file mode 100644
index 00000000000..3fa1fd4c4e8
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase1.frm
@@ -0,0 +1,187 @@
+VERSION 5.00
+Begin VB.Form frmNewDatabase1
+ BorderStyle = 5 'Sizable ToolWindow
+ Caption = "Nodes"
+ ClientHeight = 3000
+ ClientLeft = 2850
+ ClientTop = 3450
+ ClientWidth = 6240
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 3281.25
+ ScaleMode = 0 'User
+ ScaleWidth = 6359.712
+ ShowInTaskbar = 0 'False
+ StartUpPosition = 2 'CenterScreen
+ Begin VB.TextBox textApiNodes
+ Height = 285
+ Left = 2760
+ TabIndex = 12
+ Text = "4"
+ Top = 1665
+ Width = 375
+ End
+ Begin VB.VScrollBar VScroll1
+ Height = 255
+ Left = 3240
+ TabIndex = 11
+ Top = 1680
+ Width = 135
+ End
+ Begin VB.OptionButton Option4
+ Alignment = 1 'Right Justify
+ Caption = "1"
+ Height = 375
+ Left = 2760
+ TabIndex = 10
+ Top = 1020
+ Width = 375
+ End
+ Begin VB.OptionButton Option3
+ Alignment = 1 'Right Justify
+ Caption = "4"
+ Height = 375
+ Left = 3960
+ TabIndex = 9
+ Top = 360
+ Width = 375
+ End
+ Begin VB.OptionButton Option2
+ Alignment = 1 'Right Justify
+ Caption = "2"
+ Height = 375
+ Left = 3360
+ TabIndex = 8
+ Top = 360
+ Width = 375
+ End
+ Begin VB.OptionButton Option1
+ Alignment = 1 'Right Justify
+ Caption = "1"
+ Height = 375
+ Left = 2760
+ TabIndex = 7
+ Top = 360
+ Value = -1 'True
+ Width = 375
+ End
+ Begin VB.CommandButton cmdCancel
+ Cancel = -1 'True
+ Caption = "Cancel"
+ Height = 305
+ Left = 1320
+ TabIndex = 3
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdFinish
+ Caption = "Finish"
+ Enabled = 0 'False
+ Height = 305
+ Left = 5040
+ TabIndex = 2
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdBack
+ Caption = "Back"
+ Default = -1 'True
+ Enabled = 0 'False
+ Height = 305
+ Left = 2640
+ TabIndex = 0
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdNext
+ Caption = "Next"
+ Height = 305
+ Left = 3720
+ TabIndex = 1
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.Label Label3
+ Caption = "No of api nodes"
+ Height = 255
+ Left = 240
+ TabIndex = 6
+ Top = 1680
+ Width = 2415
+ End
+ Begin VB.Label Label2
+ Caption = "No of management nodes"
+ Height = 255
+ Left = 240
+ TabIndex = 5
+ Top = 1080
+ Width = 2415
+ End
+ Begin VB.Label Label1
+ Caption = "No of database nodes"
+ Height = 255
+ Left = 240
+ TabIndex = 4
+ Top = 420
+ Width = 2415
+ End
+ Begin VB.Line Line1
+ BorderColor = &H80000003&
+ X1 = 122.302
+ X2 = 6237.41
+ Y1 = 2493.75
+ Y2 = 2493.75
+ End
+End
+Attribute VB_Name = "frmNewDatabase1"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Option Explicit
+
+Private Sub Form_Resize()
+ If Me.Width < 6375 Then Me.Width = 6375
+ cmdCancel.Left = Me.ScaleWidth - 5136 + 400
+ cmdBack.Left = Me.ScaleWidth - 3897 + 400
+ cmdNext.Left = Me.ScaleWidth - 2883 + 400
+ cmdFinish.Left = Me.ScaleWidth - 1643 + 400
+ Line1.X2 = Me.ScaleWidth - 480 + 400
+
+ cmdCancel.Top = Me.ScaleHeight - 375
+ cmdBack.Top = Me.ScaleHeight - 375
+ cmdNext.Top = Me.ScaleHeight - 375
+ cmdFinish.Top = Me.ScaleHeight - 375
+ Line1.Y1 = Me.ScaleHeight - 475
+ Line1.Y2 = Me.ScaleHeight - 475
+End Sub
+
+Private Sub cmdCancel_Click()
+ 'set the global var to false
+ 'to denote a failed login
+ Unload Me
+End Sub
+
+Private Sub Option1_Click()
+ Option2.Value = False
+ Option3.Value = False
+End Sub
+
+Private Sub Option2_Click()
+ Option1.Value = False
+ Option3.Value = False
+End Sub
+
+Private Sub Option3_Click()
+ Option1.Value = False
+ Option2.Value = False
+End Sub
+
+Private Sub Option4_Click()
+ Option4.Value = True
+End Sub
+
+Private Sub textApiNodes_Validate(Cancel As Boolean)
+ 'If Not isnumber(textApiNodes.Text) Then Cancel = False
+End Sub
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.frm
new file mode 100644
index 00000000000..49806a695ea
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.frm
@@ -0,0 +1,136 @@
+VERSION 5.00
+Begin VB.Form frmNewDatabase2
+ BorderStyle = 5 'Sizable ToolWindow
+ Caption = "Computers"
+ ClientHeight = 2895
+ ClientLeft = 2850
+ ClientTop = 3450
+ ClientWidth = 6240
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 3166.406
+ ScaleMode = 0 'User
+ ScaleWidth = 6359.712
+ ShowInTaskbar = 0 'False
+ StartUpPosition = 2 'CenterScreen
+ Begin VB.ComboBox Combo1
+ Height = 315
+ Left = 2400
+ TabIndex = 7
+ Text = "Combo1"
+ Top = 360
+ Width = 1455
+ End
+ Begin VB.VScrollBar VScroll2
+ Height = 255
+ Left = 4560
+ TabIndex = 6
+ Top = 375
+ Width = 135
+ End
+ Begin VB.TextBox Text1
+ Height = 285
+ Left = 4080
+ TabIndex = 5
+ Text = "4"
+ Top = 360
+ Width = 375
+ End
+ Begin VB.CommandButton cmdCancel
+ Cancel = -1 'True
+ Caption = "Cancel"
+ Height = 305
+ Left = 1320
+ TabIndex = 3
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdFinish
+ Caption = "Finish"
+ Enabled = 0 'False
+ Height = 305
+ Left = 5040
+ TabIndex = 2
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdBack
+ Caption = "Back"
+ Default = -1 'True
+ Enabled = 0 'False
+ Height = 305
+ Left = 2640
+ TabIndex = 0
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdNext
+ Caption = "Next"
+ Height = 305
+ Left = 3720
+ TabIndex = 1
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.Label Label5
+ Caption = "Computer"
+ Height = 255
+ Left = 2400
+ TabIndex = 9
+ Top = 0
+ Width = 975
+ End
+ Begin VB.Label Label4
+ Caption = "Node id"
+ Height = 255
+ Left = 4080
+ TabIndex = 8
+ Top = 120
+ Width = 615
+ End
+ Begin VB.Label Label1
+ Caption = "Database node 1"
+ Height = 255
+ Left = 240
+ TabIndex = 4
+ Top = 420
+ Width = 2415
+ End
+ Begin VB.Line Line1
+ BorderColor = &H80000003&
+ X1 = 122.302
+ X2 = 6237.41
+ Y1 = 2493.75
+ Y2 = 2493.75
+ End
+End
+Attribute VB_Name = "frmNewDatabase2"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Option Explicit
+
+Private Sub Form_Resize()
+ If Me.Width < 6375 Then Me.Width = 6375
+ cmdCancel.Left = Me.ScaleWidth - 5136 + 400
+ cmdBack.Left = Me.ScaleWidth - 3897 + 400
+ cmdNext.Left = Me.ScaleWidth - 2883 + 400
+ cmdFinish.Left = Me.ScaleWidth - 1643 + 400
+ Line1.X2 = Me.ScaleWidth - 480 + 400
+
+ cmdCancel.Top = Me.ScaleHeight - 375
+ cmdBack.Top = Me.ScaleHeight - 375
+ cmdNext.Top = Me.ScaleHeight - 375
+ cmdFinish.Top = Me.ScaleHeight - 375
+ Line1.Y1 = Me.ScaleHeight - 475
+ Line1.Y2 = Me.ScaleHeight - 475
+End Sub
+
+Private Sub cmdCancel_Click()
+ 'set the global var to false
+ 'to denote a failed login
+ Unload Me
+End Sub
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.log b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.log
new file mode 100644
index 00000000000..808b21866e5
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase2.log
@@ -0,0 +1 @@
+Line 2: The Form or MDIForm name frmNewDatabase1 is already in use; cannot load this form.
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase3.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase3.frm
new file mode 100644
index 00000000000..ba050a58a09
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmNewDatabase3.frm
@@ -0,0 +1,88 @@
+VERSION 5.00
+Begin VB.Form frmNewDatabase3
+ BorderStyle = 5 'Sizable ToolWindow
+ Caption = "Database configuration"
+ ClientHeight = 3000
+ ClientLeft = 2850
+ ClientTop = 3450
+ ClientWidth = 6240
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 3281.25
+ ScaleMode = 0 'User
+ ScaleWidth = 6359.712
+ ShowInTaskbar = 0 'False
+ StartUpPosition = 2 'CenterScreen
+ Begin VB.CommandButton cmdCancel
+ Cancel = -1 'True
+ Caption = "Cancel"
+ Height = 305
+ Left = 1320
+ TabIndex = 3
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdFinish
+ Caption = "Finish"
+ Enabled = 0 'False
+ Height = 305
+ Left = 5040
+ TabIndex = 2
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdBack
+ Caption = "Back"
+ Default = -1 'True
+ Enabled = 0 'False
+ Height = 305
+ Left = 2640
+ TabIndex = 0
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.CommandButton cmdNext
+ Caption = "Next"
+ Height = 305
+ Left = 3720
+ TabIndex = 1
+ Top = 2400
+ Width = 1140
+ End
+ Begin VB.Line Line1
+ BorderColor = &H80000003&
+ X1 = 122.302
+ X2 = 6237.41
+ Y1 = 2493.75
+ Y2 = 2493.75
+ End
+End
+Attribute VB_Name = "frmNewDatabase3"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Option Explicit
+
+Private Sub Form_Resize()
+ If Me.Width < 6375 Then Me.Width = 6375
+ cmdCancel.Left = Me.ScaleWidth - 5136 + 400
+ cmdBack.Left = Me.ScaleWidth - 3897 + 400
+ cmdNext.Left = Me.ScaleWidth - 2883 + 400
+ cmdFinish.Left = Me.ScaleWidth - 1643 + 400
+ Line1.X2 = Me.ScaleWidth - 480 + 400
+
+ cmdCancel.Top = Me.ScaleHeight - 375
+ cmdBack.Top = Me.ScaleHeight - 375
+ cmdNext.Top = Me.ScaleHeight - 375
+ cmdFinish.Top = Me.ScaleHeight - 375
+ Line1.Y1 = Me.ScaleHeight - 475
+ Line1.Y2 = Me.ScaleHeight - 475
+End Sub
+
+Private Sub cmdCancel_Click()
+ 'set the global var to false
+ 'to denote a failed login
+ Unload Me
+End Sub
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmOptions.frm b/storage/ndb/src/cw/cpcc-win32/vb6/frmOptions.frm
new file mode 100644
index 00000000000..e526a35b3ec
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmOptions.frm
@@ -0,0 +1,231 @@
+VERSION 5.00
+Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
+Begin VB.Form frmOptions
+ BorderStyle = 3 'Fixed Dialog
+ Caption = "Options"
+ ClientHeight = 5040
+ ClientLeft = 6600
+ ClientTop = 4575
+ ClientWidth = 6150
+ KeyPreview = -1 'True
+ LinkTopic = "Form1"
+ MaxButton = 0 'False
+ MinButton = 0 'False
+ ScaleHeight = 5040
+ ScaleWidth = 6150
+ ShowInTaskbar = 0 'False
+ Tag = "Options"
+ Begin VB.CommandButton cmdOK
+ Caption = "OK"
+ Height = 375
+ Left = 2490
+ TabIndex = 1
+ Tag = "OK"
+ Top = 4455
+ Width = 1095
+ End
+ Begin VB.CommandButton cmdCancel
+ Cancel = -1 'True
+ Caption = "Cancel"
+ Height = 375
+ Left = 3720
+ TabIndex = 3
+ Tag = "Cancel"
+ Top = 4455
+ Width = 1095
+ End
+ Begin VB.CommandButton cmdApply
+ Caption = "&Apply"
+ Height = 375
+ Left = 4920
+ TabIndex = 5
+ Tag = "&Apply"
+ Top = 4455
+ Width = 1095
+ End
+ Begin VB.PictureBox picOptions
+ BorderStyle = 0 'None
+ Height = 3780
+ Index = 3
+ Left = -20000
+ ScaleHeight = 3840.968
+ ScaleMode = 0 'User
+ ScaleWidth = 5745.64
+ TabIndex = 7
+ TabStop = 0 'False
+ Top = 480
+ Width = 5685
+ Begin VB.Frame fraSample4
+ Caption = "Sample 4"
+ Height = 2022
+ Left = 505
+ TabIndex = 11
+ Tag = "Sample 4"
+ Top = 502
+ Width = 2033
+ End
+ End
+ Begin VB.PictureBox picOptions
+ BorderStyle = 0 'None
+ Height = 3780
+ Index = 2
+ Left = -20000
+ ScaleHeight = 3840.968
+ ScaleMode = 0 'User
+ ScaleWidth = 5745.64
+ TabIndex = 9
+ TabStop = 0 'False
+ Top = 480
+ Width = 5685
+ Begin VB.Frame fraSample3
+ Caption = "Sample 3"
+ Height = 2022
+ Left = 406
+ TabIndex = 10
+ Tag = "Sample 3"
+ Top = 403
+ Width = 2033
+ End
+ End
+ Begin VB.PictureBox picOptions
+ BorderStyle = 0 'None
+ Height = 3780
+ Index = 1
+ Left = -20000
+ ScaleHeight = 3840.968
+ ScaleMode = 0 'User
+ ScaleWidth = 5745.64
+ TabIndex = 6
+ TabStop = 0 'False
+ Top = 480
+ Width = 5685
+ Begin VB.Frame fraSample2
+ Caption = "Sample 2"
+ Height = 2022
+ Left = 307
+ TabIndex = 8
+ Tag = "Sample 2"
+ Top = 305
+ Width = 2033
+ End
+ End
+ Begin VB.PictureBox picOptions
+ BorderStyle = 0 'None
+ Height = 3780
+ Index = 0
+ Left = 210
+ ScaleHeight = 3840.968
+ ScaleMode = 0 'User
+ ScaleWidth = 5745.64
+ TabIndex = 2
+ TabStop = 0 'False
+ Top = 480
+ Width = 5685
+ Begin VB.Frame fraSample1
+ Caption = "Sample 1"
+ Height = 2022
+ Left = 208
+ TabIndex = 4
+ Tag = "Sample 1"
+ Top = 207
+ Width = 2033
+ End
+ End
+ Begin MSComctlLib.TabStrip tbsOptions
+ Height = 4245
+ Left = 105
+ TabIndex = 0
+ Top = 120
+ Width = 5895
+ _ExtentX = 10398
+ _ExtentY = 7488
+ _Version = 393216
+ BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628}
+ NumTabs = 4
+ BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628}
+ Caption = "Group 1"
+ ImageVarType = 2
+ EndProperty
+ BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628}
+ Caption = "Group 2"
+ ImageVarType = 2
+ EndProperty
+ BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628}
+ Caption = "Group 3"
+ ImageVarType = 2
+ EndProperty
+ BeginProperty Tab4 {1EFB659A-857C-11D1-B16A-00C0F0283628}
+ Caption = "Group 4"
+ ImageVarType = 2
+ EndProperty
+ EndProperty
+ End
+End
+Attribute VB_Name = "frmOptions"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = False
+Attribute VB_PredeclaredId = True
+Attribute VB_Exposed = False
+Private Sub cmdApply_Click()
+ 'ToDo: Add 'cmdApply_Click' code.
+ MsgBox "Apply Code goes here to set options w/o closing dialog!"
+End Sub
+
+
+Private Sub cmdCancel_Click()
+ Unload Me
+End Sub
+
+
+Private Sub cmdOK_Click()
+ 'ToDo: Add 'cmdOK_Click' code.
+ MsgBox "Code goes here to set options and close dialog!"
+ Unload Me
+End Sub
+
+
+Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
+ Dim i As Integer
+ i = tbsOptions.SelectedItem.Index
+ 'handle ctrl+tab to move to the next tab
+ If (Shift And 3) = 2 And KeyCode = vbKeyTab Then
+ If i = tbsOptions.Tabs.Count Then
+ 'last tab so we need to wrap to tab 1
+ Set tbsOptions.SelectedItem = tbsOptions.Tabs(1)
+ Else
+ 'increment the tab
+ Set tbsOptions.SelectedItem = tbsOptions.Tabs(i + 1)
+ End If
+ ElseIf (Shift And 3) = 3 And KeyCode = vbKeyTab Then
+ If i = 1 Then
+ 'last tab so we need to wrap to tab 1
+ Set tbsOptions.SelectedItem = tbsOptions.Tabs(tbsOptions.Tabs.Count)
+ Else
+ 'increment the tab
+ Set tbsOptions.SelectedItem = tbsOptions.Tabs(i - 1)
+ End If
+ End If
+End Sub
+
+
+
+
+Private Sub tbsOptions_Click()
+
+
+ Dim i As Integer
+ 'show and enable the selected tab's controls
+ 'and hide and disable all others
+ For i = 0 To tbsOptions.Tabs.Count - 1
+ If i = tbsOptions.SelectedItem.Index - 1 Then
+ picOptions(i).Left = 210
+ picOptions(i).Enabled = True
+ Else
+ picOptions(i).Left = -20000
+ picOptions(i).Enabled = False
+ End If
+ Next
+
+
+End Sub
+
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/frmSplash.frx b/storage/ndb/src/cw/cpcc-win32/vb6/frmSplash.frx
new file mode 100644
index 00000000000..fee0c5c59de
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/frmSplash.frx
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/networking.ico b/storage/ndb/src/cw/cpcc-win32/vb6/networking.ico
new file mode 100644
index 00000000000..6bbf8022fc6
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/networking.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcc-win32/vb6/open folder.ico b/storage/ndb/src/cw/cpcc-win32/vb6/open folder.ico
new file mode 100644
index 00000000000..7bb32cc83d3
--- /dev/null
+++ b/storage/ndb/src/cw/cpcc-win32/vb6/open folder.ico
Binary files differ
diff --git a/storage/ndb/src/cw/cpcd/APIService.cpp b/storage/ndb/src/cw/cpcd/APIService.cpp
new file mode 100644
index 00000000000..63d0aaafe86
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/APIService.cpp
@@ -0,0 +1,386 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+#include <Parser.hpp>
+#include <NdbOut.hpp>
+#include <Properties.hpp>
+#include <socket_io.h>
+
+#include "APIService.hpp"
+#include "CPCD.hpp"
+#include <NdbMutex.h>
+#include <OutputStream.hpp>
+
+/**
+ const char * name;
+ const char * realName;
+ const Type type;
+ const ArgType argType;
+ const ArgRequired argRequired;
+ const ArgMinMax argMinMax;
+ const int minVal;
+ const int maxVal;
+ void (T::* function)(const class Properties & args);
+ const char * description;
+*/
+
+#define CPCD_CMD(name, fun, desc) \
+ { name, \
+ 0, \
+ ParserRow<CPCDAPISession>::Cmd, \
+ ParserRow<CPCDAPISession>::String, \
+ ParserRow<CPCDAPISession>::Optional, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ 0, 0, \
+ fun, \
+ desc, 0 }
+
+#define CPCD_ARG(name, type, opt, desc) \
+ { name, \
+ 0, \
+ ParserRow<CPCDAPISession>::Arg, \
+ ParserRow<CPCDAPISession>::type, \
+ ParserRow<CPCDAPISession>::opt, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ 0, 0, \
+ 0, \
+ desc, 0 }
+
+#define CPCD_ARG2(name, type, opt, min, max, desc) \
+ { name, \
+ 0, \
+ ParserRow<CPCDAPISession>::Arg, \
+ ParserRow<CPCDAPISession>::type, \
+ ParserRow<CPCDAPISession>::opt, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ min, max, \
+ 0, \
+ desc, 0 }
+
+#define CPCD_END() \
+ { 0, \
+ 0, \
+ ParserRow<CPCDAPISession>::Arg, \
+ ParserRow<CPCDAPISession>::Int, \
+ ParserRow<CPCDAPISession>::Optional, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ 0, 0, \
+ 0, \
+ 0, 0 }
+
+#define CPCD_CMD_ALIAS(name, realName, fun) \
+ { name, \
+ realName, \
+ ParserRow<CPCDAPISession>::CmdAlias, \
+ ParserRow<CPCDAPISession>::Int, \
+ ParserRow<CPCDAPISession>::Optional, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ 0, 0, \
+ 0, \
+ 0, 0 }
+
+#define CPCD_ARG_ALIAS(name, realName, fun) \
+ { name, \
+ realName, \
+ ParserRow<CPCDAPISession>::ArgAlias, \
+ ParserRow<CPCDAPISession>::Int, \
+ ParserRow<CPCDAPISession>::Optional, \
+ ParserRow<CPCDAPISession>::IgnoreMinMax, \
+ 0, 0, \
+ 0, \
+ 0, 0 }
+
+const
+ParserRow<CPCDAPISession> commands[] =
+{
+ CPCD_CMD("define process" , &CPCDAPISession::defineProcess, ""),
+ CPCD_ARG("id", Int, Optional, "Id of process."),
+ CPCD_ARG("name", String, Mandatory, "Name of process"),
+ CPCD_ARG("group", String, Mandatory, "Group of process"),
+ CPCD_ARG("env", String, Optional, "Environment variables for process"),
+ CPCD_ARG("path", String, Mandatory, "Path to binary"),
+ CPCD_ARG("args", String, Optional, "Arguments to process"),
+ CPCD_ARG("type", String, Mandatory, "Type of process"),
+ CPCD_ARG("cwd", String, Mandatory, "Working directory of process"),
+ CPCD_ARG("owner", String, Mandatory, "Owner of process"),
+ CPCD_ARG("runas", String, Optional, "Run as user"),
+ CPCD_ARG("stdout", String, Optional, "Redirection of stdout"),
+ CPCD_ARG("stderr", String, Optional, "Redirection of stderr"),
+ CPCD_ARG("stdin", String, Optional, "Redirection of stderr"),
+ CPCD_ARG("ulimit", String, Optional, "ulimit"),
+
+ CPCD_CMD("undefine process", &CPCDAPISession::undefineProcess, ""),
+ CPCD_CMD_ALIAS("undef", "undefine process", 0),
+ CPCD_ARG("id", Int, Mandatory, "Id of process"),
+ CPCD_ARG_ALIAS("i", "id", 0),
+
+ CPCD_CMD("start process", &CPCDAPISession::startProcess, ""),
+ CPCD_ARG("id", Int, Mandatory, "Id of process"),
+
+ CPCD_CMD("stop process", &CPCDAPISession::stopProcess, ""),
+ CPCD_ARG("id", Int, Mandatory, "Id of process"),
+
+ CPCD_CMD("list processes", &CPCDAPISession::listProcesses, ""),
+
+ CPCD_END()
+};
+CPCDAPISession::CPCDAPISession(NDB_SOCKET_TYPE sock,
+ CPCD & cpcd)
+ : SocketServer::Session(sock)
+ , m_cpcd(cpcd)
+{
+ m_input = new SocketInputStream(sock);
+ m_output = new SocketOutputStream(sock);
+ m_parser = new Parser<CPCDAPISession>(commands, *m_input, true, true, true);
+}
+
+CPCDAPISession::CPCDAPISession(FILE * f, CPCD & cpcd)
+ : SocketServer::Session(1)
+ , m_cpcd(cpcd)
+{
+ m_input = new FileInputStream(f);
+ m_parser = new Parser<CPCDAPISession>(commands, *m_input, true, true, true);
+}
+
+CPCDAPISession::~CPCDAPISession() {
+ delete m_input;
+ delete m_parser;
+}
+
+void
+CPCDAPISession::runSession(){
+ Parser_t::Context ctx;
+ while(!m_stop){
+ m_parser->run(ctx, * this);
+ if(ctx.m_currentToken == 0)
+ break;
+
+ switch(ctx.m_status){
+ case Parser_t::Ok:
+ for(size_t i = 0; i<ctx.m_aliasUsed.size(); i++)
+ ndbout_c("Used alias: %s -> %s",
+ ctx.m_aliasUsed[i]->name, ctx.m_aliasUsed[i]->realName);
+ break;
+ case Parser_t::NoLine:
+ case Parser_t::EmptyLine:
+ break;
+ default:
+ break;
+ }
+ }
+ NDB_CLOSE_SOCKET(m_socket);
+}
+
+void
+CPCDAPISession::stopSession(){
+ CPCD::RequestStatus rs;
+ for(size_t i = 0; i<m_temporaryProcesses.size(); i++){
+ Uint32 id = m_temporaryProcesses[i];
+ m_cpcd.undefineProcess(&rs, id);
+ }
+}
+
+void
+CPCDAPISession::loadFile(){
+ Parser_t::Context ctx;
+ while(!m_stop){
+ m_parser->run(ctx, * this);
+ if(ctx.m_currentToken == 0)
+ break;
+
+ switch(ctx.m_status){
+ case Parser_t::Ok:
+ for(size_t i = 0; i<ctx.m_aliasUsed.size(); i++)
+ ndbout_c("Used alias: %s -> %s",
+ ctx.m_aliasUsed[i]->name, ctx.m_aliasUsed[i]->realName);
+ break;
+ case Parser_t::NoLine:
+ case Parser_t::EmptyLine:
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static const int g_TimeOut = 1000;
+
+void
+CPCDAPISession::defineProcess(Parser_t::Context & /* unused */,
+ const class Properties & args){
+
+ CPCD::Process * p = new CPCD::Process(args, &m_cpcd);
+
+ CPCD::RequestStatus rs;
+
+ bool ret = m_cpcd.defineProcess(&rs, p);
+ if(!m_cpcd.loadingProcessList) {
+ m_output->println("define process");
+ m_output->println("status: %d", rs.getStatus());
+ if(ret == true){
+ m_output->println("id: %d", p->m_id);
+ if(p->m_processType == TEMPORARY){
+ m_temporaryProcesses.push_back(p->m_id);
+ }
+ } else {
+ m_output->println("errormessage: %s", rs.getErrMsg());
+ }
+ m_output->println("");
+ }
+}
+
+void
+CPCDAPISession::undefineProcess(Parser_t::Context & /* unused */,
+ const class Properties & args){
+ Uint32 id;
+ CPCD::RequestStatus rs;
+
+ args.get("id", &id);
+ bool ret = m_cpcd.undefineProcess(&rs, id);
+
+ m_output->println("undefine process");
+ m_output->println("id: %d", id);
+ m_output->println("status: %d", rs.getStatus());
+ if(!ret)
+ m_output->println("errormessage: %s", rs.getErrMsg());
+
+ m_output->println("");
+}
+
+void
+CPCDAPISession::startProcess(Parser_t::Context & /* unused */,
+ const class Properties & args){
+ Uint32 id;
+ CPCD::RequestStatus rs;
+
+ args.get("id", &id);
+ const int ret = m_cpcd.startProcess(&rs, id);
+
+ if(!m_cpcd.loadingProcessList) {
+ m_output->println("start process");
+ m_output->println("id: %d", id);
+ m_output->println("status: %d", rs.getStatus());
+ if(!ret)
+ m_output->println("errormessage: %s", rs.getErrMsg());
+ m_output->println("");
+ }
+}
+
+void
+CPCDAPISession::stopProcess(Parser_t::Context & /* unused */,
+ const class Properties & args){
+ Uint32 id;
+ CPCD::RequestStatus rs;
+
+ args.get("id", &id);
+ int ret = m_cpcd.stopProcess(&rs, id);
+
+ m_output->println("stop process");
+ m_output->println("id: %d", id);
+ m_output->println("status: %d", rs.getStatus());
+ if(!ret)
+ m_output->println("errormessage: %s", rs.getErrMsg());
+
+ m_output->println("");
+}
+
+static const char *
+propToString(Properties *prop, const char *key) {
+ static char buf[32];
+ const char *retval = NULL;
+ PropertiesType pt;
+
+ prop->getTypeOf(key, &pt);
+ switch(pt) {
+ case PropertiesType_Uint32:
+ Uint32 val;
+ prop->get(key, &val);
+ BaseString::snprintf(buf, sizeof buf, "%d", val);
+ retval = buf;
+ break;
+ case PropertiesType_char:
+ const char *str;
+ prop->get(key, &str);
+ retval = str;
+ break;
+ default:
+ BaseString::snprintf(buf, sizeof buf, "(unknown)");
+ retval = buf;
+ }
+ return retval;
+}
+
+void
+CPCDAPISession::printProperty(Properties *prop, const char *key) {
+ m_output->println("%s: %s", key, propToString(prop, key));
+}
+
+void
+CPCDAPISession::listProcesses(Parser_t::Context & /* unused */,
+ const class Properties & /* unused */){
+ m_cpcd.m_processes.lock();
+ MutexVector<CPCD::Process *> *proclist = m_cpcd.getProcessList();
+
+ m_output->println("start processes");
+ m_output->println("");
+
+
+ for(size_t i = 0; i < proclist->size(); i++) {
+ CPCD::Process *p = (*proclist)[i];
+
+ m_output->println("process");
+
+ m_output->println("id: %d", p->m_id);
+ m_output->println("name: %s", p->m_name.c_str());
+ m_output->println("path: %s", p->m_path.c_str());
+ m_output->println("args: %s", p->m_args.c_str());
+ m_output->println("type: %s", p->m_type.c_str());
+ m_output->println("cwd: %s", p->m_cwd.c_str());
+ m_output->println("env: %s", p->m_env.c_str());
+ m_output->println("owner: %s", p->m_owner.c_str());
+ m_output->println("group: %s", p->m_group.c_str());
+ m_output->println("runas: %s", p->m_runas.c_str());
+ m_output->println("stdin: %s", p->m_stdin.c_str());
+ m_output->println("stdout: %s", p->m_stdout.c_str());
+ m_output->println("stderr: %s", p->m_stderr.c_str());
+ m_output->println("ulimit: %s", p->m_ulimit.c_str());
+ switch(p->m_status){
+ case STOPPED:
+ m_output->println("status: stopped");
+ break;
+ case STARTING:
+ m_output->println("status: starting");
+ break;
+ case RUNNING:
+ m_output->println("status: running");
+ break;
+ case STOPPING:
+ m_output->println("status: stopping");
+ break;
+ }
+
+ m_output->println("");
+
+ }
+
+ m_output->println("end processes");
+ m_output->println("");
+
+ m_cpcd.m_processes.unlock();
+}
+
+template class Vector<ParserRow<CPCDAPISession> const*>;
diff --git a/storage/ndb/src/cw/cpcd/APIService.hpp b/storage/ndb/src/cw/cpcd/APIService.hpp
new file mode 100644
index 00000000000..ef988785f89
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/APIService.hpp
@@ -0,0 +1,64 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 CPCD_API_HPP
+#define CPCD_API_HPP
+
+#include <Parser.hpp>
+#include <InputStream.hpp>
+#include <SocketServer.hpp>
+
+class CPCD;
+
+class CPCDAPISession : public SocketServer::Session {
+ typedef Parser<CPCDAPISession> Parser_t;
+
+ class CPCD & m_cpcd;
+ InputStream *m_input;
+ OutputStream *m_output;
+ Parser_t *m_parser;
+
+ Vector<int> m_temporaryProcesses;
+
+ void printProperty(Properties *prop, const char *key);
+public:
+ CPCDAPISession(NDB_SOCKET_TYPE, class CPCD &);
+ CPCDAPISession(FILE * f, CPCD & cpcd);
+ ~CPCDAPISession();
+
+ virtual void runSession();
+ virtual void stopSession();
+ void loadFile();
+
+ void defineProcess(Parser_t::Context & ctx, const class Properties & args);
+ void undefineProcess(Parser_t::Context & ctx, const class Properties & args);
+ void startProcess(Parser_t::Context & ctx, const class Properties & args);
+ void stopProcess(Parser_t::Context & ctx, const class Properties & args);
+ void showProcess(Parser_t::Context & ctx, const class Properties & args);
+ void listProcesses(Parser_t::Context & ctx, const class Properties & args);
+};
+
+class CPCDAPIService : public SocketServer::Service {
+ class CPCD & m_cpcd;
+public:
+ CPCDAPIService(class CPCD & cpcd) : m_cpcd(cpcd) {}
+
+ CPCDAPISession * newSession(NDB_SOCKET_TYPE theSock){
+ return new CPCDAPISession(theSock, m_cpcd);
+ }
+};
+
+#endif
diff --git a/storage/ndb/src/cw/cpcd/CPCD.cpp b/storage/ndb/src/cw/cpcd/CPCD.cpp
new file mode 100644
index 00000000000..69a7b840528
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/CPCD.cpp
@@ -0,0 +1,435 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+#include <ndb_global.h>
+#include <NdbOut.hpp>
+
+#include "APIService.hpp"
+#include "CPCD.hpp"
+#include <NdbMutex.h>
+
+#include "common.hpp"
+
+extern const ParserRow<CPCDAPISession> commands[];
+
+
+CPCD::CPCD() {
+ loadingProcessList = false;
+ m_processes.clear();
+ m_monitor = NULL;
+ m_monitor = new Monitor(this);
+ m_procfile = "ndb_cpcd.db";
+}
+
+CPCD::~CPCD() {
+ if(m_monitor != NULL) {
+ delete m_monitor;
+ m_monitor = NULL;
+ }
+}
+
+int
+CPCD::findUniqueId() {
+ int id;
+ bool ok = false;
+ m_processes.lock();
+
+ while(!ok) {
+ ok = true;
+ id = random() % 8192; /* Don't want so big numbers */
+
+ if(id == 0)
+ ok = false;
+
+ for(size_t i = 0; i<m_processes.size(); i++) {
+ if(m_processes[i]->m_id == id)
+ ok = false;
+ }
+ }
+ m_processes.unlock();
+ return id;
+}
+
+bool
+CPCD::defineProcess(RequestStatus * rs, Process * arg){
+ if(arg->m_id == -1)
+ arg->m_id = findUniqueId();
+
+ Guard tmp(m_processes);
+
+ for(size_t i = 0; i<m_processes.size(); i++) {
+ Process * proc = m_processes[i];
+
+ if((strcmp(arg->m_name.c_str(), proc->m_name.c_str()) == 0) &&
+ (strcmp(arg->m_group.c_str(), proc->m_group.c_str()) == 0)) {
+ /* Identical names in the same group */
+ rs->err(AlreadyExists, "Name already exists");
+ return false;
+ }
+
+ if(arg->m_id == proc->m_id) {
+ /* Identical ID numbers */
+ rs->err(AlreadyExists, "Id already exists");
+ return false;
+ }
+ }
+
+ m_processes.push_back(arg, false);
+
+ notifyChanges();
+ report(arg->m_id, CPCEvent::ET_PROC_USER_DEFINE);
+
+ return true;
+}
+
+bool
+CPCD::undefineProcess(CPCD::RequestStatus *rs, int id) {
+
+ Guard tmp(m_processes);
+
+ Process * proc = 0;
+ size_t i;
+ for(i = 0; i < m_processes.size(); i++) {
+ if(m_processes[i]->m_id == id) {
+ proc = m_processes[i];
+ break;
+ }
+ }
+
+ if(proc == 0){
+ rs->err(NotExists, "No such process");
+ return false;
+ }
+
+ switch(proc->m_status){
+ case RUNNING:
+ case STOPPED:
+ case STOPPING:
+ case STARTING:
+ proc->stop();
+ m_processes.erase(i, false /* Already locked */);
+ }
+
+
+ notifyChanges();
+
+ report(id, CPCEvent::ET_PROC_USER_UNDEFINE);
+
+ return true;
+}
+
+bool
+CPCD::startProcess(CPCD::RequestStatus *rs, int id) {
+
+ Process * proc = 0;
+ {
+
+ Guard tmp(m_processes);
+
+ for(size_t i = 0; i < m_processes.size(); i++) {
+ if(m_processes[i]->m_id == id) {
+ proc = m_processes[i];
+ break;
+ }
+ }
+
+ if(proc == 0){
+ rs->err(NotExists, "No such process");
+ return false;
+ }
+
+ switch(proc->m_status){
+ case STOPPED:
+ proc->m_status = STARTING;
+ if(proc->start() != 0){
+ rs->err(Error, "Failed to start");
+ return false;
+ }
+ break;
+ case STARTING:
+ rs->err(Error, "Already starting");
+ return false;
+ case RUNNING:
+ rs->err(Error, "Already started");
+ return false;
+ case STOPPING:
+ rs->err(Error, "Currently stopping");
+ return false;
+ }
+
+ notifyChanges();
+ }
+ report(id, CPCEvent::ET_PROC_USER_START);
+
+ return true;
+}
+
+bool
+CPCD::stopProcess(CPCD::RequestStatus *rs, int id) {
+
+ Guard tmp(m_processes);
+
+ Process * proc = 0;
+ for(size_t i = 0; i < m_processes.size(); i++) {
+ if(m_processes[i]->m_id == id) {
+ proc = m_processes[i];
+ break;
+ }
+ }
+
+ if(proc == 0){
+ rs->err(NotExists, "No such process");
+ return false;
+ }
+
+ switch(proc->m_status){
+ case STARTING:
+ case RUNNING:
+ proc->stop();
+ break;
+ case STOPPED:
+ rs->err(AlreadyStopped, "Already stopped");
+ return false;
+ break;
+ case STOPPING:
+ rs->err(Error, "Already stopping");
+ return false;
+ }
+
+ notifyChanges();
+
+ report(id, CPCEvent::ET_PROC_USER_START);
+
+ return true;
+}
+
+bool
+CPCD::notifyChanges() {
+ bool ret = true;
+ if(!loadingProcessList)
+ ret = saveProcessList();
+
+ m_monitor->signal();
+
+ return ret;
+}
+
+/* Must be called with m_processlist locked */
+bool
+CPCD::saveProcessList(){
+ char newfile[PATH_MAX+4];
+ char oldfile[PATH_MAX+4];
+ char curfile[PATH_MAX];
+ FILE *f;
+
+ /* Create the filenames that we will use later */
+ BaseString::snprintf(newfile, sizeof(newfile), "%s.new", m_procfile.c_str());
+ BaseString::snprintf(oldfile, sizeof(oldfile), "%s.old", m_procfile.c_str());
+ BaseString::snprintf(curfile, sizeof(curfile), "%s", m_procfile.c_str());
+
+ f = fopen(newfile, "w");
+
+ if(f == NULL) {
+ /* XXX What should be done here? */
+ logger.critical("Cannot open `%s': %s\n", newfile, strerror(errno));
+ return false;
+ }
+
+ for(size_t i = 0; i<m_processes.size(); i++){
+ m_processes[i]->print(f);
+ fprintf(f, "\n");
+
+ if(m_processes[i]->m_processType == TEMPORARY){
+ /**
+ * Interactive process should never be "restarted" on cpcd restart
+ */
+ continue;
+ }
+
+ if(m_processes[i]->m_status == RUNNING ||
+ m_processes[i]->m_status == STARTING){
+ fprintf(f, "start process\nid: %d\n\n", m_processes[i]->m_id);
+ }
+ }
+
+ fclose(f);
+ f = NULL;
+
+ /* This will probably only work on reasonably Unix-like systems. You have
+ * been warned...
+ *
+ * The motivation behind all this link()ing is that the daemon might
+ * crash right in the middle of updating the configuration file, and in
+ * that case we want to be sure that the old file is around until we are
+ * guaranteed that there is always at least one copy of either the old or
+ * the new configuration file left.
+ */
+
+ /* Remove an old config file if it exists */
+ unlink(oldfile);
+
+ if(link(curfile, oldfile) != 0) /* make a backup of the running config */
+ logger.error("Cannot rename '%s' -> '%s'", curfile, oldfile);
+ else {
+ if(unlink(curfile) != 0) { /* remove the running config file */
+ logger.critical("Cannot remove file '%s'", curfile);
+ return false;
+ }
+ }
+
+ if(link(newfile, curfile) != 0) { /* put the new config file in place */
+ printf("-->%d\n", __LINE__);
+
+ logger.critical("Cannot rename '%s' -> '%s': %s",
+ curfile, newfile, strerror(errno));
+ return false;
+ }
+
+ /* XXX Ideally we would fsync() the directory here, but I'm not sure if
+ * that actually works.
+ */
+
+ unlink(newfile); /* remove the temporary file */
+ unlink(oldfile); /* remove the old file */
+
+ logger.info("Process list saved as '%s'", curfile);
+
+ return true;
+}
+
+bool
+CPCD::loadProcessList(){
+ BaseString secondfile;
+ FILE *f;
+
+ loadingProcessList = true;
+
+ secondfile.assfmt("%s.new", m_procfile.c_str());
+
+ /* Try to open the config file */
+ f = fopen(m_procfile.c_str(), "r");
+
+ /* If it did not exist, try to open the backup. See the saveProcessList()
+ * method for an explanation why it is done this way.
+ */
+ if(f == NULL) {
+ f = fopen(secondfile.c_str(), "r");
+
+ if(f == NULL) {
+ /* XXX What to do here? */
+ logger.info("Configuration file `%s' not found",
+ m_procfile.c_str());
+ logger.info("Starting with empty configuration");
+ loadingProcessList = false;
+ return false;
+ } else {
+ logger.info("Configuration file `%s' missing",
+ m_procfile.c_str());
+ logger.info("Backup configuration file `%s' is used",
+ secondfile.c_str());
+ /* XXX Maybe we should just rename the backup file to the official
+ * name, and be done with it?
+ */
+ }
+ }
+
+ CPCDAPISession sess(f, *this);
+ sess.loadFile();
+ loadingProcessList = false;
+
+ size_t i;
+ Vector<int> temporary;
+ for(i = 0; i<m_processes.size(); i++){
+ Process * proc = m_processes[i];
+ proc->readPid();
+ if(proc->m_processType == TEMPORARY){
+ temporary.push_back(proc->m_id);
+ }
+ }
+
+ for(i = 0; i<temporary.size(); i++){
+ RequestStatus rs;
+ undefineProcess(&rs, temporary[i]);
+ }
+
+ /* Don't call notifyChanges here, as that would save the file we just
+ loaded */
+ m_monitor->signal();
+ return true;
+}
+
+MutexVector<CPCD::Process *> *
+CPCD::getProcessList() {
+ return &m_processes;
+}
+
+void
+CPCD::RequestStatus::err(enum RequestStatusCode status, const char *msg) {
+ m_status = status;
+ BaseString::snprintf(m_errorstring, sizeof(m_errorstring), "%s", msg);
+}
+
+#if 0
+void
+CPCD::sigchild(int pid){
+ m_processes.lock();
+ for(size_t i = 0; i<m_processes.size(); i++){
+ if(m_processes[i].m_pid == pid){
+ }
+ }
+ wait(pid, 0, 0);
+}
+#endif
+
+ /** Register event subscriber */
+void
+CPCD::do_register(EventSubscriber * sub){
+ m_subscribers.lock();
+ m_subscribers.push_back(sub, false);
+ m_subscribers.unlock();
+}
+
+EventSubscriber*
+CPCD::do_unregister(EventSubscriber * sub){
+ m_subscribers.lock();
+
+ for(size_t i = 0; i<m_subscribers.size(); i++){
+ if(m_subscribers[i] == sub){
+ m_subscribers.erase(i);
+ m_subscribers.unlock();
+ return sub;
+ }
+ }
+
+ m_subscribers.unlock();
+ return 0;
+}
+
+void
+CPCD::report(int id, CPCEvent::EventType t){
+ CPCEvent e;
+ e.m_time = time(0);
+ e.m_proc = id;
+ e.m_type = t;
+ m_subscribers.lock();
+ for(size_t i = 0; i<m_subscribers.size(); i++){
+ (* m_subscribers[i]).report(e);
+ }
+ m_subscribers.unlock();
+}
+
+template class MutexVector<EventSubscriber*>;
diff --git a/storage/ndb/src/cw/cpcd/CPCD.hpp b/storage/ndb/src/cw/cpcd/CPCD.hpp
new file mode 100644
index 00000000000..a5c0bef1dac
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/CPCD.hpp
@@ -0,0 +1,382 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 CPCD_HPP
+#define CPCD_HPP
+
+#include <Vector.hpp>
+#include <Properties.hpp>
+#include <NdbOut.hpp>
+#include <NdbThread.h>
+#include <NdbCondition.h>
+#include <BaseString.hpp>
+
+/* XXX Need to figure out how to do this for non-Unix systems */
+#define CPCD_DEFAULT_WORK_DIR "/var/run/ndb_cpcd"
+#define CPCD_DEFAULT_PROC_FILE "ndb_cpcd.conf"
+#define CPCD_DEFAULT_TCP_PORT 1234
+#define CPCD_DEFAULT_POLLING_INTERVAL 5 /* seconds */
+#define CPCD_DEFAULT_CONFIG_FILE "/etc/ndb_cpcd.conf"
+
+enum ProcessStatus {
+ STOPPED = 0,
+ STARTING = 1,
+ RUNNING = 2,
+ STOPPING = 3
+};
+
+enum ProcessType {
+ PERMANENT = 0,
+ TEMPORARY = 1
+};
+
+struct CPCEvent {
+ enum EventType {
+ ET_USER_CONNECT,
+ ET_USER_DISCONNECT,
+
+ ET_PROC_USER_DEFINE, // Defined proc
+ ET_PROC_USER_UNDEFINE, // Undefined proc
+ ET_PROC_USER_START, // Proc ordered to start
+ ET_PROC_USER_STOP, // Proc ordered to stop
+ ET_PROC_STATE_RUNNING, // exec returned(?) ok
+ ET_PROC_STATE_STOPPED // detected that proc is ! running
+ };
+
+ int m_proc;
+ time_t m_time;
+ EventType m_type;
+};
+
+struct EventSubscriber {
+ virtual void report(const CPCEvent &) = 0;
+};
+
+/**
+ * @brief Error codes for CPCD requests
+ */
+enum RequestStatusCode {
+ OK = 0, ///< Everything OK
+ Error = 1, ///< Generic error
+ AlreadyExists = 2, ///< Entry already exists in list
+ NotExists = 3, ///< Entry does not exist in list
+ AlreadyStopped = 4
+};
+
+/**
+ * @class CPCD
+ * @brief Manages processes, letting them be controlled with a TCP connection.
+ *
+ * The class implementing the Cluster Process Control Daemon
+ */
+class CPCD {
+public:
+ /** @brief Describes the status of a client request */
+ class RequestStatus {
+ public:
+ /** @brief Constructs an empty RequestStatus */
+ RequestStatus() { m_status = OK; m_errorstring[0] = '\0'; };
+
+ /** @brief Sets an errorcode and a printable message */
+ void err(enum RequestStatusCode, const char *);
+
+ /** @brief Returns the error message */
+ char *getErrMsg() { return m_errorstring; };
+
+ /** @brief Returns the error code */
+ enum RequestStatusCode getStatus() { return m_status; };
+ private:
+ enum RequestStatusCode m_status;
+ char m_errorstring[256];
+ };
+ /**
+ * @brief Manages a process
+ */
+ class Process {
+ int m_pid;
+ public:
+ /**
+ * @brief Constructs and empty Process
+ */
+ Process(const Properties & props, class CPCD *cpcd);
+ /**
+ * @brief Monitors the process
+ *
+ * The process is started or stopped as needed.
+ */
+ void monitor();
+
+ /**
+ * @brief Checks if the process is running or not
+ *
+ * @return
+ * - true if the process is running,
+ * - false if the process is not running
+ */
+ bool isRunning();
+
+ /** @brief Starts the process */
+ int start();
+
+ /** @brief Stops the process */
+ void stop();
+
+ /**
+ * @brief Reads the pid from stable storage
+ *
+ * @return The pid number
+ */
+ int readPid();
+
+ /**
+ * @brief Writes the pid from stable storage
+ *
+ * @return
+ * - 0 if successful
+ - -1 and sets errno if an error occured
+ */
+ int writePid(int pid);
+
+ /**
+ * @brief Prints a textual description of the process on a file
+ */
+ void print(FILE *);
+
+ /** Id number of the Process.
+ *
+ * @note This is not the same as a pid. This number is used in the
+ * protocol, and will not be changed if a processes is restarted.
+ */
+ int m_id;
+
+ /** @brief The name shown to the user */
+ BaseString m_name;
+
+ /** @brief Used to group a number of processes */
+ BaseString m_group;
+
+ /** @brief Environment variables
+ *
+ * Environmentvariables to add for the process.
+ *
+ * @note
+ * - The environment cpcd started with is preserved
+ * - There is no way to delete variables
+ */
+ BaseString m_env;
+
+ /** @brief Path to the binary to run */
+ BaseString m_path;
+
+ /** @brief Arguments to the process.
+ *
+ * @note
+ * - This includes argv[0].
+ * - If no argv[0] is given, argv[0] will be set to m_path.
+ */
+ BaseString m_args;
+
+ /**
+ * @brief Type of process
+ *
+ * Either set to "interactive" or "permanent".
+ */
+ BaseString m_type;
+ ProcessType m_processType;
+
+ /**
+ * @brief Working directory
+ *
+ * Working directory the process will start in.
+ */
+ BaseString m_cwd;
+
+ /**
+ * @brief Owner of the process.
+ *
+ * @note This will not affect the process' uid or gid;
+ * it is only used for managemental purposes.
+ * @see m_runas
+ */
+ BaseString m_owner;
+
+ /**
+ * @bried Run as
+ * @note This affects uid
+ * @see m_owner
+ */
+ BaseString m_runas;
+
+ /**
+ * @brief redirection for stdin
+ */
+ BaseString m_stdin;
+
+ /**
+ * @brief redirection for stdout
+ */
+ BaseString m_stdout;
+
+ /**
+ * @brief redirection for stderr
+ */
+ BaseString m_stderr;
+
+ /** @brief Status of the process */
+ enum ProcessStatus m_status;
+
+ /**
+ * @brief ulimits for process
+ * @desc Format c:unlimited d:0 ...
+ */
+ BaseString m_ulimit;
+ private:
+ class CPCD *m_cpcd;
+ void do_exec();
+ };
+
+ /**
+ * @brief Starts and stops processes as needed
+ *
+ * At a specified interval (default 5 seconds) calls the monitor function
+ * of all the processes in the CPCDs list, causing the to start or
+ * stop, depending on the configuration.
+ */
+ class Monitor {
+ public:
+ /** Creates a new CPCD::Monitor object, connected to the specified
+ * CPCD.
+ * A new thread will be created, which will poll the processes of
+ * the CPCD at the specifed interval.
+ */
+ Monitor(CPCD *cpcd, int poll = CPCD_DEFAULT_POLLING_INTERVAL);
+
+ /** Stops the monitor, but does not stop the processes */
+ ~Monitor();
+
+ /** Runs the monitor thread. */
+ void run();
+
+ /** Signals configuration changes to the monitor thread, causing it to
+ * do the check without waiting for the timeout */
+ void signal();
+ private:
+ class CPCD *m_cpcd;
+ struct NdbThread *m_monitorThread;
+ bool m_monitorThreadQuitFlag;
+ struct NdbCondition *m_changeCondition;
+ NdbMutex *m_changeMutex;
+ int m_pollingInterval; /* seconds */
+ };
+
+ /** @brief Constructs a CPCD object */
+ CPCD();
+
+ /**
+ * @brief Destroys a CPCD object,
+ * but does not stop the processes it manages
+ */
+ ~CPCD();
+
+ /** Adds a Process to the CPCDs list of managed Processes.
+ *
+ * @note The process will not be started until it is explicitly
+ * marked as running with CPCD::startProcess().
+ *
+ * @return
+ * - true if the addition was successful,
+ * - false if not
+ * - RequestStatus will be filled in with a suitable error
+ * if an error occured.
+ */
+ bool defineProcess(RequestStatus *rs, Process * arg);
+
+ /** Removes a Process from the CPCD.
+ *
+ * @note A Process that is running cannot be removed.
+ *
+ * @return
+ * - true if the removal was successful,
+ * - false if not
+ * - The RequestStatus will be filled in with a suitable error
+ * if an error occured.
+ */
+ bool undefineProcess(RequestStatus *rs, int id);
+
+ /** Marks a Process for starting.
+ *
+ * @note The fact that a process has started does not mean it will actually
+ * start properly. This command only makes sure the CPCD will
+ * try to start it.
+ *
+ * @return
+ * - true if the marking was successful
+ * - false if not
+ * - RequestStatus will be filled in with a suitable error
+ * if an error occured.
+ */
+ bool startProcess(RequestStatus *rs, int id);
+
+ /** Marks a Process for stopping.
+ *
+ * @return
+ * - true if the marking was successful
+ * - false if not
+ * - The RequestStatus will be filled in with a suitable error
+ * if an error occured.
+ */
+ bool stopProcess(RequestStatus *rs, int id);
+
+ /** Generates a list of processes, and sends them to the CPCD client */
+ bool listProcesses(RequestStatus *rs, MutexVector<const char *> &);
+
+ /** Set to true while the CPCD is reading the configuration file */
+ bool loadingProcessList;
+
+ /** Saves the list of Processes and their status to the configuration file.
+ * Called whenever the configuration is changed.
+ */
+ bool saveProcessList();
+
+ /** Loads the list of Processes and their status from the configuration
+ * file.
+ * @note This function should only be called when the CPCD is starting,
+ * calling it at other times will cause unspecified behaviour.
+ */
+ bool loadProcessList();
+
+ /** Returns the list of processes */
+ MutexVector<Process *> *getProcessList();
+
+ /** The list of processes. Should not be used directly */
+ MutexVector<Process *> m_processes;
+
+ /** Register event subscriber */
+ void do_register(EventSubscriber * sub);
+ EventSubscriber* do_unregister(EventSubscriber * sub);
+
+private:
+ friend class Process;
+ bool notifyChanges();
+ int findUniqueId();
+ BaseString m_procfile;
+ Monitor *m_monitor;
+
+ void report(int id, CPCEvent::EventType);
+ MutexVector<EventSubscriber *> m_subscribers;
+};
+
+#endif
diff --git a/storage/ndb/src/cw/cpcd/Makefile.am b/storage/ndb/src/cw/cpcd/Makefile.am
new file mode 100644
index 00000000000..75f557b2af7
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/Makefile.am
@@ -0,0 +1,20 @@
+
+ndbbin_PROGRAMS = ndb_cpcd
+
+ndb_cpcd_SOURCES = main.cpp CPCD.cpp Process.cpp APIService.cpp Monitor.cpp common.cpp
+
+LDADD_LOC = \
+ $(top_builddir)/ndb/src/libndbclient.la \
+ $(top_builddir)/dbug/libdbug.a \
+ $(top_builddir)/mysys/libmysys.a \
+ $(top_builddir)/strings/libmystrings.a @NDB_SCI_LIBS@
+
+include $(top_srcdir)/ndb/config/common.mk.am
+include $(top_srcdir)/ndb/config/type_util.mk.am
+
+ndb_cpcd_LDFLAGS = @ndb_bin_am_ldflags@
+
+# Don't update the files from bitkeeper
+%::SCCS/s.%
+
+windoze-dsp:
diff --git a/storage/ndb/src/cw/cpcd/Monitor.cpp b/storage/ndb/src/cw/cpcd/Monitor.cpp
new file mode 100644
index 00000000000..141de926d4d
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/Monitor.cpp
@@ -0,0 +1,79 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include <ndb_global.h>
+
+#include <NdbThread.h>
+#include <NdbOut.hpp>
+#include <NdbSleep.h>
+
+#include "CPCD.hpp"
+#include "common.hpp"
+
+static void *
+monitor_thread_create_wrapper(void * arg) {
+ CPCD::Monitor *mon = (CPCD::Monitor *)arg;
+ mon->run();
+ return NULL;
+}
+
+CPCD::Monitor::Monitor(CPCD *cpcd, int poll) {
+ m_cpcd = cpcd;
+ m_pollingInterval = poll;
+ m_changeCondition = NdbCondition_Create();
+ m_changeMutex = NdbMutex_Create();
+ m_monitorThread = NdbThread_Create(monitor_thread_create_wrapper,
+ (NDB_THREAD_ARG*) this,
+ 32768,
+ "ndb_cpcd_monitor",
+ NDB_THREAD_PRIO_MEAN);
+ m_monitorThreadQuitFlag = false;
+}
+
+CPCD::Monitor::~Monitor() {
+ NdbThread_Destroy(&m_monitorThread);
+ NdbCondition_Destroy(m_changeCondition);
+ NdbMutex_Destroy(m_changeMutex);
+}
+
+void
+CPCD::Monitor::run() {
+ while(1) {
+ NdbMutex_Lock(m_changeMutex);
+ NdbCondition_WaitTimeout(m_changeCondition,
+ m_changeMutex,
+ m_pollingInterval * 1000);
+
+ MutexVector<CPCD::Process *> &proc = *m_cpcd->getProcessList();
+
+ proc.lock();
+
+ for(size_t i = 0; i < proc.size(); i++) {
+ proc[i]->monitor();
+ }
+
+ proc.unlock();
+
+ NdbMutex_Unlock(m_changeMutex);
+ }
+}
+
+void
+CPCD::Monitor::signal() {
+ NdbCondition_Signal(m_changeCondition);
+}
+
+template class MutexVector<CPCD::Process*>;
diff --git a/storage/ndb/src/cw/cpcd/Process.cpp b/storage/ndb/src/cw/cpcd/Process.cpp
new file mode 100644
index 00000000000..2509f34e882
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/Process.cpp
@@ -0,0 +1,479 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include <ndb_global.h>
+
+#include <BaseString.hpp>
+#include <InputStream.hpp>
+
+#include "common.hpp"
+#include "CPCD.hpp"
+
+#include <pwd.h>
+#ifdef HAVE_GETRLIMIT
+#include <sys/resource.h>
+#endif
+
+void
+CPCD::Process::print(FILE * f){
+ fprintf(f, "define process\n");
+ fprintf(f, "id: %d\n", m_id);
+ fprintf(f, "name: %s\n", m_name.c_str() ? m_name.c_str() : "");
+ fprintf(f, "group: %s\n", m_group.c_str() ? m_group.c_str() : "");
+ fprintf(f, "env: %s\n", m_env.c_str() ? m_env.c_str() : "");
+ fprintf(f, "path: %s\n", m_path.c_str() ? m_path.c_str() : "");
+ fprintf(f, "args: %s\n", m_args.c_str() ? m_args.c_str() : "");
+ fprintf(f, "type: %s\n", m_type.c_str() ? m_type.c_str() : "");
+ fprintf(f, "cwd: %s\n", m_cwd.c_str() ? m_cwd.c_str() : "");
+ fprintf(f, "owner: %s\n", m_owner.c_str() ? m_owner.c_str() : "");
+ fprintf(f, "runas: %s\n", m_runas.c_str() ? m_runas.c_str() : "");
+ fprintf(f, "stdin: %s\n", m_stdin.c_str() ? m_stdin.c_str() : "");
+ fprintf(f, "stdout: %s\n", m_stdout.c_str() ? m_stdout.c_str() : "");
+ fprintf(f, "stderr: %s\n", m_stderr.c_str() ? m_stderr.c_str() : "");
+ fprintf(f, "ulimit: %s\n", m_ulimit.c_str() ? m_ulimit.c_str() : "");
+}
+
+CPCD::Process::Process(const Properties & props, class CPCD *cpcd) {
+ m_id = -1;
+ m_pid = -1;
+ props.get("id", (Uint32 *) &m_id);
+ props.get("name", m_name);
+ props.get("group", m_group);
+ props.get("env", m_env);
+ props.get("path", m_path);
+ props.get("args", m_args);
+ props.get("cwd", m_cwd);
+ props.get("owner", m_owner);
+ props.get("type", m_type);
+ props.get("runas", m_runas);
+
+ props.get("stdin", m_stdin);
+ props.get("stdout", m_stdout);
+ props.get("stderr", m_stderr);
+ props.get("ulimit", m_ulimit);
+ m_status = STOPPED;
+
+ if(strcasecmp(m_type.c_str(), "temporary") == 0){
+ m_processType = TEMPORARY;
+ } else {
+ m_processType = PERMANENT;
+ }
+
+ m_cpcd = cpcd;
+}
+
+void
+CPCD::Process::monitor() {
+ switch(m_status) {
+ case STARTING:
+ break;
+ case RUNNING:
+ if(!isRunning()){
+ m_cpcd->report(m_id, CPCEvent::ET_PROC_STATE_STOPPED);
+ if(m_processType == TEMPORARY){
+ m_status = STOPPED;
+ } else {
+ start();
+ }
+ }
+ break;
+ case STOPPED:
+ assert(!isRunning());
+ break;
+ case STOPPING:
+ break;
+ }
+}
+
+bool
+CPCD::Process::isRunning() {
+
+ if(m_pid <= 1){
+ //logger.critical("isRunning(%d) invalid pid: %d", m_id, m_pid);
+ return false;
+ }
+ /* Check if there actually exists a process with such a pid */
+ errno = 0;
+ int s = kill((pid_t)-m_pid, 0); /* Sending "signal" 0 to a process only
+ * checkes if the process actually exists */
+ if(s != 0) {
+ switch(errno) {
+ case EPERM:
+ logger.critical("Not enough privileges to control pid %d\n", m_pid);
+ break;
+ case ESRCH:
+ /* The pid in the file does not exist, which probably means that it
+ has died, or the file contains garbage for some other reason */
+ break;
+ default:
+ logger.critical("Cannot not control pid %d: %s\n", m_pid, strerror(errno));
+ break;
+ }
+ return false;
+ }
+ return true;
+}
+
+int
+CPCD::Process::readPid() {
+ if(m_pid != -1){
+ logger.critical("Reading pid while != -1(%d)", m_pid);
+ return m_pid;
+ }
+
+ char filename[PATH_MAX*2+1];
+ char buf[1024];
+ FILE *f;
+
+ memset(buf, 0, sizeof(buf));
+
+ BaseString::snprintf(filename, sizeof(filename), "%d", m_id);
+
+ f = fopen(filename, "r");
+
+ if(f == NULL){
+ return -1; /* File didn't exist */
+ }
+
+ errno = 0;
+ size_t r = fread(buf, 1, sizeof(buf), f);
+ fclose(f);
+ if(r > 0)
+ m_pid = strtol(buf, (char **)NULL, 0);
+
+ if(errno == 0){
+ return m_pid;
+ }
+
+ return -1;
+}
+
+int
+CPCD::Process::writePid(int pid) {
+ char tmpfilename[PATH_MAX+1+4+8];
+ char filename[PATH_MAX*2+1];
+ FILE *f;
+
+ BaseString::snprintf(tmpfilename, sizeof(tmpfilename), "tmp.XXXXXX");
+ BaseString::snprintf(filename, sizeof(filename), "%d", m_id);
+
+ int fd = mkstemp(tmpfilename);
+ if(fd < 0) {
+ logger.error("Cannot open `%s': %s\n", tmpfilename, strerror(errno));
+ return -1; /* Couldn't open file */
+ }
+
+ f = fdopen(fd, "w");
+
+ if(f == NULL) {
+ logger.error("Cannot open `%s': %s\n", tmpfilename, strerror(errno));
+ return -1; /* Couldn't open file */
+ }
+
+ fprintf(f, "%d", pid);
+ fclose(f);
+
+ if(rename(tmpfilename, filename) == -1){
+ logger.error("Unable to rename from %s to %s", tmpfilename, filename);
+ return -1;
+ }
+ return 0;
+}
+
+static void
+setup_environment(const char *env) {
+ char **p;
+ p = BaseString::argify("", env);
+ for(int i = 0; p[i] != NULL; i++){
+ /*int res = */ putenv(p[i]);
+ }
+}
+
+static
+int
+set_ulimit(const BaseString & pair){
+#ifdef HAVE_GETRLIMIT
+ errno = 0;
+ Vector<BaseString> list;
+ pair.split(list, ":");
+ if(list.size() != 2){
+ logger.error("Unable to process ulimit: split >%s< list.size()=%d",
+ pair.c_str(), list.size());
+ return -1;
+ }
+
+ int res;
+ rlim_t value = RLIM_INFINITY;
+ if(!(list[1].trim() == "unlimited")){
+ value = atoi(list[1].c_str());
+ }
+
+ struct rlimit rlp;
+#define _RLIMIT_FIX(x) { res = getrlimit(x,&rlp); if(!res){ rlp.rlim_cur = value; res = setrlimit(x, &rlp); }}
+
+ if(list[0].trim() == "c"){
+ _RLIMIT_FIX(RLIMIT_CORE);
+ } else if(list[0] == "d"){
+ _RLIMIT_FIX(RLIMIT_DATA);
+ } else if(list[0] == "f"){
+ _RLIMIT_FIX(RLIMIT_FSIZE);
+ } else if(list[0] == "n"){
+ _RLIMIT_FIX(RLIMIT_NOFILE);
+ } else if(list[0] == "s"){
+ _RLIMIT_FIX(RLIMIT_STACK);
+ } else if(list[0] == "t"){
+ _RLIMIT_FIX(RLIMIT_CPU);
+ } else {
+ res= -11;
+ errno = EINVAL;
+ }
+ if(res){
+ logger.error("Unable to process ulimit: %s res=%d error=%d(%s)",
+ pair.c_str(), res, errno, strerror(errno));
+ return -1;
+ }
+#endif
+ return 0;
+}
+
+void
+CPCD::Process::do_exec() {
+ size_t i;
+ setup_environment(m_env.c_str());
+
+ char **argv = BaseString::argify(m_path.c_str(), m_args.c_str());
+
+ if(strlen(m_cwd.c_str()) > 0) {
+ int err = chdir(m_cwd.c_str());
+ if(err == -1) {
+ BaseString err;
+ logger.error("%s: %s\n", m_cwd.c_str(), strerror(errno));
+ _exit(1);
+ }
+ }
+
+ Vector<BaseString> ulimit;
+ m_ulimit.split(ulimit);
+ for(i = 0; i<ulimit.size(); i++){
+ if(ulimit[i].trim().length() > 0 && set_ulimit(ulimit[i]) != 0){
+ _exit(1);
+ }
+ }
+
+ int fd = open("/dev/null", O_RDWR, 0);
+ if(fd == -1) {
+ logger.error("Cannot open `/dev/null': %s\n", strerror(errno));
+ _exit(1);
+ }
+
+ BaseString * redirects[] = { &m_stdin, &m_stdout, &m_stderr };
+ int fds[3];
+ for(i = 0; i<3; i++){
+ if(redirects[i]->empty()){
+#ifndef DEBUG
+ dup2(fd, i);
+#endif
+ continue;
+ }
+
+ if((* redirects[i]) == "2>&1" && i == 2){
+ dup2(fds[1], 2);
+ continue;
+ }
+
+ /**
+ * Make file
+ */
+ int flags = 0;
+ int mode = S_IRUSR | S_IWUSR ;
+ if(i == 0){
+ flags |= O_RDONLY;
+ } else {
+ flags |= O_WRONLY | O_CREAT | O_APPEND;
+ }
+ int f = fds[i]= open(redirects[i]->c_str(), flags, mode);
+ if(f == -1){
+ logger.error("Cannot redirect %d to/from '%s' : %s\n", i,
+ redirects[i]->c_str(), strerror(errno));
+ _exit(1);
+ }
+ dup2(f, i);
+ }
+
+ /* Close all filedescriptors */
+ for(i = STDERR_FILENO+1; (int)i < getdtablesize(); i++)
+ close(i);
+
+ execv(m_path.c_str(), argv);
+ /* XXX If we reach this point, an error has occurred, but it's kind of hard
+ * to report it, because we've closed all files... So we should probably
+ * create a new logger here */
+ logger.error("Exec failed: %s\n", strerror(errno));
+ /* NOTREACHED */
+}
+
+int
+CPCD::Process::start() {
+ /* We need to fork() twice, so that the second child (grandchild?) can
+ * become a daemon. The original child then writes the pid file,
+ * so that the monitor knows the pid of the new process, and then
+ * exit()s. That way, the monitor process can pickup the pid, and
+ * the running process is a daemon.
+ *
+ * This is a bit tricky but has the following advantages:
+ * - the cpcd can die, and "reconnect" to the monitored clients
+ * without restarting them.
+ * - the cpcd does not have to wait() for the childs. init(1) will
+ * take care of that.
+ */
+ logger.info("Starting %d: %s", m_id, m_name.c_str());
+ m_status = STARTING;
+
+ int pid = -1;
+ switch(m_processType){
+ case TEMPORARY:{
+ /**
+ * Simple fork
+ * don't ignore child
+ */
+ switch(pid = fork()) {
+ case 0: /* Child */
+ setsid();
+ writePid(getpgrp());
+ if(runas(m_runas.c_str()) == 0){
+ signal(SIGCHLD, SIG_DFL);
+ do_exec();
+ }
+ _exit(1);
+ break;
+ case -1: /* Error */
+ logger.error("Cannot fork: %s\n", strerror(errno));
+ m_status = STOPPED;
+ return -1;
+ break;
+ default: /* Parent */
+ logger.debug("Started temporary %d : pid=%d", m_id, pid);
+ m_cpcd->report(m_id, CPCEvent::ET_PROC_STATE_RUNNING);
+ break;
+ }
+ break;
+ }
+ case PERMANENT:{
+ /**
+ * PERMANENT
+ */
+ switch(fork()) {
+ case 0: /* Child */
+ signal(SIGCHLD, SIG_IGN);
+ switch(pid = fork()) {
+ case 0: /* Child */
+ setsid();
+ writePid(getpgrp());
+ if(runas(m_runas.c_str()) != 0){
+ _exit(1);
+ }
+ signal(SIGCHLD, SIG_DFL);
+ do_exec();
+ _exit(1);
+ /* NOTREACHED */
+ break;
+ case -1: /* Error */
+ logger.error("Cannot fork: %s\n", strerror(errno));
+ writePid(-1);
+ _exit(1);
+ break;
+ default: /* Parent */
+ logger.debug("Started permanent %d : pid=%d", m_id, pid);
+ _exit(0);
+ break;
+ }
+ break;
+ case -1: /* Error */
+ logger.error("Cannot fork: %s\n", strerror(errno));
+ m_status = STOPPED;
+ return -1;
+ break;
+ default: /* Parent */
+ m_cpcd->report(m_id, CPCEvent::ET_PROC_STATE_RUNNING);
+ break;
+ }
+ break;
+ }
+ default:
+ logger.critical("Unknown process type");
+ return -1;
+ }
+
+ while(readPid() < 0){
+ sched_yield();
+ }
+
+ errno = 0;
+ pid_t pgid = getpgid(pid);
+
+ if(pgid != -1 && pgid != m_pid){
+ logger.error("pgid and m_pid don't match: %d %d (%d)", pgid, m_pid, pid);
+ }
+
+ if(isRunning()){
+ m_status = RUNNING;
+ return 0;
+ }
+ m_status = STOPPED;
+ return -1;
+}
+
+void
+CPCD::Process::stop() {
+
+ char filename[PATH_MAX*2+1];
+ BaseString::snprintf(filename, sizeof(filename), "%d", m_id);
+ unlink(filename);
+
+ if(m_pid <= 1){
+ logger.critical("Stopping process with bogus pid: %d id: %d",
+ m_pid, m_id);
+ return;
+ }
+ m_status = STOPPING;
+
+ errno = 0;
+ int ret = kill(-m_pid, SIGTERM);
+ switch(ret) {
+ case 0:
+ logger.debug("Sent SIGTERM to pid %d", (int)-m_pid);
+ break;
+ default:
+ logger.debug("kill pid: %d : %s", (int)-m_pid, strerror(errno));
+ break;
+ }
+
+ if(isRunning()){
+ errno = 0;
+ ret = kill(-m_pid, SIGKILL);
+ switch(ret) {
+ case 0:
+ logger.debug("Sent SIGKILL to pid %d", (int)-m_pid);
+ break;
+ default:
+ logger.debug("kill pid: %d : %s\n", (int)-m_pid, strerror(errno));
+ break;
+ }
+ }
+
+ m_pid = -1;
+ m_status = STOPPED;
+}
diff --git a/storage/ndb/src/cw/cpcd/common.cpp b/storage/ndb/src/cw/cpcd/common.cpp
new file mode 100644
index 00000000000..53c0e4d5a64
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/common.cpp
@@ -0,0 +1,98 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include <ndb_global.h>
+
+#include "common.hpp"
+#include <logger/Logger.hpp>
+#include <pwd.h>
+
+#include <Properties.hpp>
+#include <BaseString.hpp>
+
+int debug = 0;
+
+Logger logger;
+
+int
+runas(const char * user){
+ if(user == 0 || strlen(user) == 0){
+ return 0;
+ }
+ struct passwd * pw = getpwnam(user);
+ if(pw == 0){
+ logger.error("Can't find user to %s", user);
+ return -1;
+ }
+ uid_t uid = pw->pw_uid;
+ gid_t gid = pw->pw_gid;
+ int res = setgid(gid);
+ if(res != 0){
+ logger.error("Can't change group to %s(%d)", user, gid);
+ return res;
+ }
+
+ res = setuid(uid);
+ if(res != 0){
+ logger.error("Can't change user to %s(%d)", user, uid);
+ }
+ return res;
+}
+
+int
+insert(const char * pair, Properties & p){
+ BaseString tmp(pair);
+
+ tmp.trim(" \t\n\r");
+
+ Vector<BaseString> split;
+ tmp.split(split, ":=", 2);
+
+ if(split.size() != 2)
+ return -1;
+
+ p.put(split[0].trim().c_str(), split[1].trim().c_str());
+
+ return 0;
+}
+
+int
+insert_file(FILE * f, class Properties& p, bool break_on_empty){
+ if(f == 0)
+ return -1;
+
+ while(!feof(f)){
+ char buf[1024];
+ fgets(buf, 1024, f);
+ BaseString tmp = buf;
+
+ if(tmp.length() > 0 && tmp.c_str()[0] == '#')
+ continue;
+
+ if(insert(tmp.c_str(), p) != 0 && break_on_empty)
+ break;
+ }
+
+ return 0;
+}
+
+int
+insert_file(const char * filename, class Properties& p){
+ FILE * f = fopen(filename, "r");
+ int res = insert_file(f, p);
+ if(f) fclose(f);
+ return res;
+}
diff --git a/storage/ndb/src/cw/cpcd/common.hpp b/storage/ndb/src/cw/cpcd/common.hpp
new file mode 100644
index 00000000000..4f5f702762f
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/common.hpp
@@ -0,0 +1,36 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 __CPCD_COMMON_HPP_INCLUDED__
+#define __CPCD_COMMON_HPP_INCLUDED__
+
+#include <ndb_global.h>
+#include <logger/Logger.hpp>
+#if 0
+#include <getarg.h>
+#endif
+
+extern int debug;
+
+extern Logger logger;
+
+int runas(const char * user);
+int insert(const char * pair, class Properties & p);
+
+int insert_file(const char * filename, class Properties&);
+int insert_file(FILE *, class Properties&, bool break_on_empty = false);
+
+#endif /* ! __CPCD_COMMON_HPP_INCLUDED__ */
diff --git a/storage/ndb/src/cw/cpcd/main.cpp b/storage/ndb/src/cw/cpcd/main.cpp
new file mode 100644
index 00000000000..9bbd5e484d4
--- /dev/null
+++ b/storage/ndb/src/cw/cpcd/main.cpp
@@ -0,0 +1,187 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include <ndb_global.h> /* Needed for mkdir(2) */
+#include <my_sys.h>
+#include <my_getopt.h>
+#include <mysql_version.h>
+#include <ndb_version.h>
+
+#include "CPCD.hpp"
+#include "APIService.hpp"
+#include <NdbMain.h>
+#include <NdbSleep.h>
+#include <BaseString.hpp>
+#include <logger/Logger.hpp>
+#include <logger/FileLogHandler.hpp>
+#include <logger/SysLogHandler.hpp>
+
+#include "common.hpp"
+
+static const char *work_dir = CPCD_DEFAULT_WORK_DIR;
+static short unsigned int port;
+static int use_syslog;
+static const char *logfile = NULL;
+static const char *config_file = CPCD_DEFAULT_CONFIG_FILE;
+static const char *user = 0;
+
+static struct my_option my_long_options[] =
+{
+ { "work-dir", 'w', "Work directory",
+ (gptr*) &work_dir, (gptr*) &work_dir, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "port", 'p', "TCP port to listen on",
+ (gptr*) &port, (gptr*) &port, 0,
+ GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 },
+ { "syslog", 'S', "Log events to syslog",
+ (gptr*) &use_syslog, (gptr*) &use_syslog, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "logfile", 'L', "File to log events to",
+ (gptr*) &logfile, (gptr*) &logfile, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "debug", 'D', "Enable debug mode",
+ (gptr*) &debug, (gptr*) &debug, 0,
+ GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+ { "config", 'c', "Config file",
+ (gptr*) &config_file, (gptr*) &config_file, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { "user", 'u', "Run as user",
+ (gptr*) &user, (gptr*) &user, 0,
+ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
+static my_bool
+get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
+ char *argument)
+{
+ return 0;
+}
+
+static CPCD * g_cpcd = 0;
+#if 0
+extern "C" static void sig_child(int signo, siginfo_t*, void*);
+#endif
+
+const char *progname = "ndb_cpcd";
+
+int main(int argc, char** argv){
+ int save_argc= argc;
+ char** save_argv= argv;
+ const char *load_default_groups[]= { "ndb_cpcd",0 };
+ MY_INIT(argv[0]);
+
+ load_defaults("ndb_cpcd",load_default_groups,&argc,&argv);
+ if (handle_options(&argc, &argv, my_long_options, get_one_option)) {
+ my_print_help(my_long_options);
+ my_print_variables(my_long_options);
+ exit(1);
+ }
+
+ logger.setCategory(progname);
+ logger.enable(Logger::LL_ALL);
+
+ if(debug)
+ logger.createConsoleHandler();
+
+ if(user && runas(user) != 0){
+ logger.critical("Unable to change user: %s", user);
+ _exit(1);
+ }
+
+ if(logfile != NULL){
+ BaseString tmp;
+ if(logfile[0] != '/')
+ tmp.append(work_dir);
+ tmp.append(logfile);
+ logger.addHandler(new FileLogHandler(tmp.c_str()));
+ }
+
+ if(use_syslog)
+ logger.addHandler(new SysLogHandler());
+
+ logger.info("Starting");
+
+ CPCD cpcd;
+ g_cpcd = &cpcd;
+
+ /* XXX This will probably not work on !unix */
+ int err = mkdir(work_dir, S_IRWXU | S_IRGRP | S_IROTH);
+ if(err != 0) {
+ switch(errno) {
+ case EEXIST:
+ break;
+ default:
+ fprintf(stderr, "Cannot mkdir %s: %s\n", work_dir, strerror(errno));
+ exit(1);
+ }
+ }
+
+ if(strlen(work_dir) > 0){
+ logger.debug("Changing dir to '%s'", work_dir);
+ if((err = chdir(work_dir)) != 0){
+ fprintf(stderr, "Cannot chdir %s: %s\n", work_dir, strerror(errno));
+ exit(1);
+ }
+ }
+
+ cpcd.loadProcessList();
+
+ SocketServer * ss = new SocketServer();
+ CPCDAPIService * serv = new CPCDAPIService(cpcd);
+ if(!ss->setup(serv, &port)){
+ logger.critical("Cannot setup server: %s", strerror(errno));
+ sleep(1);
+ delete ss;
+ delete serv;
+ return 1;
+ }
+
+ ss->startServer();
+
+ {
+ signal(SIGPIPE, SIG_IGN);
+ signal(SIGCHLD, SIG_IGN);
+#if 0
+ struct sigaction act;
+ act.sa_handler = 0;
+ act.sa_sigaction = sig_child;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_SIGINFO;
+ sigaction(SIGCHLD, &act, 0);
+#endif
+ }
+
+ logger.debug("Start completed");
+ while(true) NdbSleep_MilliSleep(1000);
+
+ delete ss;
+ return 0;
+}
+
+#if 0
+extern "C"
+void
+sig_child(int signo, siginfo_t* info, void*){
+ printf("signo: %d si_signo: %d si_errno: %d si_code: %d si_pid: %d\n",
+ signo,
+ info->si_signo,
+ info->si_errno,
+ info->si_code,
+ info->si_pid);
+
+}
+#endif
diff --git a/storage/ndb/src/cw/test/socketclient/Makefile b/storage/ndb/src/cw/test/socketclient/Makefile
new file mode 100644
index 00000000000..04f11f031e5
--- /dev/null
+++ b/storage/ndb/src/cw/test/socketclient/Makefile
@@ -0,0 +1,24 @@
+include .defs.mk
+
+TYPE :=
+
+BIN_TARGET := socketclient
+
+
+
+CCFLAGS_LOC += -I../../util/ -I../../cpcd/
+
+LIBS_LOC += -L$(NDB_TOP)/lib/ -L$(EXTERNAL_LIB_DIR)/sci
+
+LIBS_SPEC += -lsocketclient
+
+
+SOURCES = socketClientTest.cpp
+
+
+include $(NDB_TOP)/Epilogue.mk
+
+
+
+
+
diff --git a/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp b/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp
new file mode 100644
index 00000000000..423c196aa43
--- /dev/null
+++ b/storage/ndb/src/cw/test/socketclient/socketClientTest.cpp
@@ -0,0 +1,64 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+#include <ndb_global.h>
+#include <NdbOut.hpp>
+#include <Properties.hpp>
+#include <socket_io.h>
+#include <NdbTick.h>
+#include <NdbMain.h>
+#include <NdbSleep.h>
+#include "SocketService.hpp"
+#include "SocketRegistry.hpp"
+#include "SocketClient.hpp"
+#include "ClientInterface.hpp"
+
+#include <InputStream.hpp>
+
+#include <Parser.hpp>
+
+NDB_MAIN(socketclient) {
+
+
+ if(argc<3) {
+ printf("wrong args: socketclient <hostname> <port>\n");
+ return 0;
+ }
+ const char * remotehost = argv[1];
+ const int port = atoi(argv[2]);
+
+
+ ClientInterface * ci = new ClientInterface(2);
+ ci->connectCPCDdaemon(remotehost,port);
+
+ /*ci->listProcesses(remotehost);
+
+ ci->startProcess(remotehost, "1247");
+
+ ci->stopProcess(remotehost, "1247");*/
+
+ ci->defineProcess(remotehost, "ndb", "ndb-cluster1", "envirnm", "/ndb/bin",
+ "-i", "permanent", "/ndb/ndb.2", "team");
+
+ ci->startProcess(remotehost, "1247");
+
+ ci->listProcesses(remotehost);
+
+ //ci->undefineProcess(remotehost, "1247");
+
+ ci->disconnectCPCDdaemon(remotehost);
+}
diff --git a/storage/ndb/src/cw/util/ClientInterface.cpp b/storage/ndb/src/cw/util/ClientInterface.cpp
new file mode 100644
index 00000000000..627b622f1dd
--- /dev/null
+++ b/storage/ndb/src/cw/util/ClientInterface.cpp
@@ -0,0 +1,185 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include "ClientInterface.hpp"
+
+
+
+ClientInterface::ClientInterface(Uint32 maxNoOfCPCD) {
+ sr = new SocketRegistry<SocketService>(maxNoOfCPCD);
+ ss = new SocketService();
+}
+
+
+ClientInterface::~ClientInterface() {
+ delete sr;
+ delete ss;
+
+}
+
+
+void ClientInterface::connectCPCDdaemon(const char * remotehost, Uint16 port)
+{
+ sr->createSocketClient(remotehost, port);
+}
+
+void ClientInterface::disconnectCPCDdaemon(const char * remotehost)
+{
+ sr->removeSocketClient(remotehost);
+}
+
+void ClientInterface::removeCPCDdaemon(const char * remotehost)
+{
+ sr->removeSocketClient(remotehost);
+}
+
+void ClientInterface::startProcess(const char * remotehost, char * id) {
+ char buf[255] = "start process ";
+ char str[80];
+ char line[10];
+
+ strcpy(line, id);
+ strcpy(str, "id:");
+ strcat(str, line);
+ strcat(str, "\n\n");
+ strcat(buf, str);
+ printf("Request: %s\n", buf);
+
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
+
+void ClientInterface::stopProcess(const char * remotehost, char * id) {
+ char buf[255] = "stop process ";
+ char str[80];
+ char line[10];
+
+ strcpy(line, id);
+ strcpy(str, "id:");
+ strcat(str, line);
+ strcat(str, "\n\n");
+ strcat(buf, str);
+ printf("Request: %s\n", buf);
+
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
+
+void ClientInterface::defineProcess(const char * remotehost, char * name,
+ char * group, char * env, char * path,
+ char * args, char * type, char * cwd, char * owner){
+ char buf[255] = "define process ";
+ char str[80];
+ char line[10];
+
+ strcpy(line, name);
+ strcpy(str, "name:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, group);
+ strcpy(str, "group:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, env);
+ strcpy(str, "env:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, path);
+ strcpy(str, "path:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, args);
+ strcpy(str, "args:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, type);
+ strcpy(str, "type:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, cwd);
+ strcpy(str, "cwd:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, " \n");
+
+ strcpy(line, owner);
+ strcpy(str, "owner:");
+ strcat(str, line);
+ strcat(buf, str);
+ strcat(buf, "\n\n");
+
+ printf("Request: %s\n", buf);
+
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
+
+void ClientInterface::undefineProcess(const char * remotehost, char * id){
+ char buf[255] = "undefine process ";
+ char str[80];
+ char line[10];
+
+ strcpy(line, id);
+ strcpy(str, "id:");
+ strcat(str, line);
+ strcat(str, "\n\n");
+ strcat(buf, str);
+ printf("Request: %s\n", buf);
+
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
+
+void ClientInterface::listProcesses(const char * remotehost) {
+ char buf[255]="list processes\n\n";
+ printf("Request: %s\n", buf);
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
+
+void ClientInterface::showProcess(const char * remotehost, char * id) {
+ char buf[255] = "show process ";
+ char str[80];
+ char line[10];
+
+ strcpy(line, id);
+ strcpy(str, "id:");
+ strcat(str, line);
+ strcat(str, "\n\n");
+ strcat(buf, str);
+ printf("Request: %s\n", buf);
+
+ sr->performSend(buf,255,remotehost);
+ sr->syncPerformReceive(remotehost, *ss, 0);
+ ss->getPropertyObject();
+}
diff --git a/storage/ndb/src/cw/util/ClientInterface.hpp b/storage/ndb/src/cw/util/ClientInterface.hpp
new file mode 100644
index 00000000000..66ecfe05197
--- /dev/null
+++ b/storage/ndb/src/cw/util/ClientInterface.hpp
@@ -0,0 +1,49 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 CLIENT_IF_HPP
+#define CLIENT_IF_HPP
+#include <ndb_global.h>
+#include <Parser.hpp>
+#include <InputStream.hpp>
+#include <Parser.hpp>
+#include <NdbOut.hpp>
+#include <Properties.hpp>
+#include "SocketRegistry.hpp"
+#include "SocketService.hpp"
+
+class ClientInterface {
+private:
+ SocketService * ss;
+ SocketRegistry<SocketService> * sr;
+
+public:
+ ClientInterface(Uint32 maxNoOfCPC);
+ ~ClientInterface();
+ void startProcess(const char * remotehost, char * id);
+ void stopProcess(const char * remotehost, char * id);
+ void defineProcess(const char * remotehost, char * name, char * group,
+ char * env, char * path, char * args, char * type,
+ char * cwd, char * owner);
+ void undefineProcess(const char * remotehost, char * id);
+ void listProcesses(const char * remotehost);
+ void showProcess(const char * remotehost, char * id);
+ void connectCPCDdaemon(const char * remotehost, Uint16 port);
+ void disconnectCPCDdaemon(const char * remotehost);
+ void removeCPCDdaemon(const char * remotehost);
+
+};
+#endif
diff --git a/storage/ndb/src/cw/util/Makefile b/storage/ndb/src/cw/util/Makefile
new file mode 100644
index 00000000000..f5ab16721be
--- /dev/null
+++ b/storage/ndb/src/cw/util/Makefile
@@ -0,0 +1,10 @@
+include .defs.mk
+TYPE := ndbapi
+
+PIC_ARCHIVE := Y
+ARCHIVE_TARGET := socketclient
+
+# Source files of non-templated classes (.cpp files)
+SOURCES = ClientInterface.cpp SocketService.cpp SocketClient.cpp
+
+include $(NDB_TOP)/Epilogue.mk
diff --git a/storage/ndb/src/cw/util/SocketRegistry.cpp b/storage/ndb/src/cw/util/SocketRegistry.cpp
new file mode 100644
index 00000000000..1dbb402f7c9
--- /dev/null
+++ b/storage/ndb/src/cw/util/SocketRegistry.cpp
@@ -0,0 +1,213 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+#include "SocketRegistry.hpp"
+#include <Parser.hpp>
+
+template<class T>
+SocketRegistry<T>::SocketRegistry(Uint32 maxSocketClients) {
+
+}
+
+
+template<class T>
+SocketRegistry<T>::~SocketRegistry() {
+ delete [] m_socketClients;
+}
+
+template<class T>
+bool
+SocketRegistry<T>::createSocketClient(const char * host, Uint16 port) {
+
+ if(port == 0)
+ return false;
+ if(host==NULL)
+ return false;
+
+ SocketClient * socketClient = new SocketClient(host, port);
+
+ if(socketClient->openSocket() < 0 || socketClient == NULL) {
+ ndbout << "could not connect" << endl;
+ delete socketClient;
+ return false;
+ }
+ else {
+ m_socketClients[m_nSocketClients] = socketClient;
+ m_nSocketClients++;
+ }
+ return true;
+}
+
+template<class T>
+int
+SocketRegistry<T>::pollSocketClients(Uint32 timeOutMillis) {
+
+
+
+ // Return directly if there are no TCP transporters configured
+ if (m_nSocketClients == 0){
+ tcpReadSelectReply = 0;
+ return 0;
+ }
+ struct timeval timeout;
+ timeout.tv_sec = timeOutMillis / 1000;
+ timeout.tv_usec = (timeOutMillis % 1000) * 1000;
+
+
+ NDB_SOCKET_TYPE maxSocketValue = 0;
+
+ // Needed for TCP/IP connections
+ // The read- and writeset are used by select
+
+ FD_ZERO(&tcpReadset);
+
+ // Prepare for sending and receiving
+ for (Uint32 i = 0; i < m_nSocketClients; i++) {
+ SocketClient * t = m_socketClients[i];
+
+ // If the socketclient is connected
+ if (t->isConnected()) {
+
+ const NDB_SOCKET_TYPE socket = t->getSocket();
+ // Find the highest socket value. It will be used by select
+ if (socket > maxSocketValue)
+ maxSocketValue = socket;
+
+ // Put the connected transporters in the socket read-set
+ FD_SET(socket, &tcpReadset);
+ }
+ }
+
+ // The highest socket value plus one
+ maxSocketValue++;
+
+ tcpReadSelectReply = select(maxSocketValue, &tcpReadset, 0, 0, &timeout);
+#ifdef NDB_WIN32
+ if(tcpReadSelectReply == SOCKET_ERROR)
+ {
+ NdbSleep_MilliSleep(timeOutMillis);
+ }
+#endif
+
+ return tcpReadSelectReply;
+
+}
+
+template<class T>
+bool
+SocketRegistry<T>::performSend(const char * buf,
+ Uint32 len,
+ const char * remotehost)
+{
+ SocketClient * socketClient;
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), remotehost)==0) {
+ if(socketClient->isConnected()) {
+ if(socketClient->writeSocket(buf, len)>0)
+ return true;
+ else
+ return false;
+ }
+ }
+ }
+ return false;
+}
+
+template<class T>
+int
+SocketRegistry<T>::performReceive(T & t) {
+ char buf[255] ; //temp. just for testing. must fix better
+
+ if(tcpReadSelectReply > 0){
+ for (Uint32 i=0; i<m_nSocketClients; i++) {
+ SocketClient *sc = m_socketClients[i];
+ const NDB_SOCKET_TYPE socket = sc->getSocket();
+ if(sc->isConnected() && FD_ISSET(socket, &tcpReadset)) {
+ t->runSession(socket,t);
+ }
+ }
+ return 1;
+ }
+ return 0;
+
+}
+
+
+
+template<class T>
+inline
+int
+SocketRegistry<T>::syncPerformReceive(char * host,
+ T & t,
+ Uint32 timeOutMillis) {
+ char buf[255] ; //temp. just for testing. must fix better
+ struct timeval timeout;
+ timeout.tv_sec = timeOutMillis / 1000;
+ timeout.tv_usec = (timeOutMillis % 1000) * 1000;
+ int reply;
+ SocketClient * sc;
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ sc = m_socketClients[i];
+ if(strcmp(sc->gethostname(), remotehost)==0) {
+ if(sc->isConnected()) {
+ FD_ZERO(&tcpReadset);
+ reply = select(sc->getSocket(), &tcpReadset, 0, 0, &timeout);
+ if(reply > 0) {
+ return t->runSession(sc->getSocket(), t);
+ }
+ }
+
+ }
+ }
+ return 0;
+}
+
+
+
+template<class T>
+bool
+SocketRegistry<T>::reconnect(const char * host){
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ SocketClient * socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), host)==0) {
+ if(!socketClient->isConnected()) {
+ if(socketClient->openSocket() > 0)
+ return true;
+ else return false;
+ }
+ }
+ }
+ return false;
+}
+
+template<class T>
+bool
+SocketRegistry<T>::removeSocketClient(const char * host){
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ SocketClient * socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), host)==0) {
+ if(!socketClient->isConnected()) {
+ if(socketClient->closeSocket() > 0) {
+ delete socketClient;
+ return true;
+ }
+ else return false;
+ }
+ }
+ }
+ return false;
+}
diff --git a/storage/ndb/src/cw/util/SocketRegistry.hpp b/storage/ndb/src/cw/util/SocketRegistry.hpp
new file mode 100644
index 00000000000..2b079156967
--- /dev/null
+++ b/storage/ndb/src/cw/util/SocketRegistry.hpp
@@ -0,0 +1,290 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 SocketClientRegistry_H
+#define SocketClientRegistry_H
+
+#include <NdbTCP.h>
+#include <NdbOut.hpp>
+
+#include "SocketClient.hpp"
+
+template<class T>
+class SocketRegistry {
+
+public:
+ SocketRegistry(Uint32 maxSocketClients);
+ ~SocketRegistry();
+ /**
+ * creates and adds a SocketClient to m_socketClients[]
+ * @param host - host name
+ * @param port - port to connect to
+ */
+ bool createSocketClient(const char * host, const Uint16 port);
+
+ /**
+ * performReceive reads from sockets should do more stuff
+ */
+ int performReceive(T &);
+
+
+ /**
+ * performReceive reads from sockets should do more stuff
+ */
+ int syncPerformReceive(const char* ,T &, Uint32);
+
+
+ /**
+ * performSend sends a command to a host
+ */
+ bool performSend(const char * buf, Uint32 len, const char * remotehost);
+
+ /**
+ * pollSocketClients performs a select (for a max. of timeoutmillis) or
+ * until there is data to be read from any SocketClient
+ * @param timeOutMillis - select timeout
+ */
+ int pollSocketClients(Uint32 timeOutMillis);
+
+ /**
+ * reconnect tries to reconnect to a cpcd given its hostname
+ * @param host - name of host to reconnect to.
+ */
+ bool reconnect(const char * host);
+
+
+ /**
+ * removeSocketClient
+ * @param host - name of host for which to remove the SocketConnection
+ */
+ bool removeSocketClient(const char * host);
+
+private:
+ SocketClient** m_socketClients;
+ Uint32 m_maxSocketClients;
+ Uint32 m_nSocketClients;
+ int tcpReadSelectReply;
+ fd_set tcpReadset;
+
+
+};
+
+
+template<class T>
+inline
+SocketRegistry<T>::SocketRegistry(Uint32 maxSocketClients) {
+ m_maxSocketClients = maxSocketClients;
+ m_socketClients = new SocketClient * [m_maxSocketClients];
+ m_nSocketClients = 0;
+}
+
+
+template<class T>
+inline
+SocketRegistry<T>::~SocketRegistry() {
+ delete [] m_socketClients;
+}
+
+template<class T>
+inline
+bool
+SocketRegistry<T>::createSocketClient(const char * host, Uint16 port) {
+
+ if(port == 0)
+ return false;
+ if(host==NULL)
+ return false;
+
+ SocketClient * socketClient = new SocketClient(host, port);
+
+ if(socketClient->openSocket() < 0 || socketClient == NULL) {
+ ndbout << "could not connect" << endl;
+ delete socketClient;
+ return false;
+ }
+ else {
+ m_socketClients[m_nSocketClients] = socketClient;
+ m_nSocketClients++;
+ }
+ return true;
+}
+
+template<class T>
+inline
+int
+SocketRegistry<T>::pollSocketClients(Uint32 timeOutMillis) {
+
+
+
+ // Return directly if there are no TCP transporters configured
+ if (m_nSocketClients == 0){
+ tcpReadSelectReply = 0;
+ return 0;
+ }
+ struct timeval timeout;
+ timeout.tv_sec = timeOutMillis / 1000;
+ timeout.tv_usec = (timeOutMillis % 1000) * 1000;
+
+
+ NDB_SOCKET_TYPE maxSocketValue = 0;
+
+ // Needed for TCP/IP connections
+ // The read- and writeset are used by select
+
+ FD_ZERO(&tcpReadset);
+
+ // Prepare for sending and receiving
+ for (Uint32 i = 0; i < m_nSocketClients; i++) {
+ SocketClient * t = m_socketClients[i];
+
+ // If the socketclient is connected
+ if (t->isConnected()) {
+
+ const NDB_SOCKET_TYPE socket = t->getSocket();
+ // Find the highest socket value. It will be used by select
+ if (socket > maxSocketValue)
+ maxSocketValue = socket;
+
+ // Put the connected transporters in the socket read-set
+ FD_SET(socket, &tcpReadset);
+ }
+ }
+
+ // The highest socket value plus one
+ maxSocketValue++;
+
+ tcpReadSelectReply = select(maxSocketValue, &tcpReadset, 0, 0, &timeout);
+#ifdef NDB_WIN32
+ if(tcpReadSelectReply == SOCKET_ERROR)
+ {
+ NdbSleep_MilliSleep(timeOutMillis);
+ }
+#endif
+
+ return tcpReadSelectReply;
+
+}
+
+template<class T>
+inline
+bool
+SocketRegistry<T>::performSend(const char * buf, Uint32 len, const char * remotehost)
+{
+ SocketClient * socketClient;
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), remotehost)==0) {
+ if(socketClient->isConnected()) {
+ if(socketClient->writeSocket(buf, len)>0)
+ return true;
+ else
+ return false;
+ }
+ }
+ }
+ return false;
+}
+
+template<class T>
+inline
+int
+SocketRegistry<T>::performReceive(T & t) {
+ char buf[255] ; //temp. just for testing. must fix better
+
+ if(tcpReadSelectReply > 0){
+ for (Uint32 i=0; i<m_nSocketClients; i++) {
+ SocketClient *sc = m_socketClients[i];
+ const NDB_SOCKET_TYPE socket = sc->getSocket();
+ if(sc->isConnected() && FD_ISSET(socket, &tcpReadset)) {
+ t->runSession(socket,t);
+ }
+ }
+ return 1;
+ }
+ return 0;
+
+}
+
+
+
+template<class T>
+inline
+int
+SocketRegistry<T>::syncPerformReceive(const char * remotehost,
+ T & t,
+ Uint32 timeOutMillis) {
+ char buf[255] ; //temp. just for testing. must fix better
+ struct timeval timeout;
+ timeout.tv_sec = timeOutMillis / 1000;
+ timeout.tv_usec = (timeOutMillis % 1000) * 1000;
+ int reply;
+ SocketClient * sc;
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ sc = m_socketClients[i];
+ if(strcmp(sc->gethostname(), remotehost)==0) {
+ if(sc->isConnected()) {
+ /*FD_ZERO(&tcpReadset);
+ reply = select(sc->getSocket()+1, 0, 0, 0, &timeout);
+ reply=1;
+ if(reply > 0) {*/
+ t.runSession(sc->getSocket(), t);
+ //}
+ }
+
+ }
+ }
+}
+
+
+
+template<class T>
+inline
+bool
+SocketRegistry<T>::reconnect(const char * host){
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ SocketClient * socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), host)==0) {
+ if(!socketClient->isConnected()) {
+ if(socketClient->openSocket() > 0)
+ return true;
+ else return false;
+ }
+ }
+ }
+ return false;
+}
+
+template<class T>
+inline
+bool
+SocketRegistry<T>::removeSocketClient(const char * host){
+ for(Uint32 i=0; i < m_nSocketClients; i++) {
+ SocketClient * socketClient = m_socketClients[i];
+ if(strcmp(socketClient->gethostname(), host)==0) {
+ if(!socketClient->isConnected()) {
+ if(socketClient->closeSocket() > 0) {
+ delete socketClient;
+ return true;
+ }
+ else return false;
+ }
+ }
+ }
+ return false;
+}
+
+
+#endif // Define of SocketRegistry
diff --git a/storage/ndb/src/cw/util/SocketService.cpp b/storage/ndb/src/cw/util/SocketService.cpp
new file mode 100644
index 00000000000..b993ec8c2c1
--- /dev/null
+++ b/storage/ndb/src/cw/util/SocketService.cpp
@@ -0,0 +1,60 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 */
+
+
+#include <Parser.hpp>
+#include <NdbOut.hpp>
+#include <Properties.hpp>
+#include "SocketService.hpp"
+
+SocketService::SocketService() {
+
+}
+
+SocketService::~SocketService() {
+
+}
+
+int
+SocketService::runSession(NDB_SOCKET_TYPE socket, SocketService & ss){
+ InputStream *m_input = new SocketInputStream(socket);
+ char buf[255];
+
+ m_input->gets(buf,255);
+ ndbout_c("SocketService:received: %s\n", buf);
+ ndbout_c("This should now be parsed\n");
+ ndbout_c("and put in a property object.\n");
+ ndbout_c("The propery is then accessible from the ClientInterface.\n");
+ ndbout_c("by getPropertyObject.\n");
+ ndbout_c("At least this is the idea.");
+ /*Parser_t *m_parser =
+ new Parser<SocketService>(commands, *m_input, true, true, true);
+ */
+ /** to do
+ * add a proprty object to which the parser will put its result.
+ */
+
+ return 1 ; //succesful
+ //return 0; //unsuccesful
+
+}
+
+void
+SocketService::getPropertyObject() {
+ ndbout << "get property object. return to front end or something" << endl;
+}
+
+
diff --git a/storage/ndb/src/cw/util/SocketService.hpp b/storage/ndb/src/cw/util/SocketService.hpp
new file mode 100644
index 00000000000..7a0c3a2fd91
--- /dev/null
+++ b/storage/ndb/src/cw/util/SocketService.hpp
@@ -0,0 +1,46 @@
+/* Copyright (C) 2003 MySQL AB
+
+ 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 SOCKET_SERVICE_HPP
+#define SOCKET_SERVICE_HPP
+#include <Parser.hpp>
+#include <InputStream.hpp>
+#include <Parser.hpp>
+#include <NdbOut.hpp>
+#include <Properties.hpp>
+#include "SocketRegistry.hpp"
+
+
+
+
+class SocketService {
+ friend class SocketRegistry<SocketService>;
+private:
+ typedef Parser<SocketService> Parser_t;
+ int runSession(NDB_SOCKET_TYPE socket, SocketService &);
+public:
+ void getPropertyObject();
+ SocketService();
+ ~SocketService();
+
+};
+
+
+
+
+
+
+#endif