void profile::open( const fc::path& profile_dir, const std::string& password ) { try { ilog("opening profile: ${profile_dir}",("profile_dir",profile_dir)); my->_profile_name = profile_dir.filename().generic_wstring(); fc::create_directories( profile_dir ); fc::create_directories( profile_dir / "addressbook" ); fc::create_directories( profile_dir / "idents" ); fc::create_directories( profile_dir / "mail" ); fc::create_directories( profile_dir / "mail" / "inbox" ); fc::create_directories( profile_dir / "mail" / "draft" ); fc::create_directories( profile_dir / "mail" / "pending" ); fc::create_directories( profile_dir / "mail" / "sent" ); fc::create_directories( profile_dir / "chat" ); fc::create_directories( profile_dir / "request" ); fc::create_directories( profile_dir / "authorization" ); ilog("loading master key file:" KEYHOTEE_MASTER_KEY_FILE); auto profile_cfg_key = fc::sha512::hash( password.c_str(), password.size() ); std::vector<char> stretched_seed_data; try { stretched_seed_data = fc::aes_load( profile_dir / KEYHOTEE_MASTER_KEY_FILE, profile_cfg_key ); } catch (fc::exception& /* e */) { //try to open legacy name for key file wlog("Could not open " KEYHOTEE_MASTER_KEY_FILE ", trying to open legacy key file (.strecthed_seed)."); stretched_seed_data = fc::aes_load( profile_dir / ".stretched_seed", profile_cfg_key ); } ilog("opening profile databases"); my->_keychain.set_seed( fc::raw::unpack<fc::sha512>(stretched_seed_data) ); my->_addressbook->open( profile_dir / "addressbook", profile_cfg_key ); my->_idents.open( profile_dir / "idents" ); my->_inbox_db->open( profile_dir / "mail" / "inbox", profile_cfg_key ); my->_draft_db->open( profile_dir / "mail" / "draft", profile_cfg_key ); my->_pending_db->open( profile_dir / "mail" / "pending", profile_cfg_key ); my->_sent_db->open( profile_dir / "mail" / "sent", profile_cfg_key ); my->_chat_db->open( profile_dir / "chat", profile_cfg_key ); my->_request_db->open( profile_dir / "request", profile_cfg_key ); my->_auth_db->open( profile_dir / "authorization", profile_cfg_key ); my->_last_sync_time.open( profile_dir / "mail" / "last_recv", true ); if( *my->_last_sync_time == fc::time_point()) { *my->_last_sync_time = fc::time_point::now() - fc::days(5); ilog("set last_sync_time to ${t}",("t",*my->_last_sync_time)); } else ilog("loaded last_sync_time = ${t}",("t",*my->_last_sync_time)); ilog("finished opening profile"); } FC_RETHROW_EXCEPTIONS( warn, "", ("profile_dir",profile_dir) ) }