MessageContent* GroupEncryptedVideoAndImageAndKeyMessageContent::integrateCallbackTaskResult(openmittsu::tasks::CallbackTask const* callbackTask) const {
				if (dynamic_cast<openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const*>(callbackTask) != nullptr) {
					openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const* kfnect = dynamic_cast<openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const*>(callbackTask);
					LOGGER_DEBUG("Integrating result from KeyAndFixedNonceEncryptionCallbackTask into a new GroupEncryptedVideoAndEncryptedImageAndKeyMessageContent.");
					return new GroupEncryptedVideoAndEncryptedImageAndKeyMessageContent(getGroupId(), m_encryptedVideoData, kfnect->getEncryptedData(), kfnect->getEncryptionKey(), m_lengthInSeconds, m_videoSizeInBytes, m_imageData.size());
				} else if (dynamic_cast<openmittsu::tasks::KeyAndFixedNonceDecryptionCallbackTask const*>(callbackTask) != nullptr) {
					openmittsu::tasks::KeyAndFixedNonceDecryptionCallbackTask const* kfndct = dynamic_cast<openmittsu::tasks::KeyAndFixedNonceDecryptionCallbackTask const*>(callbackTask);
					LOGGER_DEBUG("Integrating result from KeyAndFixedNonceDecryptionCallbackTask into a new GroupVideoMessageContent.");
					return new GroupVideoMessageContent(getGroupId(), kfndct->getDecryptedData(), m_imageData, m_lengthInSeconds);
				} else {
					LOGGER()->critical("GroupEncryptedVideoAndImageAndKeyMessageContent::integrateCallbackTaskResult called for unexpected CallbackTask.");
					throw;
				}
			}
QByteArray GroupTextMessageContent::toPacketPayload() const {
	QByteArray result(1, PROTO_MESSAGE_SIGNATURE_GROUP_TEXT);
	result.append(getGroupId().getGroupIdAsByteArray());
	result.append(text.toUtf8());

	return result;
}
예제 #3
0
int CAimProto::OnContactDeleted(WPARAM wParam,LPARAM /*lParam*/)
{
	if (state != 1) return 0;

	const HANDLE hContact = (HANDLE)wParam;

	if (DBGetContactSettingByte(hContact, MOD_KEY_CL, AIM_KEY_NL, 0))
		return 0;

	DBVARIANT dbv;
	if (!getString(hContact, AIM_KEY_SN, &dbv)) 
	{
		for(int i=1;;++i)
		{
			unsigned short item_id = getBuddyId(hContact, i);
			if (item_id == 0) break; 

			unsigned short group_id = getGroupId(hContact, i);
			if (group_id)
			{
				bool is_not_in_list = getBool(hContact, AIM_KEY_NIL, false);
				aim_ssi_update(hServerConn, seqno, true);
				aim_delete_contact(hServerConn, seqno, dbv.pszVal, item_id, group_id, 0, is_not_in_list);
				char* group = group_list.find_name(group_id);
				update_server_group(group, group_id);
				aim_ssi_update(hServerConn, seqno, false);
			}
		}
		DBFreeVariant(&dbv);
	}
	return 0;
}
예제 #4
0
int CAimProto::OnContactDeleted(WPARAM hContact, LPARAM)
{
	if (m_state != 1)
		return 0;

	if (db_get_b(hContact, MOD_KEY_CL, AIM_KEY_NL, 0))
		return 0;

	DBVARIANT dbv;
	if (!getString(hContact, AIM_KEY_SN, &dbv)) {
		for (int i = 1;; ++i) {
			unsigned short item_id = getBuddyId(hContact, i);
			if (item_id == 0) break;

			unsigned short group_id = getGroupId(hContact, i);
			if (group_id) {
				bool is_not_in_list = getBool(hContact, AIM_KEY_NIL, false);
				aim_ssi_update(m_hServerConn, m_seqno, true);
				aim_delete_contact(m_hServerConn, m_seqno, dbv.pszVal, item_id, group_id, 0, is_not_in_list);
				char *group = m_group_list.find_name(group_id);
				update_server_group(group, group_id);
				aim_ssi_update(m_hServerConn, m_seqno, false);
			}
		}
		db_free(&dbv);
	}
	return 0;
}
예제 #5
0
void printInfo(icqInfo *details_pointer, groups *groups_pointer)
{
	FILE *users;
	FILE *user;
	int i;
	int groupid;
	char usersfile[1011];
	strcpy(usersfile, basedir);
	strcat(usersfile, "/users.conf");
	users=fopen(usersfile, "w");
	if(users==NULL) {
		printf("Error: couldn't open %s for writing\n", usersfile);
		exit(1);
	}
	fputs("[users]\n", users);
	for(i=1;details_pointer;i++) {
		char uinfile[1000];
		fprintf(users, "User%d = %s\n", i, details_pointer->uin);
		sprintf(uinfile, "%s/users/%s.uin", basedir, details_pointer->uin);
		user=fopen(uinfile, "w");
		fputs("[user]\n", user);
		fprintf(user, "Alias = %s\n", details_pointer->name);
		groupid = getGroupId(details_pointer->group, groups_pointer);
		if(groupid) {
			fprintf(user, "Groups.User = %d\n", groupid);
		}
		details_pointer = details_pointer->link;
	}
	fprintf(users, "NumOfUsers = %d", i-1);
	fclose(users);
	fclose(user);
}
예제 #6
0
/*!
 * Delets current element or group (with subgroups).
 * \param item (in) - deleted element or group item.
 */
