AddMMSDlg.cpp
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:5k
源码类别:

P2P编程

开发平台:

Visual C++

  1. /*
  2.  *  Openmysee
  3.  *
  4.  *  This program is free software; you can redistribute it and/or modify
  5.  *  it under the terms of the GNU General Public License as published by
  6.  *  the Free Software Foundation; either version 2 of the License, or
  7.  *  (at your option) any later version.
  8.  *
  9.  *  This program is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  *  GNU General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU General Public License
  15.  *  along with this program; if not, write to the Free Software
  16.  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  17.  *
  18.  */
  19. //
  20. #include "stdafx.h"
  21. #include "MMSServer.h"
  22. #include "AddMMSDlg.h"
  23. #include "ConfigFile.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CAddMMSDlg dialog
  31. CAddMMSDlg::CAddMMSDlg(CMMSPool *pMMSPool, CWnd* pParent /*=NULL*/)
  32. : CDialog(CAddMMSDlg::IDD, pParent)
  33. {
  34. //{{AFX_DATA_INIT(CAddMMSDlg)
  35. m_strAddr = _T("");
  36. m_strChannel = _T("");
  37. m_bAddCurItemOnClose=TRUE;
  38. m_BDeleteRegEntriesOnClear=TRUE;
  39. //}}AFX_DATA_INIT
  40. m_pMMSPool = pMMSPool;
  41. }
  42. void CAddMMSDlg::DoDataExchange(CDataExchange* pDX)
  43. {
  44. CDialog::DoDataExchange(pDX);
  45. //{{AFX_DATA_MAP(CAddMMSDlg)
  46. DDX_Text(pDX, IDC_COMBO_MMSADDR, m_strAddr);
  47. DDX_Control(pDX,IDC_COMBO_MMSADDR,m_mcomboItems);
  48. DDX_Text(pDX,IDC_EDIT_CHNLNAME,m_strChannel);
  49. DDX_Check(pDX,IDC_BTN_CLEAR_HISTORY2,m_BDeleteRegEntriesOnClear);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(CAddMMSDlg, CDialog)
  53. //{{AFX_MSG_MAP(CAddMMSDlg)
  54. ON_BN_CLICKED(IDC_BTN_CLEAR_HISTORY2, OnBtnClearHistory2)
  55. //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CAddMMSDlg message handlers
  59. void CAddMMSDlg::OnOK() 
  60. {  
  61. /////////////Get the channel name  and add it 
  62. string strChannel;
  63. CString str;
  64. GetDlgItemText(IDC_EDIT_CHNLNAME, str);
  65. if(str.IsEmpty())
  66. {
  67. AfxMessageBox("you must enter the channel name!");
  68. return;
  69. }
  70. strChannel.append(str);
  71.   
  72. //////////////Get The MMS address  Add  Add it 
  73. string strAddr;
  74. GetDlgItemText(IDC_COMBO_MMSADDR, str);
  75. if(str.IsEmpty())
  76. {
  77. AfxMessageBox("you must enter the MMS address!");
  78. return;
  79. }
  80. strAddr.append(str);
  81.    
  82.     /////////////////Get The ModulePath  And  Write the File
  83. CString str_path;
  84. GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
  85. str_path.ReleaseBuffer();
  86. int index = str_path.ReverseFind('\');
  87.     str_path =  str_path.Left(index+1);
  88.   ////////////////Save the MMSAddress 
  89.    CString Items;
  90.    m_mcomboItems.GetWindowText(Items);
  91.    m_mcomboItems.AddString(Items);
  92.    m_mcomboItems.SaveHistory(m_bAddCurItemOnClose);
  93.  
  94.   
  95. ////////////// From Dialog Get Data And Write The file
  96. CString Name;
  97. CString MMSAddress;
  98. CString spIP;
  99. GetDlgItem(IDC_EDIT_CHNLNAME)->GetWindowText(Name);
  100. GetDlgItem(IDC_COMBO_MMSADDR)->GetWindowText(MMSAddress);
  101. GetDlgItem(IDC_EDIT_SPADDR)->GetWindowText(spIP);
  102. //write to CaptureServer.cfg
  103. FILE *pfile = fopen(str_path+"CaptureServer.cfg","w");
  104. fprintf(pfile,"%sn","[CaptureServer]");
  105. fprintf(pfile,"%s%sn","channelName=",Name);
  106. fprintf(pfile,"%sn","userID=10040");
  107. fprintf(pfile,"%sn","password=ccc602a8ef81836cdd332ce0d31ef268");
  108. fprintf(pfile,"%s%sn","spAddress=",spIP);
  109. fprintf(pfile,"%sn","ReconnectTime=120");
  110. fprintf(pfile,"%s%sn","MMSAddress=",MMSAddress);
  111. fclose(pfile);
  112. UpdateData(TRUE);
  113.  
  114. CDialog::OnOK();
  115. }
  116. BOOL CAddMMSDlg::OnInitDialog() 
  117. {
  118. CDialog::OnInitDialog();
  119. // TODO: Add extra initialization here
  120.     m_mcomboItems.LoadHistory(_T("HistoryCombos"), _T("HistoryItem"));
  121.     
  122.    ////// Get The ModulePath And Write The File 
  123.     CString str_path;
  124. GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
  125. str_path.ReleaseBuffer();
  126. int index = str_path.ReverseFind('\');
  127.     str_path=  str_path.Left(index+1);
  128.    
  129. ConfigFile myfile((str_path+"CaptureServer.cfg").GetBuffer(MAX_PATH));
  130. string spIP=myfile.Value("CaptureServer","spAddress");
  131. string Name =myfile.Value("CaptureServer","channelName");
  132. string MMSAdress=myfile.Value("CaptureServer","MMSAddress");
  133. GetDlgItem(IDC_EDIT_SPADDR)->SetWindowText(spIP.data());
  134. GetDlgItem(IDC_EDIT_CHNLNAME)->SetWindowText(Name.data());
  135. GetDlgItem(IDC_COMBO_MMSADDR)->SetWindowText(MMSAdress.data());
  136. return TRUE; 
  137. // return TRUE unless you set the focus to a control
  138.               // EXCEPTION: OCX Property Pages should return FALSE
  139. }
  140. void CAddMMSDlg::OnBtnClearHistory2() 
  141. {
  142. // TODO: Add your control notification handler code here
  143.   UpdateData(TRUE);
  144.   m_mcomboItems.ClearHistory(m_BDeleteRegEntriesOnClear);
  145. }