Esempio n. 1
0
User AuthModel::processAuthToken()
{
  WApplication *app = WApplication::instance();
  const WEnvironment& env = app->environment();

  if (baseAuth()->authTokensEnabled()) {
    const std::string *token =
      env.getCookie(baseAuth()->authTokenCookieName());

    if (token) {
      AuthTokenResult result = baseAuth()->processAuthToken(*token, users());

      switch(result.state()) {
      case AuthTokenState::Valid: {
        if (!result.newToken().empty()) {
          /*
           * Only extend the validity from what we had currently.
           */
          app->setCookie(baseAuth()->authTokenCookieName(), result.newToken(),
                         result.newTokenValidity(), "", "", app->environment().urlScheme() == "https");
        }

	return result.user();
      }
      case AuthTokenState::Invalid:
        app->setCookie(baseAuth()->authTokenCookieName(),std::string(), 0, "", "", app->environment().urlScheme() == "https");

	return User();
      }
    }
  }

  return User();
}
Esempio n. 2
0
Tweet::Tweet(const QJsonObject &json)
{
    // Use the retweeted status when possible
    QJsonObject tweet {json};
    QJsonObject retweetedTweet {json.value(QLatin1String("retweeted_status")).toObject()};
    QJsonObject displayedTweet {tweet};
    if (!retweetedTweet.isEmpty()) {
        displayedTweet = retweetedTweet;

        // Adding the retweeting user when retweeting
        m_retweetingUser = std::move(User(tweet.value(QLatin1String("user")).toObject()));
    }

    m_id = std::move(tweet.value(QLatin1String("id_str")).toString());
    m_originalId = std::move(displayedTweet.value(QLatin1String("id_str")).toString());
    m_text = std::move(displayedTweet.value(QLatin1String("text")).toString());
    m_favoriteCount = displayedTweet.value(QLatin1String("favorite_count")).toInt();
    m_favorited = displayedTweet.value(QLatin1String("favorited")).toBool();
    m_retweetCount = displayedTweet.value(QLatin1String("retweet_count")).toInt();
    m_retweeted = displayedTweet.value(QLatin1String("retweeted")).toBool();
    m_inReplyTo = std::move(displayedTweet.value(QLatin1String("in_reply_to_status_id")).toString());
    m_source = std::move(tweet.value(QLatin1String("source")).toString());
    m_timestamp = std::move(private_util::fromUtc(displayedTweet.value(QLatin1String("created_at")).toString()));
    m_user = std::move(User(displayedTweet.value(QLatin1String("user")).toObject()));

    QJsonObject entities {displayedTweet.value(QLatin1String("entities")).toObject()};
    QJsonObject extendedEntities {displayedTweet.value(QLatin1String("extended_entities")).toObject()};
    m_entities = Entity::create(entities, extendedEntities);
    m_quotedStatus = std::move(QuotedTweet(displayedTweet.value(QLatin1String("quoted_status")).toObject()));
}
Esempio n. 3
0
std::vector<Event> Event::select(std::string cond, int limit){
    DB::Result r = DB::query("SELECT type, source_id, source_name, target_id, target_name, track_id, track_title, message, date AT TIME ZONE 'UTC', id FROM events" + (cond.empty()?"":" WHERE "+cond) + " ORDER BY date DESC" + (limit?" LIMIT "+number(limit):""));
    std::vector<Event> events(r.size());
    for(unsigned i=0; i<r.size(); i++){
        Type t = r[i][0] == "publish"  ? Publish
             : r[i][0] == "comment"  ? Comment
             : r[i][0] == "favorite" ? Favorite : Follow;
        events[i] = Event(t, User(number(r[i][1]),r[i][2]), User(number(r[i][3]),r[i][4]), Track(number(r[i][5]),r[i][6]), r[i][7], r[i][8], number(r[i][9]));
    }
    return events;
}
Esempio n. 4
0
// Since we don't support CreateSecurityGroup, insert a few for testing.
void registerTestUsers() {
    users[ "1" ] = User();
    users[ "1" ].groups[ "sg-name-1" ] = Group( "sg-name-1" );
    users[ "1" ].groups[ "sg-name-2" ] = Group( "sg-name-2" );
    users[ "1" ].groups[ "sg-name-3" ] = Group( "sg-name-3" );

    // The Amazon EC2 ID we actually use for testing.
    users[ "1681MPTCV7E5BF6TWE02" ] = User();

    // The Magellan (Eucalyptus) ID we actually use for testing.
    users[ "HOq1jQmeoswWXoJTq44DbTuD8jchkWfXmbsEg" ] = User();
}
Esempio n. 5
0
    void follow(int followerId, int followeeId) {
		int flag = 0 ;
		int flag1 = 0 ;
		int ret = 0 , i = 0 ,followeri=-1, followeei = -1 ;
		User *user1 =NULL;
		list <int> * tweetid2 =NULL, * tweetdate2 =NULL;
        for( vector<User>::iterator iter = user.begin(); iter != user.end() ;++iter,++i){
			if( iter->getuserid() == followerId ){
				flag1 = 1 ;
				ret = iter->addfollower(followeeId);
				user1 = &*iter ;
				followeri = i ;
				if( ret == 1 ){
					return ;
				}
			
				
			}
			if( iter->getuserid() == followeeId ){
				flag = 1 ;
				followeei = i ;
			
			}
			if( flag==1 && flag1 == 1 ){
				break ;
			}
		}
		
		if( flag1 == 0 ){
			user.push_back(User(followerId));
			user.back().addfollower(followeeId);
			user1 = &user.back();
			
			
		}
		else{
			user1 = &user[followeri];
		}
		if( flag != 0){
			user[followeei].addfollowee(followerId);
				tweetid2 = &user[followeei].getmytweetid() ;
				tweetdate2 = &user[followeei].getmytweetdate() ;
			updatetweetid( user1 , followeeId, tweetid2 ,  tweetdate2 );
		}
		else{
			user.push_back(User(followeeId));
			user.back().addfollowee(followerId);
		}
    }
