Пример #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 QtAddVoxOxAccount::loginClicked() {
	
	std::string login = _ui->usernameComboBox->currentText().toStdString();
	std::string password = _ui->passwordLineEdit->text().toStdString();

	if (!login.empty() && !password.empty()) {
		WengoAccount wengoAccount(login, password, _ui->rememberPasswordCheckBox->isChecked());
		wengoAccount.setVisibleName(login);
		wengoAccount.setRememberPassword(_ui->rememberPasswordCheckBox->isChecked());//VOXOX CHANGE by Rolando 04-06-09
		wengoAccount.setRememberUsername(_ui->rememberPasswordCheckBox->isChecked());//VOXOX CHANGE by Rolando 04-06-09
		wengoAccount.setAutoLoginVoxOx(_ui->automaticallyLoginCheckBox->isChecked());//VOXOX CHANGE by Rolando 04-06-09
		//_currentUsername = login;

		// Looking for the selected profile
		if (!_cUserProfileHandler.userProfileExists(login)) {
			// The selected profile does not exist. Creating a new one.
			UserProfile userProfile;
			userProfile.setSipAccount(wengoAccount, false /* needInitialization */);
			UserProfileFileStorage userProfileStorage(userProfile);
			userProfileStorage.save(login);
			
		}			
		_cUserProfileHandler.setCurrentUserProfile(login, wengoAccount);	
				
		_loginDialog->accept();
		
	}

}
Пример #3
0
void QtAddWengoAccount::loginClicked() {
	std::string login = _ui->email->text().toStdString();
	
	// check if login is an email address
	//VOXOX CHANGE
	//CJC
	//We dont need any @
	/*if (login.find("@", 0) == login.npos) {
	
		QMessageBox::warning(this, tr("@product@ - Connexion"),
			tr("Please enter an email address."),
			QMessageBox::Ok, QMessageBox::NoButton);
	
		return;
	}*/
	////
	
	std::string password = _ui->password->text().toStdString();
	if (!login.empty() && !password.empty()) {
		WengoAccount wengoAccount(login, password, true/*_ui->rememberPassword->isChecked()*/);
		wengoAccount.setVisibleName(login);

		// Looking for the selected profile
		if (!_cUserProfileHandler.userProfileExists(login)) {
			// The selected profile does not exist. Create it.
			UserProfile userProfile;

			//VOXOX CHANGE by Rolando 01-20-09 eliminated add test calls
			/*Config & config = ConfigManager::getInstance().getCurrentConfig();
			QtAddAccountUtils::addTestContacts(&userProfile,
				config.getWengoAudioTestCall(),
				config.getWengoVideoTestCall()
				);*/

			userProfile.setSipAccount(wengoAccount, false /* needInitialization */);
			UserProfileFileStorage userProfileStorage(userProfile);
			userProfileStorage.save(login);
		}
		_cUserProfileHandler.setCurrentUserProfile(login, wengoAccount);
		_loginDialog->accept();
	}
}
Пример #4
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;
}
Пример #5
0
//VOXOX CHANGE by Rolando - 2009.05.22 - added parameter "loginInvisible" to be able to login with a invisible presence
void UserProfileHandler::setCurrentUserProfile(const std::string & name, const SipAccount & sipAccount, bool loginInvisible) {

	RecursiveMutex::ScopedLock lock(_mutex);

	UserProfile * result = getUserProfile(name);
	
	// Check if the desired UserProfile is different from the current UserProfile
	// and check if the WengoAccount of the current UserProfile is different from the given WengoAccount
	// (if so the WengoAccount (only 'password' and 'keep password' members) will be updated).
	if (!_currentUserProfile ||
		(_currentUserProfile &&
			((_currentUserProfile->getName() != name) ||
			((sipAccount.getUserPassword() != result->getSipAccount()->getUserPassword()) ||
				(sipAccount.isPasswordRemembered() != result->getSipAccount()->isPasswordRemembered()))))) {

		if (result) {
			// If the SipAccount is not empty, we update the one in UserProfile
			// This can happen if the password has been changed
			
			if (!sipAccount.isEmpty() ) {

				// to be virtual ?
				switch(sipAccount.getType()) {
					case SipAccount::SipAccountTypeBasic: {
					
						SipAccount * actSipAccount = result->getSipAccount();
						if (actSipAccount) {
						
							actSipAccount->setRegisterServerHostname(sipAccount.getRegisterServerHostname());
							actSipAccount->setRegisterServerPort(sipAccount.getRegisterServerPort());
							actSipAccount->setSIPProxyServerHostname(sipAccount.getSIPProxyServerHostname());
							actSipAccount->setSIPProxyServerPort(sipAccount.getSIPProxyServerPort());
							actSipAccount->setDisplayName(sipAccount.getDisplayName());
							actSipAccount->setIdentity(sipAccount.getIdentity());
							actSipAccount->setUsername(sipAccount.getUsername());
							actSipAccount->setPassword(sipAccount.getPassword());
							actSipAccount->setRealm(sipAccount.getRealm());
							actSipAccount->setVisibleName(sipAccount.getVisibleName());
							actSipAccount->enablePIM(sipAccount.isPIMEnabled());
							actSipAccount->setRememberPassword(sipAccount.isPasswordRemembered());
							actSipAccount->setRememberUsername(sipAccount.isUsernameRemembered());
							actSipAccount->setAutoLoginVoxOx(sipAccount.isAutoLoginVoxOx());
						} else {
							SipAccount mySipAccount = sipAccount;
							result->setSipAccount(mySipAccount, false);
						}
					}
					break;
					case SipAccount::SipAccountTypeWengo: {
					
						const WengoAccount & refWengoAccount = dynamic_cast<const WengoAccount &>(sipAccount);
						WengoAccount * actWengoAccount = result->getWengoAccount();
						
						if (actWengoAccount) {
							actWengoAccount->setWengoLogin(refWengoAccount.getWengoLogin());
							actWengoAccount->setWengoPassword(refWengoAccount.getWengoPassword());
							actWengoAccount->setRememberPassword(refWengoAccount.isPasswordRemembered());
							actWengoAccount->setRememberUsername(refWengoAccount.isUsernameRemembered());
							actWengoAccount->setAutoLoginVoxOx(sipAccount.isAutoLoginVoxOx());
						} else {
							WengoAccount myWengoAccount = refWengoAccount;
							result->setSipAccount(myWengoAccount, false);
						}
					}
					break;
				}
			}

			//VOXOX CHANGE by Rolando - 2009.05.22 - sets if user checked login with a invisible presence
			result->setLoginInvisible(loginInvisible);

			if (_currentUserProfile) {
				LOG_DEBUG("UserProfile will change");
				_desiredUserProfile = result;
				currentUserProfileWillDieEvent(*this);
			} else {
				LOG_DEBUG("No current UserProfile set. Change now");
				_currentUserProfile = result;
				initializeCurrentUserProfile();
			}
		} else {
			// log off
			if (_currentUserProfile && name.empty()) {

				_saveTimerRunning = false;
				_saveTimer.stop();

				_desiredUserProfile = NULL;
				currentUserProfileWillDieEvent(*this);
			// when name is empty or do not match any profile
			} else {
				noCurrentUserProfileSetEvent(*this);
			}
		}
	}
}