void CatalogForm::del_item( Q3ListViewItem * item )
{
   // cat->groupSelect(getGroupId(item));
	qulonglong id = getElementId(item);
	if(id)
	{
		cat->select(id);
		if(cat->First())
		{
			cat->delElement();
			map_el.remove(id);
			delete item;
			item = 0;
		}
	}
	else
	{
		id = getGroupId(item);
		if(id)
		{
			Q3ValueList<qulonglong> listDeletedId;
			cat->delGroup(id, listDeletedId);
			Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
			while(it!= listDeletedId.end())
			{
				if(map_el.contains(*it)) map_el.remove(*it);
				else  if(map_gr.contains(*it)) map_gr.remove(*it);
				++it;
			}
			delete item; // destructor delete all subitems
			item = 0;
		}
	}
}
예제 #7
0
/*!
 * Selects current group or element.
 * \param item (in) - selected element or group item
 */
void CatalogForm::select( Q3ListViewItem * item )
{
	qulonglong res = getGroupId(item);
	if(!res)
	{
		res = getElementId(item);
		cat->select(res);
		if(!cat->isElementMarkDeleted())
		{
			setId(res);
			doOk();
		}
	}
	else
	{
		cat->groupSelect(res);
		if(!cat->isGroupMarkDeleted())
		{
			setId(res);
			doOk();
		}
	}
	emit(selected(res));
//    return res;
}
			QByteArray GroupImageIdAndKeyMessageContent::toPacketPayload() const {
				QByteArray result(1, PROTO_MESSAGE_SIGNATURE_GROUP_PICTURE);
				result.append(getGroupId().getGroupIdAsByteArray());
				result.append(imageId);
				result.append(openmittsu::utility::Endian::uint32FromHostToLittleEndianByteArray(sizeInBytes));
				result.append(encryptionKey.getEncryptionKey());

				return result;
			}
			MessageContent* GroupImageMessageContent::integrateCallbackTaskResult(openmittsu::tasks::CallbackTask const* callbackTask) const {
				if (dynamic_cast<openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const*>(callbackTask) != nullptr) {
					openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const* kfnect = dynamic_cast<openmittsu::tasks::KeyAndFixedNonceEncryptionCallbackTask const*>(callbackTask);
					LOGGER_DEBUG("Integrating result from KeyAndFixedNonceEncryptionCallbackTask into a new GroupEncryptedImageAndKeyMessageContent.");
					return new GroupEncryptedImageAndKeyMessageContent(getGroupId(), kfnect->getEncryptedData(), kfnect->getEncryptionKey(), static_cast<quint32>(imageData.size()));
				} else {
					LOGGER()->critical("GroupImageMessageContent::integrateCallbackTaskResult called for unexpected CallbackTask.");
					throw;
				}
			}
		void GroupCreationMessageAcknowledgmentProcessor::sendResultIfDone(openmittsu::network::ProtocolClient* protocolClient) {
			if (m_messageCount == 0) {
				if (m_informViaSignal) {
					if (m_hasFailedMessage) {
						emitGroupCreationFailed(getGroupId(), protocolClient);
					} else {
						emitGroupCreationSuccess(getGroupId(), protocolClient);
					}
				} else {
					if (m_hasFailedMessage) {
						LOGGER()->warn("Failed to send group control message with message ID #{} to group {}, will fail silently.", getGroupUniqueMessageId().toString(), getGroupId().toString());
					} else {
						LOGGER()->info("Sent group control message with message ID #{} to group {}, success.", getGroupUniqueMessageId().toString(), getGroupId().toString());
					}
				}
			} else {
				LOGGER_DEBUG("Group Control Message with message ID #{} to group {} still has {} ACKs outstanding.", getGroupUniqueMessageId().toString(), getGroupId().toString(), m_messageCount);
			}
		}
예제 #11
0
Booster::Booster() :
    m_appData(new AppData),
    m_connection(NULL),
    m_oldPriority(0),
    m_oldPriorityOk(false),
    m_spaceAvailable(0),
    m_bootMode(false)
{
    m_boosted_gid = getGroupId("boosted", FALLBACK_GID);
}
예제 #12
0
/*!
 * Undo marks deleted current element or group (with subgroups).
 * \param item (in) - marked deleted element or group item.
 */
void CatalogForm::undo_mark_deleted( Q3ListViewItem * item )
{
	qulonglong id = getElementId(item);
	if(id)
	{
	  	cat->select(id);
		if(cat->First())
		{
			cat->setMarkDeletedElement(id,false);
			item->setPixmap(0,getElementPixmap());
		}
   	}
	else
	{
		id = getGroupId(item);
		if(id)
		{
		  // cat->select(QString("id=%1").arg(id),md_group);
		   //if(cat->FirstInGroupTable())
			Q3ValueList<qulonglong> listDeletedId;
		   //	cat->setMarkDeletedGroup(id, listDeletedId,false);
	   		cat->getMarkDeletedList(id, listDeletedId);
			Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
			while(it != listDeletedId.end()) //first delete elements in this group
			{
				if(map_el.contains(*it))
				{
					map_el[*it]->setPixmap(0, getElementPixmap());
					cat->setMarkDeletedElement(*it,false);
					it = listDeletedId.remove(it);
				}
				else
				{
					++it;
				}
			}
			it = listDeletedId.begin();
			while(it != listDeletedId.end()) //second delete groups
			{
				if(map_gr.contains(*it))
				{
					map_gr[*it]->setPixmap(0, getGroupPixmap());
					cat->setMarkDeletedGroup(*it,false);
					it = listDeletedId.remove(it);
					//map_el[*it]->invalidateHeight();// setHeight(10);
				}
				else
				{
					++it;
				}
			}
		}
	}
}
예제 #13
0
파일: utils.cpp 프로젝트: Civil/cantata
/*
 * Set file permissions.
 * If user is a memeber of "users" group, then set file as owned by and writeable by "users" group.
 */