UserItemWidget::UserItemWidget(const QString& username)
: m_username(username)
{
    // subscribers can listen to loved tracks and personal tags.
    bool subscriber = false;
    {
        unicorn::UserSettings us;
        QVariant v = us.value(unicorn::UserSettings::subscriptionKey(), false);
        subscriber = v.toBool();
    }

    // todo: no reason username can't come from the model...
    QPushButton* del;
    QHBoxLayout* layout = new QHBoxLayout(this);
    layout->addWidget( m_image = new QLabel );

    QVBoxLayout* vlayout = new QVBoxLayout();
    vlayout->addWidget( m_label = new QLabel );
    vlayout->addWidget( m_combo = new QComboBox() );
    vlayout->addWidget( m_playlistCombo = new QComboBox() );
    vlayout->addWidget( m_tagCombo = new QComboBox() );
    m_playlistCombo->setVisible(false);
    m_tagCombo->setVisible(false);
    m_combo->addItem( "Library", RqlSource::User );
    if (subscriber) {
        m_combo->addItem( "Loved Tracks", RqlSource::Loved );
    } else {
        // would be nice to show the option in a disabled state.
        // how?
        // fixme.
    }
    m_combo->addItem( "Recommended", RqlSource::Rec );
    m_combo->addItem( "Neighbours", RqlSource::Neigh );
    connect(m_combo, SIGNAL(currentIndexChanged(int)), SLOT(onComboChanged(int)));
    connect(m_playlistCombo, SIGNAL(currentIndexChanged(int)), SLOT(onCombo2Changed(int)));
    connect(m_tagCombo, SIGNAL(currentIndexChanged(int)), SLOT(onCombo2Changed(int)));

    layout->addLayout( vlayout );
    layout->addWidget( del = new QPushButton("X"), 0, Qt::AlignRight );
    m_image->setObjectName( "userImage" );
    m_image->setProperty( "noImage", true );
    m_label->setText( username );
    connect(del, SIGNAL(clicked()), SIGNAL(deleteClicked()));

    if (subscriber) {
        connect(User(username).getPlaylists(), SIGNAL(finished()), SLOT(onGotPlaylists()));
        connect(User(username).getTopTags(), SIGNAL(finished()), SLOT(onGotTags()));
    }
}
Esempio n. 7
0
    // Function:     waitForNewFriend
    // Inputs:       NA
    // Outputs:      true if executed to fruition, false if no user active.
    // Description:  This function wait for a user to input the name of a frined they
    //               want to add then stores the friendship in the user list.
    //
    bool Menu::waitForNewFriend()
    {
        // Check to see if there is an active user.
        if (users.hasNoActiveUser())
        {
            std::cout << NEW_LINE << TAB << TAB << STRING_NO_USER_ACTIVE;
            return false;
        }
        
        // Display prompt for a new friend.
        std::cout << NEW_LINE + TAB + TAB + STRING_ENTER_NEW_FRIEND;
        
        // Read a line from the console.
        std::string newFriend;
        std::getline(std::cin, newFriend);
        
        // Check if username is empty.
        if ( newFriend.length() == 0)
        {
            std::cout << NEW_LINE << TAB << TAB << STRING_USER_NOT_BLANK;
            return waitForNewFriend();
        }
        // Check if username is formatted correctly.
        else if ( newFriend.find(" ") != std::string::npos)
        {
            std::cout << NEW_LINE << TAB << TAB << STRING_USER_FORMAT;
            return waitForNewFriend();
        }
        else
        {
        
            // Check to see if the name entered is a valid user.
            if ( !users.isUser(User(newFriend)) )
            {
                std::cout << NEW_LINE + TAB + TAB + STRING_NO_USER;
                return waitForCommand();
            }
        
            // Check to see if the name belongs to the current user.
            if ( users.getCurrentUser().getUsername().compare(newFriend) == 0 )
            {
                std::cout << NEW_LINE + TAB + TAB + STRING_CANNOT_FRIEND_SELF;
                return waitForCommand();
            }
        
            // Check to see if the current user is already friends with newFriend.
            if ( users.isFriend(users.getCurrentUser(), users.findUserByName(newFriend)) )
            {
                std::cout << NEW_LINE + TAB + TAB + STRING_ALREADY_FRIENDS;
                return waitForCommand();
            }
        
            std::cout << NEW_LINE << TAB << TAB << STRING_NOW_FRIENDS << newFriend << NEW_LINE;
        
            // Add the friend to the current user's friends list.
            users.setFriends(users.getCurrentUser(),users.findUserByName(newFriend));

            return true;
        }
    }
