Пример #1
0
JagunMSNConnection::JagunMSNConnection(JagunKETServer *parentServer,QUdpSocket *udpSocket, int lifeTime)
                   :JagunKETConnection(parentServer,udpSocket), time(lifeTime)
{
    //QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
    //QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    //QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

    connect(this, SIGNAL(disconnected() ), this, SLOT(disconnectedConnection() ) );
    connect(this, SIGNAL(error(JagunKET::EErrorJagunKET) ), this, SLOT(errorConnection(JagunKET::EErrorJagunKET) ) );
    connect(this, SIGNAL(receive(QByteArray *)), this, SLOT(readClient(QByteArray *)) );

    connect(&lifeTimer, SIGNAL(timeout() ), this, SLOT(timeout() ) );
    connect(&parserFromXML, SIGNAL(newUser(QString, QString, QString)), this, SLOT(newUser(QString, QString, QString)) );
    connect(&parserFromXML, SIGNAL(loginUser(QString, QString)), this, SLOT(loginUser(QString, QString)) );
    connect(&parserFromXML, SIGNAL(requestContactList() ), this, SLOT(requestContactList() ) );
    connect(&parserFromXML, SIGNAL(changeStatus(QString, QString, QString, int, QStringList) ), this, SLOT(changeStatus(QString, QString, QString, int, QStringList) ) );
    connect(&parserFromXML, SIGNAL(addContact(QString, QString) ), this, SLOT(addContact(QString, QString) ) );
    connect(&parserFromXML, SIGNAL(addContactConfirmation(QString, bool) ), this, SLOT(addContactConfirmation(QString, bool) ) );
    connect(&parserFromXML, SIGNAL(sendMessage(QStringList, QString, QDateTime) ), this, SLOT(sendMessage(QStringList, QString, QDateTime) ) );

    //lifeTimer.start(time);
    logged = false;
    db.createNewConnection();
    //TODO - seta todas as id das conexoes no banco para -1
}
Пример #2
0
QSharedPointer<User> QueryExecutor::insertNewUser(const QSharedPointer<User>& user)
{
  bool result;
  QSqlQuery newUserQuery(m_database);
  qlonglong newId = nextUserKey();
  syslog(LOG_INFO,"Generating token for new user, %s : %s",user->getLogin().toStdString().c_str()
    ,user->getPassword().toStdString().c_str());
  QString newToken = generateNewToken(user->getLogin(),user->getPassword());
  //  syslog(LOG_INFO,"newToken = %s",newToken.toStdString().c_str());
  newUserQuery.prepare("insert into users (id,login,password,token) values(:id,:login,:password,:a_t);");
  newUserQuery.bindValue(":id",newId);
  syslog(LOG_INFO,"Sending: %s",newUserQuery.lastQuery().toStdString().c_str());
  newUserQuery.bindValue(":login",user->getLogin());
  syslog(LOG_INFO,"Sending: %s",newUserQuery.lastQuery().toStdString().c_str());
  newUserQuery.bindValue(":password",user->getPassword());
  syslog(LOG_INFO,"Sending: %s",newUserQuery.lastQuery().toStdString().c_str());
  newUserQuery.bindValue(":a_t",newToken);
  syslog(LOG_INFO,"Sending: %s",newUserQuery.lastQuery().toStdString().c_str());
  m_database.transaction();
  result=newUserQuery.exec();
  if(!result)
  {
    syslog(LOG_INFO,"Rollback for NewUser sql query");
    m_database.rollback();
    return QSharedPointer<User>(NULL);
  }else
  {
    syslog(LOG_INFO,"Commit for NewUser sql query");
    m_database.commit();
  }
  QSharedPointer<DbUser> newUser(new DbUser(user->getLogin(),user->getPassword(),newId,newToken));
  return newUser;
}
Пример #3
0
/** \brief Funcion para dar de alta un usuario
 * \param usuarios: arraylist donde se guardan los usuarios
 * \return
 */
void altaUsuario(ArrayList *usuarios)
{
    char name[51];
    char pass[51];
    char mail[51];
    char nick[51];
    int id;
    User *usuario;

    printf("ALTA DE USUARIO\n==================\n");
    printf("Ingrese su nombre: ");
    gets(name);
    printf("Ingrese su nick: ");
    gets(nick);
    printf("Ingrese su contraseña: ");
    gets(pass);
    printf("Ingrese su eMail: ");
    gets(mail);

    id=usuarios->size;
    usuario = newUser(name, nick,pass,mail, id);
    usuarios->add(usuarios,usuario);

    printf("\n\nUSUARIO DADO DE ALTA! :) \n\n");
}
Пример #4
0
void addUser(LinkedList<User> *listOfUsers)
{
	string name, username, password;

	clearScreen();
	displayLogo();

	//The user is prompted for the appropriate information
	cout << "Please enter the name of the new user:\n\n";
	getline(cin, name);

	cout << "\nPlease enter the username of the new user:\n\n";
	getline(cin, username);

	cout << "\nPlease enter the password of the new user:\n\n";
	getline(cin, password);

	//A new user with the specified information is created
	User newUser(name, username, password);

	//The new user is added to the list of users
	listOfUsers->append(newUser);
	
	saveUsers(listOfUsers);
}
Пример #5
0
void addBookReader(library_t * self,const char * name,const char * readerName){

for(int i = 0;i<List_getSize(self->book);i++){
            book_t * tmpBook = List_get(self->book,i,NULL);
            if(strcmp(tmpBook->name,name)==0 && tmpBook->status == 0){

                user_t * tmpUser = newUser(readerName);
                //List_add(tmpBook->users,List_getSize(tmpBook->users)-1,tmpUser);

                List_t tmpList = tmpBook->users;
                List_add(tmpList,List_getSize(tmpList),tmpUser);


                //user_t * tmpUser1 = List_get(tmpList,List_getSize(tmpList)-1,NULL);
                //puts(tmpUser1->name);

                book_t * nB = newBookchangeParam(name,1,tmpBook->curDaysUsed,"day",tmpList);
                List_remove(self->book,i,NULL);
                List_add(self->book,i,nB);

                return;
            }
    }

}
Пример #6
0
  bool	Config::addUser(int32_t id, uint32_t token)
  {
    std::ofstream	file("conf/users.json");
    Json::Value		newUser(Json::objectValue);
    Json::StyledWriter	writer;
    Json::Value::UInt	i = _root["users"].size();

    if (!file.fail())
      {
    	if ((newUser["id"] = id) == Json::nullValue)
    	  return (false);
    	if ((newUser["token"] = token) == Json::nullValue)
    	  return (false);
    	if ((_root["users"][i] = newUser) == Json::nullValue)
    	  return (false);
    	file << writer.write(_root);
    	file.close();
    	return (true);
      }
    else
      {
    	std::cerr << "can't open the file" << std::endl;
    	return (false);
      }
  }
