예제 #1
0
 virtual void handle(Mercury::Channel* pChannel, MemoryStream& s)
 {
     CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
     std::string strarg;
     s.readBlob(strarg);
     dlg->onExecScriptCommandCB(pChannel, strarg);
 };
예제 #2
0
void CProfileWindow::OnBnClickedButton1()
{
	m_pyprofile.EnableWindow(FALSE);
	m_cprofile.EnableWindow(FALSE);
	m_eventprofile.EnableWindow(FALSE);
	m_mercuryprofile.EnableWindow(FALSE);
	CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);

	CTimingLengthWindow wnd;
	wnd.m_profileName = profilename;
	if(wnd.DoModal() == IDOK)
	{
		if(dlg->startProfile(wnd.m_profileName, 0, wnd.m_timingLength))
		{
			CString outstr;
			outstr.Format(L"Waiting %.2f secs...\r\n\r\n", (float)wnd.m_timingLength);
			m_results.SetWindowText(outstr);
			m_profileShowList.ShowWindow(FALSE);
			m_results.ShowWindow(TRUE);
			return;
		}
	}

	m_pyprofile.EnableWindow(TRUE);
	m_cprofile.EnableWindow(TRUE);
	m_eventprofile.EnableWindow(TRUE);
	m_mercuryprofile.EnableWindow(TRUE);
	::AfxMessageBox(L"please select the baseapp|cellapp.");
}
예제 #3
0
BOOL CguiconsoleApp::InitInstance()
{
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinAppEx::InitInstance();

	if (!AfxSocketInit())
	{
		AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	// of your final executable, you should remove from the following
	// the specific initialization routines you do not need
	// Change the registry key under which our settings are stored
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	CguiconsoleDlg dlg;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
예제 #4
0
void CLogWindow::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	// 请求服务器拉取日志
	CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
	
	HTREEITEM item = dlg->hasCheckApp(MESSAGELOG_TYPE);
	if(item == NULL)
	{
		::AfxMessageBox(L"messagelog no select!");
		return;
	}

	Mercury::Address addr = dlg->getTreeItemAddr(item);

	Mercury::Channel* pChannel = dlg->networkInterface().findChannel(addr);
	if(pChannel == NULL)
	{
		::AfxMessageBox(L"messagelog is error!");
		return;
	}

	Mercury::Bundle bundle;
	bundle.newMessage(MessagelogInterface::registerLogWatcher);

	bundle << getSelLogTypes();
	
	CString apporder;
	m_appIDEdit.GetWindowTextW(apporder);

	char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
	COMPONENT_ORDER order = atoi(cs);
	free(cs);

	bundle << order;

	int8 count = 0;
	std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
	count = vec.size();
	bundle << count;
	std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
	for(; iter != vec.end(); iter++)
	{
		bundle << (*iter);
	}

	bundle.send(dlg->networkInterface(), pChannel);
}
예제 #5
0
void CLogWindow::OnBnClickedButton1()
{
    // TODO: Add your control notification handler code here
    // 请求服务器拉取日志
    CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);

    HTREEITEM item = dlg->hasCheckApp(LOGGER_TYPE);
    if(item == NULL)
    {
        ::AfxMessageBox(L"logger no select!");
        return;
    }

    dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    Network::Address addr = dlg->getTreeItemAddr(item);
    pullLogs(addr);
}
void CConnectRemoteMachineWindow::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
	byte ips[4];

	if (0 == m_ip.GetAddress(ips[0],ips[1],ips[2],ips[3]))
	{
		AfxMessageBox(L"address is error!");
		return;
	}
	
	char strip[256];
	sprintf_s(strip, 256, "%d.%d.%d.%d", ips[0],ips[1],ips[2],ips[3]);
	
	KBEngine::u_int16_t port = 0;
	CString sport;
	m_port.GetWindowTextW(sport);
	char* csport = KBEngine::strutil::wchar2char(sport.GetBuffer(0));
	port = atoi(csport);
	std::string command = strip;
	command += ":";
	command += csport;
	free(csport);

	KBEngine::Mercury::EndPoint* endpoint = new KBEngine::Mercury::EndPoint();

	KBEngine::u_int32_t address;
	endpoint->convertAddress(strip, address);
	KBEngine::Mercury::Address addr(address, htons(port));

	if(addr.ip == 0)
	{
		::AfxMessageBox(L"address is error!");
		delete endpoint;
		return;
	}

	endpoint->socket(SOCK_STREAM);
	if (!endpoint->good())
	{
		AfxMessageBox(L"couldn't create a socket\n");
		delete endpoint;
		return;
	}

	endpoint->addr(addr);
	if(endpoint->connect(addr.port, addr.ip) == -1)
	{
		CString err;
		err.Format(L"connect server is error! %d", ::WSAGetLastError());
		AfxMessageBox(err);
		delete endpoint;
		return;
	}

	endpoint->setnonblocking(false);
	int8 findComponentTypes[] = {MESSAGELOG_TYPE, RESOURCEMGR_TYPE, BASEAPP_TYPE, CELLAPP_TYPE, BASEAPPMGR_TYPE, CELLAPPMGR_TYPE, LOGINAPP_TYPE, DBMGR_TYPE, BOTS_TYPE, UNKNOWN_COMPONENT_TYPE};
	int ifind = 0;

	while(true)
	{
		int8 findComponentType = findComponentTypes[ifind++];
		if(findComponentType == UNKNOWN_COMPONENT_TYPE)
		{
			//INFO_MSG("Componentbridge::process: not found %s, try again...\n",
			//	COMPONENT_NAME_EX(findComponentType));
			break;
		}

		KBEngine::Mercury::Bundle bhandler;
		bhandler.newMessage(KBEngine::MachineInterface::onFindInterfaceAddr);

		KBEngine::MachineInterface::onFindInterfaceAddrArgs7::staticAddToBundle(bhandler, KBEngine::getUserUID(), KBEngine::getUsername(), 
			CONSOLE_TYPE, g_componentID, findComponentType, 0, 0);

		bhandler.send(*endpoint);

		KBEngine::Mercury::TCPPacket packet;
		packet.resize(65535);

		endpoint->setnonblocking(true);
		KBEngine::sleep(300);
		packet.wpos(endpoint->recv(packet.data(), 65535));

		while(packet.opsize() > 0)
		{
			MachineInterface::onBroadcastInterfaceArgs22 args;
			
			try
			{
				args.createFromStream(packet);
			}catch(MemoryStreamException &)
			{
				goto END;
			}

			INFO_MSG(boost::format("CConnectRemoteMachineWindow::OnBnClickedOk: found %1%, addr:%2%:%3%\n") %
				COMPONENT_NAME_EX((COMPONENT_TYPE)args.componentType) % inet_ntoa((struct in_addr&)args.intaddr) % ntohs(args.intport));

			Components::getSingleton().addComponent(args.uid, args.username.c_str(), 
				(KBEngine::COMPONENT_TYPE)args.componentType, args.componentID, args.globalorderid, args.grouporderid, 
				args.intaddr, args.intport, args.extaddr, args.extport, args.extaddrEx, args.pid, args.cpu, args.mem, args.usedmem, 
				args.extradata, args.extradata1, args.extradata2, args.extradata3);

		}
	}