void Utils::setFilePerms(const QString &file, const char *groupName)
{
    //
    // Clear any umask before setting file perms
    mode_t oldMask(umask(0000));
    gid_t gid=getGroupId(groupName);
    QByteArray fn=QFile::encodeName(file);
    ::chmod(fn.constData(), 0==gid ? 0644 : 0664);
    if (0!=gid) {
        int rv=::chown(fn.constData(), geteuid(), gid);
        Q_UNUSED(rv)
    }
예제 #14
0
/*!
 * Marks deleted current element or group (with subgroups).
 * While for mark deleted items sets ahother pixmap only.
 * \param item (in) - marked deleted element or group item.
 */
void CatalogForm::mark_deleted( Q3ListViewItem * item )
{
   qulonglong id = getElementId(item);
   if(id)
   {
   	cat->select(id);
//	cat->setSelected(true);
	if(cat->First())
	{
		cat->setMarkDeletedElement(id,true);
		item->setPixmap(0,getMarkDeletedPixmap());
	}
   }
   else
   {
	id = getGroupId(item);
	if(id)
	{
		loadElements(id); // populate items in group
		Q3ValueList<qulonglong> listDeletedId;
		cat->getMarkDeletedList(id,listDeletedId);
		Q3ValueList<qulonglong>::iterator it = listDeletedId.begin();
		while(it != listDeletedId.end()) //first delete elements in this group
		{
			if(map_el.contains(*it))
		    	{
				map_el[*it]->setPixmap(0, getMarkDeletedPixmap());
				cat->setMarkDeletedElement(*it,true);
				it = listDeletedId.remove(it);
			}
			else
			{
				++it;
			}
		}
		it = listDeletedId.begin();
		while(it != listDeletedId.end()) //second delete groups
		{
			if(map_gr.contains(*it))
			{
				map_gr[*it]->setPixmap(0, getMarkDeletedPixmap());
				cat->setMarkDeletedGroup(*it,true);
				it = listDeletedId.remove(it);
				//map_el[*it]->invalidateHeight();// setHeight(10);
			}
			else
			{
				++it;
			}
		}
	}
   }
}
QByteArray GroupLocationMessageContent::toPacketPayload() const {
	QByteArray result(1, PROTO_MESSAGE_SIGNATURE_GROUP_LOCATION);
	result.append(getGroupId().getGroupIdAsByteArray());
	
	QString const positionString = QString("%1,%2,%3").arg(latitude, 0, 'f', 6).arg(longitude, 0, 'f', 6).arg(height, 0, 'f', 6);

	result.append(positionString.toUtf8());
	result.append('\n');
	result.append(description.toUtf8());

	return result;
}
			MessageContent* GroupImageIdAndKeyMessageContent::integrateCallbackTaskResult(openmittsu::tasks::CallbackTask const* callbackTask) const {
				if (dynamic_cast<openmittsu::tasks::BlobDownloaderCallbackTask const*>(callbackTask) != nullptr) {
					openmittsu::tasks::BlobDownloaderCallbackTask const* bdct = dynamic_cast<openmittsu::tasks::BlobDownloaderCallbackTask const*>(callbackTask);
					if (bdct->getDownloadedBlob().size() != static_cast<int>(sizeInBytes)) {
						LOGGER()->warn("Size of downloaded blob differs from stated size ({} Bytes downloaded vs. {} Bytes promised).", bdct->getDownloadedBlob().size(), sizeInBytes);
					}

					LOGGER_DEBUG("Integrating result from BlobDownloaderCallbackTask into a new GroupEncryptedImageAndKeyMessageContent.");
					return new GroupEncryptedImageAndKeyMessageContent(getGroupId(), bdct->getDownloadedBlob(), encryptionKey, sizeInBytes);
				} else {
					LOGGER()->critical("GroupImageIdAndKeyMessageContent::integrateCallbackTaskResult called for unexpected CallbackTask.");
					throw;
				}
			}
예제 #17
0
Booster::Booster() :
    m_appData(new AppData),
    m_connection(NULL),
    m_oldPriority(0),
    m_oldPriorityOk(false),
    m_spaceAvailable(0),
    m_bootMode(false)
{
#ifdef HAVE_CREDS
    // initialize credentials to be filtered out from boosted applications
    convertStringsToCreds(g_strCreds, sizeof(g_strCreds) / sizeof(char*));
#endif

    m_boosted_gid = getGroupId("boosted", FALLBACK_GID);
}
static std::string
getItemIdentifier(ItemPtr item)
{
    auto itemType = item->getItemType();
    std::string name;
    if (itemType == ItemType::RPM) {
        auto rpm = std::dynamic_pointer_cast< RPMItem >(item);
        name = rpm->getName();
    } else if (itemType == ItemType::GROUP) {
        auto group = std::dynamic_pointer_cast< CompsGroupItem >(item);
        name = group->getGroupId();
    } else if (itemType == ItemType::ENVIRONMENT) {
        auto env = std::dynamic_pointer_cast< CompsEnvironmentItem >(item);
        name = env->getEnvironmentId();
    }
    return name;
}
예제 #19
0
/*!
 * Adds new group.
 * \param parentItem (in) - parent group. If parent group == 0, group adds in root.
 */
void
CatalogForm::new_group( Q3ListViewItem * parentItem )
{
	qulonglong id = getGroupId(parentItem);
	Q3ListViewItem * item;
	QPixmap pixmap(getGroupPixmap());
    //cat->groupSelect( id );
	if(!id)
	{
		id = getElementId(parentItem);
		if(id)
		{
			cfg_message(0,tr("Can't added group to element"));
			return;
		}
		else
		{
//		printf(">>>>id=0\n");
			cat->newGroup(id);
			item = new Q3ListViewItem(ListView);
			ListView->insertItem(item);
		}
	}
	else
	{
		//cat->groupSelect(id);
		if(cat->isGroupMarkDeleted())
		{
			cfg_message(0,tr("Can't added group to mark deleted group"));
			return;
		}
		cat->newGroup(id);
		item = new Q3ListViewItem(map_gr[id]);
	}
	//item->setText(0,cat->GroupSysValue(fieldListGroup[0]).toString());
	item->setPixmap(0,pixmap);
	map_gr.insert(cat->GroupSysValue("id").toULongLong(),item);
	edit(item,true);
	ListView->ensureItemVisible(item);
	ListView->setCurrentItem(item);
	ListView->setSelected(item,true);
	//ListView->setFocus();

}
예제 #20
0
void AutoSearchFrame::updateItem(const AutoSearchPtr as) {
	auto i = itemInfos.find(as->getToken());
	if (i != itemInfos.end()) {
		auto ii = &i->second;
		ii->update(as);
		int pos = ctrlAutoSearch.findItem(ii);
		if (pos >= 0) {
			ctrlAutoSearch.SetCheckState(pos, as->getEnabled());
			LVITEM lvi = { 0 };
			lvi.mask = LVIF_GROUPID | LVIF_IMAGE;
			lvi.iItem = pos;
			lvi.iGroupId = ii->getGroupId();
			lvi.iImage = as->getStatus();
			lvi.iSubItem = 0;
			ctrlAutoSearch.SetItem(&lvi);
			ctrlAutoSearch.updateItem(pos);
		}
	}
}
예제 #21
0
/*!
 * Adds new element.
 * \param parentItem (in) - parent group. If parent group == 0, element not added.
 */
void
CatalogForm::new_item( Q3ListViewItem * parentItem )
{
	if(!parentItem)
	{
		//cat->groupSelect(0);
		cat->newElement(0);
		//printf("id = %llu\n",id);
		Q3ListViewItem* item = new Q3ListViewItem(ListView);
		QPixmap pixmap(getElementPixmap());
		item->setPixmap(0,pixmap);
		map_el.insert(cat->sysValue("id").toULongLong(),item);
		edit(item,true);
		ListView->ensureItemVisible(item);
	//	cfg_message(0,tr("Can't added element"));
		return;
	}
	qulonglong id = getGroupId(parentItem);
	QPixmap pixmap(getElementPixmap());
	if(id) // parent item is group
	{
		cat->groupSelect(id);
		if(!cat->isGroupMarkDeleted())
		{
			cat->newElement(id);
			Q3ListViewItem* item = new Q3ListViewItem(map_gr[id]);
			item->setPixmap(0,pixmap);
			map_el.insert(cat->sysValue("id").toULongLong(),item);
			edit(item,true);
			ListView->ensureItemVisible(item);
			//ListView->setFocus();
		}
		else cfg_message(0,tr("Can't added new element to mark deleted group"));
	}
	else
	{
		new_item(parentItem->parent());
	}//cfg_message(0,tr("Can't added element to element"));
}
예제 #22
0
bool UserDBController::updateUser(QString strUser,QString strCard, QString strGroup){
    QString str;
    if(!getUserId(strUser))return false;
//    if(!getCardIdByName(strCard)){
    if(!getUserInCardsById(m_iUserID)){
//        qDebug()<<"card not found";
        if(getCardIdByName(strCard))
        if(!getCardIdByNameAndUserId(strCard,m_iUserID)){
        //card already exist where !!! someone reuse someOtherOne`s card
            str=QString("delete from cards where CODE=\'%2\'").arg(strCard);
            if(!m_dbCon->procsDML(str))return false;
        }
        str=QString("insert into cards (USER_ID,CODE) values (%1,\'%2\')").arg(m_iUserID).arg(strCard);
        if(!m_dbCon->procsDML(str))return false;
        if(!getCardId())return false;
//        qDebug()<<"card inserted";
    }else{
//        qDebug()<<"card found";
//        str=QString("update cards set user_id=%1 where id=%2").arg(m_iUserID).arg(m_iCardID);
        if(getCardIdByName(strCard))
        if(!getCardIdByNameAndUserId(strCard,m_iUserID)){
        //card already exist where !!! someone reuse someOtherOne`s card
            str=QString("delete from cards where CODE=\'%2\'").arg(strCard);
            if(!m_dbCon->procsDML(str))return false;
        }
        str=QString("update cards set code=\'%1\' where user_id=%2").arg(strCard).arg(m_iUserID);
        if(!m_dbCon->procsDML(str))return false;
//        qDebug()<<"card updated";
    }
    if(!getGroupIdByName(strGroup))return false;
    if(!getGroupId())str=QString("insert into usergroups (USER_ID,GROUP_ID) values (%1,%2)").arg(m_iUserID).arg(m_iGroupID);
    else
        str=QString("update usergroups set GROUP_ID=%1 where USER_ID=%2").arg(m_iGroupID).arg(m_iUserID);
    if(!m_dbCon->procsDML(str))return false;
    return true;
}
예제 #23
0
void CatalogForm::edit( Q3ListViewItem * item, bool afterNew)
{
//	QWidget *wd = topLevelWidget();
	aLog::print(aLog::Debug, tr("Catalog Form edit element start"));
   MainForm * mw = (MainForm*) topLevelWidget();
   if(mw)
   {
	qulonglong id = getElementId(item);
	if(id)
  	{
		aLog::print(aLog::Debug, tr("Catalog Form edit element with id=%1").arg(id));
		cat->select(id);
		if(idElementForm)
		{
			if(!cat->isElementMarkDeleted())
			{
				aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idElementForm);
				if(editForm)
				{
					if(afterNew) editForm->setMode(0);
					else editForm->setMode(1);
					editForm->Select(id);
					connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong)));
					editForm->show();
				}
				else
				{
					aLog::print(aLog::Error, tr("Catalog Form edit element form is null"));
				}
			}
			else cfg_message(0, tr("Can't edit mark deleted element"));
		}
		else cfg_message(1,tr("Catalog haven't edit element form"));
	}
	else
  	{
   		id = getGroupId(item);
		aLog::print(aLog::Debug, tr("Catalog Form edit group with id = %1").arg(id));
		if(id)
		{

			cat->groupSelect(id);
			if(idGroupForm)
			{
				if(!cat->isGroupMarkDeleted())
				{
					aForm *editForm = new aForm(mw->ws, &mw->engine, (long int) idGroupForm);
					if(editForm)
					{
						if(afterNew) editForm->setMode(0);
						else editForm->setMode(1);

						editForm->SelectGroup(id);
						connect(editForm, SIGNAL(closeForm(qulonglong)), this, SLOT(Refresh(qulonglong)));
						editForm->show();
					}
					else
					{
						aLog::print(aLog::Error, tr("Catalog Form edit group form is null"));
					}
     				}
				else cfg_message(0, tr("Can't edit mark deleted group"));
    			}
			else cfg_message(1,tr("Catalog haven't edit group form"));
		}
	}
  }
  else
  {
	aLog::print(aLog::Error, tr("Catalog Form main widget is not 'MainForm'"));
  }

}
bool Msg3a::gotCacheReply ( ) {

    // in cache?
    if ( ! m_seoCacheList.isEmpty() ) {
        // note it
        //log("seopipe: found ckey=%s q=%s"
        //    ,KEYSTR(&m_ckey,12)
        //    ,m_r->ptr_query
        //    );
        char *p = m_seoCacheList.getList();
        // skip key
        p += sizeof(key_t);
        // datasize
        p += 4;
        // timestamp
        //long cachedTime = *(long *)p;
        p += 4;
        // # docids
        m_numDocIds = *(long *)p;
        p += 4;
        // total # results
        m_numTotalEstimatedHits = *(long *)p;
        p += 4;
        // docids
        m_docIds = (long long *)p;
        p += 8 * m_numDocIds;
        // scores
        m_scores = (float *)p;
        p += sizeof(float) * m_numDocIds;
        // site hashes
        m_siteHashes26 = (long *)p;
        p += 4 * m_numDocIds;
        // log to log as well
        char tmp[50000];
        p = tmp;
        p += sprintf(p,
                     "seopipe: hit cache "
                     "docids=%li "
                     "query=\"%s\" ",
                     m_numDocIds,
                     m_r->ptr_query );
        // log each docid
        //for ( long i = 0 ; i < m_numDocIds ; i++ ) {
        //	//float score = m_msg3a->getScores()[i];
        //	long long d = m_docIds[i];
        //	//long sh32 = m_msg3a->getSiteHash32(i);
        //	p += sprintf(p,"d%li=%lli ",i,d);
        //}
        log("%s",tmp);
        // all done!
        return true;
    }

    CollectionRec *cr;
    cr = g_collectiondb.getRec(m_r->ptr_coll,m_r->size_coll-1);

    setTermFreqWeights ( cr->m_coll,m_q,m_termFreqs , m_termFreqWeights );

    if ( m_debug ) {
        //long long *termIds = m_q->getTermIds();
        //if ( m_numCandidates ) termIds = m_synIds;
        for ( long i = 0 ; i < m_q->m_numTerms ; i++ ) {
            // get the term in utf8
            QueryTerm *qt = &m_q->m_qterms[i];
            //char bb[256];
            //utf16ToUtf8(bb, 256, qt->m_term, qt->m_termLen);
            char *tpc = qt->m_term + qt->m_termLen;
            char c = *tpc;
            *tpc = 0;
            // this term freq is estimated from the rdbmap and
            // does not hit disk...
            logf(LOG_DEBUG,"query: term #%li \"%s\" "
                 "termid=%lli termFreq=%lli termFreqWeight=%.03f",
                 i,
                 qt->m_term,
                 qt->m_termId,
                 m_termFreqs[i],
                 m_termFreqWeights[i]);
            // put it back
            *tpc = c;
        }
    }

    // time how long to get each split's docids
    if ( m_debug )
        m_startTime = gettimeofdayInMilliseconds();

    // reset replies received count
    m_numReplies  = 0;
    // shortcut
    long n = m_q->m_numTerms;

    /////////////////////////////
    //
    // set the Msg39 request
    //
    /////////////////////////////

    // free if we should
    if ( m_rbufPtr && m_rbufPtr != m_rbuf ) {
        mfree ( m_rbufPtr , m_rbufSize , "Msg3a");
        m_rbufPtr = NULL;
    }

    // a tmp buf
    long readSizes[MAX_QUERY_TERMS];
    // update our read info
    for ( long j = 0; j < n ; j++ ) {
        // the read size for THIS query term
        long rs = 300000000; // toRead; 300MB i guess...
        // limit to 50MB man! this was 30MB but the
        // 'time enough for love' query was hitting 30MB termlists.
        //rs = 50000000;
        rs = DEFAULT_POSDB_READSIZE;//90000000; // 90MB!
        // if section stats, limit to 1MB
        if ( m_r->m_getSectionStats ) rs = 1000000;
        // get the jth query term
        QueryTerm *qt = &m_q->m_qterms[j];
        // if query term is ignored, skip it
        if ( qt->m_ignored ) rs = 0;
        // set it
        readSizes[j] = rs;
    }

    // serialize this
    m_r->ptr_readSizes  = (char *)readSizes;
    m_r->size_readSizes = 4 * n;
    // and this
    m_r->ptr_termFreqWeights  = (char *)m_termFreqWeights;
    m_r->size_termFreqWeights = 4 * n;
    // store query into request, might have changed since we called
    // Query::expandQuery() above
    m_r->ptr_query  = m_q->m_orig;
    m_r->size_query = m_q->m_origLen+1;
    // free us?
    if ( m_rbufPtr && m_rbufPtr != m_rbuf ) {
        mfree ( m_rbufPtr , m_rbufSize, "Msg3a" );
        m_rbufPtr = NULL;
    }
    m_r->m_stripe = 0;
    // debug thing
    g_r        = m_r;
    // . (re)serialize the request
    // . returns NULL and sets g_errno on error
    // . "m_rbuf" is a local storage space that can save a malloc
    // . do not "makePtrsRefNewBuf" because if we do that and this gets
    //   called a 2nd time because m_getWeights got set to 0, then we
    //   end up copying over ourselves.
    m_rbufPtr = serializeMsg ( sizeof(Msg39Request),
                               &m_r->size_readSizes,
                               &m_r->size_coll,
                               &m_r->ptr_readSizes,
                               m_r,
                               &m_rbufSize ,
                               m_rbuf ,
                               RBUF_SIZE ,
                               false );

    if ( ! m_rbufPtr ) return true;

    // free this one too
    m_rbuf2.purge();
    // and copy that!
    if ( ! m_rbuf2.safeMemcpy ( m_rbufPtr , m_rbufSize ) ) return true;
    // and tweak it
    ((Msg39Request *)(m_rbuf2.getBufStart()))->m_stripe = 1;

    /////////////////////////////
    //
    // end formulating the Msg39 request
    //
    /////////////////////////////

    // . set timeout based on docids requested!
    // . the more docs requested the longer it will take to get
    long timeout = (50 * m_docsToGet) / 1000;
    // at least 20 seconds
    if ( timeout < 20 ) timeout = 20;
    // override? this is USUALLY -1, but DupDectector.cpp needs it
    // high because it is a spider time thing.
    if ( m_r->m_timeout > 0 ) timeout = m_r->m_timeout;
    // for new posdb stuff
    if ( timeout < 60 ) timeout = 60;

    long long qh = 0LL;
    if ( m_q ) qh = m_q->getQueryHash();

    m_numHosts = g_hostdb.getNumHosts();
    // only send to one host?
    if ( ! m_q->isSplit() ) m_numHosts = 1;

    // now we run it over ALL hosts that are up!
    for ( long i = 0; i < m_numHosts ; i++ ) { // m_indexdbSplit; i++ ) {
        // get that host
        Host *h = g_hostdb.getHost(i);
        // if not a full split, just round robin the group, i am not
        // going to sweat over performance on non-fully split indexes
        // because they suck really bad anyway compared to full
        // split indexes. "gid" is already set if we are not split.
        unsigned long gid = h->m_groupId;//g_hostdb.getGroupId(i);
        long firstHostId = h->m_hostId;
        // get strip num
        char *req = m_rbufPtr;
        // if sending to twin, use slightly different request
        if ( h->m_stripe == 1 ) req = m_rbuf2.getBufStart();
        // if we are a non-split query, like gbdom:xyz.com just send
        // to the host that has the first termid local. it will call
        // msg2 to download all termlists. msg2 should be smart
        // enough to download the "non split" termlists over the net.
        // TODO: fix msg2 to do that...
        if ( ! m_q->isSplit() ) {
            long long     tid  = m_q->getTermId(0);
            key_t         k    = g_indexdb.makeKey(tid,1,1,false );
            // split = false! do not split
            gid = getGroupId ( RDB_POSDB,&k,false);
            firstHostId = -1;
        }
        // debug log
        if ( m_debug )
            logf(LOG_DEBUG,"query: Msg3a[%lu]: forwarding request "
                 "of query=%s to groupid 0x%lx.",
                 (long)this, m_q->getQuery(), gid);
        // send to this guy
        Multicast *m = &m_mcast[i];
        // clear it for transmit
        m->reset();
        // . send out a msg39 request to each split
        // . multicasts to a host in group "groupId"
        // . we always block waiting for the reply with a multicast
        // . returns false and sets g_errno on error
        // . sends the request to fastest host in group "groupId"
        // . if that host takes more than about 5 secs then sends to
        //   next host
        // . key should be largest termId in group we're sending to
        bool status;
        status = m->send ( req , // m_rbufPtr         ,
                           m_rbufSize        , // request size
                           0x39              , // msgType 0x39
                           false             , // mcast owns m_request?
                           gid               , // group to send to
                           false             , // send to whole group?
                           (long)qh          , // 0 // startKey.n1
                           this              , // state1 data
                           m                 , // state2 data
                           gotReplyWrapper3a ,
                           timeout           , // in seconds
                           m_r->m_niceness   ,
                           false             , // realtime?
                           firstHostId, // -1// bestHandlingHostId ,
                           NULL              , // m_replyBuf   ,
                           0                 , // MSG39REPLYSIZE,
                           // this is true if multicast should free the
                           // reply, otherwise caller is responsible
                           // for freeing it after calling
                           // getBestReply().
                           // actually, this should always be false,
                           // there is a bug in Multicast.cpp.
                           // no, if we error out and never steal
                           // the buffers then they will go unfreed
                           // so they are freed by multicast by default
                           // then we steal control explicitly
                           true             );
        // if successfully launch, do the next one
        if ( status ) continue;
        // . this serious error should make the whole query fail
        // . must allow other replies to come in though, so keep going
        m_numReplies++;
        log("query: Multicast Msg3a had error: %s",mstrerror(g_errno));
        m_errno = g_errno;
        g_errno = 0;
    }
    // return false if blocked on a reply
    if ( m_numReplies < m_numHosts ) return false;//indexdbSplit )
    // . otherwise, we did not block... error?
    // . it must have been an error or just no new lists available!!
    // . if we call gotAllSplitReplies() here, and we were called by
    //   mergeLists() we end up calling mergeLists() again... bad. so
    //   just return true in that case.
    //return gotAllSplitReplies();
    return true;
}
			GroupMessageContent* GroupEncryptedVideoAndImageAndKeyMessageContent::clone() const {
				return new GroupEncryptedVideoAndImageAndKeyMessageContent(getGroupId(), m_encryptedVideoData, m_imageData, m_encryptionKey, m_lengthInSeconds, m_videoSizeInBytes);
			}
