Ejemplo n.º 1
0
                void NLoginCredentials::toStruct(_NLoginCredentials & input)
                {
                    memset(&input, 0, sizeof(_NLoginCredentials));

                    getUsername().copy(input.Username, getUsername().length());
                    getPassword().copy(input.Password, getPassword().length());
                }
Ejemplo n.º 2
0
bool CPlayer::checkSequenceNumber(Cpdu* pdu, u_int16_t sequenceNumber)
{
    bool rc = false;
    char s[200];

    u_int16_t sqn = pdu->getSequenceNumber();
    if (sqn == PDU_NOT_SEQUENCED)
    {
        sprintf(s, "CPlayer::waitPdu: non-sequenced pdu type (%s, %d)\n",
                getUsername(), pdu->getType());
        Sys_LogError(s);
        rc = false;
    }
    else if (sqn != sequenceNumber)
    {   // This is ok: it can happen if there is a peek in latency
        // that causes a pdu to travel for so long the server times
        // out and the pdu arrives after that. The pdu will be ignored
        // by the caller.
        sprintf(s, "CPlayer::waitPdu: wrong sequence number for pdu (%s, expected %d got %d)\n",
                getUsername(), sequenceNumber, sqn);
        Sys_LogError(s);
        rc = false;
    }
    else
    {
        // ok, sequence number matches
        rc = true;
    }

    return rc;
}
Ejemplo n.º 3
0
QString BoardDispatch::getOpponentName(void)
{
	if(!gameData)
		return QString();
	if(gameData->black_name == getUsername())
		return gameData->white_name;
	else if(gameData->white_name == getUsername())
		return gameData->black_name;
	else
		return QString();
}
Ejemplo n.º 4
0
Archivo: core.cpp Proyecto: mpxc/qTox
void Core::changeGroupTitle(int groupId, const QString& title)
{
    ToxString cTitle(title);
    TOX_ERR_CONFERENCE_TITLE error;
    bool success = tox_conference_set_title(tox, groupId, cTitle.data(), cTitle.size(), &error);
    if (success && error == TOX_ERR_CONFERENCE_TITLE_OK) {
        emit groupTitleChanged(groupId, getUsername(), title);
        return;
    }

    qCritical() << "Fail of tox_conference_set_title";
    switch (error) {
    case TOX_ERR_CONFERENCE_TITLE_CONFERENCE_NOT_FOUND:
        qCritical() << "Conference not found";
        break;

    case TOX_ERR_CONFERENCE_TITLE_FAIL_SEND:
        qCritical() << "Conference title failed to send";
        break;

    case TOX_ERR_CONFERENCE_TITLE_INVALID_LENGTH:
        qCritical() << "Invalid length";
        break;

    default:
        break;
    }
}
bool CIRCDDBGatewayConfigIrcDDBSet::Validate()
{
	int n = m_enabled->GetCurrentSelection();
	if (n == wxNOT_FOUND)
		return false;

	bool enabled = getEnabled();
	if (!enabled)
		return true;

	bool res = getHostname().IsEmpty();
	if (res) {
		wxMessageDialog dialog(this, _("The Hostname may not be empty"), m_title + _(" Error"), wxICON_ERROR);
		dialog.ShowModal();
		return false;
	}

	res = getUsername().IsEmpty();
	if (res) {
		wxMessageDialog dialog(this, _("The Username may not be empty"), m_title + _(" Error"), wxICON_ERROR);
		dialog.ShowModal();
		return false;
	}

	return true;
}
Ejemplo n.º 6
0
Archivo: core.cpp Proyecto: Pik-9/qTox
void Core::changeGroupTitle(int groupId, const QString& title)
{
    CString cTitle(title);
    int err = tox_group_set_title(tox, groupId, cTitle.data(), cTitle.size());
    if (!err)
        emit groupTitleChanged(groupId, getUsername(), title);
}
Ejemplo n.º 7
0
/*
 * Connect to the NN as the current user/group.
 * Returns a fs handle on success, or NULL on failure.
 */
