MainFrm.cpp
上传用户:maryhy001
上传日期:2007-05-02
资源大小:2317k
文件大小:34k
- #include "stdafx.h"
- #include "trfAgent.h"
- #include "MainFrm.h"
- #include "netaddress.h"
- #include "ConfigEnv.h"
- #include "FilelistSend.h"
- #include "SendGroupMgr.h"
- #include "SysUsrLoginDlg.h"
- #include "LocalUserRenameDlg.h"
- #include "FtpConnectDlg.h"
- IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
- BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
- //{{AFX_MSG_MAP(CMainFrame)
- ON_WM_SYSCOMMAND()
- ON_WM_CREATE()
- ON_WM_SIZE()
- ON_WM_TIMER()
- ON_COMMAND(ID_SYSTEM_SETTING, OnSystemSetting)
- ON_COMMAND(ID_FILE_ADDFILES, OnFileAddfiles)
- ON_COMMAND(ID_FILE_DELFLES, OnFileDelfles)
- ON_UPDATE_COMMAND_UI(ID_FILE_DELFLES, OnUpdateFileDelfles)
- ON_COMMAND(ID_USER_USRLOGIN, OnSystemUsrlogin)
- ON_UPDATE_COMMAND_UI(ID_USER_USRLOGIN, OnUpdateSystemUsrlogin)
- ON_COMMAND(ID_USER_REFUSRLIST, OnUserRefusrlist)
- ON_COMMAND(ID_USER_SEARCH, OnUserSearch)
- ON_COMMAND(ID_USER_RENAME, OnUserRename)
- ON_COMMAND(ID_FILE_HIDESYS, OnFileHidesys)
- ON_COMMAND(ID_USER_LOCALUSRINFO, OnUserLocalusrinfo)
- ON_COMMAND(ID_FILE_SEND, OnFileSend)
- ON_COMMAND(ID_FILE_CANCEL_SEND, OnFileCancelSend)
- ON_UPDATE_COMMAND_UI(ID_FILE_CANCEL_SEND, OnUpdateFileCancelSend)
- ON_UPDATE_COMMAND_UI(ID_FILE_SEND, OnUpdateFileSend)
- ON_COMMAND(ID_SYSTEM_CRTUSRGRP, OnSystemCrtusrgrp)
- ON_COMMAND(ID_SYSTEM_FTPSITESMANG, OnSystemFtpSetting)
- ON_COMMAND(ID_FTPOPER_OPEN, OnConnectFtpSvr)
- ON_UPDATE_COMMAND_UI(ID_FTPOPER_OPEN, OnUpdateFtpoperOpen)
- ON_COMMAND(ID_FTPOPER_CLOSE, OnDisconnectFtpSvr)
- ON_UPDATE_COMMAND_UI(ID_FTPOPER_CLOSE, OnUpdateFtpoperClose)
- ON_COMMAND(ID_FTPOPER_REFDIRS, OnRefreshFtpDirs)
- ON_UPDATE_COMMAND_UI(ID_FTPOPER_REFDIRS, OnUpdateFtpoperRefdirs)
- ON_COMMAND(ID_VIEW_CHAT_BAR, OnViewChatBar)
- ON_MESSAGE(UWM_SYSTRAY, OnSysTray)
- ON_UPDATE_COMMAND_UI(ID_VIEW_CHAT_BAR, OnUpdateViewChatBar)
- //}}AFX_MSG_MAP
- ON_MESSAGE(UWM_REFRESHUSRLST, OnRefUserListNotify)
- ON_MESSAGE(UWM_UPDATESTATUSBAR, OnUpdateStatuBarNotify)
- ON_MESSAGE(UWM_UPDATESYSLOGINF, OnUpdateSystemLogInfo)
- ON_MESSAGE(UWM_SNDER_UPDATE_SNDING_START, OnSendedFileHeaderNotify)
- ON_MESSAGE(UWM_SNDER_UPDATE_SNDING_PROGRESS, OnSendedFileBodyNotify)
- ON_MESSAGE(UWM_SNDER_UPDATE_ONEFILESEND_OK, OnSendedFileOverNotify)
-
- ON_MESSAGE(UWM_RECVOR_UPDATE_RECVING_START, OnRecvedFileHeaderNotify)
- ON_MESSAGE(UWM_RECVOR_UPDATE_RECVING_PROGRESS, OnRecvedFileBodyNotify)
- ON_MESSAGE(UWM_RECVOR_UPDATE_ONEFILERECV_OK, OnRecvedFileOverNotify)
- ON_MESSAGE(UWM_SHELLSNDTONOTIFY, OnAddSendFileFrmShellNotify)
-
- END_MESSAGE_MAP()
- static UINT indicators[] =
- {
- ID_INDICATOR_OPERET_INFO,
- ID_INDICATOR_SNDING_INFO,
- ID_INDICATOR_RCVING_INFO,
- ID_SEPARATOR, // status line indicator
- };
- CMainFrame::CMainFrame()
- {
- m_ncuripindx = 0;
- m_ncurfleindx = 0;
- }
- CMainFrame::~CMainFrame()
- {
- for(; m_pdestips.size() > 0; )
- {
- m_pdestips.pop_back();
- }
- }
- int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
- return -1;
- //////////////////////////////////////////////////////////////////////////
- if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
- | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
- !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
- {
- TRACE0("Failed to create toolbarn");
- return -1;
- }
- //////////////////////////////////////////////////////////////////////////
-
- if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeofarray(indicators)))
- {
- TRACE0("Failed to create status barn");
- return -1;
- }
- for(int i = 0; i < sizeofarray(indicators); ++i)
- {
- this->m_wndStatusBar.SetPaneText(i, "");
- }
- //////////////////////////////////////////////////////////////////////////
- if(!this->m_wndSendingProgCtrl.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH, CRect(0,0,0,0), &m_wndStatusBar, 555))
- {
- TRACE0("Failed to create m_wndSendingProgCtrln");
- return -1;
- }
- this->m_wndSendingProgCtrl.ShowWindow(SW_HIDE);
- //////////////////////////////////////////////////////////////////////////
- //creating chat docking-bar window.
- if(!this->m_wndChatBar.Create(_LoadString(IDS_CHATBARTITLE).GetBuffer(0), this, CSize(0, 0), TRUE, 666))
- {
- TRACE0("Failed to create m_wndChatBarn");
- return -1;
- }
- //modify its style.
- this->m_wndChatBar.SetBarStyle(this->m_wndChatBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
-
- //first, hide it!!!
- this->ShowControlBar(&m_wndChatBar, FALSE, TRUE);
- //////////////////////////////////////////////////////////////////////////
-
- if(!m_wndSysTray.Create(this->GetSafeHwnd(), IDO_SYSTRAY,
- ::AfxGetApp()->LoadIcon(IDR_MAINFRAME),
- _LoadString(AFX_IDS_APP_TITLE).GetBuffer(0), UWM_SYSTRAY))
- {
- TRACE0("Failed to create m_wndSysTrayn");
- return -1;
- }
- //////////////////////////////////////////////////////////////////////////
- EnableDocking(CBRS_ALIGN_ANY);
-
- m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
- m_wndChatBar.EnableDocking(CBRS_ALIGN_ANY);
- DockControlBar(&m_wndToolBar);
- DockControlBar(&m_wndChatBar, AFX_IDW_DOCKBAR_BOTTOM);
- //////////////////////////////////////////////////////////////////////////
-
- CRegister regKey;
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- TRACE0("Failed to open regitry keyn");
- return -1;
- }
- PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
- if(regKey.Read_Bool_Value(REG_BSTARTTOHIDE))
- {
- this->SetTimer(IDO_FRAME_HIDETIME, 500, NULL);
- }
- //refresh tray-icon.
- this->SetTimer(IDO_FRAME_REFTRAYICON, 3000, NULL);
- //////////////////////////////////////////////////////////////////////////
- return 0;
- }
- //save bar state when mainframe window is destroying...
- BOOL CMainFrame::DestroyWindow()
- {
- return CFrameWnd::DestroyWindow();
- }
- BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
- {
- if( !CFrameWnd::PreCreateWindow(cs) )
- return FALSE;
- cs.style &= ~FWS_ADDTOTITLE ;
-
- return TRUE;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMainFrame diagnostics
- #ifdef _DEBUG
- void CMainFrame::AssertValid() const
- {
- CFrameWnd::AssertValid();
- }
- void CMainFrame::Dump(CDumpContext& dc) const
- {
- CFrameWnd::Dump(dc);
- }
- #endif //_DEBUG
- // CMainFrame message handlers
- void CMainFrame::OnSize(UINT nType, int cx, int cy)
- {
- //adjust statusbar subitems's display area
- if( this && this->GetSafeHwnd() &&
- this->m_wndStatusBar && this->m_wndStatusBar.GetSafeHwnd())
- {
- CRect rcfull;
- int nwidth;
- this->GetClientRect(&rcfull);
- nwidth = rcfull.Width();
-
- this->m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_NORMAL, nwidth / 4);
- nwidth -= nwidth / 4;
- this->m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, nwidth / 3);
- this->m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, nwidth / 3);
- this->m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_STRETCH, 0);
-
- if(this->m_wndSendingProgCtrl && this->m_wndSendingProgCtrl.GetSafeHwnd() && this->m_wndSendingProgCtrl.IsWindowVisible())
- {
- this->m_wndStatusBar.GetItemRect(1, &rcfull);
- this->m_wndSendingProgCtrl.MoveWindow(&rcfull);
- }
- }
- CFrameWnd::OnSize(nType, cx, cy);
- }
- void CMainFrame::OnTimer(UINT nIDEvent)
- {
- switch(nIDEvent) {
- case IDO_FRAME_HIDETIME:
- {
- this->ShowWindow(SW_HIDE);
- this->KillTimer(nIDEvent);
- this->m_wndSysTray.SetActive(TRUE);
- }
- break;
- case IDO_FRAME_REFTRAYICON:
- {
- this->m_wndSysTray.Refresh();
- }
- break;
- }
- CFrameWnd::OnTimer(nIDEvent);
- }
- LRESULT CMainFrame::OnSysTray(WPARAM wp, LPARAM lp)
- {
- if(lp == WM_RBUTTONUP)
- {
- m_wndSysTray.PopupMenu();
- }
- else if (lp == WM_LBUTTONDBLCLK)
- {
- this->m_wndSysTray.SetActive(FALSE);
- this->ShowWindow(SW_SHOW);
- }
- return 1;
- }
- LRESULT CMainFrame::OnRefUserListNotify(WPARAM, LPARAM)
- {
- //===update the local database contents===
- if(m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating) return 0L;
- m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = TRUE;
- theApp.m_oCSHelper.UpdateDepartsContents();
- theApp.m_oCSHelper.UpdateAgentsContents();
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.UpdateTreeForUserDatas();
- this->m_wndChatBar.LogonChatingRoom();
- m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = FALSE;
- return 0L;
- }
- //WPARAM = HIBYTE(Content type : 1-pure text; 2-ProgressBar; 4-image); LOBYTE(StatuBar panel index);
- //LPARAM = Pure text - LPSTR Pointer;
- //
- // ProgressBar - HIWORD(lparam) : Visble / Invisble
- // LOWORD(lparam) : ProgressBar's step value.
- //
- // Image - Image Object Pointer
- LRESULT CMainFrame::OnUpdateStatuBarNotify(WPARAM wparam, LPARAM lparam)
- {
- int ncontype = HIBYTE(wparam);
- int nsbindex = LOBYTE(wparam);
- if(1 == ncontype)
- {
- char *puretxt = (char*)lparam;
- this->m_wndStatusBar.SetPaneText(nsbindex, puretxt ? puretxt:"");
- if(puretxt) delete []puretxt; //!!!Warning : You must allocate this buffer by using "new TCHAR[X]" operation.
- }
- else if(2 == ncontype)
- {
- if(NULL == lparam) return 0L;
- BOOL bvisible = HIWORD(lparam) != 0 ? TRUE : FALSE;
- if(1 == nsbindex)
- {
- this->m_wndSendingProgCtrl.ShowWindow(bvisible ? SW_SHOW:SW_HIDE);
- int npos = this->m_wndSendingProgCtrl.GetPos();
- npos += LOWORD(lparam);
- this->m_wndSendingProgCtrl.SetPos(npos);
- }
- }
- return 0L;
- }
- //update the system log information
- LRESULT CMainFrame::OnUpdateSystemLogInfo(WPARAM wparam, LPARAM lparam)
- {
- if(NULL == lparam) return 1;
- BOOL bdelete = (wparam != 0) ? TRUE : FALSE;
-
- //////////////////////////////////////////////////////////////////////////
-
- char *plogtxt = (char*)lparam;
- CTime now = CTime::GetCurrentTime();
- CString strtime, strlog;
- strtime.Format(SYS_TIMEFORMAT, now.GetYear(), now.GetMonth(), now.GetDay(),
- now.GetHour(), now.GetMinute(), now.GetSecond());
- strlog.Format("%s -> %srn", strtime.GetBuffer(0), plogtxt);
- //////////////////////////////////////////////////////////////////////////
- CEdit &pedit = this->m_pwndSyslogView->GetEditCtrl();
- int ntail = pedit.GetWindowTextLength();
- pedit.SetSel(ntail, ntail);
- pedit.ReplaceSel(strlog.GetBuffer(0));
- //////////////////////////////////////////////////////////////////////////
- if(TRUE == bdelete)
- {
- delete []plogtxt;
- plogtxt = NULL;
- }
- return 0L;
- }
- //UWM_RECVOR_UPDATE_RECVING_START
- LRESULT CMainFrame::OnRecvedFileHeaderNotify(WPARAM wparam, LPARAM lparam)
- {
- LPNETFILEHDR lpfilehdr = (LPNETFILEHDR)lparam; //file header struct.
- assert(NULL != lpfilehdr);
- //add file into recved file listview.
- CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
- //disable sort function.
- precvfilelist->EnableSort(FALSE);
- int nitem = precvfilelist->AddFile(lpfilehdr);
- InterlockedIncrement((LPLONG)&(precvfilelist->m_nRecvRefCnt));
- *(int*)wparam = nitem;
- //add log info.
- CString strlog;
- char lpfilename[_MAX_PATH];
- ExtractFileName(lpfilehdr->szFileName, lpfilename, sizeof(lpfilename));
-
- strlog.Format(_LoadString(IDS_LOG_RECVFLEBEGIN).GetBuffer(0),
- lpfilename, lpfilehdr->szSenderHost, lpfilehdr->szSenderIp);
-
- ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
- return 0L;
- }
- //UWM_RECVOR_UPDATE_RECVING_PROGRESS
- LRESULT CMainFrame::OnRecvedFileBodyNotify(WPARAM wparam, LPARAM lparam)
- {
- CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
- CString sitemtxt;
- sitemtxt.Format("%d", lparam > 0?lparam:0);
- precvfilelist->GetListCtrl().SetItemText((int)wparam, 2, sitemtxt);
-
- return 0L;
- }
- //UWM_RECVOR_UPDATE_ONEFILERECV_OK
- LRESULT CMainFrame::OnRecvedFileOverNotify(WPARAM wparam, LPARAM lparam)
- {
- //enable listview's sorting ability.
- CString strlog;
-
- CFileListRecv *precvfilelist = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileRecvList;
-
- InterlockedDecrement((LPLONG)&(precvfilelist->m_nRecvRefCnt));
- if(precvfilelist->m_nRecvRefCnt == 0)
- {
- precvfilelist->EnableSort(TRUE);
- }
-
- if(wparam == 0)
- {
- //play the special sound(in resource or file)
-
- CRegister regkey;
- CString soundfile;
-
- if(regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- soundfile = regkey.Read_String_Value(REG_SALARMSOUND);
- regkey.Close();
- }
-
- //play successful sound.
- if(!FileExists(soundfile.GetBuffer(0))) //check the system setting for alarm sound file.
- {
- PlaySound(MAKEINTRESOURCE(IDR_RECVEDFILE), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
- }
- else //play default sound resource file.
- {
- PlaySound(soundfile.GetBuffer(0), NULL, SND_FILENAME | SND_ASYNC | SND_NODEFAULT);
- }
- //record the log information.
- strlog.Format(_LoadString(IDS_LOG_RECVFLEEND).GetBuffer(0),
- precvfilelist->GetListCtrl().GetItemText(lparam, 0),
- precvfilelist->GetListCtrl().GetItemText(lparam, 3));
- }
- else
- {
- //if failed to receive file then change the item's image.
- precvfilelist->GetListCtrl().SetItem(lparam, 0, LVIF_IMAGE, NULL, 10, 0, 0, NULL);
- //play unsuccessful sound.
- PlaySound(MAKEINTRESOURCE(IDR_RECVEDFAILED), AfxGetResourceHandle(), SND_RESOURCE | SND_ASYNC | SND_NODEFAULT);
-
- //record the log information.
- strlog.Format(_LoadString(IDS_LOG_RECVFLEFAILED).GetBuffer(0),
- precvfilelist->GetListCtrl().GetItemText(lparam, 0),
- precvfilelist->GetListCtrl().GetItemText(lparam, 3));
- }
- //add log info.
- ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
-
- //////////////////////////////////////////////////////////////////////////
-
- //update the db contents.
-
- precvfilelist->AddRecvRecord(lparam, wparam == 0 ? TRUE:FALSE);
-
- //////////////////////////////////////////////////////////////////////////
- return 0L;
- }
- void CMainFrame::OnSysCommand( UINT nID, LPARAM lParam )
- {
- switch(nID) {
- case SC_MINIMIZE:
- {
- CRegister regKey;
- if(!regKey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- CFrameWnd::OnSysCommand(nID, lParam);
- }
- if(regKey.Read_Bool_Value(REG_BMINITOHIDE))
- {
- HICON hFrmIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
-
- this->ShowWindow(SW_HIDE);
- this->m_wndSysTray.SetActive(TRUE);
- }
- else
- {
- CFrameWnd::OnSysCommand(nID, lParam);
- }
- }
- break;
- case SC_CLOSE:
- {
- if( MessageBox("Would you want exit(Y/N)?", "Exit Application", MB_YESNO | MB_ICONQUESTION) == IDNO)
- {
- break;
- }
- }
-
- default:
- CFrameWnd::OnSysCommand(nID, lParam);
- }
- }
- BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
- {
- ASSERT(pContext != NULL);
- //////////////////////////////////////////////////////////////////////////
- if(!this->m_wndTBSplit.CreateStatic(this, 2, 1))
- {
- TRACE0("Failed to create m_wndTBSplit windown");
- return FALSE;
- }
- if(!this->m_wndTBSplit.CreateView(0, 0, RUNTIME_CLASS(CSysLogView), CSize(0, 60), pContext))
- {
- TRACE0("Failed to create m_wndTBSplit windown");
- return FALSE;
- }
- this->m_pwndSyslogView = (CSysLogView*)m_wndTBSplit.GetPane(0, 0);
- if(!this->m_wndTBSplit.CreateView(1, 0, RUNTIME_CLASS(CWorkFrame), CSize(0, 0), pContext))
- {
- TRACE0("Failed to create m_pwndWorkFrame windown");
- return FALSE;
- }
- this->m_pwndWorkFrame = (CWorkFrame*)m_wndTBSplit.GetPane(1, 0);
- //////////////////////////////////////////////////////////////////////////
- return TRUE;
- }
- void CMainFrame::OnSystemSetting()
- {
- CConfigEnv sheet_SysConfig(_LoadString(IDS_SYSCONFIG).GetBuffer(0));
- sheet_SysConfig.DoModal();
- }
- //@1
- void CMainFrame::OnFileAddfiles()
- {
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- pSndFileList->AddFiles();
- }
- //@2
- void CMainFrame::OnFileDelfles()
- {
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- pSndFileList->DelFiles();
- }
- void CMainFrame::OnUpdateFileDelfles(CCmdUI* pCmdUI)
- {
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
-
- pCmdUI->Enable(pSndFileList->GetListCtrl().GetSelectedCount() > 0);
- }
- void CMainFrame::OnSystemUsrlogin()
- {
- if(!theApp.m_oAppInstance.m_binadminmode)
- {
- CSysUsrLoginDlg sysusrlogindlg;
- if(IDOK == sysusrlogindlg.DoModal())
- {
- MSGBOX_WARNING(_LoadString(IDS_USRINADMINMODE).GetBuffer(0));
- }
- }
- else
- {
- theApp.m_oAppInstance.m_binadminmode = false;
- memset(&theApp.m_oAppInstance.m_authorinfo, 0x0, sizeof(theApp.m_oAppInstance.m_authorinfo));
- }
- }
- void CMainFrame::OnUpdateSystemUsrlogin(CCmdUI* pCmdUI)
- {
- if(theApp.m_oAppInstance.m_binadminmode)
- pCmdUI->SetText(_LoadString(IDS_RESETUSRMODE).GetBuffer(0));
- else
- pCmdUI->SetText(_LoadString(IDS_ADMINUSRMODE).GetBuffer(0));
- }
- //////////////////////////////////////////////////////////////////////////
- DWORD CMainFrame::RefreshUserListThread(LPVOID lpParameters)
- {
- CMainFrame *pthis = (CMainFrame*)lpParameters;
- ASSERT(pthis != NULL);
-
- pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = TRUE;
-
- //update the user tree contents
- theApp.m_oCSHelper.UpdateDepartsContents();
- theApp.m_oCSHelper.UpdateAgentsContents();
- //if failed to download database table contents then list history user contents
- pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.UpdateTreeForUserDatas();
- pthis->m_wndChatBar.LogonChatingRoom();
- pthis->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating = FALSE;
-
- return 0L;
- }
- void CMainFrame::OnUserRefusrlist()
- {
- //If system is updating local database contents then cancel the user's action
- if(0 != int(theApp.m_oCSHelper.m_chstate & CCSHelper::CHS_UPTAGUSRLIST)) return ;
- if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.m_bIsUpdating) return;
- DWORD dwthreadid = 0x0000;
- ::CreateThread(NULL, 0, RefreshUserListThread, this, 0, &dwthreadid);
- }
- //////////////////////////////////////////////////////////////////////////
- void CMainFrame::OnUserSearch()
- {
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.FindSpecialedUser();
- }
- void CMainFrame::OnUserRename()
- {
- CLocalUserRenameDlg lurdlg;
- if(theApp.m_oAppInstance.m_binadminmode)
- {
- HTREEITEM hseleditem = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetSelectedItem();
- if(NULL != hseleditem)
- {
- DWORD exdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetItemData(hseleditem);
- if(HIWORD(exdata) == NT_AGENT)
- lurdlg.SetRenamedAgentId(LOWORD(exdata));
- }
- }
- lurdlg.DoModal();
- }
- void CMainFrame::OnUserLocalusrinfo()
- {
- CString strinfo;
- strinfo.Format(_LoadString(IDS_LOCALAGINFO).GetBuffer(0),
- theApp.m_oCSHelper.GetClientID(),
- theApp.m_oCSHelper.GetClientName().c_str(),
- CXNetAddress::GetLocalHostName().c_str(),
- CXNetAddress::GetLocalHostIp().c_str());
-
- MSGSHOW_INFO(strinfo.GetBuffer(0));
- }
- void CMainFrame::OnFileHidesys()
- {
- HICON hFrmIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- this->ShowWindow(SW_HIDE);
- this->m_wndSysTray.SetActive(TRUE);
- }
- //1---send to single user.
- //2---send to multi users(User Group).
- void CMainFrame::OnFileSend()
- {
- //////////////////////////////////////////////////////////////////////////
- //clear the sending ip list items.
- for(; this->m_pdestips.size() > 0; )
- {
- this->m_pdestips.pop_back();
- }
- //////////////////////////////////////////////////////////////////////////
-
- CRegister regkey;
- if(!regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- return ;
- }
- DWORD dwport = regkey.Read_DWord_Value(REG_NTRFTRANSPORT);
- regkey.Close();
- //////////////////////////////////////////////////////////////////////////
-
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- //////////////////////////////////////////////////////////////////////////
- m_ncuripindx = 0;
- m_ncurfleindx = 0;
- //////////////////////////////////////////////////////////////////////////
-
- BOOL btousrgrp = FALSE;
- int ntabindex = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TabSolExplorer.GetCurSel();
- btousrgrp = (2 == ntabindex);
-
- //////////////////////////////////////////////////////////////////////////
- AGINFO aginfo;
-
- if(!btousrgrp)
- {
- if(!this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForUsers.GetAGInfo(aginfo))
- {
- //MSGBOX_ERROR(_LoadString(IDS_GETAGINFOFAILE).GetBuffer(0));
- return ;
- }
- m_pdestips.push_back(aginfo);
- }
- else
- {
- HTREEITEM hparent = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetSelectedItem();
- DWORD dwdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetItemData(hparent);
- if(HIWORD(dwdata) == NT_DEPART)
- {
- HTREEITEM hchild = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetNextItem(hparent, TVGN_CHILD);
- for(; hchild != NULL; )
- {
- dwdata = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetItemData(hchild);
-
- if(HIWORD(dwdata) == NT_AGENT)
- {
- if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetAGInfoOfItem(hchild, aginfo))
- {
- m_pdestips.push_back(aginfo);
- }
- }
- hchild = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetNextSiblingItem(hchild);
- }
- }
- else if(HIWORD(dwdata) == NT_AGENT)
- {
- if(this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.GetAGInfoOfItem(hparent, aginfo))
- {
- m_pdestips.push_back(aginfo);
- }
- }
- }
- if(0 == m_pdestips.size())
- {
- MSGBOX_INFO(_LoadString(IDS_NOSELECTNODE).GetBuffer(0));
- return ;
- }
- //////////////////////////////////////////////////////////////////////////
- //if the sending file is virtual ftp file then download it to local first.
- if(pSndFileList->IsFtpFile(0))
- {
- //make local file name.
- CString strlocalfile = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.MakeLocalFileName(
- pSndFileList->GetListCtrl().GetItemText(0, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
- //download it.
- REMOTEFILEINFO rfRemoteFile;
-
- _snprintf(rfRemoteFile.szRemoteFile, MAX_PATH, "%s",
- pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
- rfRemoteFile.dwFilesize = atoi(pSndFileList->GetListCtrl().
- GetItemText(0, 1).GetBuffer(0));
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.DownloadFile(
- &rfRemoteFile, strlocalfile.GetBuffer(0));
- //modify sending file list contents.
- int revpos = strlocalfile.ReverseFind('\');
- pSndFileList->GetListCtrl().SetItemText(0, 2,
- revpos == -1 ? strlocalfile : strlocalfile.Left(revpos));
- }
- //////////////////////////////////////////////////////////////////////////
-
- CMutexLock omimutex(m_sndsockmutex);
-
- if(!theApp.m_oCCHelper.Start_FileSendSvr())
- {
- theApp.m_oCCHelper.Stop_FileSendSvr();
- MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
- return ;
- }
- theApp.m_oCCHelper.GetFileSenderThread()->Subscribe(this->GetSafeHwnd());
- aginfo = this->m_pdestips[0];
-
- if(!theApp.m_oCCHelper.GetFileSenderThread()->Create(false, aginfo.shostip.c_str(), dwport))
- {
- theApp.m_oCCHelper.Stop_FileSendSvr();
- MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
- return ;
- }
- CString sfilename;
- sfilename.Format("%s\%s", pSndFileList->GetListCtrl().GetItemText(0, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(0, 0).GetBuffer(0));
- if(FileExists(sfilename.GetBuffer(0)))
- {
- theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
- }
- else
- {
- pSndFileList->DeleteFile(0);
- }
- //////////////////////////////////////////////////////////////////////////
-
- pSndFileList->m_bSendingBusy = TRUE;
- pSndFileList->EnableSort(FALSE);
- }
- void CMainFrame::OnUpdateFileSend(CCmdUI* pCmdUI)
- {
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- pCmdUI->Enable(!pSndFileList->m_bSendingBusy && pSndFileList->GetListCtrl().GetItemCount() > 0);
- }
- void CMainFrame::OnFileCancelSend()
- {
- CMutexLock omimutex(m_sndsockmutex);
-
- theApp.m_oCCHelper.Stop_FileSendSvr();
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- pSndFileList->m_bSendingBusy = FALSE;
- pSndFileList->EnableSort(TRUE);
- }
- void CMainFrame::OnUpdateFileCancelSend(CCmdUI* pCmdUI)
- {
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- pCmdUI->Enable(pSndFileList->m_bSendingBusy);
- }
- //UWM_SNDER_UPDATE_SNDING_START
- LRESULT CMainFrame::OnSendedFileHeaderNotify(WPARAM wparam, LPARAM lparam)
- {
- //show and set sending progress bar properties.
- this->m_wndSendingProgCtrl.ShowWindow(SW_SHOW);
- this->m_wndSendingProgCtrl.SetRange32(0, wparam);
- this->OnSize(0, 1, 1);
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
- //record the sending time.
-
- CTime now = CTime::GetCurrentTime();
- CString strtime;
-
- strtime.Format(SYS_TIMEFORMAT, now.GetYear(), now.GetMonth(), now.GetDay(),
- now.GetHour(), now.GetMinute(), now.GetSecond());
-
- pSndFileList->GetListCtrl().SetItemText(this->m_ncurfleindx, 3, strtime.GetBuffer(0));
- //record log info.
- CString sfilename, strlog;
- AGINFO aginfo = this->m_pdestips[this->m_ncuripindx];
- sfilename.Format("%s\%s",
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
- strlog.Format(_LoadString(IDS_LOG_SENDFLEBEGIN).GetBuffer(0),
- sfilename.GetBuffer(0),
- aginfo.shostname.c_str(),
- aginfo.shostip.c_str());
-
- ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
- return 0L;
- }
- //UWM_SNDER_UPDATE_SNDING_PROGRESS
- LRESULT CMainFrame::OnSendedFileBodyNotify(WPARAM wparam, LPARAM lparam)
- {
- int pos = this->m_wndSendingProgCtrl.GetPos() + wparam;
- this->m_wndSendingProgCtrl.SetPos(pos);
-
- return 0L;
- }
- //UWM_SNDER_UPDATE_ONEFILESEND_OK
- LRESULT CMainFrame::OnSendedFileOverNotify(WPARAM wparam, LPARAM lparam)
- {
- //////////////////////////////////////////////////////////////////////////
-
- CRegister regkey;
-
- if(!regkey.Open(HKEY_CURRENT_USER, REG_SSYSSETTINGKEY))
- {
- return 0L;
- }
- BOOL bautodel = regkey.Read_Bool_Value(REG_BAUTODELSNDEDFILE);
- DWORD dwport = regkey.Read_DWord_Value(REG_NTRFTRANSPORT);
-
- regkey.Close();
- //////////////////////////////////////////////////////////////////////////
-
- //show and set sending progress bar properties.
- this->m_wndSendingProgCtrl.SetPos(0);
- this->m_wndSendingProgCtrl.SetRange32(0, 0);
- CFileListSend *pSndFileList = this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList;
- ASSERT(NULL != pSndFileList);
-
- //record log info.
- CString sfilename, strlog;
- AGINFO aginfo = this->m_pdestips[this->m_ncuripindx];
-
- sfilename.Format("%s\%s",
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
- if(wparam == 0)
- {
- strlog.Format(_LoadString(IDS_LOG_SENDFLEEND).GetBuffer(0),
- sfilename.GetBuffer(0),
- aginfo.shostname.c_str(),
- aginfo.shostip.c_str());
- }
- else
- {
- strlog.Format(_LoadString(IDS_LOG_SENDFLEFAILED).GetBuffer(0),
- sfilename.GetBuffer(0),
- aginfo.shostname.c_str(),
- aginfo.shostip.c_str());
- }
- ::AfxGetMainWnd()->SendMessage(UWM_UPDATESYSLOGINF, 0, (LPARAM)strlog.GetBuffer(0));
- //////////////////////////////////////////////////////////////////////////
- //update the db contents.
-
- CString tohost;
- tohost.Format("%s / %s", aginfo.shostname.c_str(), aginfo.shostip.c_str());
- pSndFileList->AddSendRecord(this->m_ncurfleindx, tohost.GetBuffer(0), wparam == 0 ? TRUE:FALSE);
-
- //////////////////////////////////////////////////////////////////////////
-
- this->m_ncurfleindx++;
- //////////////////////////////////////////////////////////////////////////
-
- //if the sending file is virtual ftp file then download it to local first.
- if(pSndFileList->IsFtpFile(this->m_ncurfleindx))
- {
- //make local file name.
- CString strlocalfile = this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.MakeLocalFileName(
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
-
- //download it.
- REMOTEFILEINFO rfRemoteFile;
-
- _snprintf(rfRemoteFile.szRemoteFile, MAX_PATH, "%s",
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
-
- rfRemoteFile.dwFilesize = atoi(pSndFileList->GetListCtrl().
- GetItemText(this->m_ncurfleindx, 1).GetBuffer(0));
-
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.DownloadFile(
- &rfRemoteFile, strlocalfile.GetBuffer(0));
-
- //modify sending file list contents.
- int revpos = strlocalfile.ReverseFind('\');
- pSndFileList->GetListCtrl().SetItemText(this->m_ncurfleindx, 2,
- revpos == -1 ? strlocalfile : strlocalfile.Left(revpos));
- }
- //////////////////////////////////////////////////////////////////////////
-
- if(this->m_ncurfleindx == pSndFileList->GetListCtrl().GetItemCount())
- {
- this->m_ncurfleindx = 0;
- this->m_ncuripindx++;
- if(this->m_ncuripindx < this->m_pdestips.size())
- {
- aginfo = this->m_pdestips[this->m_ncuripindx];
- CMutexLock omimutex(m_sndsockmutex);
- theApp.m_oCCHelper.Stop_FileSendSvr();
- if(!theApp.m_oCCHelper.Start_FileSendSvr())
- {
- MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
- return 0L;
- }
- theApp.m_oCCHelper.GetFileSenderThread()->Subscribe(this->GetSafeHwnd());
- if(!theApp.m_oCCHelper.GetFileSenderThread()->Create(false, aginfo.shostip.c_str(), dwport))
- {
- MSGBOX_INFO(_LoadString(IDS_CONNREMOTEAGFAIL).GetBuffer(0));
- return 0L;
- }
- sfilename.Format("%s\%s",
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
- theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
-
- //////////////////////////////////////////////////////////////////////////
- }
- else
- {
- //if system setting is auto delete sended file item then remove all items in listview.
- if(bautodel)
- {
- //pSndFileList->SelectAllItems();
- //pSndFileList->DelFiles();
- pSndFileList->DeleteFile(this->m_ncurfleindx);
- }
- //wipe dest ip list contents.
- for(; this->m_pdestips.size() > 0; )
- {
- this->m_pdestips.pop_back();
- }
- this->m_wndSendingProgCtrl.ShowWindow(SW_HIDE);
- pSndFileList->m_bSendingBusy = FALSE;
- pSndFileList->EnableSort(TRUE);
- //////////////////////////////////////////////////////////////////////////
-
- CMutexLock omimutex(m_sndsockmutex);
- theApp.m_oCCHelper.Stop_FileSendSvr();
- }
- }
- else
- {
- //if send to single user...
- if(this->m_pdestips.size() == 1)
- {
- if(bautodel)
- {
- this->m_ncurfleindx--;
-
- pSndFileList->SelectOneItem(this->m_ncurfleindx);
- pSndFileList->DelFiles();
- }
- }
- //continue send next file.
- sfilename.Format("%s\%s",
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 2).GetBuffer(0),
- pSndFileList->GetListCtrl().GetItemText(this->m_ncurfleindx, 0).GetBuffer(0));
- //////////////////////////////////////////////////////////////////////////
-
- CMutexLock omimutex(m_sndsockmutex);
- if(theApp.m_oCCHelper.GetFileSenderThread() && TS_STOPED != theApp.m_oCCHelper.GetFileSenderThread()->getThreadState())
- {
- theApp.m_oCCHelper.GetFileSenderThread()->pushFile(sfilename.GetBuffer(0));
- }
- }
- //////////////////////////////////////////////////////////////////////////
- return 0L;
- }
- void CMainFrame::OnSystemCrtusrgrp()
- {
- CSendGroupMgr dlg;
- dlg.DoModal();
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForGrpSend.UpdateTreeForUserDatas();
- }
- //UWM_SHELLSNDTONOTIFY
- LRESULT CMainFrame::OnAddSendFileFrmShellNotify(WPARAM wp, LPARAM lp)
- {
- CRegister regkey;
-
- if(!regkey.Open(HKEY_CURRENT_USER, REG_SSHLSNDTOFLEDIR)) return 0L;
-
- DWORD count = regkey.Read_DWord_Value(REG_SSHLSNDTOFLECNT);
- CString keyname, keyval;
- for(int i = 0; i < count; ++i)
- {
- keyname.Format("%d", i);
- keyval = regkey.Read_String_Value(keyname.GetBuffer(0));
- this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList->AddFile(keyval.GetBuffer(0));
- regkey.DeleteValue(keyname.GetBuffer(0));
- }
- regkey.Write_DWord_Value(REG_SSHLSNDTOFLECNT);
-
- return 0L;
- }
- //System ftp-sites setting management.
- void CMainFrame::OnSystemFtpSetting()
- {
- CFtpConnectDlg dlg;
- dlg.DoModal();
- }
- void CMainFrame::OnConnectFtpSvr()
- {
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
- SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_OPEN, 1), NULL);
- }
- void CMainFrame::OnUpdateFtpoperOpen(CCmdUI* pCmdUI)
- {
- BOOL bEnable = (m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.GetSelectedItem() != NULL);
- bEnable = bEnable && !(m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.ExistsConnection());
- pCmdUI->Enable(bEnable);
- }
- void CMainFrame::OnDisconnectFtpSvr()
- {
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
- SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_CLOSE, 1), NULL);
-
- this->m_pwndWorkFrame->m_pwndFileTransView->m_pwndFileSendList->RemoveAllFtpFiles();
- }
- void CMainFrame::OnUpdateFtpoperClose(CCmdUI* pCmdUI)
- {
- BOOL bEnable = m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.ExistsConnection();
- pCmdUI->Enable(bEnable);
- }
- void CMainFrame::OnRefreshFtpDirs()
- {
- this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.
- SendMessage(WM_COMMAND, MAKEWPARAM(ID_FTPOPER_REFDIRS, 1), NULL);
- }
- void CMainFrame::OnUpdateFtpoperRefdirs(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(!this->m_pwndWorkFrame->m_pwndWorkspaceView->m_TreeForFtp.IsConnectingState());
- }
- void CMainFrame::OnViewChatBar()
- {
- BOOL bshowing = this->m_wndChatBar.IsWindowVisible();
- this->ShowControlBar(&m_wndChatBar, !bshowing, TRUE);
- }
- void CMainFrame::OnUpdateViewChatBar(CCmdUI* pCmdUI)
- {
- BOOL bshowing = this->m_wndChatBar.IsWindowVisible();
- pCmdUI->SetCheck(bshowing);
- }