| 112 | } |
| 113 | |
| 114 | int FTPSettings::LoadSettings(const TiXmlElement * settingsElem) { |
| 115 | int outState = 0; |
| 116 | const char * outstr = settingsElem->Attribute("outputShown", &outState); |
| 117 | if (!outstr) { |
| 118 | outState = 0; |
| 119 | } |
| 120 | m_showOutput = (outState != 0); |
| 121 | |
| 122 | double ratio = 0.5; |
| 123 | const char * ratiostr = settingsElem->Attribute("windowRatio", &ratio); |
| 124 | if (!ratiostr) { |
| 125 | ratio = 0.5; |
| 126 | } |
| 127 | m_splitRatio = ratio; |
| 128 | |
| 129 | //Imperative that masterpassword be set before loading all profiles |
| 130 | const char * passstr = settingsElem->Attribute("MasterPass"); |
| 131 | if (passstr) { |
| 132 | InputDialog inputPass; |
| 133 | const TCHAR * query = TEXT("Please enter master password"); |
| 134 | bool success = false; |
| 135 | while(!success) { |
| 136 | int res = inputPass.Create(_MainOutputWindow, TEXT("NppFTP: Master password required"), query, TEXT("")); |
| 137 | if (res == 1) { |
| 138 | char * localPass = SU::TCharToCP(inputPass.GetValue(), CP_ACP); |
| 139 | char * challenge = Encryption::Decrypt(localPass, -1, passstr, true); |
| 140 | |
| 141 | if (strcmp(challenge, "NppFTP")) { |
| 142 | query = TEXT("Wrong password.\r\nPlease enter master password"); |
| 143 | } else { |
| 144 | //Encryption::SetDefaultKey(localPass, -1); |
| 145 | SetEncryptionKey(localPass); |
| 146 | success = true; |
| 147 | } |
| 148 | |
| 149 | Encryption::FreeData(challenge); |
| 150 | SU::FreeChar(localPass); |
| 151 | } else { |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | if (!success) { |
| 156 | MessageBox(_MainOutputWindow, |
| 157 | TEXT("Incorrect password entered.\r\n") |
| 158 | TEXT("The passwords will most likely be corrupted and you have to reenter them"), |
| 159 | TEXT("NppFTP: Password manager error"), MB_OK); |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | const char * defaultCacheutf8 = settingsElem->Attribute("defaultCache"); |
| 165 | TCHAR * defaultCache; |
| 166 | if (defaultCacheutf8) { |
| 167 | defaultCache = SU::Utf8ToTChar(defaultCacheutf8); |
| 168 | SetGlobalCachePath(defaultCache); |
| 169 | SU::FreeTChar(defaultCache); |
| 170 | } |
| 171 | |