MainFrm.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:34k
源码类别:

网格计算

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "trfAgent.h"
  3. #include "MainFrm.h"
  4. #include "netaddress.h"
  5. #include "ConfigEnv.h"
  6. #include "FilelistSend.h"
  7. #include "SendGroupMgr.h"
  8. #include "SysUsrLoginDlg.h"
  9. #include "LocalUserRenameDlg.h"
  10. #include "FtpConnectDlg.h"
  11. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  12. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  13. //{{AFX_MSG_MAP(CMainFrame)
  14. ON_WM_SYSCOMMAND()
  15. ON_WM_CREATE()
  16. ON_WM_SIZE()
  17. ON_WM_TIMER()
  18. ON_COMMAND(ID_SYSTEM_SETTING, OnSystemSetting)
  19. ON_COMMAND(ID_FILE_ADDFILES, OnFileAddfiles)
  20. ON_COMMAND(ID_FILE_DELFLES, OnFileDelfles)
  21. ON_UPDATE_COMMAND_UI(ID_FILE_DELFLES, OnUpdateFileDelfles)
  22. ON_COMMAND(ID_USER_USRLOGIN, OnSystemUsrlogin)
  23. ON_UPDATE_COMMAND_UI(ID_USER_USRLOGIN, OnUpdateSystemUsrlogin)
  24. ON_COMMAND(ID_USER_REFUSRLIST, OnUserRefusrlist)
  25. ON_COMMAND(ID_USER_SEARCH, OnUserSearch)
  26. ON_COMMAND(ID_USER_RENAME, OnUserRename)
  27. ON_COMMAND(ID_FILE_HIDESYS, OnFileHidesys)
  28. ON_COMMAND(ID_USER_LOCALUSRINFO, OnUserLocalusrinfo)
  29. ON_COMMAND(ID_FILE_SEND, OnFileSend)
  30. ON_COMMAND(ID_FILE_CANCEL_SEND, OnFileCancelSend)
  31. ON_UPDATE_COMMAND_UI(ID_FILE_CANCEL_SEND, OnUpdateFileCancelSend)
  32. ON_UPDATE_COMMAND_UI(ID_FILE_SEND, OnUpdateFileSend)
  33. ON_COMMAND(ID_SYSTEM_CRTUSRGRP, OnSystemCrtusrgrp)
  34. ON_COMMAND(ID_SYSTEM_FTPSITESMANG, OnSystemFtpSetting)
  35. ON_COMMAND(ID_FTPOPER_OPEN, OnConnectFtpSvr)
  36. ON_UPDATE_COMMAND_UI(ID_FTPOPER_OPEN, OnUpdateFtpoperOpen)
  37. ON_COMMAND(ID_FTPOPER_CLOSE, OnDisconnectFtpSvr)
  38. ON_UPDATE_COMMAND_UI(ID_FTPOPER_CLOSE, OnUpdateFtpoperClose)
  39. ON_COMMAND(ID_FTPOPER_REFDIRS, OnRefreshFtpDirs)
  40. ON_UPDATE_COMMAND_UI(ID_FTPOPER_REFDIRS, OnUpdateFtpoperRefdirs)
  41. ON_COMMAND(ID_VIEW_CHAT_BAR, OnViewChatBar)
  42. ON_MESSAGE(UWM_SYSTRAY, OnSysTray)
  43. ON_UPDATE_COMMAND_UI(ID_VIEW_CHAT_BAR, OnUpdateViewChatBar)
  44. //}}AFX_MSG_MAP
  45. ON_MESSAGE(UWM_REFRESHUSRLST, OnRefUserListNotify)
  46. ON_MESSAGE(UWM_UPDATESTATUSBAR, OnUpdateStatuBarNotify)
  47. ON_MESSAGE(UWM_UPDATESYSLOGINF, OnUpdateSystemLogInfo)
  48. ON_MESSAGE(UWM_SNDER_UPDATE_SNDING_START, OnSendedFileHeaderNotify)
  49. ON_MESSAGE(UWM_SNDER_UPDATE_SNDING_PROGRESS, OnSendedFileBodyNotify)
  50. ON_MESSAGE(UWM_SNDER_UPDATE_ONEFILESEND_OK, OnSendedFileOverNotify)
  51. ON_MESSAGE(UWM_RECVOR_UPDATE_RECVING_START, OnRecvedFileHeaderNotify)
  52. ON_MESSAGE(UWM_RECVOR_UPDATE_RECVING_PROGRESS, OnRecvedFileBodyNotify)
  53. ON_MESSAGE(UWM_RECVOR_UPDATE_ONEFILERECV_OK, OnRecvedFileOverNotify)
  54. ON_MESSAGE(UWM_SHELLSNDTONOTIFY, OnAddSendFileFrmShellNotify)
  55. END_MESSAGE_MAP()
  56. static UINT indicators[] =
  57. {
  58. ID_INDICATOR_OPERET_INFO,
  59. ID_INDICATOR_SNDING_INFO,
  60. ID_INDICATOR_RCVING_INFO,
  61. ID_SEPARATOR,           // status line indicator
  62. };
  63. CMainFrame::CMainFrame()
  64. {
  65. m_ncuripindx = 0;
  66. m_ncurfleindx = 0;
  67. }
  68. CMainFrame::~CMainFrame()
  69. {
  70. for(; m_pdestips.size() > 0; )
  71. {
  72. m_pdestips.pop_back();
  73. }
  74. }
  75. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  76. {
  77. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  78. return -1;
  79. //////////////////////////////////////////////////////////////////////////
  80. if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
  81. | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
  82. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  83. {
  84. TRACE0("Failed to create toolbarn");
  85. return -1;
  86. }
  87. //////////////////////////////////////////////////////////////////////////
  88. if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeofarray(indicators)))
  89. {
  90. TRACE0("Failed to create status barn");
  91. return -1;
  92. }
  93. for(int i = 0; i < sizeofarray(indicators); ++i)
  94. {
  95. this->m_wndStatusBar.SetPaneText(i, "");
  96. }
  97. //////////////////////////////////////////////////////////////////////////
  98. if(!this->m_wndSendingProgCtrl.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, CRect(0,0,0,0), &m_wndStatusBar, 555))
  99. {
  100. TRACE0("Failed to create m_wndSendingProgCtrln");
  101. return -1;
  102. }
  103. this->m_wndSendingProgCtrl.ShowWindow(SW_HIDE);
  104. //////////////////////////////////////////////////////////////////////////
  105. //creating chat docking-bar window.
  106. if(!this->m_wndChatBar.Create(_LoadString(IDS_CHATBARTITLE).GetBuffer(0), this, CSize(0, 0), TRUE, 666))
  107. {
  108. TRACE0("Failed to create m_wndChatBarn");
  109. return -1;
  110. }
  111. //modify its style.
  112. this->m_wndChatBar.SetBarStyle(this->m_wndChatBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  113. //first, hide it!!!
  114. this->ShowControlBar(&m_wndChatBar, FALSE, TRUE);
  115. //////////////////////////////////////////////////////////////////////////
  116. if(!m_wndSysTray.Create(this->GetSafeHwnd(), IDO_SYSTRAY, 
  117. ::AfxGetApp()->LoadIcon(IDR_MAINFRAME), 
  118. _LoadString(AFX_IDS_APP_TITLE).GetBuffer(0), UWM_SYSTRAY))
  119. {
  120. TRACE0("Failed to create m_wndSysTrayn");
  121. return -1;
  122. }
  123. //////////////////////////////////////////////////////////////////////////
  124. EnableDocking(CBRS_ALIGN_ANY);
  125. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  126. m_wndChatBar.EnableDocking(CBRS_ALIGN_ANY);
  127. DockControlBar(&m_wndToolBar);
  128. DockControlBar(&m_wndChatBar, AFX_IDW_DOCKBAR_BOTTOM);
  129. //////////////////////////////////////////////////////////////////////////
  130. CRegister regKey;
  131. if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
  132. {
  133. TRACE0("Failed to open regitry keyn");
  134. return -1;
  135. }
  136. PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
  137. if(regKey.Read_Bool_Value(REG_BSTARTTOHIDE))
  138. {
  139. this->SetTimer(IDO_FRAME_HIDETIME, 500, NULL);
  140. }
  141. //refresh tray-icon.
  142. this->SetTimer(IDO_FRAME_REFTRAYICON, 3000, NULL);
  143. //////////////////////////////////////////////////////////////////////////
  144. return 0;
  145. }
  146. //save bar state when mainframe window is destroying...
  147. BOOL CMainFrame::DestroyWindow() 
  148. {
  149. return CFrameWnd::DestroyWindow();
  150. }
  151. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  152. {
  153. if( !CFrameWnd::PreCreateWindow(cs) )
  154. return FALSE;
  155. cs.style &= ~FWS_ADDTOTITLE ;
  156. return TRUE;
  157. }
  158. /////////////////////////////////////////////////////////////////////////////
  159. // CMainFrame diagnostics
  160. #ifdef _DEBUG
  161. void CMainFrame::AssertValid() const
  162. {
  163. CFrameWnd::AssertValid();
  164. }
  165. void CMainFrame::Dump(CDumpContext& dc) const
  166. {
  167. CFrameWnd::Dump(dc);
  168. }
  169. #endif //_DEBUG
  170. // CMainFrame message handlers
  171. void CMainFrame::OnSize(UINT nType, int cx, int cy) 
  172. {
  173. //adjust statusbar subitems's display area
  174. if( this && this->GetSafeHwnd() && 
  175. this->m_wndStatusBar && this->m_wndStatusBar.GetSafeHwnd())
  176. {
  177. CRect rcfull;
  178. int nwidth;
  179. this->GetClientRect(&rcfull);
  180. nwidth = rcfull.Width();
  181. this->m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_NORMAL, nwidth / 4);
  182. nwidth -= nwidth / 4;
  183. this->m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, nwidth / 3);
  184. this->m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, nwidth / 3);
  185. this->m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_STRETCH, 0);
  186. if(this->m_wndSendingProgCtrl && this->m_wndSendingProgCtrl.GetSafeHwnd() && this->m_wndSendingProgCtrl.IsWindowVisible())
  187. {
  188. this->m_wndStatusBar.GetItemRect(1, &rcfull);
  189. this->m_wndSendingProgCtrl.MoveWindow(&rcfull);
  190. }
  191. }
  192. CFrameWnd::OnSize(nType, cx, cy);
  193. }
  194. void CMainFrame::OnTimer(UINT nIDEvent) 
  195. {
  196. switch(nIDEvent) {
  197. case IDO_FRAME_HIDETIME:
  198. {
  199. this->ShowWindow(SW_HIDE);
  200. this->KillTimer(nIDEvent);
  201. this->m_wndSysTray.SetActive(TRUE);
  202. }
  203. break;
  204. case IDO_FRAME_REFTRAYICON:
  205. {
  206. this->m_wndSysTray.Refresh();
  207. }
  208. break;
  209. }
  210. CFrameWnd::OnTimer(nIDEvent);
  211. }
  212. LRESULT CMainFrame::OnSysTray(WPARAM wp, LPARAM lp)
  213. {
  214. if(lp == WM_RBUTTONUP)
  215. {
  216. m_wndSysTray.PopupMenu();
  217. }
  218. else if (lp == WM_LBUTTONDBLCLK) 
  219. {
  220. this->m_wndSysTray.SetActive(FALSE);
  221. this->ShowWindow(SW_SHOW);
  222. }
  223. return 1;
  224. }
  225. LRESULT CMainFrame::OnRefUserListNotify(WPARAM, LPARAM)
  226. {
  227. //===update the local database contents===
  228. if(m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating) return 0L;
  229. m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = TRUE;
  230. theApp.m_oCSHelper.UpdateDepartsContents();
  231. theApp.m_oCSHelper.UpdateAgentsContents();
  232. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.UpdateTreeForUserDatas();
  233. this->m_wndChatBar.LogonChatingRoom();
  234. m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = FALSE;
  235. return 0L;
  236. }
  237. //WPARAM = HIBYTE(Content type : 1-pure text; 2-ProgressBar; 4-image); LOBYTE(StatuBar panel index); 
  238. //LPARAM = Pure text - LPSTR Pointer;
  239. //
  240. //    ProgressBar - HIWORD(lparam) : Visble / Invisble
  241. //   LOWORD(lparam) : ProgressBar's step value.
  242. //
  243. //    Image - Image Object Pointer
  244. LRESULT CMainFrame::OnUpdateStatuBarNotify(WPARAM wparam, LPARAM lparam)
  245. {
  246. int ncontype = HIBYTE(wparam);
  247. int nsbindex = LOBYTE(wparam);
  248. if(1 == ncontype) 
  249. {
  250. char *puretxt = (char*)lparam;
  251. this->m_wndStatusBar.SetPaneText(nsbindex, puretxt ? puretxt:"");
  252. if(puretxt) delete []puretxt; //!!!Warning : You must allocate this buffer by using "new TCHAR[X]" operation.
  253. }
  254. else if(2 == ncontype)
  255. {
  256. if(NULL == lparam) return 0L;
  257. BOOL bvisible = HIWORD(lparam) != 0 ? TRUE : FALSE;
  258. if(1 == nsbindex)
  259. {
  260. this->m_wndSendingProgCtrl.ShowWindow(bvisible ? SW_SHOW:SW_HIDE);
  261. int npos = this->m_wndSendingProgCtrl.GetPos();
  262. npos += LOWORD(lparam);
  263. this->m_wndSendingProgCtrl.SetPos(npos);
  264. }
  265. }
  266. return 0L;
  267. }
  268. //update the system log information
  269. LRESULT CMainFrame::OnUpdateSystemLogInfo(WPARAM wparam, LPARAM lparam)
  270. {
  271. if(NULL == lparam) return 1;
  272. BOOL bdelete = (wparam != 0) ? TRUE : FALSE;
  273. //////////////////////////////////////////////////////////////////////////
  274. char *plogtxt = (char*)lparam;
  275. CTime now = CTime::GetCurrentTime();
  276. CString strtime, strlog;
  277. strtime.Format(SYS_TIMEFORMAT, now.GetYear(), now.GetMonth(), now.GetDay(),
  278. now.GetHour(), now.GetMinute(), now.GetSecond());
  279. strlog.Format("%s -> %srn", strtime.GetBuffer(0), plogtxt);
  280. //////////////////////////////////////////////////////////////////////////
  281. CEdit &pedit = this->m_pwndSyslogView->GetEditCtrl();
  282. int ntail = pedit.GetWindowTextLength();
  283. pedit.SetSel(ntail, ntail);
  284. pedit.ReplaceSel(strlog.GetBuffer(0));
  285. //////////////////////////////////////////////////////////////////////////
  286. if(TRUE == bdelete)
  287. {
  288. delete []plogtxt;
  289. plogtxt = NULL;
  290. }
  291. return 0L;
  292. }
  293. //UWM_RECVOR_UPDATE_RECVING_START
  294. LRESULT CMainFrame::OnRecvedFileHeaderNotify(WPARAM wparam, LPARAM lparam)
  295. {
  296. LPNETFILEHDR lpfilehdr = (LPNETFILEHDR)lparam; //file header struct.
  297. assert(NULL != lpfilehdr);
  298. //add file into recved file listview.
  299. CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
  300. //disable sort function.
  301. precvfilelist->EnableSort(FALSE);
  302. int nitem = precvfilelist->AddFile(lpfilehdr);
  303. InterlockedIncrement((LPLONG)&(precvfilelist->m_nRecvRefCnt));
  304. *(int*)wparam = nitem;
  305. //add log info.
  306. CString strlog;
  307. char lpfilename[_MAX_PATH];
  308. ExtractFileName(lpfilehdr->szFileName, lpfilename, sizeof(lpfilename));
  309. strlog.Format(_LoadString(IDS_LOG_RECVFLEBEGIN).GetBuffer(0), 
  310. lpfilename, lpfilehdr->szSenderHost, lpfilehdr->szSenderIp);
  311. ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
  312. return 0L;
  313. }
  314. //UWM_RECVOR_UPDATE_RECVING_PROGRESS
  315. LRESULT CMainFrame::OnRecvedFileBodyNotify(WPARAM wparam, LPARAM lparam)
  316. {
  317. CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
  318. CString sitemtxt;
  319. sitemtxt.Format("%d", lparam > 0?lparam:0);
  320. precvfilelist->GetListCtrl().SetItemText((int)wparam, 2, sitemtxt);
  321. return 0L;
  322. }
  323. //UWM_RECVOR_UPDATE_ONEFILERECV_OK
  324. LRESULT CMainFrame::OnRecvedFileOverNotify(WPARAM wparam, LPARAM lparam)
  325. {
  326. //enable listview's sorting ability.
  327. CString strlog;
  328. CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
  329. InterlockedDecrement((LPLONG)&(precvfilelist->m_nRecvRefCnt));
  330. if(precvfilelist->m_nRecvRefCnt == 0)
  331. {
  332. precvfilelist->EnableSort(TRUE);
  333. }
  334. if(wparam == 0)
  335. {
  336. //play the special sound(in resource or file)
  337. CRegister regkey;
  338. CString soundfile;
  339. if(regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
  340. {
  341. soundfile = regkey.Read_String_Value(REG_SALARMSOUND);
  342. regkey.Close();
  343. }
  344. //play successful sound.
  345. if(!FileExists(soundfile.GetBuffer(0))) //check the system setting for alarm sound file.
  346. {
  347. PlaySound(MAKEINTRESOURCE(IDR_RECVEDFILE), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
  348. }
  349. else //play default sound resource file.
  350. {
  351. PlaySound(soundfile.GetBuffer(0), NULL, SND_FILENAME | SND_ASYNC | SND_NODEFAULT);
  352. }
  353. //record the log information.
  354. strlog.Format(_LoadString(IDS_LOG_RECVFLEEND).GetBuffer(0), 
  355. precvfilelist->GetListCtrl().GetItemText(lparam, 0),
  356. precvfilelist->GetListCtrl().GetItemText(lparam, 3));
  357. }
  358. else
  359. {
  360. //if failed to receive file then change the item's image.
  361. precvfilelist->GetListCtrl().SetItem(lparam, 0, LVIF_IMAGE, NULL, 10, 0, 0, NULL);
  362. //play unsuccessful sound.
  363. PlaySound(MAKEINTRESOURCE(IDR_RECVEDFAILED), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
  364. //record the log information.
  365. strlog.Format(_LoadString(IDS_LOG_RECVFLEFAILED).GetBuffer(0), 
  366. precvfilelist->GetListCtrl().GetItemText(lparam, 0),
  367. precvfilelist->GetListCtrl().GetItemText(lparam, 3));
  368. }
  369. //add log info.
  370. ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
  371. //////////////////////////////////////////////////////////////////////////
  372. //update the db contents.
  373. precvfilelist->AddRecvRecord(lparam, wparam == 0 ? TRUE:FALSE);
  374. //////////////////////////////////////////////////////////////////////////
  375. return 0L;
  376. }
  377. void CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )
  378. {
  379. switch(nID) {
  380. case SC_MINIMIZE:
  381. {
  382. CRegister regKey;
  383. if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
  384. {
  385. CFrameWnd::OnSysCommand(nID, lParam);
  386. }
  387. if(regKey.Read_Bool_Value(REG_BMINITOHIDE))
  388. {
  389. HICON hFrmIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  390. this->ShowWindow(SW_HIDE);
  391. this->m_wndSysTray.SetActive(TRUE);
  392. }
  393. else
  394. {
  395. CFrameWnd::OnSysCommand(nID, lParam);
  396. }
  397. }
  398. break;
  399. case SC_CLOSE:
  400. {
  401. if( MessageBox("Would you want exit(Y/N)?", "Exit Application", MB_YESNO | MB_ICONQUESTION) == IDNO)
  402. {
  403. break;
  404. }
  405. }
  406. default:
  407. CFrameWnd::OnSysCommand(nID, lParam);
  408. }
  409. }
  410. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
  411. {
  412. ASSERT(pContext != NULL);
  413. //////////////////////////////////////////////////////////////////////////
  414. if(!this->m_wndTBSplit.CreateStatic(this, 2, 1))
  415. {
  416. TRACE0("Failed to create m_wndTBSplit windown");
  417. return FALSE;
  418. }
  419. if(!this->m_wndTBSplit.CreateView(0, 0, RUNTIME_CLASS(CSysLogView), CSize(0, 60), pContext))
  420. {
  421. TRACE0("Failed to create m_wndTBSplit windown");
  422. return FALSE;
  423. }
  424. this->m_pwndSyslogView = (CSysLogView*)m_wndTBSplit.GetPane(0, 0);
  425. if(!this->m_wndTBSplit.CreateView(1, 0, RUNTIME_CLASS(CWorkFrame), CSize(0, 0), pContext))
  426. {
  427. TRACE0("Failed to create m_pwndWorkFrame windown");
  428. return FALSE;
  429. }
  430. this->m_pwndWorkFrame = (CWorkFrame*)m_wndTBSplit.GetPane(1, 0);
  431. //////////////////////////////////////////////////////////////////////////
  432. return TRUE;
  433. }
  434. void CMainFrame::OnSystemSetting() 
  435. {
  436. CConfigEnv sheet_SysConfig(_LoadString(IDS_SYSCONFIG).GetBuffer(0));
  437. sheet_SysConfig.DoModal();
  438. }
  439. //@1
  440. void CMainFrame::OnFileAddfiles() 
  441. {
  442. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  443. ASSERT(NULL != pSndFileList);
  444. pSndFileList->AddFiles();
  445. }
  446. //@2
  447. void CMainFrame::OnFileDelfles() 
  448. {
  449. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  450. ASSERT(NULL != pSndFileList);
  451. pSndFileList->DelFiles();
  452. }
  453. void CMainFrame::OnUpdateFileDelfles(CCmdUI* pCmdUI) 
  454. {
  455. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  456. ASSERT(NULL != pSndFileList);
  457. pCmdUI->Enable(pSndFileList->GetListCtrl().GetSelectedCount() > 0);
  458. }
  459. void CMainFrame::OnSystemUsrlogin() 
  460. {
  461. if(!theApp.m_oAppInstance.m_binadminmode)
  462. {
  463. CSysUsrLoginDlg sysusrlogindlg;
  464. if(IDOK == sysusrlogindlg.DoModal())
  465. {
  466. MSGBOX_WARNING(_LoadString(IDS_USRINADMINMODE).GetBuffer(0));
  467. }
  468. }
  469. else
  470. {
  471. theApp.m_oAppInstance.m_binadminmode = false;
  472. memset(&theApp.m_oAppInstance.m_authorinfo, 0x0, sizeof(theApp.m_oAppInstance.m_authorinfo));
  473. }
  474. }
  475. void CMainFrame::OnUpdateSystemUsrlogin(CCmdUI* pCmdUI) 
  476. {
  477. if(theApp.m_oAppInstance.m_binadminmode)
  478. pCmdUI->SetText(_LoadString(IDS_RESETUSRMODE).GetBuffer(0));
  479. else
  480. pCmdUI->SetText(_LoadString(IDS_ADMINUSRMODE).GetBuffer(0));
  481. }
  482. //////////////////////////////////////////////////////////////////////////
  483. DWORD CMainFrame::RefreshUserListThread(LPVOID lpParameters)
  484. {
  485. CMainFrame *pthis = (CMainFrame*)lpParameters;
  486. ASSERT(pthis != NULL);
  487. pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = TRUE;
  488. //update the user tree contents
  489. theApp.m_oCSHelper.UpdateDepartsContents();
  490. theApp.m_oCSHelper.UpdateAgentsContents();
  491. //if failed to download database table contents then list history user contents
  492. pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.UpdateTreeForUserDatas();
  493. pthis->m_wndChatBar.LogonChatingRoom();
  494. pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = FALSE;
  495. return 0L;
  496. }
  497. void CMainFrame::OnUserRefusrlist() 
  498. {
  499. //If system is updating local database contents then cancel the user's action
  500. if(0 != int(theApp.m_oCSHelper.m_chstate & CCSHelper::CHS_UPTAGUSRLIST)) return ;
  501. if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating) return;
  502. DWORD dwthreadid = 0x0000;
  503. ::CreateThread(NULL, 0, RefreshUserListThread, this, 0, &dwthreadid);
  504. }
  505. //////////////////////////////////////////////////////////////////////////
  506. void CMainFrame::OnUserSearch() 
  507. {
  508. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.FindSpecialedUser();
  509. }
  510. void CMainFrame::OnUserRename() 
  511. {
  512. CLocalUserRenameDlg lurdlg;
  513. if(theApp.m_oAppInstance.m_binadminmode)
  514. {
  515. HTREEITEM hseleditem = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetSelectedItem();
  516. if(NULL != hseleditem)
  517. {
  518. DWORD exdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetItemData(hseleditem);
  519. if(HIWORD(exdata) == NT_AGENT)
  520. lurdlg.SetRenamedAgentId(LOWORD(exdata));
  521. }
  522. }
  523. lurdlg.DoModal();
  524. }
  525. void CMainFrame::OnUserLocalusrinfo() 
  526. {
  527. CString strinfo;
  528. strinfo.Format(_LoadString(IDS_LOCALAGINFO).GetBuffer(0), 
  529. theApp.m_oCSHelper.GetClientID(),
  530. theApp.m_oCSHelper.GetClientName().c_str(),
  531. CXNetAddress::GetLocalHostName().c_str(),
  532. CXNetAddress::GetLocalHostIp().c_str());
  533. MSGSHOW_INFO(strinfo.GetBuffer(0));
  534. }
  535. void CMainFrame::OnFileHidesys() 
  536. {
  537. HICON hFrmIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  538. this->ShowWindow(SW_HIDE);
  539. this->m_wndSysTray.SetActive(TRUE);
  540. }
  541. //1---send to single user.
  542. //2---send to multi users(User Group).
  543. void CMainFrame::OnFileSend() 
  544. {
  545. //////////////////////////////////////////////////////////////////////////
  546. //clear the sending ip list items.
  547. for(; this->m_pdestips.size() > 0; )
  548. {
  549. this->m_pdestips.pop_back();
  550. }
  551. //////////////////////////////////////////////////////////////////////////
  552. CRegister regkey;
  553. if(!regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
  554. {
  555. return ;
  556. }
  557. DWORD dwport = regkey.Read_DWord_Value(REG_NTRFTRANSPORT);
  558. regkey.Close();
  559. //////////////////////////////////////////////////////////////////////////
  560. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  561. ASSERT(NULL != pSndFileList);
  562. //////////////////////////////////////////////////////////////////////////
  563. m_ncuripindx = 0;
  564. m_ncurfleindx = 0;
  565. //////////////////////////////////////////////////////////////////////////
  566. BOOL btousrgrp = FALSE;
  567. int ntabindex = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TabSolExplorer.GetCurSel();
  568. btousrgrp = (2 == ntabindex);
  569. //////////////////////////////////////////////////////////////////////////
  570. AGINFO aginfo;
  571. if(!btousrgrp)
  572. {
  573. if(!this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetAGInfo(aginfo))
  574. {
  575. //MSGBOX_ERROR(_LoadString(IDS_GETAGINFOFAILE).GetBuffer(0));
  576. return ;
  577. }
  578. m_pdestips.push_back(aginfo);
  579. }
  580. else
  581. {
  582. HTREEITEM hparent = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetSelectedItem();
  583. DWORD dwdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetItemData(hparent);
  584. if(HIWORD(dwdata) == NT_DEPART) 
  585. {
  586. HTREEITEM hchild = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetNextItem(hparent, TVGN_CHILD);
  587. for(; hchild != NULL; )
  588. {
  589. dwdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetItemData(hchild);
  590. if(HIWORD(dwdata) == NT_AGENT)
  591. {
  592. if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetAGInfoOfItem(hchild, aginfo))
  593. {
  594. m_pdestips.push_back(aginfo);
  595. }
  596. }
  597. hchild = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetNextSiblingItem(hchild);
  598. }
  599. }
  600. else if(HIWORD(dwdata) == NT_AGENT) 
  601. {
  602. if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetAGInfoOfItem(hparent, aginfo))
  603. {
  604. m_pdestips.push_back(aginfo);
  605. }
  606. }
  607. }
  608. if(0 == m_pdestips.size())
  609. {
  610. MSGBOX_INFO(_LoadString(IDS_NOSELECTNODE).GetBuffer(0));
  611. return ;
  612. }
  613. //////////////////////////////////////////////////////////////////////////
  614. //if the sending file is virtual ftp file then download it to local first.
  615. if(pSndFileList->IsFtpFile(0))
  616. {
  617. //make local file name.
  618. CString strlocalfile = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.MakeLocalFileName(
  619. pSndFileList->GetListCtrl().GetItemText(0, 2).GetBuffer(0),
  620. pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
  621. //download it.
  622. REMOTEFILEINFO rfRemoteFile;
  623. _snprintf(rfRemoteFile.szRemoteFile, MAX_PATH, "%s", 
  624. pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
  625. rfRemoteFile.dwFilesize = atoi(pSndFileList->GetListCtrl().
  626. GetItemText(0, 1).GetBuffer(0));
  627. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.DownloadFile(
  628. &rfRemoteFile, strlocalfile.GetBuffer(0));
  629. //modify sending file list contents.
  630. int revpos = strlocalfile.ReverseFind('\');
  631. pSndFileList->GetListCtrl().SetItemText(0, 2, 
  632. revpos == -1 ? strlocalfile : strlocalfile.Left(revpos));
  633. }
  634. //////////////////////////////////////////////////////////////////////////
  635. CMutexLock omimutex(m_sndsockmutex);
  636. if(!theApp.m_oCCHelper.Start_FileSendSvr())
  637. {
  638. theApp.m_oCCHelper.Stop_FileSendSvr();
  639. MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
  640. return ;
  641. }
  642. theApp.m_oCCHelper.GetFileSenderThread()->Subscribe(this->GetSafeHwnd());
  643. aginfo = this->m_pdestips[0];
  644. if(!theApp.m_oCCHelper.GetFileSenderThread()->Create(false, aginfo.shostip.c_str(), dwport))
  645. {
  646. theApp.m_oCCHelper.Stop_FileSendSvr();
  647. MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
  648. return ;
  649. }
  650. CString sfilename;
  651. sfilename.Format("%s\%s",  pSndFileList->GetListCtrl().GetItemText(0, 2).GetBuffer(0),
  652. pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
  653. if(FileExists(sfilename.GetBuffer(0)))
  654. {
  655. theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
  656. }
  657. else
  658. {
  659. pSndFileList->DeleteFile(0);
  660. }
  661. //////////////////////////////////////////////////////////////////////////
  662. pSndFileList->m_bSendingBusy = TRUE;
  663. pSndFileList->EnableSort(FALSE);
  664. }
  665. void CMainFrame::OnUpdateFileSend(CCmdUI* pCmdUI) 
  666. {
  667. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  668. ASSERT(NULL != pSndFileList);
  669. pCmdUI->Enable(!pSndFileList->m_bSendingBusy && pSndFileList->GetListCtrl().GetItemCount() > 0);
  670. }
  671. void CMainFrame::OnFileCancelSend() 
  672. {
  673. CMutexLock omimutex(m_sndsockmutex);
  674. theApp.m_oCCHelper.Stop_FileSendSvr();
  675. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  676. ASSERT(NULL != pSndFileList);
  677. pSndFileList->m_bSendingBusy = FALSE;
  678. pSndFileList->EnableSort(TRUE);
  679. }
  680. void CMainFrame::OnUpdateFileCancelSend(CCmdUI* pCmdUI) 
  681. {
  682. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  683. ASSERT(NULL != pSndFileList);
  684. pCmdUI->Enable(pSndFileList->m_bSendingBusy);
  685. }
  686. //UWM_SNDER_UPDATE_SNDING_START
  687. LRESULT CMainFrame::OnSendedFileHeaderNotify(WPARAM wparam, LPARAM lparam)
  688. {
  689. //show and set sending progress bar properties.
  690. this->m_wndSendingProgCtrl.ShowWindow(SW_SHOW);
  691. this->m_wndSendingProgCtrl.SetRange32(0, wparam);
  692. this->OnSize(0, 1, 1);
  693. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  694. ASSERT(NULL != pSndFileList);
  695. //record the sending time.
  696. CTime now = CTime::GetCurrentTime();
  697. CString strtime;
  698. strtime.Format(SYS_TIMEFORMAT, now.GetYear(), now.GetMonth(), now.GetDay(),
  699. now.GetHour(), now.GetMinute(), now.GetSecond());
  700. pSndFileList->GetListCtrl().SetItemText(this->m_ncurfleindx, 3, strtime.GetBuffer(0));
  701. //record log info.
  702. CString sfilename, strlog;
  703. AGINFO aginfo = this->m_pdestips[this->m_ncuripindx];
  704. sfilename.Format("%s\%s", 
  705. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
  706. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  707. strlog.Format(_LoadString(IDS_LOG_SENDFLEBEGIN).GetBuffer(0), 
  708. sfilename.GetBuffer(0), 
  709. aginfo.shostname.c_str(), 
  710. aginfo.shostip.c_str());
  711. ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
  712. return 0L;
  713. }
  714. //UWM_SNDER_UPDATE_SNDING_PROGRESS
  715. LRESULT CMainFrame::OnSendedFileBodyNotify(WPARAM wparam, LPARAM lparam)
  716. {
  717. int pos = this->m_wndSendingProgCtrl.GetPos() + wparam;
  718. this->m_wndSendingProgCtrl.SetPos(pos);
  719. return 0L;
  720. }
  721. //UWM_SNDER_UPDATE_ONEFILESEND_OK
  722. LRESULT CMainFrame::OnSendedFileOverNotify(WPARAM wparam, LPARAM lparam)
  723. {
  724. //////////////////////////////////////////////////////////////////////////
  725. CRegister regkey;
  726. if(!regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
  727. {
  728. return 0L;
  729. }
  730. BOOL  bautodel = regkey.Read_Bool_Value(REG_BAUTODELSNDEDFILE);
  731. DWORD dwport = regkey.Read_DWord_Value(REG_NTRFTRANSPORT);
  732. regkey.Close();
  733. //////////////////////////////////////////////////////////////////////////
  734. //show and set sending progress bar properties.
  735. this->m_wndSendingProgCtrl.SetPos(0);
  736. this->m_wndSendingProgCtrl.SetRange32(0, 0);
  737. CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
  738. ASSERT(NULL != pSndFileList);
  739. //record log info.
  740. CString sfilename, strlog;
  741. AGINFO aginfo = this->m_pdestips[this->m_ncuripindx];
  742. sfilename.Format("%s\%s", 
  743. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
  744. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  745. if(wparam == 0)
  746. {
  747. strlog.Format(_LoadString(IDS_LOG_SENDFLEEND).GetBuffer(0), 
  748. sfilename.GetBuffer(0), 
  749. aginfo.shostname.c_str(), 
  750. aginfo.shostip.c_str());
  751. }
  752. else
  753. {
  754. strlog.Format(_LoadString(IDS_LOG_SENDFLEFAILED).GetBuffer(0), 
  755. sfilename.GetBuffer(0), 
  756. aginfo.shostname.c_str(), 
  757. aginfo.shostip.c_str());
  758. }
  759. ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
  760. //////////////////////////////////////////////////////////////////////////
  761. //update the db contents.
  762. CString tohost;
  763. tohost.Format("%s / %s", aginfo.shostname.c_str(), aginfo.shostip.c_str());
  764. pSndFileList->AddSendRecord(this->m_ncurfleindx, tohost.GetBuffer(0), wparam == 0 ? TRUE:FALSE);
  765. //////////////////////////////////////////////////////////////////////////
  766. this->m_ncurfleindx++;
  767. //////////////////////////////////////////////////////////////////////////
  768. //if the sending file is virtual ftp file then download it to local first.
  769. if(pSndFileList->IsFtpFile(this->m_ncurfleindx))
  770. {
  771. //make local file name.
  772. CString strlocalfile = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.MakeLocalFileName(
  773. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
  774. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  775. //download it.
  776. REMOTEFILEINFO rfRemoteFile;
  777. _snprintf(rfRemoteFile.szRemoteFile, MAX_PATH, "%s", 
  778. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  779. rfRemoteFile.dwFilesize = atoi(pSndFileList->GetListCtrl().
  780. GetItemText(this->m_ncurfleindx, 1).GetBuffer(0));
  781. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.DownloadFile(
  782. &rfRemoteFile, strlocalfile.GetBuffer(0));
  783. //modify sending file list contents.
  784. int revpos = strlocalfile.ReverseFind('\');
  785. pSndFileList->GetListCtrl().SetItemText(this->m_ncurfleindx, 2, 
  786. revpos == -1 ? strlocalfile : strlocalfile.Left(revpos));
  787. }
  788. //////////////////////////////////////////////////////////////////////////
  789. if(this->m_ncurfleindx == pSndFileList->GetListCtrl().GetItemCount())
  790. {
  791. this->m_ncurfleindx = 0;
  792. this->m_ncuripindx++;
  793. if(this->m_ncuripindx < this->m_pdestips.size())
  794. {
  795. aginfo = this->m_pdestips[this->m_ncuripindx];
  796. CMutexLock omimutex(m_sndsockmutex);
  797. theApp.m_oCCHelper.Stop_FileSendSvr();
  798. if(!theApp.m_oCCHelper.Start_FileSendSvr())
  799. {
  800. MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
  801. return 0L;
  802. }
  803. theApp.m_oCCHelper.GetFileSenderThread()->Subscribe(this->GetSafeHwnd());
  804. if(!theApp.m_oCCHelper.GetFileSenderThread()->Create(false, aginfo.shostip.c_str(), dwport))
  805. {
  806. MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
  807. return 0L;
  808. }
  809. sfilename.Format("%s\%s", 
  810. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
  811. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  812. theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
  813. //////////////////////////////////////////////////////////////////////////
  814. }
  815. else
  816. {
  817. //if system setting is auto delete sended file item then remove all items in listview.
  818. if(bautodel)
  819. {
  820. //pSndFileList->SelectAllItems();
  821. //pSndFileList->DelFiles();
  822. pSndFileList->DeleteFile(this->m_ncurfleindx);
  823. }
  824. //wipe dest ip list contents.
  825. for(; this->m_pdestips.size() > 0; )
  826. {
  827. this->m_pdestips.pop_back();
  828. }
  829. this->m_wndSendingProgCtrl.ShowWindow(SW_HIDE);
  830. pSndFileList->m_bSendingBusy = FALSE;
  831. pSndFileList->EnableSort(TRUE);
  832. //////////////////////////////////////////////////////////////////////////
  833. CMutexLock omimutex(m_sndsockmutex);
  834. theApp.m_oCCHelper.Stop_FileSendSvr();
  835. }
  836. }
  837. else
  838. {
  839. //if send to single user...
  840. if(this->m_pdestips.size() == 1)
  841. {
  842. if(bautodel)
  843. {
  844. this->m_ncurfleindx--;
  845. pSndFileList->SelectOneItem(this->m_ncurfleindx);
  846. pSndFileList->DelFiles();
  847. }
  848. }
  849. //continue send next file.
  850. sfilename.Format("%s\%s", 
  851. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
  852. pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
  853. //////////////////////////////////////////////////////////////////////////
  854. CMutexLock omimutex(m_sndsockmutex);
  855. if(theApp.m_oCCHelper.GetFileSenderThread() && TS_STOPED != theApp.m_oCCHelper.GetFileSenderThread()->getThreadState())
  856. {
  857. theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
  858. }
  859. }
  860. //////////////////////////////////////////////////////////////////////////
  861. return 0L;
  862. }
  863. void CMainFrame::OnSystemCrtusrgrp()
  864. {
  865. CSendGroupMgr dlg;
  866. dlg.DoModal();
  867. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.UpdateTreeForUserDatas();
  868. }
  869. //UWM_SHELLSNDTONOTIFY
  870. LRESULT CMainFrame::OnAddSendFileFrmShellNotify(WPARAM wp, LPARAM lp)
  871. {
  872. CRegister regkey;
  873. if(!regkey.Open(HKEY_CURRENT_USER, REG_SSHLSNDTOFLEDIR)) return 0L;
  874. DWORD count = regkey.Read_DWord_Value(REG_SSHLSNDTOFLECNT);
  875. CString keyname, keyval;
  876. for(int i = 0; i < count; ++i)
  877. {
  878. keyname.Format("%d", i);
  879. keyval = regkey.Read_String_Value(keyname.GetBuffer(0));
  880. this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList->AddFile(keyval.GetBuffer(0));
  881. regkey.DeleteValue(keyname.GetBuffer(0));
  882. }
  883. regkey.Write_DWord_Value(REG_SSHLSNDTOFLECNT);
  884. return 0L;
  885. }
  886. //System ftp-sites setting management.
  887. void CMainFrame::OnSystemFtpSetting() 
  888. {
  889. CFtpConnectDlg dlg;
  890. dlg.DoModal();
  891. }
  892. void CMainFrame::OnConnectFtpSvr() 
  893. {
  894. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
  895. SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_OPEN, 1), NULL);
  896. }
  897. void CMainFrame::OnUpdateFtpoperOpen(CCmdUI* pCmdUI) 
  898. {
  899. BOOL bEnable = (m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.GetSelectedItem() != NULL);
  900. bEnable = bEnable && !(m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.ExistsConnection());
  901. pCmdUI->Enable(bEnable);
  902. }
  903. void CMainFrame::OnDisconnectFtpSvr() 
  904. {
  905. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
  906. SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_CLOSE, 1), NULL);
  907. this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList->RemoveAllFtpFiles();
  908. }
  909. void CMainFrame::OnUpdateFtpoperClose(CCmdUI* pCmdUI) 
  910. {
  911. BOOL bEnable = m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.ExistsConnection();
  912. pCmdUI->Enable(bEnable);
  913. }
  914. void CMainFrame::OnRefreshFtpDirs()
  915. {
  916. this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
  917. SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_REFDIRS, 1), NULL);
  918. }
  919. void CMainFrame::OnUpdateFtpoperRefdirs(CCmdUI* pCmdUI)
  920. {
  921. pCmdUI->Enable(!this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.IsConnectingState());
  922. }
  923. void CMainFrame::OnViewChatBar() 
  924. {
  925. BOOL bshowing = this->m_wndChatBar.IsWindowVisible();
  926. this->ShowControlBar(&m_wndChatBar, !bshowing, TRUE);
  927. }
  928. void CMainFrame::OnUpdateViewChatBar(CCmdUI* pCmdUI) 
  929. {
  930. BOOL bshowing = this->m_wndChatBar.IsWindowVisible();
  931. pCmdUI->SetCheck(bshowing);
  932. }