new implementation
| 963 | |
| 964 | /// new implementation |
| 965 | CPreferences::CPreferences() |
| 966 | { |
| 967 | srand( wxGetLocalTimeMillis().GetLo() ); // we need random numbers sometimes |
| 968 | |
| 969 | // load preferences.dat or set standard values |
| 970 | wxString fullpath(s_configDir + "preferences.dat"); |
| 971 | CFile preffile; |
| 972 | if (wxFileExists(fullpath)) { |
| 973 | if (preffile.Open(fullpath, CFile::read)) { |
| 974 | try { |
| 975 | preffile.ReadUInt8(); // Version. Value is not used. |
| 976 | s_userhash = preffile.ReadHash(); |
| 977 | } catch (const CSafeIOException& e) { |
| 978 | AddDebugLogLineC(logGeneral, |
| 979 | "Error while reading userhash: " + e.what()); |
| 980 | } |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | if (s_userhash.IsEmpty()) { |
| 985 | for (int i = 0; i < 8; i++) { |
| 986 | RawPokeUInt16(s_userhash.GetHash() + (i * 2), rand()); |
| 987 | } |
| 988 | |
| 989 | Save(); |
| 990 | } |
| 991 | |
| 992 | // Mark hash as an eMule-type hash |
| 993 | // See also CUpDownClient::GetHashType |
| 994 | s_userhash[5] = 14; |
| 995 | s_userhash[14] = 111; |
| 996 | |
| 997 | #ifndef CLIENT_GUI |
| 998 | LoadPreferences(); |
| 999 | ReloadSharedFolders(); |
| 1000 | |
| 1001 | // serverlist addresses |
| 1002 | CTextFile slistfile; |
| 1003 | if (slistfile.Open(s_configDir + "addresses.dat", CTextFile::read)) { |
| 1004 | addresses_list = slistfile.ReadLines(); |
| 1005 | } |
| 1006 | #endif |
| 1007 | } |
| 1008 | |
| 1009 | // |
| 1010 | // Gets called at init time |