//VOXOX CHANGE by Rolando - 2009.05.21 -commented line, we are now using a logo //VOXOX CHANGE by Rolando 04-06-09 //void QtAddVoxOxAccount::updateAvatarLabel(std::string profileName){ // // UserProfile * userProfile = new UserProfile(); // // //gets userprofile // _cUserProfileHandler.getUserProfileHandler().LoadUserProfileFromName(userProfile, profileName); // std::string backgroundPixmapFilename = ":/pics/avatar_background.png"; // // if(userProfile){ // std::string foregroundPixmapData = userProfile->getIcon().getData(); // _ui->avatarLabel->setPixmap(PixmapMerging::merge(foregroundPixmapData, backgroundPixmapFilename));//merge two images // } // else{ // QPixmap backgroundPixmap; // backgroundPixmap.loadFromData((uchar *) backgroundPixmapFilename.c_str(), backgroundPixmapFilename.size()); // _ui->avatarLabel->setPixmap(backgroundPixmap); // } // // // //} //VOXOX CHANGE by Rolando 04-06-09 void QtAddVoxOxAccount::itemActivatedComboBoxSlot(int index) { QString profileName = _ui->usernameComboBox->itemText(index); UserProfile userProfile; if (_cUserProfileHandler.getUserProfileHandler().LoadUserProfileFromName(&userProfile, _profileMap[profileName.toStdString()])) { SipAccount * sipAccount = userProfile.getSipAccount(); if (sipAccount) { if (sipAccount->isPasswordRemembered()) { setPassword(sipAccount->getUserPassword()); _ui->rememberPasswordCheckBox->setCheckState(Qt::Checked); } else { setPassword(""); _ui->rememberPasswordCheckBox->setCheckState(Qt::Unchecked); } _ui->publicComputerCheckBox->setChecked(!sipAccount->isUsernameRemembered()); _ui->automaticallyLoginCheckBox->setChecked(sipAccount->isAutoLoginVoxOx()); } } //VOXOX CHANGE by Rolando - 2009.05.21 -commented line, we are now using a logo //updateAvatarLabel(profileName.toStdString()); }
void UserProfileHandler::saveUserProfile(UserProfile & userProfile) { if (_autoSave && &userProfile && !userProfile.isDestroying() ) //VOXOX - JRT - 2009.09.22 { UserProfileFileStorage userProfileStorage(userProfile); userProfileStorage.save(userProfile.getName()); } }
pair<double,int> UserDemographicCache::GetUserAdGroupsCtr(const UserProfile & user_profile, Ice::Long zone_id,int pos_id, Ice::Long group_id, Ice::Long sponsor_id,string app_name) { //get stage gender //Ice::Long group_id = group_ptr->group_id(); //Ice::Long sponsor_id = group_ptr->member_id(); int gender = user_profile.gender(); int stage = user_profile.stage(); int uid = user_profile.id(); stringstream zone_name; zone_name.str(""); if (zone_id == 100000000001 && app_name.size() > 0) { zone_name << app_name; } else { zone_name << zone_id; } pair <double ,int> res = GetDemoCtr(zone_name.str(),sponsor_id, group_id , pos_id , gender, stage, uid); //当zone_id == 100000000001 且 res.second == 3 时表示没有此app数据,此时回退到01位置的人口学 if (zone_id == 100000000001 && res.second == 3 && app_name.size() > 0) { zone_name.str(""); zone_name << zone_id; res = GetDemoCtr(zone_name.str(),sponsor_id, group_id , pos_id , gender, stage, uid); } else if (zone_id == 100000000001 && res.second >= 0 && res.second != 3 && app_name.size() > 0) { res.second += 1000; } //pair <double ,int> res = GetDemoCtr(zone_id,sponsor_id, group_id , pos_id , gender, stage, uid); //group_ptr->SetDemoState(res.second); //MCE_DEBUG("3Us::GetUserAdGroupsCtr:zone_id:" << zone_id <<",pos_id:" << pos_id <<",state:" << group_ptr->GetDemoState()<< ",uid:" << user_profile.id() <<"groupid:" << group_id); return res; }
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(); } }
void RegisterLayer::onEnter() { TextInputDelegate::onEnter(); UserProfile* user = UserProfile::sharedUserProfile(); if(!user->email().empty()) setTextFieldString(kTagEmail, user->email().c_str()); }
CoIpManager * WengoPhone::getCoIpManager() const { CoIpManager *result = NULL; UserProfile *userProfile = _userProfileHandler->getCurrentUserProfile(); if (userProfile) { result = &userProfile->getCoIpManager(); } return result; }
int TriggerInterface::trigger(const UserProfile &profile, std::vector<long> &zones, GroupDict& groups) { TriggerInputInfo input; input.age = profile.age(); input.gender = profile.gender(); input.stage = profile.stage(); input.grade = profile.grade(); input.uid = profile.id(); stringstream ss; ss << profile.school(); input.school = ss.str(); input.ipArea = profile.ip_area(); input.currentArea = profile.current_area(); input.company = profile.work_place(); input.zones = zones; PingStat stat; try { int ret = IndexServiceReplicaAdapter::instance().trigger(input, groups); return ret; } catch (Ice::Exception& e) { MCE_WARN("IndexServiceReplicaAdapter trigger caught ICEexception: " << e << " ,uid: " << input.uid); return -1; } catch (std::exception& e) { MCE_WARN("IndexServiceReplicaAdapter trigger caught STDexception: " << e.what() << " ,uid: " << input.uid); return -1; } }
bool UserProfileClient::Set(const UserProfile & o) { char key[32]; GetUserKey(o.id(), key, 32); const UserProfile & profile = o; string value; o.SerializeToString(&value); return SetMemcached(key, value, 0); }
CUserProfile::CUserProfile(UserProfile & userProfile, CWengoPhone & cWengoPhone) : _userProfile(userProfile), _cWengoPhone(cWengoPhone), _cContactList(userProfile.getContactList(), cWengoPhone), _cWenboxPlugin(*userProfile.getWenboxPlugin(), cWengoPhone), _cChatHandler(userProfile.getChatHandler(), *this) { _cHistory = NULL; _cPhoneLine = NULL; _cSms = NULL; _cSoftUpdate = NULL; _cWsCallForward = NULL; _cWsContactProfile = NULL; //VOXOX - JRT - 2009.08.03 _pUserProfile = PFactory::getFactory().createPresentationUserProfile(*this); //JRT-XXX _userProfile.userProfileInitializedEvent += boost::bind(&CUserProfile::userProfileInitializedEventHandler, this, _1); _userProfile.phoneLineCreatedEvent += boost::bind(&CUserProfile::phoneLineCreatedEventHandler, this, _1, _2); _userProfile.wsSmsCreatedEvent += boost::bind(&CUserProfile::wsSmsCreatedEventHandler, this, _1, _2); _userProfile.wsSoftUpdateCreatedEvent += boost::bind(&CUserProfile::wsSoftUpdateCreatedEventHandler, this, _1, _2, _3); //VOXOX - JRT - 2009.10.27 _userProfile.wsCallForwardCreatedEvent += boost::bind(&CUserProfile::wsCallForwardCreatedEventHandler, this, _1, _2); _userProfile.loginStateChangedEvent += boost::bind(&CUserProfile::loginStateChangedEventHandler, this, _1, _2); _userProfile.networkDiscoveryStateChangedEvent += boost::bind(&CUserProfile::networkDiscoveryStateChangedEventHandler, this, _1, _2); _userProfile.getHistory().historyLoadedEvent += boost::bind(&CUserProfile::historyLoadedEventHandler, this, _1); _userProfile.getPresenceHandler().authorizationRequestEvent += boost::bind(&CUserProfile::authorizationRequestEventHandler, this, _1, _2, _3); _userProfile.getPresenceHandler().incomingSubscribeEvent += boost::bind(&CUserProfile::incomingSubscribeEventHandler, this, _1, _2, _3, _4, _5); //Check if a PhoneLine already exist if (_userProfile.getActivePhoneLine()) { phoneLineCreatedEventHandler(_userProfile, *_userProfile.getActivePhoneLine()); } historyLoadedEventHandler(_userProfile.getHistory()); /*if (_userProfile.getWsSms()) { wsSmsCreatedEventHandler(_userProfile, *_userProfile.getWsSms()); }*/ checkForSoftUpdate( false ); //Automatic - //VOXOX - JRT - 2009.10.27 createWsContactProfile(); //Call now in case event already fired. //VOXOXCHANGE CJC //VOXOX - JRT - 2009.05.24 TODO: find supporting files and remove from project. //Don't need call transfer functionality /*if (_userProfile.getWsCallForward()) { wsCallForwardCreatedEventHandler(_userProfile, *_userProfile.getWsCallForward()); }*/ }
AdResultMap AdEngineBReplicaAdapter::GetAds(const string & user_profile, const string & referer, int rotate_index, bool hide) { Ice::Context ctx; if(hide) { ctx["hide"] = "true"; } else { ctx["hide"] = "false"; } UserProfile profile; UserProfileClient::instance().Deserialize(user_profile, &profile); return getManager(GetServerIndex(profile.id()))->GetAds(user_profile, referer, rotate_index, ctx); // return getManager(profile.id() / 10 % 10)->GetAds(user_profile, referer, rotate_index); }
void UserDao::put(string email, Entity* e) { UserProfile* user = dynamic_cast<UserProfile*>(e); if (user == 0) { throw InvalidEntityException(); } std::string json = user->toJson(); DbHelper::put(email, json, USER); }
bool ConfigImporter::importContactsFromV1toV3(const string & fromDir, UserProfile & userProfile) { File mDir(fromDir); StringList fileList = mDir.getFileList(); ContactList & contactList = userProfile.getContactList(); ContactGroup contactGroup( "Classic", EnumGroupType::GroupType_User); //JRT-GRPS contactList.addContactGroup( contactGroup ); ///VOXOX - JRT - 2009.05.07 - JRT-GRPS IMAccountList imAccountList = userProfile.getIMAccountManager().getIMAccountsOfProtocol(EnumIMProtocol::IMProtocolWengo); if (!imAccountList.size()) { return false; } for (unsigned i = 0; i < fileList.size(); i++) { File mFile(fromDir + fileList[i]); string Id = fileList[i].substr(0, fileList[i].find("_", 0)); vcard_t mVcard; initVcard(&mVcard); if (!mFile.getExtension().compare("vcf")) { if (classicVcardParser(fromDir + fileList[i], &mVcard) == false) { continue; } int extPos = fileList[i].find_last_of('.'); string fileWoExt = fileList[i].substr(0, extPos + 1); classicXMLParser(fromDir + fileWoExt + "xml", &mVcard); // IMContact imContact(*imAccountList.begin(), mVcard.id); //VOXOX - JRT - 2009.04.09 IMContact imContact(imAccountList.begin()->second, mVcard.id); //VOXOX - JRT - 2009.04.26 // Contact & contact = contactList.createContact(); // contact.setGroupId(contactList.getContactGroupIdFromName("Classic")); // addContactDetails(contact, &mVcard); // contact.addIMContact(imContact); Contact* contact = contactList.createContact(); // contact->setGroupId(contactList.getContactGroupIdFromName("Classic")); contact->addToGroup(contactList.getContactGroupIdFromName("Classic"), EnumGroupType::GroupType_User); //VOXOX - JRT - 2009.05.06 JRT-GRPS addContactDetails(*contact, &mVcard); contact->addIMContact(imContact); contactList.addContact( contact ); //ContactList will delete contact //End Voxox } } return true; }
WsAccount::WsAccount(UserProfile & userProfile ) : WengoWebService(userProfile.getWengoAccount()), _userProfile(userProfile) { Config & config = ConfigManager::getInstance().getCurrentConfig(); //Setup the web service // setHostname(config.getWengoServerHostname()); #if 1 // setHostname( "" );//VOXOX - CJC - 2009.07.05 Set server address setHostname( config.getApiHostname() ); setServicePath( config.getVoxOxSyncWSPath() ); setHttps(true); setPort(443); #else setHostname( "" ); setServicePath( "" );//VOXOX - CJC - 2009.07.05 Ser server address setHttps(false); setPort( 80 ); #endif setGet(true); //true = POST in Curl lib. setWengoAuthentication(false); _userNetworkId = 0; _bDeleted = false; }
vector<UserProfile> UsersFile::getUserList() { std::string line; std::ifstream file("UserProfileDb"); int val; bool boolval; if (file.is_open()) { users.clear(); UserProfile *p; while (file >> line) { p = new UserProfile(); p->setUserName(line); file >> val; p->setAge(val); file >> boolval; p->setGender(boolval); file >> val; p->setHeight(val); file >> val; p->setWeight(val); file >> val; p->setActivityLevel(val); users.insert(users.begin(),*p); } file.close(); }
AdResultMap AdMatchManagerI::GetAdsTest(::Ice::Int uid, ::Ice::Int stage, ::Ice::Int gender, ::Ice::Int age, const ::std::string& currentArea, const ::std::string& ipArea, ::Ice::Long school, ::Ice::Int grade, int count, const string & referer, int rotate_index, const Ice::Current& current) { AdInfoSeq out; string serialized; if (uid > 0) { bool b = UserProfileClient::instance().GetSerialized(uid, &serialized); if (!b) { MCE_INFO("profile not found in memcache. id=" << uid); /*try { serialized = AdUserCacheLoaderAdapter::instance().GetById(uid); } catch(Ice::Exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e << " uid=" << _login_uid); } catch(std::exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e.what() << " uid=" << _login_uid); }*/ } } UserProfile profile; profile.ParseFromString(serialized); /*UserProfile profile; profile.set_age(age); profile.set_id(uid); profile.set_gender(gender); profile.set_stage(stage); profile.set_current_area(currentArea); profile.set_ip_area(ipArea); profile.set_school(school); profile.set_grade(grade);*/ profile.set_ip(1896477159); string tmp; UserProfileClient::instance().Serialize(profile, &tmp); string tmpref = referer; return AdMatchManagerI::GetAds(tmp, tmpref, rotate_index); }
QtHistory::QtHistory(CHistory & cHistory) : QAbstractTableModel(NULL), _cHistory(cHistory) { _chatLogViewer = NULL; _mutex = new QMutex(QMutex::Recursive); _stateFilter = HistoryMemento::Any; QtWengoPhone * qtWengoPhone = (QtWengoPhone *) _cHistory.getCWengoPhone().getPresentation(); _historyWidget = new QtHistoryWidget(qtWengoPhone->getWidget(), this); SAFE_CONNECT(_historyWidget, SIGNAL(replayItemRequested(int)), SLOT(replayItem(int)) ); SAFE_CONNECT(_historyWidget, SIGNAL(showChatLogRequested(int)), SLOT(showChatLog(int)) ); SAFE_CONNECT(_historyWidget, SIGNAL(removeItemRequested(int)), SLOT(removeItem(int)) ); SAFE_CONNECT(_historyWidget, SIGNAL(missedCallsSeen()), SLOT(resetUnseenMissedCalls()) ); SAFE_CONNECT(_historyWidget, SIGNAL(showOnlyItemOfType(int)), SLOT(showOnlyItemOfTypeSlot(int)) ); qtWengoPhone->setQtHistoryWidget(_historyWidget); // define user use a Wengo or a SIP account UserProfile * userProfile = _cHistory.getCWengoPhone().getCUserProfileHandler().getUserProfileHandler().getCurrentUserProfile(); if (userProfile) { _isWengoAccountConnected = userProfile->hasWengoAccount(); } else { _isWengoAccountConnected = false; } //// updatePresentation(); }
void QtAddVoxOxAccount::load(std::string sipAccountName) { //load userprofile UserProfile * userProfile = _cUserProfileHandler.getUserProfileHandler().getUserProfile(sipAccountName); if (userProfile) { SipAccount * sipAccount = userProfile->getSipAccount(); //VOXOX CHANGE by Rolando 04-06-09 if (sipAccount) { if (sipAccount->isPasswordRemembered()) { setPassword(sipAccount->getUserPassword()); _ui->rememberPasswordCheckBox->setCheckState(Qt::Checked); } else { setPassword(""); _ui->rememberPasswordCheckBox->setCheckState(Qt::Unchecked); } if (!sipAccount->isUsernameRemembered()) { setAccountName(""); setPassword(""); _ui->rememberPasswordCheckBox->setCheckState(Qt::Unchecked); /*_ui->publicComputerCheckBox->setCheckState(Qt::Checked);*/ } else { // Add and select the given SipAccount //SERGIO MARIN IF EXISTS ACCOUNT IN COMBO BOX if (_ui->usernameComboBox->findText(QString::fromStdString(sipAccountName))== -1){ _ui->usernameComboBox->addItem(QString::fromStdString(sipAccountName)); } setAccountName(QString::fromStdString(sipAccountName)); _ui->publicComputerCheckBox->setCheckState(Qt::Unchecked); } _ui->automaticallyLoginCheckBox->setChecked(sipAccount->isAutoLoginVoxOx()); } } else { //VOXOX CHANGE by Rolando - 2009.05.21 -commented line, we are now using a logo //updateAvatarLabel(""); } }
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(); } }
void DtmfTheme::playTone(const std::string & key) const { const Tone * tone = getTone(key); if (!tone) { LOG_WARN("Could not find a tone for key '" + key + "'"); return; } Config & config = ConfigManager::getInstance().getCurrentConfig(); std::string soundfile = _repertory + tone->getSoundFile(); if (tone->getLocalAction() == Tone::Play) { Sound::play(File::convertPathSeparators(soundfile), config.getAudioRingerDeviceId() ); } if (tone->getRemoteAction() == Tone::Play) { UserProfile * userprofile = _wengoPhone.getUserProfileHandler().getCurrentUserProfile(); if (userprofile) { IPhoneLine * iphoneline = userprofile->getActivePhoneLine(); if (iphoneline) { PhoneCall * phonecall = iphoneline->getActivePhoneCall(); if (phonecall) { if (tone->getAudioFormat() == Tone::Dtmf) { iphoneline->playDtmf( phonecall->getCallId(), (char)tone->getKey()[0] ); } else { iphoneline->playSoundFile( phonecall->getCallId(), File::convertPathSeparators(soundfile) ); } } } } } }
void UserProfileMapper::fromPersistent(Object* object, const ResultRecord& record) { UserProfile * profile = (UserProfile*)object; UserProfileInfo p_info; p_info.profile_code = fromString<int>(record.getValue( PROFILE_ID )); p_info.profile_name = record.getValue(PROFILE_NAME); p_info.access_rigths[AR_REGISTRATION_BY_CODE] = record.getValue(PROFILE_R_CODEREG) == "t"; p_info.access_rigths[AR_REGISTRATION_BY_BARCODE] = record.getValue(PROFILE_R_SCANERREG) == "t"; p_info.access_rigths[AR_REGISTRATION_BY_MANUAL_INPUT_BARCODE] = record.getValue(PROFILE_R_BARCODEMANUALREG) == "t"; p_info.access_rigths[AR_REGISTRATION_BY_VISUAL_SEARCH] = record.getValue(PROFILE_R_VSREG) == "t"; p_info.access_rigths[AR_REGISTRATION_CANCEL] = record.getValue(PROFILE_R_CANCELREG) == "t"; p_info.access_rigths[AR_QUANTITY_EDITION] = record.getValue(PROFILE_R_QUANTITYEDITION) == "t"; p_info.access_rigths[AR_PRICE_EDITION] = record.getValue(PROFILE_R_PRICEEDITION) == "t"; p_info.access_rigths[AR_REGISTRATION_REPEAT] = record.getValue(PROFILE_R_REGISTRATION_REPEAT) == "t"; p_info.access_rigths[AR_CHECK_CANCEL] = record.getValue(PROFILE_R_CHECK_CANCEL) == "t"; p_info.access_rigths[AR_MANUAL_DISCOUNT] = record.getValue(PROFILE_R_MANUAL_DISCOUNT) == "t"; p_info.access_rigths[AR_FIXED_DISCOUNT] = record.getValue(PROFILE_R_FIXED_DISCOUNT) == "t"; p_info.access_rigths[AR_DISCOUNT_CANCEL] = record.getValue(PROFILE_R_DISCOUNT_CANCEL) == "t"; p_info.access_rigths[AR_RETURN_BY_NUMBER] = record.getValue(PROFILE_R_RETURN_BY_NUMBER) == "t"; p_info.access_rigths[AR_RETURN_MANUAL] = record.getValue(PROFILE_R_RETURN_MANUAL) == "t"; p_info.access_rigths[AR_CASH_PAYMENT] = record.getValue(PROFILE_R_CASH_PAYMENT) == "t"; p_info.access_rigths[AR_CREDIT_PAYMENT] = record.getValue(PROFILE_R_CREDIT_PAYMENT) == "t"; p_info.access_rigths[AR_CONT_PAYMENT] = record.getValue(PROFILE_R_CONT_PAYMENT) == "t"; p_info.access_rigths[AR_Z_REPORT] = record.getValue(PROFILE_R_Z_REPORT) == "t"; p_info.access_rigths[AR_OTHER_REPORT] = record.getValue(PROFILE_R_OTHER_REPORT) == "t"; p_info.access_rigths[AR_KKM_SYNCHRONIZATION] = record.getValue(PROFILE_R_KKM_SYNCHRONIZATION) == "t"; p_info.access_rigths[AR_ENTERING] = record.getValue(PROFILE_R_ENTERING) == "t"; p_info.access_rigths[AR_GETTING] = record.getValue(PROFILE_R_GETTING) == "t"; p_info.access_rigths[AR_CHECK_COPY] = record.getValue(PROFILE_R_CHECK_COPY) == "t"; p_info.access_rigths[AR_OPEN_BOX] = record.getValue(PROFILE_R_OPEN_BOX) == "t"; p_info.access_rigths[AR_PROGRAMM_SETUP] = record.getValue(PROFILE_R_PROGRAMM_SETUP) == "t"; p_info.access_rigths[AR_HANDLE_UNLOAD] = record.getValue(PROFILE_R_HANDLE_UNLOAD) == "t"; p_info.access_rigths[AR_HANDLE_UPLOAD] = record.getValue(PROFILE_R_HANDLE_UPLOAD) == "t"; p_info.access_rigths[AR_PS_RECONSILIATION] = record.getValue(PROFILE_R_PS_RECONSILIATION) == "t"; profile->replaceInfo(p_info); }
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; }
void UserProfileMapper::toPersistent(Object* object, RDBSetExpression& rdb_expression) { UserProfile * profile = (UserProfile*)object; UserProfileInfo p_info = profile->getInfo(); rdb_expression.addField(PROFILE_ID, p_info.profile_code); rdb_expression.addField(PROFILE_NAME, p_info.profile_name); rdb_expression.addField(PROFILE_R_CODEREG, p_info.access_rigths[AR_REGISTRATION_BY_CODE] ? "t" : "f"); rdb_expression.addField(PROFILE_R_SCANERREG, p_info.access_rigths[AR_REGISTRATION_BY_BARCODE] ? "t" : "f"); rdb_expression.addField(PROFILE_R_BARCODEMANUALREG, p_info.access_rigths[AR_REGISTRATION_BY_MANUAL_INPUT_BARCODE] ? "t" : "f"); rdb_expression.addField(PROFILE_R_VSREG, p_info.access_rigths[AR_REGISTRATION_BY_VISUAL_SEARCH] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CANCELREG, p_info.access_rigths[AR_REGISTRATION_CANCEL] ? "t" : "f"); rdb_expression.addField(PROFILE_R_QUANTITYEDITION, p_info.access_rigths[AR_QUANTITY_EDITION] ? "t" : "f"); rdb_expression.addField(PROFILE_R_PRICEEDITION, p_info.access_rigths[AR_PRICE_EDITION] ? "t" : "f"); rdb_expression.addField(PROFILE_R_REGISTRATION_REPEAT, p_info.access_rigths[AR_REGISTRATION_REPEAT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CHECK_CANCEL, p_info.access_rigths[AR_CHECK_CANCEL] ? "t" : "f"); rdb_expression.addField(PROFILE_R_MANUAL_DISCOUNT, p_info.access_rigths[AR_MANUAL_DISCOUNT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_FIXED_DISCOUNT, p_info.access_rigths[AR_FIXED_DISCOUNT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_AUTO_DISCOUNT_CANCEL, "t"); rdb_expression.addField(PROFILE_R_DISCOUNT_CANCEL, p_info.access_rigths[AR_DISCOUNT_CANCEL] ? "t" : "f"); rdb_expression.addField(PROFILE_R_RETURN_BY_NUMBER, p_info.access_rigths[AR_RETURN_BY_NUMBER] ? "t" : "f"); rdb_expression.addField(PROFILE_R_RETURN_MANUAL, p_info.access_rigths[AR_RETURN_MANUAL] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CASH_PAYMENT, p_info.access_rigths[AR_CASH_PAYMENT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CREDIT_PAYMENT, p_info.access_rigths[AR_CREDIT_PAYMENT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CONT_PAYMENT, p_info.access_rigths[AR_CONT_PAYMENT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_PAYMENT_TYPE4, "t"); rdb_expression.addField(PROFILE_R_Z_REPORT, p_info.access_rigths[AR_Z_REPORT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_OTHER_REPORT, p_info.access_rigths[AR_OTHER_REPORT] ? "t" : "f"); rdb_expression.addField(PROFILE_R_KKM_SYNCHRONIZATION, p_info.access_rigths[AR_KKM_SYNCHRONIZATION] ? "t" : "f"); rdb_expression.addField(PROFILE_R_ENTERING, p_info.access_rigths[AR_ENTERING] ? "t" : "f"); rdb_expression.addField(PROFILE_R_GETTING, p_info.access_rigths[AR_GETTING] ? "t" : "f"); rdb_expression.addField(PROFILE_R_CHECK_COPY, p_info.access_rigths[AR_CHECK_COPY] ? "t" : "f"); rdb_expression.addField(PROFILE_R_OPEN_BOX, p_info.access_rigths[AR_OPEN_BOX] ? "t" : "f"); rdb_expression.addField(PROFILE_R_PROGRAMM_SETUP, p_info.access_rigths[AR_PROGRAMM_SETUP] ? "t" : "f"); rdb_expression.addField(PROFILE_R_HANDLE_UNLOAD, p_info.access_rigths[AR_HANDLE_UNLOAD] ? "t" : "f"); rdb_expression.addField(PROFILE_R_HANDLE_UPLOAD, p_info.access_rigths[AR_HANDLE_UPLOAD] ? "t" : "f"); rdb_expression.addField(PROFILE_R_PS_RECONSILIATION, p_info.access_rigths[AR_PS_RECONSILIATION] ? "t" : "f"); }
AdInfoSeq AdMatchAdapter::GetAds(string & user_profile, int count,const string & referer) { UserProfile profile; UserProfileClient::instance().Deserialize(user_profile, &profile); MCE_DEBUG("AdMatchAdapter::GetAds --> age = " << profile.age() << ",stage = " << profile.stage() << ",grade = " << profile.grade() << ",current_area = " << profile.current_area()); return getManager(profile.age() % 10)->GetAds(user_profile, count,referer); }
/************************TEST********************************/ AdResultMap AdMatchManagerI::GetAdsTest(::Ice::Int uid, ::Ice::Int stage, ::Ice::Int gender, ::Ice::Int age, const ::std::string& currentArea, const ::std::string& ipArea, ::Ice::Long school, ::Ice::Int grade, int count, const string & referer, int rotate_index, const Ice::Current& current) { AdInfoSeq out; UserProfile profile; profile.set_age(age); profile.set_id(uid); profile.set_gender(gender); profile.set_stage(stage); profile.set_current_area(currentArea); profile.set_ip_area(ipArea); profile.set_school(school); profile.set_grade(grade); profile.set_ip(1896477159); string tmp; UserProfileClient::instance().Serialize(profile, &tmp); string tmpref = referer; return AdMatchManagerI::GetAds(tmp, tmpref, rotate_index); }
void QtAddWengoAccount::load(std::string sipAccountName) { //load userprofile UserProfile * userProfile = _cUserProfileHandler.getUserProfileHandler().getUserProfile(sipAccountName); if (userProfile && userProfile->hasSipAccount()) { //tests account type if (userProfile->hasWengoAccount()) { //loads the wengo acccount WengoAccount * wengoAccount = userProfile->getWengoAccount(); _ui->email->setText(QString::fromStdString(wengoAccount->getWengoLogin())); _ui->password->setText(QString::fromStdString(wengoAccount->getWengoPassword())); setInfoMessage(); } else { //should be loaded as a sip account //_loginDialog->changePage(QtLoginDialog::AddSIPAccount, sipAccountName);//VOXOX CHANGE by Rolando 02-25-09 _loginDialog->changePage(QtLoginDialog::AddVoxOxAccount, sipAccountName);//VOXOX CHANGE by Rolando 02-25-09 } } else { //_loginDialog->changePage(QtLoginDialog::AddAccount);//VOXOX CHANGE by Rolando 02-25-09 _loginDialog->changePage(QtLoginDialog::AddVoxOxAccount, sipAccountName);//VOXOX CHANGE by Rolando 02-25-09 } OWSAFE_DELETE(userProfile); }
WsContactUpload::WsContactUpload(UserProfile & userProfile) : WengoWebService(userProfile.getWengoAccount()), _userProfile(userProfile) { Config & config = ConfigManager::getInstance().getCurrentConfig(); //Setup the web service setHostname(config.getWengoServerHostname()); setGet(true); setServicePath(config.getVoxoxContactUploadPath()); setWengoAuthentication(false); #if 1 setHttps(true); //VOXOX - JRT - 2009.10.05 setPort(443); #else setHttps(false); setPort(80); #endif }
bool AdTestRequest::response() { MCE_DEBUG("AdTestRequest::response"); if (!_fcgi_out) { MCE_WARN("AdTestRequest::response fcgi_out null"); return false; } string uid = getProperty("uid"); if (_cookies.find("id") != _cookies.end()) { uid = _cookies["id"]; } if (!uid.empty()) { try { _login_uid = boost::lexical_cast<int>(uid); } catch (...) { MCE_WARN("lexical_cast cookie id error : " << uid); } } uid = getProperty("uid"); string gender = getProperty("gender"); string age = getProperty("age"); string stage = getProperty("stage"); string area = getProperty("area"); string school = getProperty("school"); string school_area = getProperty("school_area"); string work_area = getProperty("work_area"); string home_area = getProperty("home_area"); string grade = getProperty("grade"); string ip = getProperty("ip"); string ip_area = getProperty("ip_area"); string referer = getProperty("ref"); MCE_DEBUG("AdTestRequest --> referer=" << referer << ",uid:" << uid << ", ip:" << ip << ", ip_area = " << ip_area); //UserID|Gender|Birthday|Age|Stage|Area|School_SchoolArea|Grade|IPArea UserProfile profile; //profile.set_ip_area(IpAreaCache::instance().GetIpArea(ip)); profile.set_ip_area(ip_area); try { profile.set_id(boost::lexical_cast<int>(uid)); } catch (...) { } try { profile.set_stage(boost::lexical_cast<int>(stage)); } catch (...) { } try { profile.set_home_area(home_area); } catch (...) { } try { profile.set_gender(boost::lexical_cast<int>(gender)); } catch (...) { } try { profile.set_age(boost::lexical_cast<int>(age)); } catch (...) { } if (stage == "4") { profile.set_current_area(work_area); profile.set_school(0); profile.set_grade(0); } else if (stage == "2" || stage == "1") { profile.set_current_area(school_area); try { profile.set_school(boost::lexical_cast<Ice::Long>(school)); profile.set_grade(boost::lexical_cast<int>(grade)); } catch (...) { } } string serialized; profile.SerializeToString(&serialized); int rotate_slot = GetCookieInt("an_slot", rand()); rotate_slot %= 10000; bool hide = false; string isvip = getProperty("isvip"); string hideads = getProperty("hideads"); if(isvip.compare("true")==0 && hideads.compare("true")==0) { hide = true; } AdResultMap ads; // string referer = GetParamFix("HTTP_REFERER"); try { ads = AdEngineBAdapter::instance().GetAds(serialized, referer, rotate_slot, hide); } catch (Ice::Exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e << " uid=" << uid); } catch (std::exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e.what() << " uid=" << uid); } for (AdResultMap::iterator it = ads.begin(); it != ads.end(); ++it) { for (size_t i = 0; i < it->second.size(); ++i) { if (it->second.at(i).creativeid == 0) { MCE_WARN("test, creativeid is 0"); } } } MCE_INFO("AdEngineBAdapter::GetAds return size : " << ads.size() << " uid=" << uid << " stage=" << profile.stage() << " ip_area=" << profile.ip_area()); string ad_json; string ad_body; AdCreativeCache::instance().Get(ads, &ad_body); ad_body = ad_body + "<p/>" + ad_json; MCE_DEBUG("AdTestRequest::response --> uid:" << uid << " ,body:" << ad_body); ostringstream ad_header; ad_header << "Content-type: text/html; charset=utf-8\r\nSet-Cookie: an_slot=" << ++rotate_slot << "; path=/ebpn\r\n\r\n"; FCGX_PutS(ad_header.str().c_str(), _fcgi_out); FCGX_PutS(ad_body.c_str(), _fcgi_out); return true; }
bool AdNewGetRequest::response() { timeval start; gettimeofday(&start, NULL); if (!_fcgi_out) { MCE_WARN("remove notify fcgi_out null"); return false; } _login_uid = 2; string uid = getProperty("uid"); if (_cookies.find("id") != _cookies.end()) { uid = _cookies["id"]; } if (!uid.empty()) { try { _login_uid = boost::lexical_cast<int>(uid); } catch (...) { MCE_WARN("lexical_cast cookie id error : " << uid); } } string serialized; if (_login_uid > 0) { bool b = false; try { StatFunc stat("memc GetSerialized"); b = UserProfileClient::instance().GetSerialized(_login_uid, &serialized); } catch (std::exception& e) { MCE_WARN("UserProfileClient error : " << e.what() << " uid=" << _login_uid); } if (!b) { MCE_INFO("profile not found in memcache. id=" << _login_uid); try { StatFunc stat("memc AdUserCacheLoader"); serialized = AdUserCacheLoaderAdapter::instance().GetById(_login_uid); } catch (Ice::Exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e << " uid=" << _login_uid); } catch (std::exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e.what() << " uid=" << _login_uid); } } } // FCGX_PutS("Content-type: application/x-javascript; charset=utf-8\r\n\r\n{}", _fcgi_out); // return true; UserProfile profile; if (serialized.empty()) { profile.set_stage(4); profile.set_gender(0); profile.set_age(25); profile.set_school(0); profile.set_major(0); profile.set_grade(0); profile.set_home_area(""); profile.set_current_area(""); } else { profile.ParseFromString(serialized); } unsigned int ip = ntohl(inet_addr(GetRemoteAddr().c_str())); profile.set_id(_login_uid); profile.set_ip(ip); profile.set_ip_area(IpAreaCache::instance().GetIpArea(ip)); profile.SerializeToString(&serialized); int rotate_slot = GetCookieInt("an_slot", rand()); rotate_slot %= 10000; AdResultMap ads; AdZone2Creatives final_ads; string referer = getProperty("ref"); //MCE_DEBUG("[UrlMaping] ref = " << referer); if (referer.empty() || referer.find("http://") == string::npos) { referer = getProperty("r"); if (referer.empty() || referer.find("http://") == string::npos) { referer = GetParamFix("HTTP_REFERER"); //MCE_DEBUG("[UrlMaping] HTTP_REFERER = " << referer); } } bool err_flag = false; bool hide = false; string isvip = getProperty("isvip"); string hideads = getProperty("hideads"); if(isvip.compare("true")==0 && hideads.compare("true")==0) { hide = true; } stringstream log_url; try { char sep = '&'; if (referer.find_first_of('?') == string::npos) { sep = '?'; } int refresh_source = getPropertyInt("refresh_source", 0); int refresh_idx = getPropertyInt("refresh_idx", 0); log_url << referer << sep << "refresh_source=" << refresh_source << "&refresh_idx=" << refresh_idx; stringstream stat_desc; stat_desc << _login_uid << " GetAds"; StatFunc stat(stat_desc.str()); } catch (Ice::Exception& e) { MCE_WARN("AdGetRequest::response error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdGetRequest::response : " << e.what() << " uid=" << _login_uid); err_flag = true; } // string emtag = "M"; MCE_DEBUG("debug 001"); try { ads = AdEngineBAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot, hide); MCE_DEBUG("EngineB size=" << ads.size()); AdGateI::instance().translate(ads,final_ads); MCE_DEBUG("EngineB size=" << final_ads.size()); // emtag = "M"; } catch (Ice::Exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } MCE_DEBUG("debug 002"); bool tw_flag = false; string tag, photo; map<long, EngineTypes> self_zones; // 需要中小自助广告广告位id for(AdResultMap::iterator it = ads.begin(); it != ads.end(); it++) { if(!it->second.empty() && (it->second.at(0).groupid == -1)) { //台湾分尾号流量切分 //MCE_INFO("Get Ads from AdEngine/AdTw"); MCE_DEBUG("debug 003"); if(_login_uid%10 < 2 || _login_uid == 287341024) { self_zones[it->first] = TW; tw_flag = true; } else { self_zones[it->first] = ENGINE; } } else if(!it->second.empty() && (it->second.at(0).groupid == -2)) { //余量,不分给台湾 self_zones[it->first] = ENGINE; tag = "rr_REMAIN_1"; } else if(!it->second.empty() && (it->second.at(0).groupid == -3)) { //余量,不分给台湾 self_zones[it->first] = ENGINE; tag = "rr_REMAIN_2"; photo = "true"; MCE_DEBUG("photo = true"); } } MCE_DEBUG("debug 004"); if (!self_zones.empty()) { try { AdResultMap e_ads_; AdZone2Creatives e_ads; MCE_DEBUG("debug 005"); //台湾分尾号流量切分 if((_login_uid%10 < 2 || _login_uid == 287341024) && tw_flag) { MCE_DEBUG("debug 006"); MCE_DEBUG("[TW_DEBUG] AdGetRequest::response --> enter to request Tw"); e_ads_ = AdTwAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot); AdGateI::instance().translate(ads,final_ads); } else { MCE_DEBUG("debug 007"); MCE_DEBUG("AdGetRequest::response --> from AdEngine rotate_slot = " << rotate_slot); UserAndAction ua; ua.id = profile.id(); ua.stage = profile.stage(); ua.gender = profile.gender(); ua.age = profile.age(); ua.school = profile.school(); ua.userMajor = profile.major(); ua.grade = profile.grade(); ua.homeArea = profile.home_area(); ua.currentArea = profile.current_area(); ua.ip = profile.ip(); ua.ipArea = profile.ip_area(); ua.actionType = ActionType::PAGEVIEW; AdRequest ad_request; ad_request.userAndAction = ua; ad_request.referer = referer; //url_mapping // set<Ice::Long> zone_ids; for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) { long z_key = (*zit).first; if( photo == "true" && z_key == 100000000072 ) { ad_request.zoneDict[z_key] = 2; }else{ ad_request.zoneDict[z_key] = 0; } ad_request.attributes[boost::lexical_cast<string>(z_key)]=tag; } // AdUrlMaping::instance().GetAdZone(referer, ua.stage, zone_ids); //AdCreativeCache::instance().GetZoneDict(zone_ids, ad_request.zoneDict); MCE_DEBUG("AdGetRequest::response --> enter to request JavaServer"); e_ads_=AdEngineJAdapter::instance().Request(ad_request); AdGateI::instance().translate(e_ads_,e_ads); //e_ads = AdEngineUAdapter::instance().GetAdsByZone(serialized, log_url.str(), rotate_slot, _login_uid, tag); //e_ads_ = AdEngineUAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot, _login_uid, tag, photo); } if (e_ads.empty()) { MCE_DEBUG("AdGetRequest::response --> from AdEngineJ empty "); } else { for(AdZone2Creatives::iterator xxit = e_ads.begin(); xxit != e_ads.end(); xxit++) { MCE_DEBUG("AdGetRequest::response --> from AdEngineJ" << xxit->second.size()); } } for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) { AdZone2Creatives::iterator eit = e_ads.find(zit->first); if (eit != e_ads.end()) { //eads[zit->first] = eit->second; //在相册页面,如果广告位wb1成功展示自助,则去掉wb2位置的广告 /*if(100000000072 == zit->first) { ads[100000000073] = AdInfoSeq(); }*/ } else { ads[zit->first] = AdInfoSeq(); } } for(AdZone2Creatives::const_iterator ad_x_it = e_ads.begin() ; ad_x_it != e_ads.end() ; ad_x_it ++ ){ final_ads[ad_x_it->first] = ad_x_it->second; MCE_DEBUG("AdGetRequest::response --> from AdEngineJ " << ad_x_it->first <<" " <<ad_x_it->second.size()); if( ad_x_it->second.size() > 0 ) { for( int vi =0 ; vi < ad_x_it->second.size() ;vi ++ ) { MCE_DEBUG("widgetis = " << ad_x_it->second[vi].widgetid); } } } } catch (Ice::Exception& e) { MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } } if (err_flag) { stringstream stat_desc; stat_desc << _login_uid << " PushDefault"; StatFunc stat(stat_desc.str()); AdCreativeCache::instance().PushDefault(_login_uid, profile.stage(), GetRemoteAddr(), referer, &ads); AdGateI::instance().translate(ads,final_ads); } stringstream ad_header; string ad_body; if (render_ == RT_HTML) { ad_header << "Content-type: text/html; charset=utf-8\r\nSet-Cookie: an_slot=" << ++rotate_slot << "; path=/ebpn\r\n\r\n"; AdCreativeCache::instance().Get(final_ads, &ad_body); MCE_INFO("final ad size : "<< final_ads.size()); } else if (render_ == RT_JSON) { ad_header << "Content-type: application/x-javascript; charset=utf-8\r\nSet-Cookie: an_slot=" << ++rotate_slot << "; path=/ebpn\r\n\r\n"; stringstream stat_desc; stat_desc << _login_uid << " GetJson"; StatFunc stat(stat_desc.str()); AdCreativeCache::instance().GetJson(referer, getPropertyInt( "refresh_source", 0), getPropertyInt("refresh_idx", 0), self_zones, final_ads, &ad_body); MCE_INFO("final ad size(json) : "<< final_ads.size()); } FCGX_PutS(ad_header.str().c_str(), _fcgi_out); FCGX_PutS(ad_body.c_str(), _fcgi_out); timeval end; gettimeofday(&end, NULL); AdGateI::instance().ping_sender_.Send("GetAds", 1000*(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000); return true; }
bool AdGetRequest::response() { timeval start; gettimeofday(&start, NULL); if (!_fcgi_out) { MCE_WARN("remove notify fcgi_out null"); return false; } _login_uid = 2; string uid = getProperty("uid"); if (_cookies.find("id") != _cookies.end()) { uid = _cookies["id"]; } if (!uid.empty()) { try { _login_uid = boost::lexical_cast<int>(uid); } catch (...) { MCE_WARN("lexical_cast cookie id error : " << uid); } } string serialized; if (_login_uid > 0) { bool b = false; try { StatFunc stat("memc GetSerialized"); b = UserProfileClient::instance().GetSerialized(_login_uid, &serialized); } catch (std::exception& e) { MCE_WARN("UserProfileClient error : " << e.what() << " uid=" << _login_uid); } if (!b) { MCE_INFO("profile not found in memcache. id=" << _login_uid); try { StatFunc stat("memc AdUserCacheLoader"); serialized = AdUserCacheLoaderAdapter::instance().GetById(_login_uid); } catch (Ice::Exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e << " uid=" << _login_uid); } catch (std::exception& e) { MCE_WARN("AdUserCacheLoaderAdapter GetById error : " << e.what() << " uid=" << _login_uid); } } } // FCGX_PutS("Content-type: application/x-javascript; charset=utf-8\r\n\r\n{}", _fcgi_out); // return true; UserProfile profile; if (serialized.empty()) { profile.set_stage(4); profile.set_gender(0); profile.set_age(25); profile.set_school(0); profile.set_major(0); profile.set_grade(0); profile.set_home_area(""); profile.set_current_area(""); } else { profile.ParseFromString(serialized); } unsigned int ip = ntohl(inet_addr(GetRemoteAddr().c_str())); profile.set_id(_login_uid); profile.set_ip(ip); profile.set_ip_area(IpAreaCache::instance().GetIpArea(ip)); profile.SerializeToString(&serialized); int rotate_slot = GetCookieInt("an_slot", rand()); rotate_slot %= 10000; string referer = getProperty("ref"); if (referer.empty() || referer.find("http://") == string::npos) { referer = getProperty("r"); if (referer.empty() || referer.find("http://") == string::npos) { referer = GetParamFix("HTTP_REFERER"); } } bool err_flag = false; stringstream log_url; try { char sep = '&'; if (referer.find_first_of('?') == string::npos) { sep = '?'; } int refresh_source = getPropertyInt("refresh_source", 0); int refresh_idx = getPropertyInt("refresh_idx", 0); log_url << referer << sep << "refresh_source=" << refresh_source << "&refresh_idx=" << refresh_idx; stringstream stat_desc; stat_desc << _login_uid << " GetAds"; StatFunc stat(stat_desc.str()); } catch (Ice::Exception& e) { MCE_WARN("AdGetRequest::response error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdGetRequest::response : " << e.what() << " uid=" << _login_uid); err_flag = true; } AdResultMap ads; AdZone2Creatives final_ads; try { ads = AdEngineBAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot); //AdGateI::instance().translate(ads,final_ads); } catch (Ice::Exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdEngineBAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } bool tw_flag = false; string tag, photo; map<long, EngineTypes> self_zones; // 需要中小自助广告广告位id for(AdResultMap::iterator it = ads.begin(); it != ads.end(); it++) { if(!it->second.empty() && (it->second.at(0).groupid == -1)) { //台湾分尾号流量切分 //MCE_INFO("Get Ads from AdEngine/AdTw"); if(_login_uid%10 < 2 || _login_uid == 287341024) { self_zones[it->first] = TW; tw_flag = true; } else { self_zones[it->first] = ENGINE; } } else if(!it->second.empty() && (it->second.at(0).groupid == -2)) { //余量,不分给台湾 self_zones[it->first] = ENGINE; tag = "rr_REMAIN_1"; } else if(!it->second.empty() && (it->second.at(0).groupid == -3)) { //余量,不分给台湾 self_zones[it->first] = ENGINE; tag = "rr_REMAIN_2"; photo = "true"; MCE_DEBUG("photo = true"); } } if (!self_zones.empty()) { try { //台湾分尾号流量切分 if((_login_uid%10 < 2 || _login_uid == 287341024) && tw_flag) { try { AdResultMap e_ads; MCE_DEBUG("[TW_DEBUG] AdGetRequest::response --> enter to request Tw"); e_ads = AdTwAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot); if (e_ads.empty()) { MCE_INFO("AdGetRequest::response --> from AdTwS empty "); } else { for(AdResultMap::iterator xxit = e_ads.begin(); xxit != e_ads.end(); xxit++) { MCE_DEBUG("AdGetRequest::response --> from AdTwS " << xxit->second.size()); } } for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) { AdResultMap::iterator eit = e_ads.find(zit->first); if (eit != e_ads.end()) { ads[zit->first] = eit->second; } else { ads[zit->first] = AdInfoSeq(); } } AdGateI::instance().translate(ads,final_ads); } catch (Ice::Exception& e) { MCE_WARN("AdTwAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdTwAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } } else { try { MCE_DEBUG("AdGetRequest::response --> from AdEngine rotate_slot = " << rotate_slot); //e_ads = AdEngineUAdapter::instance().GetAds(serialized, log_url.str(), rotate_slot, _login_uid, tag, photo); AdZone2Creatives e_ads; e_ads = AdEngineUAdapter::instance().GetAdsByZone(serialized, log_url.str(), rotate_slot, _login_uid, tag, photo); if (e_ads.empty()) { MCE_INFO("AdGetRequest::response --> from AdEngineU empty: uid = " << _login_uid << ", referer = " << log_url.str() << ", tag = " << tag << ", photo = " << photo); } else { for(AdZone2Creatives::iterator xxit = e_ads.begin(); xxit != e_ads.end(); xxit++) { MCE_DEBUG("AdGetRequest::response --> from AdEngineU " << xxit->second.size()); } } AdGateI::instance().translate(ads,final_ads); for (map<long, EngineTypes>::iterator zit = self_zones.begin(); zit != self_zones.end(); zit++) { AdZone2Creatives::iterator eit = e_ads.find(zit->first); if (eit != e_ads.end()) { final_ads[zit->first] = eit->second; } else { final_ads[zit->first] = AdCreativeSeq(); } } } catch (Ice::Exception& e) { MCE_WARN("AdEngineUAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdEngineUAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } } } catch (Ice::Exception& e) { MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e << " uid=" << _login_uid); err_flag = true; } catch (std::exception& e) { MCE_WARN("AdEngineUAdapter/AdTwAdapter::GetAds error : " << e.what() << " uid=" << _login_uid); err_flag = true; } } else { AdGateI::instance().translate(ads,final_ads); } if (err_flag) { stringstream stat_desc; stat_desc << _login_uid << " PushDefault"; StatFunc stat(stat_desc.str()); AdCreativeCache::instance().PushDefault(_login_uid, profile.stage(), GetRemoteAddr(), referer, &ads); AdGateI::instance().translate(ads,final_ads); } stringstream ad_header; string ad_body; if (render_ == RT_HTML) { ad_header << "Content-type: text/html; charset=utf-8\r\nSet-Cookie: an_slot=" << ++rotate_slot << "; path=/ebpn\r\n\r\n"; //AdCreativeCache::instance().Get(ads, &ad_body); AdCreativeCache::instance().Get(final_ads, &ad_body); } else if (render_ == RT_JSON) { ad_header << "Content-type: application/x-javascript; charset=utf-8\r\nSet-Cookie: an_slot=" << ++rotate_slot << "; path=/ebpn\r\n\r\n"; stringstream stat_desc; stat_desc << _login_uid << " GetJson"; StatFunc stat(stat_desc.str()); AdCreativeCache::instance().GetJson(referer, getPropertyInt("refresh_source", 0), getPropertyInt("refresh_idx", 0), self_zones, final_ads, &ad_body); } FCGX_PutS(ad_header.str().c_str(), _fcgi_out); FCGX_PutS(ad_body.c_str(), _fcgi_out); timeval end; gettimeofday(&end, NULL); AdGateI::instance().ping_sender_.Send("GetAds", 1000*(end.tv_sec-start.tv_sec)+(end.tv_usec-start.tv_usec)/1000); return true; }
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; }