예제 #26
0
bool UserDBController::loadAllUserInfo(QString strUser){
    if(!getUserId(strUser))return false;
    if(!getGroupId())return false;
    if(!getCardId())return false;
    return true;
}
void Indexdb::deepVerify ( char *coll ) {
	log ( LOG_INFO, "db: Deep Verifying Indexdb for coll %s...", coll );
	g_threads.disableThreads();

	Msg5 msg5;
	Msg5 msg5b;
	RdbList list;
	key_t startKey;
	key_t endKey;
	startKey.setMin();
	endKey.setMax();
	//long minRecSizes = 64000;
	
	collnum_t collnum = g_collectiondb.getCollnum(coll);
	RdbBase *rdbBase = g_indexdb.m_rdb.getBase(collnum);
	long numFiles = rdbBase->getNumFiles();
	long currentFile = 0;
	
deepLoop:
	// done after scanning all files
	if ( currentFile >= numFiles ) {
		g_threads.enableThreads();
		log ( LOG_INFO, "db: Finished deep verify for %li files.",
				numFiles );
		return;
	}
	// scan this file
	if ( ! msg5.getList ( RDB_INDEXDB   ,
			      coll          ,
			      &list         ,
			      startKey      ,
			      endKey        ,
			      64000         , // minRecSizes   ,
			      true          , // includeTree   ,
			      false         , // add to cache?
			      0             , // max cache age
			      currentFile   , // startFileNum  ,
			      1             , // numFiles      ,
			      NULL          , // state
			      NULL          , // callback
			      0             , // niceness
			      false         , // err correction?
			      NULL          ,
			      0             ,
			      -1            ,
			      true          ,
			      -1LL          ,
			      &msg5b        ,
			      false         )) {
		g_threads.enableThreads();
		log("db: HEY! it did not block");
		return;
	}

	long count = 0;
	long got   = 0;
	for ( list.resetListPtr() ; ! list.isExhausted() ;
	      list.skipCurrentRecord() ) {
		key_t k = list.getCurrentKey();
		count++;
		//unsigned long groupId = k.n1 & g_hostdb.m_groupMask;
		unsigned long groupId = getGroupId ( RDB_INDEXDB , &k );
		if ( groupId == g_hostdb.m_groupId ) got++;
	}
	if ( got != count ) {
		BigFile *f = rdbBase->getFile(currentFile);
		log ("db: File %s: Out of first %li records in indexdb, "
		     "only %li belong to our group.",
		     f->getFilename(),count,got );
	}
	//else
	//	log ( LOG_INFO, "db: File %li: Indexdb passed verification "
	//	      "successfully for %li recs.",currentFile,count );
	// next file
	currentFile++;
	goto deepLoop;
}
bool Indexdb::verify ( char *coll ) {
	return true;
	log ( LOG_INFO, "db: Verifying Indexdb for coll %s...", coll );
	g_threads.disableThreads();

	Msg5 msg5;
	Msg5 msg5b;
	RdbList list;
	key_t startKey;
	key_t endKey;
	startKey.setMin();
	endKey.setMax();
	//long minRecSizes = 64000;
	
	if ( ! msg5.getList ( RDB_INDEXDB   ,
			      coll          ,
			      &list         ,
			      startKey      ,
			      endKey        ,
			      64000         , // minRecSizes   ,
			      true          , // includeTree   ,
			      false         , // add to cache?
			      0             , // max cache age
			      0             , // startFileNum  ,
			      -1            , // numFiles      ,
			      NULL          , // state
			      NULL          , // callback
			      0             , // niceness
			      false         , // err correction?
			      NULL          ,
			      0             ,
			      -1            ,
			      true          ,
			      -1LL          ,
			      &msg5b        ,
			      true          )) {
		g_threads.enableThreads();
		return log("db: HEY! it did not block");
	}

	long count = 0;
	long got   = 0;
	bool printedKey = false;
	bool printedZeroKey = false;
	for ( list.resetListPtr() ; ! list.isExhausted() ;
	      list.skipCurrentRecord() ) {
		key_t k = list.getCurrentKey();
		count++;
		//unsigned long groupId = k.n1 & g_hostdb.m_groupMask;
		unsigned long groupId = getGroupId ( RDB_INDEXDB , &k );
		if ( groupId == g_hostdb.m_groupId ) got++;
		else if ( !printedKey ) {
			log ( "db: Found bad key in list (only printing once): "
			      "%lx %llx", k.n1, k.n0 );
			printedKey = true;
		}
		if ( k.n1 == 0 && k.n0 == 0 ) {
			if ( !printedZeroKey ) {
				log ( "db: Found Zero key in list, passing. "
				      "(only printing once)." );
				printedZeroKey = true;
			}
			if ( groupId != g_hostdb.m_groupId )
				got++;
		}
	}
	if ( got != count ) {
		log ("db: Out of first %li records in indexdb, only %li belong "
		     "to our group.",count,got);
		// exit if NONE, we probably got the wrong data
		if ( got == 0 ) log("db: Are you sure you have the "
				    "right "
				    "data in the right directory? "
				    "Exiting.");
		log ( "db: Exiting due to Indexdb inconsistency." );
		g_threads.enableThreads();
		return g_conf.m_bypassValidation;
	}
	log ( LOG_INFO, "db: Indexdb passed verification successfully for %li "
			"recs.", count );
	// DONE
	g_threads.enableThreads();
	return true;
}
예제 #29
0
TA_RetCode TA_FuncTableAlloc( const char *group, TA_StringTable **table )
{
   TA_RetCode retCode;
   unsigned int i;
   TA_StringTable *stringTable;
   unsigned int groupId; /* TA_GroupId */
   unsigned int groupSize;
   const char *stringPtr;
   TA_StringTablePriv *stringTablePriv;

   if( (group == NULL) || (table == NULL ) )
   {
      return TA_BAD_PARAM;
   }

   *table = NULL;
   stringPtr = NULL;

   /* Get information on the group. */
   retCode = getGroupId( group, &groupId );
   if( retCode != TA_SUCCESS )
   {
      return retCode;
   }

   retCode = getGroupSize( (TA_GroupId)groupId, &groupSize );
   if( retCode != TA_SUCCESS )
   {
      return retCode;
   }

   /* Allocate the table. */

   stringTable = (TA_StringTable *)TA_Malloc( sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   if( !stringTable )
   {
      *table = NULL;
      return TA_ALLOC_ERR;
   }

   memset( stringTable, 0, sizeof(TA_StringTable) + sizeof(TA_StringTablePriv) );
   stringTablePriv = (TA_StringTablePriv *)(((char *)stringTable)+sizeof(TA_StringTable));
   stringTablePriv->magicNumber = TA_STRING_TABLE_FUNC_MAGIC_NB;
   stringTable->hiddenData = stringTablePriv;

   /* From this point, TA_FuncTableFree can be safely called. */
   stringTable->size = groupSize;
   if( groupSize != 0 )
   {
      stringTable->string = (const char **)TA_Malloc( (stringTable->size) *
                                                      sizeof(const char *) );

      if( stringTable->string == NULL )
      {
         *table = NULL;
         TA_FuncTableFree( stringTable );
         return TA_ALLOC_ERR;
      }

      memset( (void *)stringTable->string, 0,
              (stringTable->size) * sizeof(const char *) );

      for( i=0; i < stringTable->size; i++ )
      {
         retCode = getFuncNameByIdx( (TA_GroupId)groupId, i, &stringPtr );

         if( retCode != TA_SUCCESS )
         {
            *table = NULL;
            TA_FuncTableFree( stringTable );
            return TA_ALLOC_ERR;
         }

         (stringTable->string)[i] = stringPtr;
      }
   }

   /* Return the table to the caller. */
   *table = stringTable;

   return TA_SUCCESS;
}
GroupMessageContent* GroupLocationMessageContent::clone() const {
	return new GroupLocationMessageContent(getGroupId(), latitude, longitude, height, description);
}