hdfsFS doConnectAsUser(const char *hostname, int port) {
  uid_t uid = fuse_get_context()->uid;
  char *user = getUsername(uid);
  int ret;
  hdfsFS fs = NULL;
  if (NULL == user) {
    goto done;
  }

  ret = pthread_mutex_lock(&tableMutex);
  assert(0 == ret);

  fs = findFs(user);
  if (NULL == fs) {
    fs = hdfsConnectAsUserNewInstance(hostname, port, user);
    if (NULL == fs) {
      ERROR("Unable to create fs for user %s", user);
      goto done;
    }
    if (-1 == insertFs(user, fs)) {
      ERROR("Unable to cache fs for user %s", user);
    }
  }

done:
  ret = pthread_mutex_unlock(&tableMutex);
  assert(0 == ret);
  if (user) {
    free(user);
  }
  return fs;
}
Ejemplo n.º 8
0
void Lvk::FE::ChatHistoryWidget::addDateContactTableRow(const Lvk::Cmn::Conversation::Entry &entry)
{
    QString date = entry.dateTime.toString(DATE_FORMAT);
    QString username = getUsername(entry.from);
    QString fullname = getFullname(entry.from);

    if (fullname.isEmpty()) {
        fullname = username;
    }

    int nextRow = ui->dateContactTable->rowCount();
    ui->dateContactTable->insertRow(nextRow);
    ui->dateContactTable->setItem(nextRow, DateColumnn,    new QTableWidgetItem(date));
    ui->dateContactTable->setItem(nextRow, UsernameColumn, new QTableWidgetItem(fullname));

    ui->dateContactTable->item(nextRow, DateColumnn)->setData(HashKeyRole, hashKey(entry));
    ui->dateContactTable->item(nextRow, UsernameColumn)->setData(HashKeyRole, hashKey(entry));
    ui->dateContactTable->item(nextRow, UsernameColumn)->setData(EntryFromRole, entry.from);

    if (username.contains("@gmail.com")) {
        ui->dateContactTable->item(nextRow, UsernameColumn)->setIcon(QIcon(GMAIL_ICON));
    } else if (username.contains("@chat.facebook.com")) {
        ui->dateContactTable->item(nextRow, UsernameColumn)->setIcon(QIcon(FB_ICON));
    } else if (username.contains(tr("(test)"))) {
        ui->dateContactTable->item(nextRow, UsernameColumn)->setIcon(QIcon(LOCAL_TEST_ICON));
    }
}
Ejemplo n.º 9
0
bool MAP_SHARING::isDebugger()
{
    if( debuggers.find( getUsername() ) != debuggers.end() ) {
        return true;
    }
    return false;
}
Ejemplo n.º 10
0
Result Server::connect()
{
    if(mServerHandle)
    {
        return Error;
    }

    mServerHandle = mysql_init(NULL);
    if(mServerHandle == NULL)
    {
        return Error;
    }
    
    unsigned long flags=0;
    if(mysql_real_connect(mServerHandle,
                          getHost()->c_str(),
                          getUsername()->c_str(),
                          getPassword()->c_str(),
                          NULL,
                          mPort,
                          NULL,
                          flags) == NULL)
    {

        printError();
        
        return Error;
    }
    
    return OK;
}
Ejemplo n.º 11
0
void Skype::login() {
	// Do not allow usernames with unsecure symbols
	if (m_username.find("..") == 0 || m_username.find("/") != std::string::npos) {
		m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Invalid username");
		return;
	}

	m_db = createSkypeDirectory();

	bool spawned = spawnSkype(m_db);
	if (!spawned) {
		m_np->handleDisconnected(m_user, pbnetwork::CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, "Error spawning the Skype instance.");
		return;
	}

	m_db += "/" + getUsername() + "/main.db";

	if (m_connection == NULL) {
		LOG4CXX_INFO(logger, "Creating DBUS connection.");
		GError *error = NULL;
		m_connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
		if (m_connection == NULL && error != NULL)
		{
			LOG4CXX_INFO(logger,  m_username << ": Creating DBUS Connection error: " << error->message);
			g_error_free(error);
			return;
		}
	}

	m_timer = g_timeout_add_seconds(1, create_dbus_proxy, this);
}
Ejemplo n.º 12
0
bool MAP_SHARING::isAdmin()
{
    if( admins.find( getUsername() ) != admins.end() ) {
        return true;
    }
    return false;
}
Ejemplo n.º 13
0
bool Checkin::operator==(const Checkin& other) const {
	return true
		 && _isUsernameSet(mgen::SHALLOW) == other._isUsernameSet(mgen::SHALLOW)
		 && _isPasswordSet(mgen::SHALLOW) == other._isPasswordSet(mgen::SHALLOW)
		 && getUsername() == other.getUsername()
		 && getPassword() == other.getPassword();
}
Ejemplo n.º 14
0
void Core::loadConfiguration()
{
    QString path = Settings::getSettingsDirPath() + '/' + CONFIG_FILE_NAME;

    QFile configurationFile(path);

    if (!configurationFile.exists()) {
        qWarning() << "The Tox configuration file was not found";
        return;
    }

    if (!configurationFile.open(QIODevice::ReadOnly)) {
        qCritical() << "File " << path << " cannot be opened";
        return;
    }

    qint64 fileSize = configurationFile.size();
    if (fileSize > 0) {
        QByteArray data = configurationFile.readAll();
        tox_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size());
    }

    configurationFile.close();

    // set GUI with user and statusmsg
    QString name = getUsername();
    if (name != "")
        emit usernameSet(name);
    
    QString msg = getStatusMessage();
    if (msg != "")
        emit statusMessageSet(msg);

    loadFriends();
}
Ejemplo n.º 15
0
// Sets the login security tokens for a user.
// Also store whether the device is touch-enabled.
// It only writes to the table if the combination of username and tokens differs from what the table already contains.
void Database_Login::setTokens (string username, string address, string agent, string fingerprint, string cookie, bool touch)
{
  bool daily;
  if (username == getUsername (cookie, daily)) return;
  address = md5 (address);
  agent = md5 (agent);
  fingerprint = md5 (fingerprint);
  SqliteDatabase sql (database ());
  sql.add ("INSERT INTO logins VALUES (");
  sql.add (username);
  sql.add (",");
  sql.add (address);
  sql.add (",");
  sql.add (agent);
  sql.add (",");
  sql.add (fingerprint);
  sql.add (",");
  sql.add (cookie);
  sql.add (",");
  sql.add (touch);
  sql.add (",");
  sql.add (timestamp ());
  sql.add (");");
  sql.execute ();
}
Ejemplo n.º 16
0
 void _pmdExternClient::logout()
 {
    if ( _isAuthed )
    {
       CHAR szTmp[ 16 ] = { 0 } ;
       ossSnprintf( szTmp, sizeof(szTmp)-1, "%llu", _pEDUCB->getID() ) ;
       PD_AUDIT( AUDIT_ACCESS, getUsername(), getPeerIPAddr(),
                 getPeerPort(), "LOGOUT", AUDIT_OBJ_SESSION,
                 szTmp, SDB_OK,
                 "User[UserName:%s, RemoteIP:%s, RemotePort:%u, "
                 "LocalIP:%s, LocalPort:%u] logout succeed",
                 getUsername(), getPeerIPAddr(), getPeerPort(),
                 getLocalIPAddr(), getLocalPort() ) ;
    }
    _isAuthed = FALSE ;
 }
Ejemplo n.º 17
0
int main( int argc, char *argv[] ) {
   

if(argc == 2)
{
        if(strcmp(argv[1],"user")==0) 
        {
              getUsername();
        }
        else if(strcmp(argv[1],"group")==0)
      {	
              getGroupname();
      }
      else if(strcmp(argv[1],"computer")==0)
      {	
            getComputorName();
      }
  }
else
{
	printf("error\n");
}

  return 1;
}
Ejemplo n.º 18
0
void Core::saveConfiguration()
{
    if (QThread::currentThread() != coreThread)
        return (void) QMetaObject::invokeMethod(this, "saveConfiguration");

    if (!isReady())
        return;

    ProfileLocker::assertLock();

    QString dir = Settings::getSettingsDirPath();
    QDir directory(dir);
    if (!directory.exists() && !directory.mkpath(directory.absolutePath()))
    {
        qCritical() << "Error while creating directory " << dir;
        return;
    }

    QString profile = Settings::getInstance().getCurrentProfile();

    if (profile == "")
    { // no profile active; this should only happen on startup, if at all
        profile = sanitize(getUsername());

        if (profile == "") // happens on creation of a new Tox ID
            profile = getIDString();

        Settings::getInstance().switchProfile(profile);
    }

    QString path = directory.filePath(profile + TOX_EXT);

    saveConfiguration(path);
}
Ejemplo n.º 19
0
int CPlayerProxy::send(Cpdu& pdu)
{
  CpduRoutePlayerPdu wrapper;

  // The wrapper prepends additional routing data
  // and sends the PDU forward.
  return wrapper.routePdu(&pdu, getUsername());
}
Ejemplo n.º 20
0
void handle_client_message(connection_info clients[], int sender)
{
  int read_size;
  SBCP_message msg;

  if((read_size = recv(clients[sender].socket, &msg, sizeof(msg), 0)) == 0)
  {
    printf("User disconnected: %s.\n", clients[sender].username);
    close(clients[sender].socket);
    clients[sender].socket = 0;
    clients[sender].username[0] = 0;
    //send_disconnect_message(clients, clients[sender].username);

  } else {
    // interprete msg
    header_type h_type = getHeaderType( msg );


    switch(h_type)
    {

      case JOIN: ;    
      
      // JOIN
        // duplicated name
      char tempname[21];
      getUsername(msg, tempname);
      int i;
      for(i = 0; i < MAX_CLIENTS; i++)
      {
        if(strcmp(clients[i].username, tempname) == 0)
        {
          puts("Dected one duplicated usename");
          send_duplicated_name(clients[sender].socket);
          close(clients[sender].socket);
          clients[sender].socket = 0;
          return;
        }
      }
      puts("Server detected one JOIN");
      strcpy(clients[sender].username, tempname);
      printf("User connected: %s\n", clients[sender].username);
          //send_connect_message(clients, sender);
      break;

      case SEND:
        puts("Server detected one SEND");
        char msg_content[256];
        getMessageContent(msg, msg_content);
        send_public_message(clients, sender, msg_content);  //TODO
        break;

        default:
        fprintf(stderr, "Unknown message type received.\n");
        break;
    }
  }
}
Ejemplo n.º 21
0
//-------------------------------------------------------------------------------------
void Baseapp::onGetEntityAppFromDbmgr(Mercury::Channel* pChannel, int32 uid, std::string& username, 
						int8 componentType, uint64 componentID, 
						uint32 intaddr, uint16 intport, uint32 extaddr, uint16 extport)
{
	if(pChannel->isExternal())
		return;

	EntityApp<Base>::onRegisterNewApp(pChannel, uid, username, componentType, componentID, 
									intaddr, intport, extaddr, extport);

	KBEngine::COMPONENT_TYPE tcomponentType = (KBEngine::COMPONENT_TYPE)componentType;

	Components::COMPONENTS cts = Componentbridge::getComponents().getComponents(DBMGR_TYPE);
	KBE_ASSERT(cts.size() >= 1);
	
	Components::ComponentInfos* cinfos = Componentbridge::getComponents().findComponent(tcomponentType, uid, componentID);
	cinfos->pChannel = NULL;

	int ret = Components::getSingleton().connectComponent(tcomponentType, uid, componentID);
	KBE_ASSERT(ret != -1);

	Mercury::Bundle bundle;

	switch(tcomponentType)
	{
	case BASEAPP_TYPE:
		bundle.newMessage(BaseappInterface::onRegisterNewApp);
		BaseappInterface::onRegisterNewAppArgs8::staticAddToBundle(bundle, getUserUID(), getUsername(), BASEAPP_TYPE, componentID_, 
			this->getNetworkInterface().intaddr().ip, this->getNetworkInterface().intaddr().port, 
			this->getNetworkInterface().extaddr().ip, this->getNetworkInterface().extaddr().port);
		break;
	case CELLAPP_TYPE:
		bundle.newMessage(CellappInterface::onRegisterNewApp);
		CellappInterface::onRegisterNewAppArgs8::staticAddToBundle(bundle, getUserUID(), getUsername(), BASEAPP_TYPE, componentID_, 
			this->getNetworkInterface().intaddr().ip, this->getNetworkInterface().intaddr().port, 
			this->getNetworkInterface().extaddr().ip, this->getNetworkInterface().extaddr().port);
		break;
	default:
		KBE_ASSERT(false && "no support!\n");
		break;
	};
	
	bundle.send(this->getNetworkInterface(), cinfos->pChannel);
}
Ejemplo n.º 22
0
/*
** This one returns the configuration, useful for displaying information before running an attack.
** Basically just grabs information from the getters and puts it together in a more stylish way for terminal or log output.
**
** @return std::string
*/
std::string panda::getConfiguration()
{
    std::string config;
    config = "\n\n+--------------[AngryPanda Configuration]---------------\n|\n|\tHosts: \t\t" + stringify(getHosts());
    config += "\n|\tTarget count:\t\t" + stringify(getHostCount());
    config += "\n|\tPort:\t\t" + stringify(getPort());
    config += "\n|\tMode:\t\t" + stringify(getMode());
    config += "\n|\tTries/IP:\t" + stringify(getTries());

    if(arguments.mode)
    {
        config += "\n|\tWordlist:\t" + stringify(getWordlist());
        config += "\n|\tUsername:\t" + stringify(getUsername());
    }
    else
    {
        config += "\n|\tUsername:\t" + stringify(getUsername());
        config += "\n|\tPassword:\t" + stringify(getPassword());
    }
    return config;
}
Ejemplo n.º 23
0
bool Core::loadConfiguration()
{
    QString path = QDir(Settings::getSettingsDirPath()).filePath(CONFIG_FILE_NAME);

    QFile configurationFile(path);

    if (!configurationFile.exists()) {
        qWarning() << "The Tox configuration file was not found";
        return true;
    }

    if (!configurationFile.open(QIODevice::ReadOnly)) {
        qCritical() << "File " << path << " cannot be opened";
        return true;
    }

    qint64 fileSize = configurationFile.size();
    if (fileSize > 0) {
        QByteArray data = configurationFile.readAll();
        int error = tox_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size());
        if (error < 0)
        {
            qWarning() << "Core: tox_load failed with error "<<error;
        }
        else if (error == 1) // Encrypted data save
        {
            qWarning() << "Core: Can not open encrypted tox save";
            if (QMessageBox::Ok != QMessageBox::warning(nullptr, tr("Encrypted profile"),
                tr("Your tox profile seems to be encrypted, qTox can't open it\nDo you want to erase this profile ?"),
                QMessageBox::Ok | QMessageBox::Cancel))
            {
                qWarning() << "Core: Couldn't open encrypted save, giving up";
                configurationFile.close();
                return false;
            }
        }
    }

    configurationFile.close();

    // set GUI with user and statusmsg
    QString name = getUsername();
    if (name != "")
        emit usernameSet(name);
    
    QString msg = getStatusMessage();
    if (msg != "")
        emit statusMessageSet(msg);

    loadFriends();
    return true;
}
Ejemplo n.º 24
0
void IRCMsgThread::parseMessage(std::wstring message){
	//Old Style
	//:[email protected] PRIVMSG #ptken :what song is this ?
	//
	//New Style
	//@color=#FF4500;display-name=Gm470520;emotes=;mod=0;room-id=47281189;subscriber=1;turbo=0;user-id=24255667;user-type= :[email protected] PRIVMSG #tetristhegrandmaster3 :這片到底在沖三小w
	//@color=#1E90FF;display-name=pikads;emotes=;mod=1;room-id=24805060;subscriber=0;turbo=0;user-id=25141849;user-type=mod :[email protected] PRIVMSG #ptken :诶
	std::vector<std::wstring> firstParse = split(message,L' ',4);
    if(firstParse.size()<3) return; //Do Nothing
	//parse[0]=@color=#1E90FF;display-name=pikads;emotes=;mod=1;room-id=24805060;subscriber=0;turbo=0;user-id=25141849;user-type=mod
	//parse[1]=:[email protected]
	//parse[2]=PRIVMSG
	//parse[3]=#ptken
	//parse[4]=:诶
    if(!firstParse[2].compare(L"PRIVMSG")){
        std::vector<std::wstring> parse = split(message,L' ',5);
		if(parse.size() < 5) return; //discard this incomplete message
        /*
         * parse[1].substr(1): sender
         * parse[3]: target channel/user
         * parse[4].subString(1): message
         */
		//std::wstring sender = getUsername(parse[1].substr(1)); Old Style
		std::wstring sender = getUsername(parse[0].substr(1),parse[1].substr(1));
		std::wstring target = parse[3]; //maybe need .c_str(), but never used in the plugin
		std::wstring content = parse[4].substr(1);
        if(parse[3][0]==L'#'){
            if(!content.substr(0,8).compare(L"ACTION ")){
                //onChatAction(target, sender, replaceFirst(content.substr(8),L"", L"").c_str());
				onChatAction(target, sender, content);
            }else{
                onChatMsg(target, sender, false, content);
            }
        }else{
            onPrivateMsg(sender, content); //not sure about the number of tokens, but for a plugin, never mind.
        }
        
    }else if(!firstParse[1].compare(L"JOIN")){ //JOIN: LOG to [SYS]
        std::vector<std::wstring> parse = split(message,L' ',3);
		if(parse.size() < 3) return; //discard this incomplete message
        if(!(parse[2].compare(ToLowerString(ircbotPtr->lastIRCChannel)))){ //user succesffully joins a channel
//            onSysMsg(L"Joined %ls",parse[2]);
        }
	/*	else { //other users join the channel
			onIRCMsg(L"%ls Joined %ls\n",getUsername(parse[0].substr(1)).c_str(),parse[2].c_str());
		}*/
		
    }else if(!firstParse[1].compare(L"001")){ //login successful        
        ircbotPtr->loginSuccessful = true;
        ircbotPtr->onLoginSuccess();
    }
}
Ejemplo n.º 25
0
int ManagedDatasource::grabLock(ExceptionSink *xsink) {
   if (grabLockIntern() < 0) {
      endDBActionIntern();
      const char *un = getUsername();
      const char *db = getDBName();
      xsink->raiseException("TRANSACTION-LOCK-TIMEOUT", "%s:%s@%s: TID %d timed out on datasource '%s@%s' after waiting %d millisecond%s on transaction lock held by TID %d",
			    getDriverName(), getUsernameStr().c_str(), getDBNameStr().c_str(), 
			    gettid(), un ? un : "<n/a>", db ? db : "<n/a>", tl_timeout_ms, 
			    tl_timeout_ms == 1 ? "" : "s", tid);
      return -1;
   }
   return 0;
}
Ejemplo n.º 26
0
int main() {
	// initialize the variable to store the query string at
	char *data;
	FILE *dashboard;
	char line[1000];
	char *username;
	char *password;

	// Store the query string environment variable by CGI's GET
	data = getenv("QUERY_STRING");
	
	// get the username and password fields
	username = getUsername(data);
	password = getPassword(data);

	// Print the output to the browser
	printf("Content-Type:text/html\n\n");
	printf("<html>");

	// have the dashboard up and running on the cgi server
	// use fgets to read it line by line
	dashboard = fopen(DASHBOARD, "r+");

	// If the file does not exist, print error and exit program.
	if( dashboard == NULL ) {
		printf("<p>Error! Attempted to access invalid page %s</p>", DASHBOARD);
	}

	printf("<p> Data is: %s</p>\n", data);
	printf("<p> Username is %s</p>\n", username);
	printf("<p> Password is %s</p>\n", password);

	int validInput = validateInput(username, password);

	printf("<p> ValidInput is %d</p>\n", validInput);
	
	while(fgets(line, sizeof(line), dashboard) != NULL) {
		//printf("<p>hmm</p>\n");
		if(strstr(line, "</body>") != NULL) {
			printf("<p>true!!</p>\n");
			
			printf("%s\n", line);
		}
		else{
			printf("%s\n", line);
		}
	}
	fclose(dashboard);

	return 0;
}
Ejemplo n.º 27
0
SessionWidget::SessionWidget( QGraphicsItem * parent, Qt::WindowFlags wFlags)
  : QGraphicsWidget ( parent, wFlags)
{
  this->setFocusPolicy(Qt::ClickFocus);

   m_signalMapper = new QSignalMapper(this);

  QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
  mainLayout->setSpacing(0);
  mainLayout->addStretch();
  this->setLayout(mainLayout);

  connect( m_signalMapper, SIGNAL(mapped(int)),
           this, SLOT(slotSwitchSession(int)));

  Q_ASSERT(mainLayout->count() == 0);

  //Cache the icon pixmaps
  QSize iconSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);

  SessList sessions;
  KDisplayManager manager;
  manager.localSessions(sessions);

  QList<QGraphicsWidget*> entries;

  foreach(SessEnt session, sessions) {
    QPixmap pixmap;
    KUser user (session.user);
    if (!user.isValid())
      continue;

    if (session.tty)
      continue;

    Plasma::IconWidget* entry = createButton(this);
    pixmap = getUserIcon(user);

    entry->setIcon(pixmap);

    QString username = getUsername(false, user);
    entry->setText(username);

    connect(entry, SIGNAL(clicked()), m_signalMapper, SLOT(map()));
    m_signalMapper->setMapping(entry, session.vt);

    if (session.self)
      entry->setEnabled(false);

    entries << entry;
  }
Ejemplo n.º 28
0
repo::core::RepoBSON repo::core::RepoUser::command(const RepoBSONCommands &command) const
{
    mongo::BSONObjBuilder builder;

    //--------------------------------------------------------------------------
    // Command : Username
    // See http://docs.mongodb.org/manual/reference/command/
    switch(command)
    {
    case CREATE:
        builder << REPO_COMMAND_CREATE_USER << getUsername();
        break;
    case UPDATE:
        builder << REPO_COMMAND_UPDATE_USER << getUsername();
        break;
    case DROP :
        builder << REPO_COMMAND_DROP_USER << getUsername();
        break;
    }

    if (DROP != command)
    {
        //----------------------------------------------------------------------
        // Password
        std::string cleartextPassword = getCleartextPassword();
        if (!cleartextPassword.empty())
            builder << REPO_LABEL_PWD << getCleartextPassword();

        //----------------------------------------------------------------------
        // Custom data
        builder << REPO_LABEL_CUSTOM_DATA << getCustomDataBSON();

        //----------------------------------------------------------------------
        // Roles
        builder.appendArray(REPO_LABEL_ROLES, getRolesBSON());
    }
    return RepoBSON(builder.obj());
}
Ejemplo n.º 29
0
void ChatTests::testInviteNonexistent()
{
    QVERIFY(chat);

    QSignalSpy spy(chat.data(), SIGNAL(inviteCompleted(bool, QString)));
    QVERIFY(spy.isValid());
    QVERIFY(spy.isEmpty());

    QSharedPointer<const User> u(new User(getUsername("thisuserbetternotexist"),
                                          WORKING_DIR "public.pem"));
    chat->invite(u);
    waitForResult(spy);

    QCOMPARE(spy.count(), 1);
    QList<QVariant> arguments = spy.takeFirst();
    QVERIFY2(arguments.at(0) == false, arguments.at(1).toString().toStdString().c_str());
}
Ejemplo n.º 30
0
Archivo: core.cpp Proyecto: Pik-9/qTox
void Core::setUsername(const QString& username)
{
    if (username == getUsername())
        return;

    CString cUsername(username);

    if (!tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr))
    {
        emit failedToSetUsername(username);
        return;
    }

    emit usernameSet(username);
    if (ready)
        profile.saveToxSave();
}