RadioStation
PlayableItemWidget::getMultiStation() const
{
    QList<User> users;

    int endPos = m_rs.url().indexOf( "/", 14 );
    if ( endPos == -1 )
        endPos = m_rs.url().length();

    users << User( m_rs.url().mid( 14, endPos - 14 ) );
    users << User();

    RadioStation station = RadioStation::library( users );
    station.setTitle( tr( "Multi-Library Radio" ) );
    return station;
}
Esempio n. 9
0
void UserManagerBackend::refreshUsers() {
    qDebug() << "Refreshing user list...";
    userList.clear();
    QFile userFile(chroot + "/etc/passwd");
    if ( userFile.open(QIODevice::ReadOnly) ) {
	QTextStream stream(&userFile);
	stream.setCodec("UTF-8");
	QString line;
	
	while ( !stream.atEnd() ) {
	    line = stream.readLine();
	    
	    if ((line.indexOf("#") != 0) && (! line.isEmpty())) { //Make sure it isn't a comment or blank
		QString username = line.section(":",0,0);
		int uid = line.section(":",2,2).toInt();
		int gid = line.section(":",3,3).toInt();
		QString home = line.section(":",5,5);
		QString shell = line.section(":",6,6);
		QString fullname = line.section(":",4,4);
		
		userList[username] = User(username, uid, gid, home, shell, fullname);
	    }
	}
    }
    else {
	//Unable to open file error
	qWarning("Error! Unable to open /etc/passwd");
    }
}
// Returns vector with all users information.
std::vector<User> RadioStation::loadAllUsersToVector() {

	std::vector <User> allUsersVec;

	std::string filename = "users.csv";
	ifstream file(filename);

	std::string tempStr;

	// Temporary user information.
	unsigned int newID, newAge, newHits;
	std::string newName, newGender, newPass;
	bool newSpecial;

	if(file.is_open()) {
		getline(file, tempStr); // Get first line (fields titles).

		while(getline(file, tempStr)) {
			// Gets user information from file.
			newID = convertStrInt(extractInfo(tempStr));
			newName = extractInfo(tempStr);
			newAge = convertStrInt(extractInfo(tempStr));
			newGender = extractInfo(tempStr);
			newSpecial = convertToBool(convertStrInt(extractInfo(tempStr)));
			newPass = extractInfo(tempStr);
			newHits = convertStrInt(extractInfo(tempStr));
			// Stores user information to vector.
			allUsersVec.push_back(User(newID, newName, newAge, newGender, newSpecial, newPass, newHits, true));
		}

		file.close();
	}

	return allUsersVec;
}
Esempio n. 11
0
FriendWidget::FriendWidget( const lastfm::XmlQuery& user, QWidget* parent)
    :QFrame( parent ),
      ui( new Ui::FriendWidget ),
      m_user( user ),
      m_order( 0 - 1 ),
      m_listeningNow( false )
{   
    ui->setupUi( this );

    layout()->setAlignment( ui->avatar, Qt::AlignTop );

    m_movie = new QMovie( ":/icon_eq.gif", "GIF", this );
    m_movie->setCacheMode( QMovie::CacheAll );
    ui->equaliser->setMovie( m_movie );
    ui->equaliser->hide();

    update( user, -1 );

    QRegExp re( "/serve/(\\d*)s?/" );
    ui->avatar->loadUrl( user["image size=medium"].text().replace( re, "/serve/\\1s/" ), HttpImageWidget::ScaleNone );
    ui->avatar->setHref( user["url"].text() );

    ui->radio->setStation( RadioStation::library( User( user["name"].text() ) ), tr("%1%2s Library Radio").arg( user["name"].text(), QChar(0x2019) ), "" );

    ui->avatar->setUser( m_user );
}
Esempio n. 12
0
bool lmcMessaging::addUser(QString szUserId, QString szVersion, QString szAddress, QString szName, QString szStatus,
                           QString szAvatar, QString szNote, QString szCaps) {
	for(int index = 0; index < userList.count(); index++)
		if(userList[index].id.compare(szUserId) == 0)
			return false;

	lmcTrace::write("Adding new user: "******", " + szVersion + ", " + szAddress);

	if(!userGroupMap.contains(szUserId) || !groupList.contains(Group(userGroupMap.value(szUserId))))
		userGroupMap.insert(szUserId, GRP_DEFAULT_ID);

	int nAvatar = szAvatar.isNull() ? -1 : szAvatar.toInt();

    userList.append(User(szUserId, szVersion, szAddress, szName, szStatus, userGroupMap[szUserId],
                         nAvatar, szNote, QString::null, szCaps));
	if(!szStatus.isNull()) {
		XmlMessage xmlMessage;
		xmlMessage.addHeader(XN_FROM, szUserId);
		xmlMessage.addData(XN_STATUS, szStatus);
		//	send a status message to app layer, this is different from announce message
		emit messageReceived(MT_Status, &szUserId, &xmlMessage);
		int statusIndex = Helper::statusIndexFromCode(szStatus);
		if(statusType[statusIndex] == StatusTypeOffline) // offline status
			return false;	//	no need to send a new user message to app layer
	}

	emit messageReceived(MT_Announce, &szUserId, NULL);
	return true;
}
void
PlayableItemWidget::contextMenuEvent( QContextMenuEvent* event )
{
    QMenu* contextMenu = new QMenu( this );

    contextMenu->addAction( tr( "Play %1" ).arg( m_rs.title() ), this, SLOT(play()));

    if ( RadioService::instance().state() == Playing )
        contextMenu->addAction( tr( "Cue %1" ).arg( m_rs.title() ), this, SLOT(playNext()));

    if ( m_rs.url().startsWith( "lastfm://user/" )
         &&  ( m_rs.url().endsWith( "/library" ) || m_rs.url().endsWith( "/personal" ) )
         && m_rs.url() != RadioStation::library( User() ).url() )
    {
        int endPos = m_rs.url().indexOf( "/", 14 );
        if ( endPos == -1 )
            endPos = m_rs.url().length();

        // if it's a user station that isn't yours we should
        // let them start a multi-station with yours
        contextMenu->addSeparator();
        contextMenu->addAction( tr( "Play %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMulti()));
        if ( RadioService::instance().state() == Playing )
            contextMenu->addAction( tr( "Cue %1 and %2 Library Radio" ).arg( m_rs.url().mid( 14, endPos - 14 ), User().name() ), this, SLOT(playMultiNext()));
    }

    if ( contextMenu->actions().count() )
        contextMenu->exec( event->globalPos() );
}
void SMsgUsrGetPolledUserListReplyEx::unpack_multiple_message_specific_data()
	{
	// Retrieve the data source id

	m_i_data_source_id = ReadLong();

	// Retrieve the data source specific status information

	m_data_source_specific_status = static_cast<WONMsg::ServerStatus>(static_cast<short>(ReadShort()));

	// Retrieve the number of users found

	unsigned long number_of_user_objects = ReadLong();

	// Retrieve each user, adding each user to the end of the user vector array

	for (unsigned long counter = 0;
		 counter < number_of_user_objects;
		 counter++)
		{
		// Add a new user to the end of the array

		m_a_users.push_back(User());

		m_a_users.back().unpack_data(*this);
		}
	}
/** @brief NoGuiSinglePlayerBattle
  *
  * @todo: document this function
  */
NoGuiSinglePlayerBattle::NoGuiSinglePlayerBattle()
    :  m_me( User( usync().IsLoaded() ? usync().GetDefaultNick() : _T("invalid") ) )
{
    OnUserAdded( m_me );
    m_me.BattleStatus().colour = sett().GetBattleLastColour();
    SetFounder( m_me.GetNick() );
}
Esempio n. 16
0
User MainDataBase::getUser(QString name)
{
    if (db.isOpen())
    {
        QSqlQuery query;


        QString strQuery = QString("SELECT * FROM ScrabbleDataBase WHERE name ='%1'").arg(name);
        bool result = query.exec(strQuery);
        QSqlRecord record = query.record();

        assert(result);

        while (query.next())
        {
            int loseCount = query.value(record.indexOf("loseCount")).toInt();
            int winCount = query.value(record.indexOf("winCount")).toInt();
            int usersCS = query.value(record.indexOf("usersCurrentScore")).toInt();
            int botsCS = query.value(record.indexOf("botsCurrentScore")).toInt();
            QString board = query.value(record.indexOf("currentBoard")).toString();
            string sBoard = "";
            for (int i = 0; i < (int)board.size(); ++i)
                sBoard += board[i].toLatin1();
            return User(name, loseCount, winCount, sBoard, usersCS, botsCS);
        }
        addUser(name);
        return getUser(name);
    }    
}
Esempio n. 17
0
Panzerfaust::Panzerfaust()
{
	
	m_renderer = Renderer();
	//debugUnitTest(m_elements);
	m_internalTime = 0.f;
	m_isQuitting = m_renderer.m_fatalError;
	m_console.m_log = ConsoleLog();
	//m_world = World();
	m_worldCamera = Camera();

	m_displayConsole = false;

	//HACK test values
	m_console.m_log.appendLine("This is a test of the emergency broadcast system");
	m_console.m_log.appendLine("Do not be alarmed or concerned");
	m_console.m_log.appendLine("This is only a test");

	UnitTestXMLParser(".\\Data\\UnitTest.xml");
	unitTestEventSystem();
	//g_serverConnection = new Connection("129.119.246.221", "5000");
	g_serverConnection = new Connection("127.0.0.1", "8080");
	g_localUser = User();
	g_localUser.m_unit = Entity();
	g_localUser.m_unit.m_color = Color4f(0.2f, 1.0f, 0.2f, 1.f);
	g_localUser.m_userType = USER_LOCAL;
	g_localUser.m_unit.m_position = Vector2f(0,0);
	g_flag.m_color = Color4f(1.f, 1.f, 1.f, 1.f);
	CommandParser::RegisterCommand("connect", ChangeServer);
	CommandParser::RegisterCommand("color", ChangeColor);
}
Esempio n. 18
0
 // Function:     waitForAlternateUser
 // Inputs:       NA
 // Outputs:      true if executed to fruition
 // Description:  This function waits for a user to enter the name of another
 //               existing user whose account they want to switch to.
 //
 bool Menu::waitForAlternateUser()
 {
     // Check to see if there is are any users enrolled in the system.
     if (users.hasNoUsersEnrolled() )
     {
         std::cout << NEW_LINE << TAB << TAB << STRING_NO_USERS;
         return false;
     }
     
     // Query for the username to switch to.
     std::cout << NEW_LINE + TAB + TAB + STRING_CHANGE_USER;
     
     // Input a string for a username.
     std::string altUser;
     std::getline(std::cin, altUser);
     
     // Check if username is empty.
     if ( altUser.length() == 0)
     {
         std::cout << NEW_LINE << TAB << TAB << STRING_USER_NOT_BLANK;
         return waitForAlternateUser();
     }
     // Check if username is formatted correctly.
     else if ( altUser.find(" ") != std::string::npos)
     {
         std::cout << NEW_LINE << TAB << TAB << STRING_USER_FORMAT;
         return waitForAlternateUser();
     }
     else
     {
     
         // Check to see if the name entered is a valid user.
         if ( !users.isUser(User(altUser)) )
         {
             std::cout << NEW_LINE + TAB + TAB + STRING_NO_USER;
             return waitForCommand();
         }
     
         // Change to the specified user.
         users.setCurrentUser(User(altUser));
     
         // Display the new user's message board header.
         std::cout << users.getCurrentUser().getBoardHeader();
     
         return true;
     }
 }
Esempio n. 19
0
User& IBattle::OnBotAdded( const std::string& nick, const UserBattleStatus& bs )
{
	m_internal_bot_list[nick] = User(nick);
	User& user = m_internal_bot_list[nick];
	user.UpdateBattleStatus( bs );
	User& usr = OnUserAdded( user );
	return usr;
}
Esempio n. 20
0
User EditUserDialog::creatUserObject(){
    FileAccess fa;
    fa.aread = ui->freadCb->isChecked();
    fa.awrite = ui->fwriteCb->isChecked();
    fa.adelete = ui->fdeleteCb->isChecked();
    fa.aappend= ui->fappendCb->isChecked();
    return User(ui->usernameEdt->text(), ui->enterpassRB->isChecked()?passHash:"", ui->folderEdt->text(),fa);
}
Esempio n. 21
0
void Panzerfaust::update(float deltaTime)
{
	bool forwardVelocity = m_IOHandler.m_keyIsDown['W'];
	bool backwardVelocity = m_IOHandler.m_keyIsDown['S'];
	bool leftwardVelocity = m_IOHandler.m_keyIsDown['A'];
	bool rightwardVelocity = m_IOHandler.m_keyIsDown['D'];

	//HACK
	const float SPEED_OF_CAMERA = 50.f;

	g_localUser.m_unit.m_target.x += (rightwardVelocity - leftwardVelocity)*SPEED_OF_CAMERA*deltaTime;
	g_localUser.m_unit.m_target.y += (forwardVelocity - backwardVelocity)*SPEED_OF_CAMERA*deltaTime;
	g_localUser.update(deltaTime);

	GamePacket currentPacket;
	do 
	{
		bool newUser = true;
		currentPacket = g_serverConnection->receivePackets();
		if (currentPacket.ID != 0)
		{
			Color3b packetColor = Color3b();
			packetColor.r = currentPacket.r;
			packetColor.g = currentPacket.g;
			packetColor.b = currentPacket.b;

			for (unsigned int ii = 0; ii < g_users.size(); ii++)
			{
				
				if (Color3b(g_users[ii].m_unit.m_color) == packetColor)
				{
					newUser = false;
					g_users[ii].m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
				}
			}
			if (newUser)
			{
				User tempUser = User();
				tempUser.m_unit.m_position = Vector2f(currentPacket.x, currentPacket.y);
				tempUser.m_unit.m_target = Vector2f(currentPacket.x, currentPacket.y);
				tempUser.m_unit.m_color = Color4f(packetColor.r/255.f, packetColor.g/255.f, packetColor.b/255.f, 1.f);
				tempUser.m_userType = USER_REMOTE;
				g_users.push_back(tempUser);
			}
		}
	} while (currentPacket.ID != 0);

	for (unsigned int ii = 0; ii < g_users.size(); ii++)
	{
		g_users[ii].update(deltaTime);
	}

	mouseUpdate();

	m_internalTime += deltaTime;

	//m_world.update(deltaTime);
}
SinglePlayerBattle::SinglePlayerBattle( MainSinglePlayerTab& msptab ):
  m_sptab(msptab),
  m_me( User( usync().IsLoaded() ? usync().GetDefaultNick() : _T("invalid") ) )
{
	OnUserAdded( m_me );
	m_me.BattleStatus().side = sett().GetBattleLastSideSel( GetHostModName() );
	m_me.BattleStatus().colour = sett().GetBattleLastColour();
	CustomBattleOptions().setSingleOption( _T("startpostype"), wxFormat(_T("%d") ) % ST_Pick, OptionsWrapper::EngineOption );
}
Esempio n. 23
0
User Authenticator::authenticate(const char* name, const char* password) {
    for (int i = 0; i < m_users.size(); ++i) {
        User u = m_users.at(i);
        if ((u.name() == name) && (u.password() == password)) {
            return u;
        }
    }
    return User("anonymous", "guest");
}
Esempio n. 24
0
void Path::Decode(std::string &path) {
	if (path[0] != 94) // "^"
		return;
	try {
		if (path.find("^CONFIG") == 0) {
			path.replace(0, 7, Config());
			return;
		}

		if (path.find("^USER") == 0) {
			path.replace(0, 5, User());
			return;
		}

		if (path.find("^DATA") == 0) {
			path.replace(0, 5, Data());
			return;
		}

		if (path.find("^DOC") == 0) {
			path.replace(0, 4, Doc());
			return;
		}

		if (path.find("^TEMP") == 0) {
			path.replace(0, 5, Temp());
			return;
		}

		if (path.find("^AUDIO") == 0) {
			std::string path_str(opt->Get("Last/Audio")->GetString());
			Decode(path_str);
			path.replace(0, 6, path_str);
			return;
		}

		if (path.find("^VIDEO") == 0) {
			std::string path_str(opt->Get("Last/Video")->GetString());
			Decode(path_str);
			path.replace(0, 6, path_str);
			return;
		}

		if (path.find("^SUBTITLE") == 0) {
			std::string path_str(opt->Get("Last/Subtitle")->GetString());
			Decode(path_str);
			path.replace(0, 5, path_str);
			return;
		}

		throw PathErrorInvalid("Invalid cookie used");

	} catch (OptionErrorNotFound&) {
		throw PathErrorInternal("Failed to find key in Decode");
	}
}
Esempio n. 25
0
// we can register those name that hadn't been used
bool AgendaService::userRegister(std::string userName, std::string password,
				 std::string email, std::string phone) {
  if (storage_->queryUser([&](const User& u) {
	return u.getName() == userName;}).size()) {
    return false;
  } else {
    storage_->createUser(User(userName, password, email, phone));
    return true;
  }
}
Esempio n. 26
0
// 090511 LUJ, 사용자를 삭제함
void CUserIPCheckMgr::RemoveUser( DWORD connectionIndex )
{
	User& user = GetUser( connectionIndex );

	if( user.dwIdx )
	{
		user = User();
		--mUserSize;
	}
}
Esempio n. 27
0
void UserEditDialog::slotEditMethod()
{
	UserDialog* ud = new UserDialog(this);
	if (mCurrent.isValid())
		ud->setUser(mCurrent);
	else
		ud->setUser(User());
	ud->exec();
	delete ud;
}
SinglePlayerBattle::SinglePlayerBattle( MainSinglePlayerTab& msptab ):
  m_sptab(msptab),
  m_me( User(sett().GetDefaultNick()))
{
	OnUserAdded( m_me );
	m_me.BattleStatus().side = sett().GetBattleLastSideSel( GetHostModName() );
	m_me.BattleStatus().colour = sett().GetBattleLastColour();
    CustomBattleOptions().setSingleOption( "startpostype", LSL::Util::ToString(ST_Pick), LSL::OptionsWrapper::EngineOption );
	ConnectGlobalEvent(this, GlobalEvent::OnUnitsyncReloaded, wxObjectEventFunction(&SinglePlayerBattle::OnUnitsyncReloaded));
}
Esempio n. 29
0
Game::Game()
{
    generateFood();

    user= User();
    dead   = false;
    paused = false;

    score = 1;
    speed = 0;
}
void
ScrobblesListWidget::fetchTrackInfo( const QList<lastfm::Track>& tracks )
{
    if ( isVisible() )
    {
        // Make sure we fetch info for any tracks with unknown loved status
        foreach ( const lastfm::Track& track, tracks )
            if ( track.loveStatus() == lastfm::Track::UnknownLoveStatus )
                track.getInfo(  this, "write", User().name() );
    }
}