Пример #1
0
bool ConfigImporter::importConfigFromV1toV3() {
	string classicPath = getWengoClassicConfigPath();
	File mDir(classicPath);
	last_user_t * lastUser = (last_user_t *) getLastWengoUser(classicPath + USERCONFIG_FILENAME, CONFIG_VERSION1);
	if (lastUser) {
		UserProfile userProfile;
		WengoAccount wAccount(lastUser->login, lastUser->password, true);
		userProfile.setSipAccount(wAccount, false);
	
		// An SSO request was made here before.
		// The SSO request was made to get the SIP identity of the user and link Wengo contacts to this id.
		// Faking this SSO request.
		IMAccount imAccount(FAKE_LOGIN, FAKE_PASSWORD, EnumIMProtocol::IMProtocolWengo);
		userProfile.addIMAccount(imAccount);

		string sep = mDir.getPathSeparator();
		String oldPath = classicPath + lastUser->login + sep + "contacts" + sep;
		importContactsFromV1toV3(oldPath, userProfile);

		String accountDir(userProfile.getProfileDirectory());
		File::createPath(accountDir);
		UserProfileFileStorage1 fStorage(userProfile);
		fStorage.save(userProfile.getName());

		Settings settings = readConfigFile();
		settings.set(Config::PROFILE_LAST_USED_NAME_KEY, userProfile.getName());
		writeConfigFile(settings);
	}

	return true;
}
Пример #2
0
void UserProfileHandler::saveUserProfile(UserProfile & userProfile) {
	if (_autoSave && &userProfile && !userProfile.isDestroying() )	//VOXOX - JRT - 2009.09.22 
	{
		UserProfileFileStorage userProfileStorage(userProfile);
		userProfileStorage.save(userProfile.getName());
	}
}
Пример #3
0
bool ConfigImporter::importConfigFromV2toV3() {
	String configDir = Config::getConfigDir();

	FileReader file(configDir + USERPROFILE_FILENAME);
	if (file.open()) {
		string data = file.read();

		last_user_t * lastUser = (last_user_t *) getLastWengoUser(configDir + USERCONFIG_FILENAME, CONFIG_VERSION2);
		if (lastUser == NULL) {
			return false;
		}

		UserProfile userProfile;

		UserProfileXMLSerializer serializer(userProfile);
		serializer.unserialize(data);

		WengoAccount wAccount(lastUser->login, Base64::decode(lastUser->password), true);
		userProfile.setSipAccount(wAccount, false);
	
		// An SSO request was made here before.
		// The SSO request was made to get the SIP identity of the user and link Wengo contacts to this id.
		// Faking this SSO request.
		IMAccount imAccount(FAKE_LOGIN, FAKE_PASSWORD, EnumIMProtocol::IMProtocolWengo);
		userProfile.addIMAccount(imAccount);

		//remove user.config and userprofile.xml from the main directory
		File userConfigFile(configDir + USERCONFIG_FILENAME);
		userConfigFile.remove();
		File userProfileFile(configDir + USERPROFILE_FILENAME);
		userProfileFile.remove();

		String accountDir(userProfile.getProfileDirectory());
		File::createPath(accountDir);
		UserProfileFileStorage1 fStorage(userProfile);
		fStorage.save(userProfile.getName());

		File mFile1(configDir + IMACCOUNTS_FILENAME);
		mFile1.move(accountDir + IMACCOUNTS_FILENAME, true);

		File mFile2(configDir + CONTACTLIST_FILENAME);
		mFile2.move(accountDir + CONTACTLIST_FILENAME, true);

		File mDir(configDir);
		StringList dirList = mDir.getFileList();
		for (unsigned i = 0; i < dirList.size(); i++) {
			if (dirList[i].length() > OLD_HISTORY_FILENAME.length()) {
				if (dirList[i].substr(dirList[i].length() - OLD_HISTORY_FILENAME.length()) == OLD_HISTORY_FILENAME) {
					File mFile3(configDir + dirList[i]);
					mFile3.move(accountDir + NEW_HISTORY_FILENAME, true);
					break;
				}
			}
		}

		Settings settings = readConfigFile();
		settings.set(Config::PROFILE_LAST_USED_NAME_KEY, userProfile.getName());
		writeConfigFile(settings);
	}

	return true;
}
Пример #4
0
void UserProfileHandler::setLastUsedUserProfile(const UserProfile & userProfile) {
	Config & config = ConfigManager::getInstance().getCurrentConfig();
	config.set(Config::PROFILE_LAST_USED_NAME_KEY, userProfile.getName());
}