Browse Source

show additional network password on friends dialog and show network password in plain text
[SAB]


git-svn-id: svn://svn.code.sf.net/p/ditto-cp/code/trunk@170 595ec19a-5cb4-439b-94a8-42fb3063c22c

sabrogden 21 years ago
parent
commit
182c5a5547
6 changed files with 91 additions and 62 deletions
  1. 5 2
      CP_Main.rc
  2. 70 51
      Misc.cpp
  3. 3 0
      Misc.h
  4. 10 8
      OptionFriends.cpp
  5. 1 0
      OptionFriends.h
  6. 2 1
      Resource.h

+ 5 - 2
CP_Main.rc

@@ -701,9 +701,9 @@ CAPTION "Friends"
 FONT 8, "MS Sans Serif"
 BEGIN
     CONTROL         "List1",IDC_LIST,"SysListView32",LVS_REPORT | WS_BORDER | 
-                    WS_TABSTOP,7,113,307,114
+                    WS_TABSTOP,7,142,307,85
     LTEXT           "If Send All Copies is selected then all copies from this computer will be sent to the other computer.  If that is not selected then it will just be in the right click menu to send a copy to that computer.",
-                    IDC_STATIC,7,85,278,24
+                    IDC_STATIC,7,113,278,24
     EDITTEXT        IDC_EDIT_PLACE_ON_CLIPBOARD,96,34,210,13,ES_AUTOHSCROLL
     LTEXT           "IP/Computer Names seperated by commas",IDC_STATIC,7,32,
                     70,17
@@ -715,6 +715,9 @@ BEGIN
                     "Button",BS_AUTOCHECKBOX | WS_TABSTOP,95,48,90,10
     LTEXT           "Network Password",IDC_STATIC,7,68,79,9
     EDITTEXT        IDC_EDIT_PASSWORD,96,65,210,13,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_ADDITIONAL,95,100,210,11,ES_AUTOHSCROLL
+    LTEXT           "If you are recieving clips from computers where your network password does not match, enter additional network passwords seperated by commas",
+                    IDC_STATIC,7,81,307,16
 END
 
 IDD_FRIEND_DETAILS DIALOG DISCARDABLE  0, 0, 203, 79

+ 70 - 51
Misc.cpp

@@ -520,29 +520,8 @@ CGetSetOptions::CGetSetOptions()
 	m_bEnsureEntireWindowCanBeSeen = GetEnsureEntireWindowCanBeSeen();
 	m_bShowAllClipsInMainList = GetShowAllClipsInMainList();
 
-	m_csNetworkPasswordArray.RemoveAll();
-
-	CString cs = GetProfileString("NetorkPassword1", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword2", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword3", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword4", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword5", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword6", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword7", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword8", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword9", "");
-	m_csNetworkPasswordArray.Add(cs);
-	cs = GetProfileString("NetworkPassword10", "");
-	m_csNetworkPasswordArray.Add(cs);
-
+	GetExtraNetworkPassword(true);
+	
 	#ifdef _DEBUG
 	m_bUseHookDllForFocus = FALSE;
 	#endif
@@ -1202,46 +1181,86 @@ BOOL CGetSetOptions::GetDrawThumbnail()
 	return GetProfileLong("DrawThumbnail", TRUE);
 }
 
-void CGetSetOptions::SetNetworkPassword(CString csPassword)
+void CGetSetOptions::SetExtraNetworkPassword(CString csPassword)
 {
-	m_csPassword = csPassword;
+	SetProfileString("NetworkExtraPassword", csPassword);
+}
 
-	UCHAR *pData = NULL;
-	int nLength = 0;
+CString CGetSetOptions::GetExtraNetworkPassword(bool bFillArray)
+{
+	CString cs = GetProfileString("NetworkExtraPassword", "");
 
-	if(EncryptString(csPassword, pData, nLength))
+	if(bFillArray)
 	{
-		SetProfileData("NetworkPassword", pData, nLength);
-	}
-	else
-	{
-		SetProfileData("NetworkPassword", NULL, 0);
+		m_csNetworkPasswordArray.RemoveAll();
+
+		char seps[]   = ",";
+		char *token;
+
+		char *pString = cs.GetBuffer(cs.GetLength());
+		
+		/* Establish string and get the first token: */
+		token = strtok(pString, seps);
+		while(token != NULL)
+		{
+			CString cs(token);
+			cs.TrimLeft();
+			cs.TrimRight();
+
+			m_csNetworkPasswordArray.Add(cs);
+
+			// Get next token
+			token = strtok( NULL, seps );
+		}
+
+		cs.ReleaseBuffer();
 	}
 
-	DELETE_PTR(pData);
+	return cs;
 }
 
-CString CGetSetOptions::GetNetworkPassword()
+void CGetSetOptions::SetNetworkPassword(CString csPassword)
 {
-	CString cs = "";
-	DWORD dwLength = 0;
-	LPVOID lpVoid = GetProfileData("NetworkPassword", dwLength);
-	if(lpVoid)
-	{
-		UCHAR *pData = NULL;
-		int nLength = 0;
-
-		if(DecryptString((UCHAR *)lpVoid, dwLength, pData, nLength))
-			cs = pData;
+	m_csPassword = csPassword;
 
-		DELETE_PTR(pData);
-		DELETE_PTR(lpVoid);
-	}
+	SetProfileString("NetworkStringPassword", csPassword);
 
-	if(cs == "")
-		cs = "LetMeIn";
+//	UCHAR *pData = NULL;
+//	int nLength = 0;
+//
+//	if(EncryptString(csPassword, pData, nLength))
+//	{
+//		SetProfileData("NetworkPassword", pData, nLength);
+//	}
+//	else
+//	{
+//		SetProfileData("NetworkPassword", NULL, 0);
+//	}
+//
+//	DELETE_PTR(pData);
+}
 