END:
	dlg->updateTree();
	delete endpoint;
	wchar_t* wcommand = KBEngine::strutil::char2wchar(command.c_str());
	bool found = false;
	std::deque<CString>::iterator iter = m_historyCommand.begin();
	for(; iter != m_historyCommand.end(); iter++)
	{
		if((*iter) == wcommand)
		{
			found = true;
			break;
		}
	}
	
	if(!found)
	{
		m_historyCommand.push_front(wcommand);
		if(m_historyCommand.size() > 10)
			m_historyCommand.pop_back();

		saveHistory();
	}

	free(wcommand);

	OnOK(); 
}
예제 #7
0
void CLogWindow::updateSettingToServer()
{
    Network::Bundle* pBundle = Network::Bundle::createPoolObject();
    (*pBundle).newMessage(LoggerInterface::updateLogWatcherSetting);

    CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    int32 uid = dlg->getSelTreeItemUID();
    (*pBundle) << uid;

    (*pBundle) << getSelLogTypes();

    CString apporder;
    m_appIDEdit.GetWindowTextW(apporder);

    char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
    COMPONENT_ORDER order = atoi(cs);
    free(cs);

    (*pBundle) << order;

    m_appIDEdit1.GetWindowTextW(apporder);
    cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
    order = atoi(cs);
    free(cs);

    (*pBundle) << order;

    CString date;
    m_dateEdit.GetWindowTextW(date);
    cs = KBEngine::strutil::wchar2char(date.GetBuffer(0));
    (*pBundle) << cs;
    free(cs);

    CString keystr;
    m_findEdit.GetWindowTextW(keystr);
    cs = KBEngine::strutil::wchar2char(keystr.GetBuffer(0));
    (*pBundle) << cs;
    free(cs);

    int8 count = 0;
    std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
    count = vec.size();
    (*pBundle) << count;
    std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
    for(; iter != vec.end(); iter++)
    {
        (*pBundle) << (*iter);
    }

    HTREEITEM item = dlg->hasCheckApp(LOGGER_TYPE);
    if(item == NULL)
    {
        ::AfxMessageBox(L"logger no select!");
        Network::Bundle::reclaimPoolObject(pBundle);
        return;
    }

    dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    Network::Address addr = dlg->getTreeItemAddr(item);
    Network::Channel* pChannel = dlg->networkInterface().findChannel(addr);
    if(pChannel == NULL)
    {
        ::AfxMessageBox(L"logger is error!");
        Network::Bundle::reclaimPoolObject(pBundle);
        return;
    }

    bool first = m_loglist.GetCount() <= 0;
    (*pBundle) << first;
    pChannel->send(pBundle);
}
예제 #8
0
void CLogWindow::pullLogs(KBEngine::Network::Address addr)
{
    CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    Network::Channel* pChannel = dlg->networkInterface().findChannel(addr);
    if(pChannel == NULL)
    {
        ::AfxMessageBox(L"logger is error!");
        return;
    }

    if(!pulling)
    {
        Network::Bundle* pBundle = Network::Bundle::createPoolObject();
        (*pBundle).newMessage(LoggerInterface::registerLogWatcher);

        int32 uid = dlg->getSelTreeItemUID();
        (*pBundle) << uid;

        (*pBundle) << getSelLogTypes();

        CString apporder;
        m_appIDEdit.GetWindowTextW(apporder);

        char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
        COMPONENT_ORDER order = atoi(cs);
        free(cs);

        (*pBundle) << order;

        m_appIDEdit1.GetWindowTextW(apporder);
        cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
        order = atoi(cs);
        free(cs);

        (*pBundle) << order;

        CString date;
        m_dateEdit.GetWindowTextW(date);
        cs = KBEngine::strutil::wchar2char(date.GetBuffer(0));
        (*pBundle) << cs;
        free(cs);

        CString keystr;
        m_findEdit.GetWindowTextW(keystr);
        cs = KBEngine::strutil::wchar2char(keystr.GetBuffer(0));
        (*pBundle) << cs;
        free(cs);

        int8 count = 0;
        std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
        count = vec.size();
        (*pBundle) << count;
        std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
        for(; iter != vec.end(); iter++)
        {
            (*pBundle) << (*iter);
        }

        (*pBundle) << isfind_;

        bool first = m_loglist.GetCount() <= 0;
        (*pBundle) << first;
        pChannel->send(pBundle);

        m_autopull.SetWindowTextW(L"stop");
    }
    else
    {
        m_autopull.SetWindowTextW(L"auto");

        Network::Bundle* pBundle = Network::Bundle::createPoolObject();
        (*pBundle).newMessage(LoggerInterface::deregisterLogWatcher);
        pChannel->send(pBundle);
    }

    pulling = !pulling;
}
예제 #9
0
void CWatcherWindow::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default

	CDialog::OnTimer(nIDEvent);
	if(!this->IsWindowVisible())
		return;

	CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
	dlg->reqQueryWatcher(getCurrSelPath());

	if(m_status.GetItemCount() == 1)
	{
		int nColumnCount = m_status.GetHeaderCtrl()->GetItemCount();   

		if(m_statusShow.GetItemCount() != nColumnCount)
		{
			m_statusShow.InsertColumn(0, L"WatcherName", LVCFMT_LEFT,	150);
			m_statusShow.InsertColumn(1, L"WatcherValue", LVCFMT_LEFT, 1000);

			m_statusShow.DeleteAllItems();

			for (int i=0;i < nColumnCount; i++)
			{
				LVCOLUMN lvcol;
				WCHAR str[256];
				memset(str, 0, 256);
				lvcol.mask = LVCF_TEXT|LVCF_WIDTH;
				lvcol.pszText = str;
				lvcol.cchTextMax = 256;
				lvcol.cx = i;
				m_status.GetColumn(i, &lvcol);
				
				m_statusShow.InsertItem(0, lvcol.pszText);
			}
		}

		for(int ii = 0; ii<m_status.GetHeaderCtrl()->GetItemCount(); ii++)
		{
			CString s = m_status.GetItemText(0, ii);

			LVCOLUMN lvcol;
			WCHAR str[256];
			memset(str, 0, 256);
			lvcol.mask = LVCF_TEXT|LVCF_WIDTH;
			lvcol.pszText = str;
			lvcol.cchTextMax = 256;
			lvcol.cx = ii;
			m_status.GetColumn(ii, &lvcol);

			for(int iix = 0; iix < m_statusShow.GetItemCount(); iix++)
			{
				CString ss = m_statusShow.GetItemText(iix, 0);
				if(ss == lvcol.pszText)
					m_statusShow.SetItemText(iix, 1, s);
			}
		}
	}
	else
	{
		int nColumnCount = 0;

		if(m_status.GetHeaderCtrl())
		{
			nColumnCount = m_status.GetHeaderCtrl()->GetItemCount();     

			if(m_statusShow.GetHeaderCtrl() == NULL || nColumnCount != m_statusShow.GetHeaderCtrl()->GetItemCount() ||
				m_status.GetItemCount() != m_statusShow.GetItemCount())
			{
				m_statusShow.DeleteAllItems();
				if(m_statusShow.GetHeaderCtrl())
				{
					int nColumnCount = m_statusShow.GetHeaderCtrl()->GetItemCount();       
					for (int i=0;i < nColumnCount;i++)
					{
						m_statusShow.DeleteColumn(0);
					}
				}

				for (int i=0;i < nColumnCount;i++)
				{
					LVCOLUMN lvcol;
					WCHAR str[256];
					memset(str, 0, 256);
					lvcol.mask=LVCF_TEXT|LVCF_WIDTH;
					lvcol.pszText=str;
					lvcol.cchTextMax=256;
					lvcol.cx = i;
					m_status.GetColumn(i, &lvcol);

					addHeaderShow(lvcol.pszText);
				}
			}

			for(int i=0; i<m_status.GetItemCount(); i++)
			{
				if(i + 1 > m_statusShow.GetItemCount())
				{
					m_statusShow.InsertItem(0, m_status.GetItemText(i, 0));
				}

				for(int ii = 0; ii<m_status.GetHeaderCtrl()->GetItemCount(); ii++)
				{
					m_statusShow.SetItemText(i, ii, m_status.GetItemText(i, ii));
				}
			}
		}
	}
}