Пример #7
0
void Adresis::addUser(const QString& name, const QString& code,const QString& login,const QString& passwd,QMap<Logic::TypeUser, bool> permissions )
{
    dDebug() << "Adresis::addUser(const QString& name, const QString& code,const QString& login,const QString& passwd,QMap<Logic::TypeModule, bool> permissions )";
    ADUser newUser(name,  code, login,passwd, permissions);
    ADInsertPackage insert = newUser.insertPackage();
    m_connector->sendPackage( insert );
    getInfoModule(Logic::users);
}
Пример #8
0
	void dns_requester::incoming_message(connection& aConnection, const message& aMessage)
	{
		if (aMessage.command() != message::NICK)
			return;
		user oldUser(aMessage.origin(), aConnection);
		user newUser(oldUser);
		if (!aMessage.parameters().empty())
			newUser.nick_name() = aMessage.parameters()[0];
		nick_change(oldUser.nick_name(), newUser.nick_name());
	}
Пример #9
0
void Adresis::modifyUser(const QString& name, const QString& code,const QString& login, const QString& passwd, QMap<Logic::TypeUser, bool> permissions )
{
    D_FUNCINFO;
    ADUser newUser(name, code, login,passwd, permissions);
    ADUpdatePackage update = newUser.updatePackage();
    QString where = "loginuser = '******'";
    update.setWhere(where);
    m_connector->sendPackage( update );
    getInfoModule(Logic::users);
}
Пример #10
0
void createUsers::sendUser()
{
    QString userName = ui->nameEdit->toPlainText();
    bool fl = false;
    for (int i = 0; i < userName.size(); ++i)
        if (userName[i].toLatin1() != ' ')
            fl = true;
    if (fl){
        ui->nameEdit->setText("");
        emit newUser(userName);
    }
}
Пример #11
0
int User::createUser(const char* bytes, int length) {
    if((unsigned char)bytes[length - 1] == 0xff) {
        UserAttributes attribs = User::extractAttributes(bytes + 2, length - 2);
        if(attribs.location == 0) return -1;
        
        User newUser(attribs);
        newUser.save();
        
        return newUser.getID();
    }
    return -1;
}
Пример #12
0
bool AgendaService::userRegister(std::string userName, std::string password,
		  std::string email, std::string phone) {
  User newUser(userName, password, email, phone);
  std::list<User> result = \
    storage_->queryUser([=](const User& u){return u.getName() == userName;});
  if (result.size() != 0) {
    return false;
  } else {
    storage_->createUser(newUser);
    return true;
  }
}
Пример #13
0
MyChat::MyChat(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags)
{
	QHostAddress addr;
	Settings st(&myNick, &addr);
	st.exec();

	setupUi(this);
	lineEdit->setFocusPolicy(Qt::StrongFocus);
    textEdit->setReadOnly(true);
    listWidget->setFocusPolicy(Qt::NoFocus);

	engine = new NetworkEngine(myNick, addr);

	connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
    connect(engine, SIGNAL(newMessage(QString,QString)), this, SLOT(appendMessage(QString,QString)));
    connect(engine, SIGNAL(newUser(QString)), this, SLOT(newUser(QString)));
    connect(engine, SIGNAL(userLeft(QString)), this, SLOT(userLeft(QString)));

	tableFormat.setBorder(0);
	newUser(myNick);
}
Пример #14
0
/** \brief Permite modificar un usuario, ingresando el nick del mismo
 *         se puede alterar Nombre, Mail y/o Clave de acceso
 * \param usuarios: arraylist donde se guardan los usuarios
 * \return
 */
void modUsuario(ArrayList *usuarios)
{
    char nickAux[51];
    char nameAux[51];
    char passAux[51];
    char mailAux[51];
    int i;
    int flag = 0;
    User *usuario;

    if(usuarios->size==0)
    {
        printf("NO HAY USUARIOS!!!\n\n");
    }
    else
    {
        printf("MODIFICACION DE USUARIO\n=============================\n");
        printf("Ingrese su nick: ");
        gets(nickAux);
        fflush(stdin);
        for(i=0; i<usuarios->size; i++)
        {

            usuario = usuarios->get(usuarios,i);

            if(strcmp(nickAux,usuario->nick) == 0)
            {
                printf("Ingrese su nuevo nombre: ");
                gets(nameAux);
                printf("Ingrese su nueva contraseña: ");
                gets(passAux);
                printf("Ingrese su nuevo eMail: ");
                gets(mailAux);
                usuario = newUser(nameAux, usuario->nick,passAux,mailAux, usuario->id);

                usuarios->set(usuarios,usuario->id,usuario);
                flag =1;
            }
        }
        if(flag==0)
        {
            printf("\n\nNo se realizo la modificacion :(\n\n");
        }
        else
        {
            printf("\n\nSe realizo la modificacion :)\n\n");
        }
    }
}
// Add a new User (if the name is not used yet) to the Users list
bool EntityManager_AddUser(EntityManager *entityManager, const char *name) {
  userData *entity = NULL;

  if (entityManager == NULL || name == NULL) {
    snprintf(errStr, sizeof(errStr), "EntityManager_AddUser entityManager (isNull %d) and user name '%s' must not be NULL", entityManager == NULL, name);
    return false;
  }
  if (checkAddValidParams(entityManager, name) == false) return false;
  if (newUser(&entity, name) == false) return false;
  if (ItemsList_AddItem(entityManager->Users, name, entity) == false) {
    freeUser(entity);
    return false;
  }
  return EntityManager_AddUserToGroup(entityManager, ALL_ACL_NAME, name);
}
Пример #16
0
bool Storage::readFromFile(const char *fpath) {
  std::ifstream inFile;
  inFile.open(fpath);
  if (!inFile.is_open()) return false;

  std::string line;
  std::string collection;
  int total;
  std::getline(inFile, line);
  std::string totalString = getMessage(line, "total:", '}');
  std::stringstream ss;
  ss << totalString;
  ss >> total;
  ss.clear();
  for (int i = 0; i < total; i++) {
    std::getline(inFile, line);
    std::string name = getMessage(line, "name:\"", '\"');
    std::string password = getMessage(line, "password:\"", '\"');
    std::string email = getMessage(line, "email:\"", '\"');
    std::string phone = getMessage(line, "phone:\"", '\"');
    if (name == "" || password == "" || email == "" || phone == "") continue;
    User newUser(name, password, email, phone);
    createUser(newUser);
  }

  std::getline(inFile, line);
  totalString = getMessage(line, "total:", '}');
  ss << totalString;
  ss >> total;
  ss.clear();
  for (int i = 0; i < total; i++) {
    std::getline(inFile, line);
    std::string sponsor = getMessage(line, "sponsor:\"", '\"');
    std::string participator = getMessage(line, "participator:\"", '\"');
    std::string sdateString = getMessage(line, "sdate:\"", '\"');
    std::string edateString = getMessage(line, "edate:\"", '\"');
    std::string title = getMessage(line, "title:\"", '\"');

    Date sdate = Date::stringToDate(sdateString);
    Date edate = Date::stringToDate(edateString);
    if (sponsor == "" || participator == "" ||
        !Date::isValid(sdate) || !Date::isValid(edate)) continue;
    Meeting newMeeting(sponsor, participator, sdate, edate, title);
    createMeeting(newMeeting);
  }
  inFile.close();
  return true;
}
Пример #17
0
void Xmpp::vCardReceived (const QXmppVCardIq& vCard)
{
    QByteArray photo = vCard.photo();
    QBuffer buffer;
    buffer.setData (photo);
    buffer.open (QIODevice::ReadOnly);
    QImageReader imageReader (&buffer);
    QImage image = imageReader.read();

    if (image.isNull())
        image = QImage (":/faces/faces/generic-user.png");

    jids.append (vCard.from());
    users.append (vCard.fullName());

    emit newUser (vCard.fullName(), vCard.from(), image);
}
Пример #18
0
int Tcp::hasNewUser()
{
    struct User *user;
    quint32 ip;
    user = new struct User;
    int len;
    stream>>len;
    user->name.resize(len);
    stream>>user->name;
    stream>>ip;
    stream>>user->port;
    stream>>user->online;
    user->add.setAddress(ip);
    emit newUser(user);
    return 0;

}
Пример #19
0
PolkitInterface::PolkitInterface(QObject *parent) : PolkitQt1::Agent::Listener(parent)
{
    //Register our Polkit service on DBus
    new PolkitAuthAgentAdaptor(this);
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerService("org.thesuite.polkitAuthAgent");

    if (!QDBusConnection::sessionBus().registerObject("/org/thesuite/polkitAuthAgent", this,
                                                      QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportAdaptors)) {
        qDebug() << "Could not initiate Authentication Agent on DBus!";
    }

    //Create a new authentication window
    authWin = new Authenticate();
    connect(authWin, SIGNAL(okClicked()), this, SLOT(windowAccepted()));
    connect(authWin, SIGNAL(rejected()), this, SLOT(windowRejected()));
    connect(authWin, SIGNAL(newUser(PolkitQt1::Identity)), this, SLOT(setUser(PolkitQt1::Identity)));
}
Пример #20
0
void *processConnection(threadOptions *options) {
	char buf[2048];
	char type[128];
	int len;
	int sd = options->sd;
	free((void *)options);
	struct timeval tv;
	tv.tv_sec = 30;
	tv.tv_usec = 0;
	setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,  sizeof tv);
	len = recv(sd,buf,sizeof(buf),MSG_NOSIGNAL);
	if(len == -1) { //timeout
		sendError(sd,"The search has timedout");
		return NULL;
	}
	makeStringSafe((char *)&buf, sizeof(buf));
	if(!find_param(0, buf, type,sizeof(type))) {
		sendError(sd,"Error recieving request");
		return NULL;	
	}
	//TODO: pmatch(product matching), others(showing buddies),otherslist(wait until GPCM is implemented)
	if(stricmp(type,"valid") == 0) {
		checkEmailValid(sd,buf);
	} else if(stricmp(type,"nicks") == 0) {
		sendNicks(sd,buf);
	} else if(stricmp(type,"check") == 0) {
		checkNick(sd,buf);
	} else if(stricmp(type,"newuser") == 0) {
		newUser(sd,buf);
	} else if(stricmp(type,"search") == 0) { 
		searchUsers(sd,buf);
	} else if(stricmp(type,"others") == 0) {
		sendReverseBuddies(sd,buf);
	} else if(stricmp(type,"otherslist") == 0) {
		sendReverseBuddies(sd,buf);
	} else if(stricmp(type,"uniquesearch") == 0) { //nameinator
	} else if(stricmp(type,"profilelist") == 0) { //nameinator
	}else {
		sendError(sd,"Error recieving request");	
		return NULL;
	}
	close(sd);
	return NULL;
}
Пример #21
0
void helpBrowser::processPrintAll() {

  // to print all we prune the individual html help files by hand and then
  // concatenate them
  QRegExp head("<html>.*</head>");
  QRegExp next("Next: *<a.*\\n");
  next.setMinimal(true);
  QRegExp top("Top: *<a.*\\n");
  top.setMinimal(true);
  QRegExp previous("Previous: *<a.*\\n");
  previous.setMinimal(true);
  QRegExp foot("</body>.*");
  QRegExp newUser("<h1>New User.*</p>");
  newUser.setMinimal(true);
  QRegExp dmc("<h1>A Note On DMC.*</p>");
  dmc.setMinimal(true);

  QString overview(::readTextFile(":/overview.html"));
  overview.replace(next, "").replace(top, "").replace(previous, "").replace(foot, "");

  QString colorChooser(::readTextFile(":/colorChooser.html"));
  colorChooser.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "").replace(newUser, "").replace(dmc, "");

  QString colorcompare(::readTextFile(":/colorCompare.html"));
  colorcompare.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "");

  QString square(::readTextFile(":/square.html"));
  square.replace(head, "").replace(top, "").replace(previous, "").replace(next, "").replace(foot, "");

  QString pattern(::readTextFile(":/pattern.html"));
  pattern.replace(head, "").replace(top, "").replace(previous, "").replace(next, "");

  QString newText(overview + colorChooser + colorcompare + square + pattern);

  QPrinter printer;
  //printer.setOutputFileName("helpOutAll.pdf");
  QPrintDialog printDialog(&printer, this);
  const int dialogReturnCode = printDialog.exec();
  if (dialogReturnCode == QDialog::Accepted) {
    QTextEdit editor(newText);
    editor.print(&printer);
  }
}
Пример #22
0
void ViewConnection::setView()
{
    _parent->setUser();

    _labelIcon.setParent(_parent);
    _labelIcon.setPixmap(QPixmap("images/dislekclik.png"));
    _labelIcon.setAlignment(Qt::AlignCenter);
    _labelIcon.setGeometry(_parent->width()/2-250,_parent->height()/2-315,500,200);
    _labelIcon.setVisible(true);

    _label.setParent(_parent);
    _label.setText("Quel est ton prénom?");
    _label.setAlignment(Qt::AlignCenter);
    _label.setFont(QFont("Times New Roman", 24));
    _label.setGeometry(_parent->width()/2-150,_parent->height()/2-110,300,50);
    _label.setVisible(true);

    _comboBox.setParent(_parent);
    _comboBox.setGeometry(_parent->width()/2-200,_parent->height()/2-55, 400,50);
    _comboBox.setVisible(true);

    _buttonConnect.setParent(_parent);
    _buttonConnect.setText("Connecter");
    QObject::connect(&_buttonConnect, SIGNAL(clicked()),_parent,  SLOT(connect()));
    _buttonConnect.setGeometry(_parent->width()/2-75, _parent->height()/2+5, 150, 30);
    _buttonConnect.setVisible(true);

    _buttonNew.setParent(_parent);
    _buttonNew.setText("Nouvel utilisateur");
    QObject::connect(&_buttonNew, SIGNAL(clicked()),_parent,  SLOT(newUser()));
    _buttonNew.setGeometry(_parent->width()/2-75, _parent->height()/2+40, 150, 30);
    _buttonNew.setVisible(true);

    _buttonQuit.setParent(_parent);
    _buttonQuit.setText("Quitter");
    QObject::connect(&_buttonQuit, SIGNAL(clicked()),_parent,  SLOT(quit()));
    _buttonQuit.setGeometry(_parent->width()/2-75, _parent->height()/2+75, 150, 30);
    _buttonQuit.setVisible(true);
}
Пример #23
0
ReturnValues Users::addUser(
    const QString &name,
    const QString &surname,
    const QString &login,
    const QString &password,
    const QString &ipAddress)
{
    QList<User>::iterator it = m_users.begin();

    while (it != m_users.end())
    {
        if (login == (*it).getLogin())
        {
            return ReturnValues::loginBusy;
        }
        it++;
    }

    User newUser(name,surname,login,password,ipAddress);
    m_users.push_back(newUser);

    return registered;
}
Пример #24
0
void VKStorage::addUser(QSharedPointer<VKContainerUser> user) {
    //FIXME
    qDebug()<<user->id()<<user->firstName()<<user->lastName();
    m_users[user->id()] = user;
    emit newUser(user->id(), user);
}
Пример #25
0
shared_ptr<User> Model::createNewUser(const string &userName, int port, string IP) {
    shared_ptr<User> newUser(new User(usersCounter++, port, IP, userName));
    users[newUser->getID()] = newUser;

    return newUser;
}
Пример #26
0
/* -------------------------------------------------------------------- */
void loginNew(char *initials, char *password)
{
    int i; 
    ulong newpointer;
    
    if (getYesNo(cfg.l_verified ? " No record: Enter as new user" 
                                : " No record: Request access", 1))
    {
        if (!CARRIER) return;
        
        if (cfg.l_closedsys && (!sysopNew && !(onConsole && !debug)))
        {
            tutorial("closesys.blb");
            drop_dtr();
            return;
        }
        
        tutorial("userinfo.blb");
        
        if (cfg.l_create || sysopNew || (onConsole && !debug))
        {
            logBuf.VERIFIED = (onConsole && !debug) ? FALSE : !cfg.l_verified;
            newUser(initials, password);
            if (!loggedIn)
                return;
            newaccount();
            update25();
        }

        if (cfg.l_questionare && (!(onConsole && !debug)))
        {
            newUserFile();
        }

        if (cfg.l_application && (!(onConsole && !debug)))
        {
            if (changedir(cfg.aplpath) == ERROR)
            {
                mPrintf("  -- Can't find application directory.\n\n");
                changedir(cfg.homepath);
                return;
            }
            apsystem(cfg.newuserapp);
            changedir(cfg.homepath);
        }

        if (cfg.l_sysop_msg && (!(onConsole && !debug)))
        {
            tutorial("newmsg.blb");
            
            i = loggedIn;       /* force to sysop */
            loggedIn = FALSE; 
            mailFlag  = TRUE; 
            oldFlag   = FALSE;
            limitFlag = FALSE;
            linkMess  = FALSE;
            makeMessage();
            loggedIn = (uchar)i;
        }
        
        if (logBuf.VERIFIED && !sysopNew && loggedIn)
        {
            verbose = FALSE;
            terminate(TRUE);
            mPrintf("\n Thank you, Good Bye.\n");
            Hangup();
        }
    }



/**********************************************************************/
/* Icky Hack designed to make #oldcount functional                    */
/* this was moved here because for some reason making messages        */
/* was causing the pointers to get screwed up                         */
/**********************************************************************/

    if (cfg.oldcount)
    {
        newpointer = (cfg.newest - cfg.oldcount);
        if (newpointer < cfg.oldest)  newpointer = cfg.oldest;

        /* logBuf.lbvisit[0] = newpointer; */ /* pushed down later by setlbvisit() */

        for (i = 0; i < MAXROOMS;  i++)
        {
            logBuf.newpointer[i] = newpointer;

            /* logBuf.lbroom[i].lvisit = 0; */ /* becomes==1 later by setlbvisit() */
        }
    }

/**********************************************************************/
/* ^^^ Disgusting? Wasn't it?  ^^^ Hope it works!                     */
/**********************************************************************/
    
    sysopNew = FALSE;
    
    return;
}
Пример #27
0
void Skype::skypeMessage(const QString &message) {
	kdDebug(14311) << k_funcinfo << endl;//some debug info

	QString messageType = message.section(' ', 0, 0).stripWhiteSpace().upper();//get the first part of the message
	if (messageType == "CONNSTATUS") {//the connection status
		QString value = message.section(' ', 1, 1).stripWhiteSpace().upper();//get the second part of the message
		if (value == "OFFLINE")
			d->connStatus = csOffline;
		else if (value == "CONNECTING")
			d->connStatus = csConnecting;
		else if (value == "PAUSING")
			d->connStatus = csPausing;
		else if (value == "ONLINE")
			d->connStatus = csOnline;
		else if (value == "LOGGEDOUT")
			d->connStatus = csLoggedOut;

		resetStatus();//set new status
	} else if (messageType == "USERSTATUS") {//Status of this user
		QString value = message.section(' ', 1, 1).stripWhiteSpace().upper();//get the second part
		if (value == "UNKNOWN")
			d->onlineStatus = usUnknown;
		else if (value == "OFFLINE")
			d->onlineStatus = usOffline;
		else if (value == "ONLINE")
			d->onlineStatus = usOnline;
		else if (value == "SKYPEME")
			d->onlineStatus = usSkypeMe;
		else if (value == "AWAY")
			d->onlineStatus = usAway;
		else if (value == "NA")
			d->onlineStatus = usNA;
		else if (value == "DND")
			d->onlineStatus = usDND;
		else if (value == "INVISIBLE")
			d->onlineStatus = usInvisible;

		resetStatus();
	} else if (messageType == "USERS") {//some user info
		QString theRest = message.section(' ', 1).stripWhiteSpace();//take the rest
		if (d->searchFor == "FRIENDS") {//it was initial search for al users
			QStringList names = QStringList::split(",", theRest);//divide it into names by comas
			kdDebug(14311) << "Names: " << names << endl;//write what you have done with that
			for (QStringList::iterator it = names.begin(); it != names.end(); ++it) {//run trough the names
				QString name = (*it).stripWhiteSpace();//get the name only
				if (name.isEmpty())
					continue;//just skip the empty names
				emit newUser(name);//add the user to list
			}
			if (d->scanForUnread)
				search("MISSEDMESSAGES");
		}
	} else if (messageType == "USER") {//This is for some contact
		const QString &contactId = message.section(' ', 1, 1);//take the second part, it is the user name
		const QString &type = message.section(' ', 2, 2).stripWhiteSpace().upper();//get what it is
		if ((type == "FULLNAME") || (type == "DISPLAYNAME") || (type == "SEX") ||
			(type == "PHONE_HOME") || (type == "PHONE_OFFICE") ||
			(type == "PHONE_MOBILE") ||
			(type == "ONLINESTATUS") || (type == "BUDDYSTATUS") || (type == "HOMEPAGE")) {
			const QString &info = message.section(' ', 2);//and the rest is just the message for that contact
			emit contactInfo(contactId, info);//and let the contact know
		} else kdDebug(14311) << "Unknown message for contact, ignored" << endl;
	} else if (messageType == "CHATMESSAGE") {//something with message, maebe incoming/sent
		QString messageId = message.section(' ', 1, 1).stripWhiteSpace();//get the second part of message - it is the message ID
		QString type = message.section(' ', 2, 2).stripWhiteSpace().upper();//This part significates what about the message are we talking about (status, body, etc..)
		QString chatMessageType = (d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper();
		if (chatMessageType == "ADDEDMEMBERS") {
			QString status = message.section(' ', 3, 3).stripWhiteSpace().upper();
			if (d->recvMessages.find(messageId) != d->recvMessages.end())
				return;
			d->recvMessages << messageId;
			const QString &users = (d->connection % QString("GET CHATMESSAGE %1 USERS").arg(messageId)).section(' ', 3).stripWhiteSpace();
			QStringList splitUsers = QStringList::split(' ', users);
			const QString &chatId = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace();
			for (QStringList::iterator it = splitUsers.begin(); it != splitUsers.end(); ++it) {
				if ((*it).upper() == getMyself().upper())
					continue;
				emit joinUser(chatId, *it);
			}
			return;
		} else if (chatMessageType == "LEFT") {
			QString status = message.section(' ', 3, 3).stripWhiteSpace().upper();
			if (d->recvMessages.find(messageId) != d->recvMessages.end())
				return;
			d->recvMessages << messageId;
			const QString &chatId = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace();
			const QString &chatType = (d->connection % QString("GET CHAT %1 STATUS").arg(chatId)).section(' ', 3, 3).stripWhiteSpace().upper();
			if ((chatType == "DIALOG") || (chatType == "LEGACY_DIALOG"))
				return;
			const QString &user = (d->connection % QString("GET CHATMESSAGE %1 FROM_HANDLE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace();
			const QString &reason = (d->connection % QString("GET CHATMESSAGE %1 LEAVEREASON").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper();
			QString showReason = i18n("Unknown");
			if (reason == "USER_NOT_FOUND") {
				showReason = i18n("User not found");
			} else if (reason == "USER_INCAPABLE") {
				showReason = i18n("Does not have multi-user chat capability");
			} else if ((reason == "ADDER_MUST_BE_FRIEND") || ("ADDER_MUST_BE_AUTHORIZED")) {
				showReason = i18n("Chat denied");
			} else if (reason == "UNSUBSCRIBE") {
				showReason = "";
			}
			if (user.upper() == getMyself().upper())
				return;
			emit leftUser(chatId, user, showReason);
			return;
		}
		if (type == "STATUS") {//OK, status of some message has changed, check what is it
			QString value = message.section(' ', 3, 3).stripWhiteSpace().upper();//get the last part, what status it is
			if (value == "RECEIVED") {//OK, received new message, possibly read it
				if (chatMessageType == "SAID") {//OK, it is some IM
					hitchHike(messageId);//receive the message
				}
			} else if (value == "SENDING") {
				if ((d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper() == "SAID") {
					emit gotMessageId(messageId);
				}
			} else if (value == "SENT") {//Sendign out some message, that means it is a new one
				if ((d->connection % QString("GET CHATMESSAGE %1 TYPE").arg(messageId)).section(' ', 3, 3).stripWhiteSpace().upper() == "SAID")//it is some message I'm interested in
					emit gotMessageId(messageId);//Someone may be interested in its ID
					if (d->recvMessages.find(messageId) != d->recvMessages.end())
						return;//we already got this one
					d->recvMessages << messageId;
					const QString &chat = (d->connection % QString("GET CHATMESSAGE %1 CHATNAME").arg(messageId)).section(' ', 3, 3).stripWhiteSpace();
					const QString &body = (d->connection % QString("GET CHATMESSAGE %1 BODY").arg(messageId)).section(' ', 3);
					if (!body.isEmpty())//sometimes skype shows empty messages, just ignore them
						emit outgoingMessage(body, chat);
			}
		}
	} else if (messageType == "CHATMESSAGES") {
		if (d->searchFor == "MISSEDMESSAGES") {//Theese are messages we did not read yet
			QStringList messages = QStringList::split(' ', message.section(' ', 1));//get the meassage IDs
			for (QStringList::iterator it = messages.begin(); it != messages.end(); ++it) {
				QString Id = (*it).stripWhiteSpace();
				if (Id.isEmpty())
					continue;
				skypeMessage(QString("CHATMESSAGE %1 STATUS RECEIVED").arg(Id));//simulate incoming message notification
			}
		}
	} else if (messageType == "CALL") {
		const QString &callId = message.section(' ', 1, 1).stripWhiteSpace();
		if (message.section(' ', 2, 2).stripWhiteSpace().upper() == "CONF_ID") {
			if (d->knownCalls.findIndex(callId) == -1) {//new call
				d->knownCalls << callId;
				const QString &userId = (d->connection % QString("GET CALL %1 PARTNER_HANDLE").arg(callId)).section(' ', 3, 3).stripWhiteSpace();
				emit newCall(callId, userId);
			}
			const QString &confId = message.section(' ', 3, 3).stripWhiteSpace().upper();
			if (confId != "0") {//It is an conference
				emit groupCall(callId, confId);
			}
		}
		if (message.section(' ', 2, 2).stripWhiteSpace().upper() == "STATUS") {
			if (d->knownCalls.findIndex(callId) == -1) {//new call
				d->knownCalls << callId;
				const QString &userId = (d->connection % QString("GET CALL %1 PARTNER_HANDLE").arg(callId)).section(' ', 3, 3).stripWhiteSpace();
				emit newCall(callId, userId);
			}
			const QString &status = message.section(' ', 3, 3).stripWhiteSpace().upper();
			if (status == "FAILED") {
				int reason = (d->connection % QString("GET CALL %1 FAILUREREASON").arg(callId)).section(' ', 3, 3).stripWhiteSpace().toInt();
				QString errorText = i18n("Unknown error");
				switch (reason) {
					case 1:
						errorText = i18n("Misc error");
						break;
					case 2:
						errorText = i18n("User or phone number does not exist");
						break;
					case 3:
						errorText = i18n("User is offline");
						break;
					case 4:
						errorText = i18n("No proxy found");
						break;
					case 5:
						errorText = i18n("Session terminated");
						break;
					case 6:
						errorText = i18n("No common codec found");
						break;
					case 7:
						errorText = i18n("Sound I/O error");
						break;
					case 8:
						errorText = i18n("Problem with remote sound device");
						break;
					case 9:
						errorText = i18n("Call blocked by recipient");
						break;
					case 10:
						errorText = i18n("Recipient not a friend");
						break;
					case 11:
						errorText = i18n("User not authorized by recipient");
						break;
					case 12:
						errorText = i18n("Sound recording error");
						break;
				}
				emit callError(callId, errorText);
			}
			emit callStatus(callId, status);
		}
	} else if (messageType == "CURRENTUSERHANDLE") {
		QString user = message.section(' ', 1, 1).stripWhiteSpace();
		QString name = (d->connection % QString("GET USER %1 DISPLAYNAME").arg(user)).section(' ', 3).stripWhiteSpace();
		if (name.isEmpty())
			name = (d->connection % QString("GET USER %1 FULLNAME").arg(user)).section(' ', 3).stripWhiteSpace();
		if (name.isEmpty())
			name = user;
		emit setMyselfName(name);
	}
}
Пример #28
0
int action(char** TabArgs,char** TabFonction,superBlock *sb, int *argInode,int nbfonction, int *userCo){
	int i,NbInstruction=-1,k;

	for(i=0;i<nbfonction;i++){
		if(strcmp(TabArgs[0],TabFonction[i])==0)
			NbInstruction=i;
			}

	switch(NbInstruction){
		case 0://touch
		touch(sb,*argInode,TabArgs[1],*userCo);
		
		break;

		case 1://cat

		cat(sb,chemin(sb,*argInode,TabArgs[1]),*userCo);
		
		break;
		
		case 2://ls
	
		ls(sb,*argInode);		

		break;

		case 3://rm

		unlink(sb,chemin(sb,*argInode, TabArgs[1]),*argInode,*userCo);
		break;	
		case 4://mkdir

		mkdir(sb,*argInode,TabArgs[1],*userCo);
		break;	
		case 5://cd
			*argInode=cd(sb,*argInode,TabArgs[1],*userCo); 
		break;
		case 6://newU
		if(TabArgs[1]!=NULL && TabArgs[2]!=NULL)
		    newUser(sb,TabArgs[1], TabArgs[2]); 
		break;
		case 7://changeU
		if(TabArgs[1]!=NULL && TabArgs[2]!=NULL){
		    int res =connexion(sb,TabArgs[1], TabArgs[2]); 
		    if(res !=-1){
				*userCo=res;
			}
		}
		break;
		case 8://tableU
		    tableUser(sb,*userCo);
		break;
		case 9://chmod
			if(TabArgs[1]!=NULL && TabArgs[2]!= NULL && TabArgs[3]!= NULL)
				chmod(sb,chemin(sb,*argInode,TabArgs[1]), *userCo,atoi(TabArgs[2]), atoi(TabArgs[3]));
		break;
		case 10: //help
			
			printf("commandes : \n");
			for(k;k<NbInstruction;k++){
				printf("%s\t",TabFonction[k]);
			}
			printf("\n");
		break;
		case 11:
			printf("bye\n");
			exit(0);
		break;
		case 12://ln
			ln(sb, chemin(sb,*argInode,TabArgs[1]), chemin(sb,*argInode,TabArgs[3]), TabArgs[2],*userCo);
		break;
		case 13://cp
		    cp(sb,chemin(sb,*argInode,TabArgs[1]),TabArgs[2],chemin(sb,*argInode,TabArgs[3]),*userCo);
		break;
		case 14://echo
			if(chemin(sb,*argInode,TabArgs[1])!=0)
			{
				echo(sb,chemin(sb,*argInode,TabArgs[1]),*userCo);
			}
		break;
		case 15://mv
		    mv(sb,*argInode,chemin(sb,*argInode,TabArgs[1]),chemin(sb,*argInode,TabArgs[3]),TabArgs[2],*userCo);
		break;
		case 16://tableI
			toStringInode(sb);
		break;
		case 17://tableF
			toStringBlocksF(sb);
		break;
		case 18://df
			df(sb);
		break;
		case 19://delU
			if(TabArgs[1]!=NULL)
			delUser(sb, *userCo, TabArgs[1]);
		break;
		case 20://changeP
			if(TabArgs[1]!=NULL)
			delUser(sb, *userCo, TabArgs[2]);
		break;
default:
printf("action non reconnue\n");
break;
	
		}
		
	return 1;
}
Пример #29
0
void* thread1(int sock){
	printf("New client\n");
	char buffer[256];
	int n;
	char str[50];
		char result[50];
		FILE *file;
		int i, numberTrueAnswer = 0;
		char *clientFile = "/home/user/workspace/server/registration.txt";
		int numberTest = 0;
		char *name = (char*) malloc(50 * sizeof(char));
		while (1) {
				bzero(buffer, 256);
				n = read(sock, buffer, 1);
				if (n < 0) {
					perror("ERROR reading from socket");
					exit(1);
				}
				n = write(sock, buffer, 1);
				if (n < 0) {
					perror("ERROR writing to socket");
					exit(1);
			}
				if (buffer[0] == '!')
					break;
		}
			//Registration
			int numberClient;
			int clientSize = sizeFile(clientFile);
			struct Client c[50];
			file = fopen(clientFile, "r");
			if (file == NULL) {
				perror("ERROR open file");
				exit(1);
			}
			for (i = 0; fgets(str, sizeof(str), file); i++) {
				writeSizeClient(&c[i], &str);
			}
			fclose(file);
			char bufferNew[256];
			numberClient = -1;
			bzero(buffer, 256);
			bzero(bufferNew, 256);
			n = read(sock, buffer, 255);
			if (n < 0) {
				perror("ERROR reading from socket");
				exit(1);
			}
			for (i = 0; i < strlen(buffer) - 1; i++)
				bufferNew[i] = buffer[i];
			for (i = 0; i < clientSize; i++) {
				if (strcmp(bufferNew, c[i].login) == NULL) {
					numberClient = i;
					break;
				}
			}
			//New client
			if (numberClient == -1) {
				clientSize++;
				struct Client client;
				newUser(bufferNew, &client);
				c[clientSize - 1] = client;
				numberClient = clientSize - 1;
			}
			char strres[50];
			sprintf(strres,"%d#%d#%d#%s/\n",c[numberClient].numberTest,
					c[numberClient].sizeQuestion,c[numberClient].sizeTrueAnswer,c[numberClient].login);
			strcpy(result ,strres);
			n = write(sock, result, strlen(result));
				if (n < 0) {
					perror("ERROR writing to socket");
					exit(1);
				}
			//List of test
			while (1) {
				bzero(buffer, 256);
								n = read(sock, buffer, 1);
								if (n < 0) {
									perror("ERROR reading from socket");
									exit(1);
								}
								n = write(sock, buffer, 1);
								if (n < 0) {
									perror("ERROR writing to socket");
									exit(1);
							}
								if (buffer[0] == '1')
									break;
			}
			char res[60]="/" ;
			char s[3];
			for (i = 50; i >0; i--) {
				sprintf(name, "%s%d%s", "/home/user/workspace/server/test/", i, ".txt");
				if ((file = fopen(name, "r")) != NULL) {
					sprintf(s, "#%d", i);
					strcat(res, s);
					fclose(file);
				}
			}
			n = write(sock, res, strlen(res));
			if (n < 0) {
				perror("ERROR writing to socket");
				exit(1);
			}

		//Number test
			bzero(buffer, 256);
				n = read(sock, buffer, 255);
				if (n < 0) {
					perror("ERROR reading from socket");
					exit(1);
				}
				numberTest=toInt(buffer);
				sprintf(name, "%s%d%s", "/home/user/workspace/server/test/", numberTest,
						".txt");
				file = fopen(name, "r");
			int testSize = sizeFile(name);
			int trueAnswer;
			file = fopen(name, "r");
			if (file == NULL) {
				perror("ERROR open file");
				exit(1);
			}
			int end=0;
			while(1){
				if(!fgets(str, sizeof(str), file))
					end=1;
				while (1) {
								bzero(buffer, 256);
												n = read(sock, buffer, 1);
												if (n < 0) {
													perror("ERROR reading from socket");
													exit(1);
												}
												if(end)
													buffer[0]='/';
												n = write(sock, buffer, 1);
												if (n < 0) {
													perror("ERROR writing to socket");
													exit(1);
											}
												if (buffer[0] == '2' || buffer[0] == '/')
													break;
							}
				if(end)
					break;
				trueAnswer=readTrueAnswer(str);
				n = write(sock, str, strlen(str));
					if (n < 0) {
						perror("ERROR writing to socket");
						exit(1);
					}
					//Answer
				bzero(buffer, 256);
				n = read(sock, buffer, 1);
				if (n < 0) {
					perror("ERROR reading from socket");
					exit(1);
				}
				printf("Answer: %s\n", buffer);
				if (buffer[0] == trueAnswer+'0') {
					n = write(sock, "Right\n", 6);
					if (n < 0) {
						perror("ERROR writing to socket");
						exit(1);
					}
					numberTrueAnswer = numberTrueAnswer + 1;
				} else
					n = write(sock, "Wrong\n", 6);
				if (n < 0) {
					perror("ERROR writing to socket");
					exit(1);
				}
			}
			sprintf(name, "%d#%d#%d#%s/", numberTest,testSize, numberTrueAnswer,c[numberClient].login);
			n = write(sock, name, strlen(name));
			if (n < 0) {
				perror("ERROR writing to socket");
				exit(1);
			}


			newResult(&c[numberClient], numberTest, testSize, numberTrueAnswer);
			file = fopen("/home/user/workspace/server/registration.txt", "w");
			if (file == NULL) {
				perror("ERROR open file");
				exit(1);
			}
			for (i = 0; i < clientSize; i++) {
				fprintf(file, "%d#%d#%d#%s/\n", c[i].numberTest, c[i].sizeQuestion,
						c[i].sizeTrueAnswer, c[i].login);
			};
			fclose(file);
			free(name);
}
void PGENET_UserManager::registerUser(const QString &name, std::shared_ptr<PGENETLL_Session> sessionObj)
{
    std::unique_ptr<PGENET_ServerUser> newUser(new PGENET_ServerUser(name));
    newUser->setSession(sessionObj);
    m_regUsers.push_back(std::move(newUser));
}