-	return cs;
+CString CGetSetOptions::GetNetworkPassword()
+{
+	return GetProfileString("NetworkStringPassword", "LetMeIn");
+
+//	CString cs = "";
+//	DWORD dwLength = 0;
+//	LPVOID lpVoid = GetProfileData("NetworkPassword", dwLength);
+//	if(lpVoid)
+//	{
+//		UCHAR *pData = NULL;
+//		int nLength = 0;
+//
+//		if(DecryptString((UCHAR *)lpVoid, dwLength, pData, nLength))
+//			cs = pData;
+//
+//		DELETE_PTR(pData);
+//		DELETE_PTR(lpVoid);
+//	}
+//
+//	if(cs == "")
+//		cs = "LetMeIn";
 }
 
 void CGetSetOptions::SetDrawRTF(long bDraw)

+ 3 - 0
Misc.h

@@ -344,6 +344,9 @@ public:
 	static void		SetShowAllClipsInMainList(BOOL bVal);
 	static BOOL		GetShowAllClipsInMainList();
 
+	static void		SetExtraNetworkPassword(CString csPassword);
+	static CString	GetExtraNetworkPassword(bool bFillArray);
+
 	static CStringArray m_csNetworkPasswordArray;
 
 	/*

+ 10 - 8
OptionFriends.cpp

@@ -24,6 +24,7 @@ COptionFriends::COptionFriends() : CPropertyPage(COptionFriends::IDD)
 	//{{AFX_DATA_INIT(COptionFriends)
 	m_PlaceOnClipboard = _T("");
 	m_csPassword = _T("");
+	m_csAdditionalPasswords = _T("");
 	//}}AFX_DATA_INIT
 }
 
@@ -40,6 +41,7 @@ void COptionFriends::DoDataExchange(CDataExchange* pDX)
 	DDX_Control(pDX, IDC_LIST, m_List);
 	DDX_Text(pDX, IDC_EDIT_PLACE_ON_CLIPBOARD, m_PlaceOnClipboard);
 	DDX_Text(pDX, IDC_EDIT_PASSWORD, m_csPassword);
+	DDX_Text(pDX, IDC_EDIT_ADDITIONAL, m_csAdditionalPasswords);
 	//}}AFX_DATA_MAP
 }
 
@@ -68,12 +70,11 @@ BOOL COptionFriends::OnInitDialog()
 	InsertItems();
 
 	m_SendRecieve.SetCheck(CGetSetOptions::GetLogSendReceiveErrors());
-
 	m_bDisableRecieve.SetCheck(CGetSetOptions::GetDisableRecieve());
 
 	m_PlaceOnClipboard = g_Opt.m_csIPListToPutOnClipboard;
-
-	m_csPassword = "[Not Shown]";
+	m_csPassword = g_Opt.m_csPassword;
+	m_csAdditionalPasswords = CGetSetOptions::GetExtraNetworkPassword(false);
 
 	UpdateData(FALSE);
 		
@@ -101,20 +102,21 @@ BOOL COptionFriends::OnApply()
 		g_Opt.SetSendClients(client, i);
 	}
 
+	CGetSetOptions::SetNetworkPassword(m_csPassword);
 	CGetSetOptions::SetLogSendReceiveErrors(m_SendRecieve.GetCheck());
 
-
 	CGetSetOptions::SetDisableRecieve(m_bDisableRecieve.GetCheck());
 	theApp.StartStopServerThread();
 
 	UpdateData();
 
 	g_Opt.SetListToPutOnClipboard(m_PlaceOnClipboard);
-
-	if(m_csPassword != "[Not Shown]")
-		g_Opt.SetNetworkPassword(m_csPassword);
-
+	g_Opt.SetNetworkPassword(m_csPassword);
 	g_Opt.GetClientSendCount();
+
+	g_Opt.SetExtraNetworkPassword(m_csAdditionalPasswords);
+	//get get to refill the array extra passwords
+	g_Opt.GetExtraNetworkPassword(true);
 	
 	return CPropertyPage::OnApply();
 }

+ 1 - 0
OptionFriends.h

@@ -28,6 +28,7 @@ public:
 	CListCtrl	m_List;
 	CString	m_PlaceOnClipboard;
 	CString	m_csPassword;
+	CString	m_csAdditionalPasswords;
 	//}}AFX_DATA
 
 

+ 2 - 1
Resource.h

@@ -144,6 +144,7 @@
 #define IDC_CHECK_FIND_AS_YOU_TYPE      2036
 #define IDC_CHECK_WIN6                  2037
 #define IDC_CHECK_ENTIRE_WINDOW_IS_VISIBLE 2037
+#define IDC_EDIT_ADDITIONAL             2037
 #define IDC_CHECK_WIN7                  2038
 #define IDC_CHECK_SHOW_ALL_IN_MAIN_LIST 2038
 #define IDC_CHECK_WIN8                  2039
@@ -239,7 +240,7 @@
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        157
 #define _APS_NEXT_COMMAND_VALUE         32852
-#define _APS_NEXT_CONTROL_VALUE         2037
+#define _APS_NEXT_CONTROL_VALUE         2038
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif