Пример #1
0
bool MySqlStorage::contactExists(QString jid, QString contactJid)
{
    int user_id = getUserId(jid);

    if (user_id == -1)
        return false;

    QSqlQuery query;
    query.prepare("SELECT id FROM qjabberd_contact WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.exec();
    return query.first();
}
Пример #2
0
bool MySqlStorage::addItemsToPrivacyList(QString jid, QString privacyListName, QList<PrivacyListItem> items)
{
    int user_id = getUserId(jid);

    m_database.transaction();

    QJsonDocument document;
    QJsonObject object;
    foreach (PrivacyListItem item, items)
    {
        object.insert("childs", QJsonArray::fromStringList(QStringList::fromSet(item.getChildsElement())));
        document.setObject(object);

        QSqlQuery query;
        query.prepare("INSERT INTO qjabberd_privacylist(user_id, ptype, pvalue, action, iorder, child, privacyListName)"
                      " VALUES(:user_id, :ptype, :pvalue, :action, :iorder, :child, :privacyListName)");
        query.bindValue(":user_id", user_id);
        query.bindValue(":ptype", item.getType());
        query.bindValue(":pvalue", item.getValue());
        query.bindValue(":action", item.getAction());
        query.bindValue(":iorder", item.getOrder());
        query.bindValue(":child", document.toJson());
        query.bindValue(":privacyListName", privacyListName);
        query.exec();
    }
Пример #3
0
int
checkPermissionByObjType( rsComm_t *rsComm, char *objName, char *objType, char *user, char *zone, char *oper ) {
    int i;
    int operId;
    int userId;
    operId = getTokenId( rsComm, "access_type", oper );
    if ( operId < 0 ) {
        return operId;
    }

    userId = getUserId( rsComm, user, zone );
    if ( userId < 0 ) {
        return userId;
    }

    if ( !strcmp( objType, "-d" ) ) {
        i = checkPermitForDataObject( rsComm, objName, userId, operId );
    }
    else  if ( !strcmp( objType, "-c" ) ) {
        i = checkPermitForCollection( rsComm, objName, userId, operId );
    }
    else  if ( !strcmp( objType, "-r" ) ) {
        i = checkPermitForResource( rsComm, objName, userId, operId );
    }
    /*
    else  if (!strcmp(objType,"-m"))
      i = checkPermitForMetadata(rsComm, objName, userId, operId);
    */
    else {
        i = INVALID_OBJECT_TYPE;
    }
    return i;
}
Пример #4
0
bool MySqlStorage::updateSubscriptionToContact(QString jid, QString contactJid,
                                         QString subscription)
{
    if (!contactExists(jid, contactJid))
    {
        Contact contact("", false, "", contactJid, "", subscription, QSet<QString>());
        return addContactToRoster(jid, contact);
    }

    QString contactSubscription = getContact(jid, contactJid).getSubscription();

    QSqlQuery query;
    query.prepare("UPDATE qjabberd_contact SET subscription = :subscription WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);

    if (((subscription == "from") && (contactSubscription == "to")) ||
            ((subscription == "to") && (contactSubscription == "from")))
    {
        query.bindValue(":subscription", "both");
    }
    else
    {
        query.bindValue(":subscription", subscription);
    }
    return query.exec();
}
Пример #5
0
bool MySqlStorage::addContactToRoster(QString jid, Contact contact)
{
    if (contactExists(jid, contact.getJid()))
    {
        updateNameToContact(jid, contact.getJid(), contact.getName());
        updateGroupToContact(jid, contact.getJid(), contact.getGroups());
        return true;
    }
    else
    {
        if (userExists(contact.getJid()))
        {
            QJsonDocument document;
            QJsonObject object;
            object.insert("groups", QJsonArray::fromStringList(QStringList::fromSet(contact.getGroups())));
            document.setObject(object);

            QSqlQuery query;
            query.prepare("INSERT INTO qjabberd_contact(user_id, approved, ask, groups, jid, name, subscription, version)"
                          " VALUES(:user_id, :approved, :ask, :groups, :jid, :name, :subscription, :version)");
            query.bindValue(":user_id", getUserId(jid));
            query.bindValue(":version", contact.getVersion());
            query.bindValue(":approved", (int)contact.getApproved());
            query.bindValue(":ask", contact.getAsk());
            query.bindValue(":jid", contact.getJid());
            query.bindValue(":name", contact.getName());
            query.bindValue(":subscription", contact.getSubscription());
            query.bindValue(":groups", document.toJson());
            return query.exec();
        }
    }
    return false;
}
Пример #6
0
int MDSubscribeRequest::serialize(char* buf)
{
  int bytes = 0;
  UNSIGNED_CHARACTER tmpChar = 0;
  UNSIGNED_LONG tmpLong = 0;
  UNSIGNED_SHORT tmpShort = 0;

  bytes = sizeof(UNSIGNED_SHORT);  // Leave 2 bytes for packet size
  
  // Put category of command
  SERIALIZE_8(tmpChar, 
      (UNSIGNED_CHARACTER)(CMD::CommandCategory_MARKET_DATA_SUBSCRIPTION), 
      buf, 
      bytes);  //Command Category

  // Put fields of this class
  SERIALIZE_16(tmpShort, isSubscriptionReq(), buf, bytes);
  SERIALIZE_64(tmpLong, getSymbolId(), buf, bytes);
  //memcpy(buf + bytes, getLoginToken(), TOKEN_LENGTH);
  SERIALIZE_16(tmpShort, getUserId(), buf, bytes);
  
  UNSIGNED_SHORT dummyBytes = 0;
  // Put size as the first field after deducting 2 bytes reserved for size
  SERIALIZE_16(tmpShort, (UNSIGNED_SHORT)(bytes-sizeof(UNSIGNED_SHORT)), buf, dummyBytes);

  return bytes;
}
/*---------------------------------------------------------------------*//**
	セットのコール ⇒ js_SetSprop
**//*---------------------------------------------------------------------*/
bool EsScopeProperty::callSetProperty(EsContext* ctx, EsObject* obj, const EsValue* val)
{
	ASSERT(_funcSetter != 0L);
	if(_funcSetter == 0L)	{	return false;	}

	if(TFW_IS_FLAG(_atrbf, ATRBF_OBJ_SETTER))
	{
		// ※※※ 実装保留 ※※※ ⇒ js_CastAsObjectJSVal, js_InternalGetOrSet
		ASSERT(false);
		return false;
	}
	if(TFW_IS_FLAG(_atrbf, ATRBF_OBJ_GETTER))
	{
		// ※※※ 実装保留 ※※※ ⇒ js_ReportGetterOnlyAssignment
		ASSERT(false);
		return false;
	}

	if(obj->getClass()->getClassType() == EsSysClasses::CLASSTYPE_WITH)
	{
		obj = obj->getThisObjectOv(ctx);
	}

	EsValue valUserId(getUserId());
	return _funcSetter(ctx, obj, &valUserId, val);
}
Пример #8
0
long ServicesDb::insertUser(QString email, QString displayName)
{
  if (_insertUser == 0)
  {
    _insertUser.reset(new QSqlQuery(_db));
    _insertUser->prepare("INSERT INTO users (email, display_name) "
                        "VALUES (:email, :display_name) "
                        "RETURNING id");
  }
  _insertUser->bindValue(":email", email);
  _insertUser->bindValue(":display_name", displayName);

  long id = -1;
  // if we failed to execute the query the first time
  if (_insertUser->exec() == false)
  {
    // it may be that another process beat us to it and the user was already inserted. This can
    // happen if a bunch of converts are run in parallel. See #3588
    id = getUserId(email, false);

    // nope, there is something else wrong. Report an error.
    if (id == -1)
    {
      QString err = QString("Error executing query: %1 (%2)").arg(_insertUser->executedQuery()).
          arg(_insertUser->lastError().text());
      LOG_WARN(err)
      throw HootException(err);
    }
    else
    {
      LOG_DEBUG("Did not insert user, queryied a previously created user.")
    }
  }
Пример #9
0
ParticleCellSampler::ParticleCellSampler(const ParticleSamplerObject* definition, const Source* source)
         : ParticleSampler(definition,source),
           max_samples(source->getEnvironment()->getSetting<size_t>("max_source_samples","value")) {

	/* Get cells */
	try {
		cells = source->getEnvironment()->getObject<Geometry,Cell>(definition->getCellId());
	} catch (exception& error) {
		throw(BadSamplerCreation(getUserId(),error.what()));
	}
	/*
	 * We have a problem here... From all the distributions given by the user, we should
	 * find out which ones are related to the position variable in phase space. And reject
	 * or accept the particles based on the cell specified ONLY sampling the distributions that
	 * change the position of the particle.
	 */
	for(vector<DistributionBase*>::const_iterator it = distributions.begin() ; it != distributions.end() ; ++it) {
		/* Find positions distributions */
		if(isPositionDistribution(*it))
			/* Push to the container */
			pos_distributions.push_back((*it));
	}
	/* Remove those from the original container */
	vector<DistributionBase*>::iterator it = remove_if(distributions.begin(),distributions.end(),isPositionDistribution);
	distributions.resize(it - distributions.begin());
}
Пример #10
0
bool CWizDatabase::CreateDocumentAndInit(const CString& strHtml, \
                                         const CString& strHtmlUrl, \
                                         int nFlags, \
                                         const CString& strTitle, \
                                         const CString& strName, \
                                         const CString& strLocation, \
                                         const CString& strURL, \
                                         WIZDOCUMENTDATA& data)
{
    bool bRet = false;
    try
    {
        BeginUpdate();

        data.strKbGUID = kbGUID();
        data.strOwner = getUserId();
        bRet = CreateDocument(strTitle, strName, strLocation, strHtmlUrl, data);
        if (bRet)
        {
            bRet = UpdateDocumentData(data, strHtml, strURL, nFlags);

            Q_EMIT documentCreated(data);
        }
    }
    catch (...)
    {

    }

    EndUpdate();

    return bRet;
}
Пример #11
0
bool MySqlStorage::deleteContactToRoster(QString jid, QString contactJid)
{
    QSqlQuery query;
    query.prepare("DELETE FROM qjabberd_contact WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    return query.exec();
}
Пример #12
0
bool MySqlStorage::updateApprovedToContact(QString jid, QString contactJid, bool approved)
{
    QSqlQuery query;
    query.prepare("UPDATE qjabberd_contact SET approved = :approved WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.bindValue(":approved", approved);
    return query.exec();
}
Пример #13
0
bool MySqlStorage::updateNameToContact(QString jid, QString contactJid,
                                         QString name)
{
    QSqlQuery query;
    query.prepare("UPDATE qjabberd_contact SET name = :name WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.bindValue(":name", name);
    return query.exec();
}
Пример #14
0
UtlBoolean
ValidateMailboxCGIHelper::isNumeric( const UtlString& mailboxIdentity ) const
{
    UtlString userid ;
    getUserId( mailboxIdentity, userid ) ;

    static RegEx sAllDigits("^\\d+$");

    return sAllDigits.Search(userid.data());
}
Пример #15
0
void Url::dump()
{
    UtlString proto;
    getUrlType(proto);
    printf("Url type: '%s'\n", proto.data());

    UtlString disp;
    getDisplayName(disp);
    printf("DisplayName: '%s'\n", disp.data());

    UtlString user;
    getUserId(user);
    printf("UserId: '%s'\n", user.data());

    UtlString pwd;
    getPassword(pwd);
    printf("Password: '******'\n", pwd.data());

    UtlString server;
    getHostAddress(server);
    printf("Address: '%s'\n", server.data());

    int port = getHostPort();
    printf("Port: %d\n", port);

    UtlString callId;
    getHeaderParameter("call-id", callId);
    printf("Call-Id: '%s'\n", callId.data());

    UtlString name;
    UtlString value;
    int index = 0;
    printf("\nHeader Parameters:\n");
    while(getHeaderParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }

    index = 0;
    printf("\nField Parameters:\n");
    while(getFieldParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }

    index = 0;
    printf("\nURL Parameters:\n");
    while(getUrlParameter(index, name, value))
    {
        printf("'%s'='%s'\n", name.data(), value.data());
        index++;
    }
}
Пример #16
0
node_t* findMember(tree_t* userInfoTree, char* str)
{
	char inputStr[BUFFERSIZE] = { 0, };
	int idx = 0;
	int input = 0;
	node_t* resultNodeArr[BUFFERSIZE] = { 0, };
	
	if (!userInfoTree)
	{
		return -1;
	}

	while (1)
	{
		system("cls");
		printf("=============================================================================\n");
		printf("%34s할 %s\t\n", str, "회원 검색");
		printf("=============================================================================\n");
		printf("\n\t%3s", "1. ID로 검색\n");
		printf("\n\t%3s", "2. 이름으로 검색\n");
		printf("\n\t%3s", "3. 주소로 검색\n");
		printf("\n\t%3s", "4. 전화 번호로 검색\n");
		printf("\n\t%3s", "0. 종료\n");
		printf("\n\t실행할 번호를 입력하세요: ");
		scanf_s("\n%d", &input);

		switch (input)
		{
		case 1:
			getUserId(inputStr);
			//ID는 한개만 있으므로 바로 키값처럼 검색해서 리턴
			resultNodeArr[idx] = searchBSTbyUserIdWithNode(userInfoTree->root, atoi(inputStr));
			break;
		case 2:
			getUserName(inputStr);
			searchBSTbyNameWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 3:
			getUserAddress(inputStr);
			searchBSTbyAddressWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 4:
			getPhoneNumber(inputStr);
			searchBSTbyPhoneWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 0:
			return (node_t*)NULL;
		default:
			break;
		}
		printArrData(resultNodeArr, inputStr);
		return selectNode(resultNodeArr);
	}
}
Пример #17
0
    /// Callback to handle connection established.
void 
connectionEstablishedHandler(struct PusherConnection *conn,
                             cJSON *data) {
    cJSON *socketItem = cJSON_GetObjectItem(data, "socket_id");
    if (socketItem != NULL && socketItem->valuestring != NULL) {
        char *socketId = strdup(socketItem->valuestring);
        printf("Pusher connection established, id=%s\n", socketId);
        conn->socketId = socketId;
        subscribe(conn, getUserId(), NULL, 0);
    }
}
void QtConfrenceVideoWindow::resizeEvent ( QResizeEvent * event )
{
	//报告窗口大小变更,以便调整视频显示方式
	ConferenceRoomService::getInstance()->resizeMediaWindow( 
    getUserId(), (int)(_ui.videoFrame->winId()) );

	const int width = event->size().width();
	const int height = event->size().height();

  // 必须先设置字体大小再调整位置,字幕栏在最上面,提供下面的frame的Y坐标
  adjustLabelStyle();

	const int frameWidth = 35;   //固定stopAudioFrame和stopVideoFrame的图标大小 add by lzb
  const int frameStartY = 10 + 
    (_isLabelTransparent ? 0 : _textLabel->height());

	//stopVideoFrame->setGeometry(width-frameWidth-10,10+frameWidth,frameWidth,frameWidth);
	_stopAudioFrame->setGeometry(width-frameWidth-10,frameStartY,frameWidth,frameWidth);
	_stopRecvAudioFrame->setGeometry(width-frameWidth-10,frameStartY+2*frameWidth,frameWidth,frameWidth);

	int stateFrameWidth = height/4;
	int left = (width-stateFrameWidth)/2;
	int top = (height-stateFrameWidth)/2;
	_mediaStateFrame->setGeometry( left , top , stateFrameWidth , stateFrameWidth );

	if (_videoStatuslabel) {
		/*if (((float)width) / (height) >= 16.0 /9)
		{
			const int myHeight = height;
			const int myWidth = myHeight / 9 * 16;
			_stopVideoFrame->setGeometry((width - myWidth)/2,0,myWidth,myHeight);
		}
		else
		{
			const int myWidth = width;
			const int myHeight = width / 16 * 9;
			_stopVideoFrame->setGeometry(width,(height-myHeight)/2,width,myHeight);
		}*/
    const int label_width = _videoStatuslabel->width();
    const int label_height = _videoStatuslabel->height();
    QPoint pos((width - label_width)/2, (height - label_height)/2);
    _videoStatuslabel->move(pos);
	}

  // text label
  resizeTextLabel();

  //RecCtrlPanel
  if (_recordAdvancedPanel) {
    _recordAdvancedPanel->setGeometry(
      width - _recordAdvancedPanel->width(), _ui.topWidget->height(), 
      _recordAdvancedPanel->width(), _recordAdvancedPanel->height());
  }
}
/**
* getTweetOwned function
* Getter of bool if the selected tweed is owned by the user
* @param[out] bool if owned
*/
bool ProfilePageArea::getTweetOwned() {
    if (currentlySelected.compare("0"))
    {
        if (getUserId().compare(TwitterApp::getInstance()->userID))
        {
            return false;
        }
        return true;
    }
    return false;
}
Пример #20
0
			bool  SocketSession::check(){

				time_t now = time(NULL);
				//检查不活跃期超时(activity)
				if(now - getLastActivity() > getWait()){
					LOG_DEBUG("SocketSession::check => del a session : sid = " << getSessionId() << " userId = " << getUserId());
					LOG_TRACE_ACTION(" sockSessionTimeOut"<<" | "<<getUserId()<<" | "<<getSessionId()<<" | "<<getCAppId()<<" | "<<"000000");
					internalClose();
					return 1;
				} 			
				return 0;
			}
Пример #21
0
QString MySqlStorage::getContactSubscription(QString jid, QString contactJid)
{
    QSqlQuery query;
    query.prepare("SELECT subscription FROM qjabberd_contact WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.exec();

    if (query.first())
        return query.value(0).toString();
    return QString();
}
Пример #22
0
QSet<QString> MySqlStorage::getContactGroups(QString jid, QString contactJid)
{
    QSqlQuery query;
    query.prepare("SELECT group FROM qjabberd_contact WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.exec();

    if (query.first())
        return QJsonDocument::fromJson(query.value(0).toByteArray()).object().value("groups").toVariant().toStringList().toSet();
    return QSet<QString>();
}
/**
 * 	This method broadcasts a message for this watcher.
 *
 * 	@param message		The message to broadcast.
 * 	@param withid		If true, the id and names are also sent.
 */
int WatcherNub::watcherControlMessage(int message, bool withid)
{
    int ret = 0;

	// turn on the broadcast flag
	if (socket_.setbroadcast(true))
	{
		perror( "WatcherNub::watcherControlMessage: "
                "setsockopt(SO_BROADCAST) failed\n" );
        ret = -1;
    }
    else
    {
        // build the packet
        WatcherRegistrationMsg  wrm;
        wrm.version = 0;
        wrm.uid = getUserId();
        wrm.message = message;

        if(withid)
        {
            wrm.id = id_;
            strcpy(wrm.abrv,abrv_);
            strcpy(wrm.name,name_);
        }
        else
        {
            wrm.id = -1;
            wrm.abrv[0] = 0;
            wrm.name[0] = 0;
        }

        // send the message
        if (socket_.sendto( &wrm,sizeof(wrm),
					htons( PORT_WATCHER ) ) != sizeof(wrm))
        {
            perror( "WatcherNub::watcherControlMessage: sendto failed\n" );
            ret = -1;
        }

        // turn off the broadcast flag
        if (socket_.setbroadcast( false ))
        {
            perror( "WatcherNub::watcherControlMessage: "
                    "setsockopt(-SO_BROADCAST) failed\n" );
            ret = -1;
        }

    }

    return ret;
}
Пример #24
0
/*
	Goes through the spool queue directory and creates a linked list
	of queueEntry nodes, 1 node for each file, sorted by order in
	which files were put into the queue.
*/
queueEntry *getFiles() {
	DIR *dir;
	struct dirent *f;
	int numFiles = getNumFiles();
	if(numFiles == 0) return NULL;
	queueEntry *root = NULL;
	
	//iterate over every file in queue
	if((dir = opendir(QUEUE_DIR)) != NULL) {
		while((f = readdir(dir)) != NULL) {
		
			if(strcmp(f->d_name, ".") == 0 || strcmp(f->d_name, "..") == 0 || strcmp(f->d_name, "index.txt") == 0 ) {
				continue;
			}
			queueEntry *entry = (queueEntry *) malloc(sizeof(queueEntry));
			entry->next = NULL;
			entry->prev = NULL;
			char name[128] = "";
			strncpy(name, f->d_name, strlen(f->d_name)+1);
			char *token = strtok(name, "_");
			
			//create entry->name and entry->unqiueName
			strncpy(entry->name, token, strlen(token)+1);
			strncpy(entry->uniqueName, f->d_name+(strlen(token)+1), (strlen(f->d_name) - strlen(token)));
			
			char path[1024] = "";
			strncpy(path, QUEUE_DIR, strlen(QUEUE_DIR));
			strncat(path, f->d_name, strlen(f->d_name) + 1);
			
			struct stat statbuf;
			if(stat(path, &statbuf) == -1) {
				printf("Error getting file stats for file: %s\n", path);
				return NULL;
			}
			
			int owner = getUserId(f->d_name);
			if(owner <= 0) {
				printf("Error getting owner of file from queue index\n");
				return NULL;
			}
			
			entry->owner = owner;
			entry->time = statbuf.st_mtime;
			
			root = insert(root, entry);
		}
		closedir(dir);
	}	
	 return root;
}
Пример #25
0
void CWebUser::saveToCookie(time_t duration)
{
	CWebApplication * app = dynamic_cast<CWebApplication*>(Cws::app());
	CHttpCookie cookie = createIdentityCookie(getStateKeyPrefix());
	cookie.expire = time(0) + duration;

	CWebUserState data;
	data.id = getUserId();
	data.name = getName();
	data.duration = duration;
	data.states = saveIdentityStates();
	cookie.value = CStringUtils::base64Encode(app->getSecurityManager()->hashData(CArchiver<CWebUserState>::save(data)));
	app->getResponse()->addCookie(cookie);
}
Пример #26
0
QSet<QString> MySqlStorage::getGroups(QString jid)
{
    QSqlQuery query;
    query.prepare("SELECT groups FROM qjabberd_contact WHERE user_id = :user_id");
    query.bindValue(":user_id", getUserId(jid));
    query.exec();

    QSet<QString> groups;
    while (query.next())
    {
        foreach (QString group, QJsonDocument::fromJson(query.value(0).toByteArray()).object().value("groups").toVariant().toStringList().toSet())
            groups << group;
    }
    return groups;
}
Пример #27
0
bool MySqlStorage::updateGroupToContact(QString jid, QString contactJid,
                                         QSet<QString> groups)
{
    QJsonDocument document;
    QJsonObject object;
    object.insert("groups", QJsonArray::fromStringList(QStringList::fromSet(groups)));
    document.setObject(object);

    QSqlQuery query;
    query.prepare("UPDATE qjabberd_contact SET groups = :groups WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);
    query.bindValue(":groups", document.toJson());
    return query.exec();
}
Пример #28
0
void InteractionChangeStateEvent::execute() {
	Interaction* intIntf;
	User* localUser = UserDatabase::getLocalUser();

	if (localUser->getId() == getUserId()) {
		intIntf = (Interaction*)SystemCore::getModuleByName("Interaction");
		assert(intIntf);

		if (previousStateActionModel)
			previousStateActionModel->exit();
		intIntf->state = (Interaction::INTERACTIONSTATE)nextState;
		if (nextStateActionModel)
			nextStateActionModel->enter(&pickedEntitiesCopy);
	}

}
Пример #29
0
QList<Contact> MySqlStorage::getContactsList(QString jid)
{
    QList<Contact> contactList;
    QSqlQuery query;
    query.prepare("SELECT version, approved, ask, jid, name, subscription, groups"
                  " FROM qjabberd_contact WHERE user_id = :user_id");
    query.bindValue(":user_id", getUserId(jid));
    query.exec();
    while (query.next())
    {
        contactList << Contact(query.value(0).toString(), query.value(1).toBool(), query.value(2).toString(),
                               query.value(3).toString(), query.value(4).toString(), query.value(5).toString(),
                               QJsonDocument::fromJson(query.value(6).toByteArray()).object().value("groups").toVariant().toStringList().toSet());
    }
    return contactList;
}
Пример #30
0
bool MySqlStorage::updateAskAttributeToContact(QString jid, QString contactJid,
                                         QString ask)
{
    Contact contact = getContact(jid, contactJid);

    QSqlQuery query;
    query.prepare("UPDATE qjabberd_contact SET ask = :ask WHERE user_id = :user_id AND jid = :jid");
    query.bindValue(":user_id", getUserId(jid));
    query.bindValue(":jid", contactJid);

    if ((contact.getSubscription() != "to") && (contact.getSubscription() != "both"))
    {
        query.bindValue(":ask", ask);
    }
    return query.exec();
}