当前位置: 首页>>代码示例>>C++>>正文


C++ BQuery::SetVolume方法代码示例

本文整理汇总了C++中BQuery::SetVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ BQuery::SetVolume方法的具体用法?C++ BQuery::SetVolume怎么用?C++ BQuery::SetVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BQuery的用法示例。


在下文中一共展示了BQuery::SetVolume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BQuery

bool
GeneralView::_CanFindServer(entry_ref* ref)
{
	// Try searching with be_roster
	if (be_roster->FindApp(kNotificationServerSignature, ref) == B_OK)
		return true;

	// Try with a query and take the first result
	BVolumeRoster vroster;
	BVolume volume;
	char volName[B_FILE_NAME_LENGTH];

	vroster.Rewind();

	while (vroster.GetNextVolume(&volume) == B_OK) {
		if ((volume.InitCheck() != B_OK) || !volume.KnowsQuery())
			continue;

		volume.GetName(volName);

		BQuery *query = new BQuery();
		query->SetPredicate("(BEOS:APP_SIG==\""kNotificationServerSignature"\")");
		query->SetVolume(&volume);
		query->Fetch();

		if (query->GetNextRef(ref) == B_OK)
			return true;
	}

	return false;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:31,代码来源:GeneralView.cpp

示例2: new

status_t
QueryEntryListCollection::FetchOneQuery(const BQuery* copyThis,
	BHandler* target, BObjectList<BQuery>* list, BVolume* volume)
{
	BQuery* query = new (nothrow) BQuery;
	if (query == NULL)
		return B_NO_MEMORY;

	// have to fake a copy constructor here because BQuery doesn't have
	// a copy constructor
	BString buffer;
	const_cast<BQuery*>(copyThis)->GetPredicate(&buffer);
	query->SetPredicate(buffer.String());

	query->SetTarget(BMessenger(target));
	query->SetVolume(volume);

	status_t result = query->Fetch();
	if (result != B_OK) {
		PRINT(("fetch error %s\n", strerror(result)));
		delete query;
		return result;
	}

	list->AddItem(query);

	return B_OK;
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:28,代码来源:QueryPoseView.cpp

示例3: volume

void
LiveQuery::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgAddQuery:
		{
			int32 device;
			const char* predicate;
			if (message->FindInt32("volume", &device) != B_OK
				|| message->FindString("predicate", &predicate) != B_OK)
				break;

			BVolume volume(device);
			BQuery* query = new BQuery;

			// Set up the volume and predicate for the query.
			query->SetVolume(&volume);
			query->SetPredicate(predicate);
			query->SetTarget(this);

			fQueries.AddItem(query);
			_PerformQuery(*query);
			break;
		}

		case B_QUERY_UPDATE:
		{
			int32 what;
			message->FindInt32("opcode", &what);

			int32 device;
			int64 directory;
			int64 node;
			const char* name;
			message->FindInt32("device", &device);
			message->FindInt64("directory", &directory);
			message->FindInt64("node", &node);
			message->FindString("name", &name);

			switch (what) {
				case B_ENTRY_CREATED:
				{
					printf("CREATED %s\n", name);
					break;
				}
				case B_ENTRY_REMOVED:
					printf("REMOVED %s\n", name);
					break;
			}
			break;
		}

		default:
			BApplication::MessageReceived(message);
			break;
	}
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:57,代码来源:live_query.cpp

示例4:

void
THeaderView::InitEmailCompletion()
{
	// get boot volume
	BVolume volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.SetPredicate("META:email=**");
		// Due to R5 BFS bugs, you need two stars, META:email=** for the query.
		// META:email="*" will just return one entry and stop, same with
		// META:email=* and a few other variations.  Grumble.
	query.Fetch();
	entry_ref ref;

	while (query.GetNextRef (&ref) == B_OK) {
		BNode file;
		if (file.SetTo(&ref) == B_OK) {
			// Add the e-mail address as an auto-complete string.
			BString email;
			if (file.ReadAttrString("META:email", &email) >= B_OK)
				fEmailList.AddChoice(email.String());

			// Also add the quoted full name as an auto-complete string.  Can't
			// do unquoted since auto-complete isn't that smart, so the user
			// will have to type a quote mark if he wants to select someone by
			// name.
			BString fullName;
			if (file.ReadAttrString("META:name", &fullName) >= B_OK) {
				if (email.FindFirst('<') < 0) {
					email.ReplaceAll('>', '_');
					email.Prepend("<");
					email.Append(">");
				}
				fullName.ReplaceAll('\"', '_');
				fullName.Prepend("\"");
				fullName << "\" " << email;
				fEmailList.AddChoice(fullName.String());
			}

			// support for 3rd-party People apps.  Looks like a job for
			// multiple keyword (so you can have several e-mail addresses in
			// one attribute, perhaps comma separated) indices!  Which aren't
			// yet in BFS.
			for (int16 i = 2; i < 6; i++) {
				char attr[16];
				sprintf(attr, "META:email%d", i);
				if (file.ReadAttrString(attr, &email) >= B_OK)
					fEmailList.AddChoice(email.String());
			}
		}
	}
}
开发者ID:sahil9912,项目名称:haiku,代码行数:54,代码来源:Header.cpp

示例5:

status_t
CDDBQuery::_OpenContentFile(const int32 &discID)
{
	// Makes sure that the lookup has a valid file to work with for the CD
	// content. Returns true if there is an existing file, false if a lookup is
	// required.

	BFile file;
	BString predicate;
	predicate << "CD:key == " << discID;
	entry_ref ref;

	BVolumeRoster roster;
	BVolume volume;
	roster.Rewind();
	while (roster.GetNextVolume(&volume) == B_OK) {
		if (volume.IsReadOnly() || !volume.IsPersistent() || !volume.KnowsAttr()
			|| !volume.KnowsQuery())
			continue;

		// make sure the volume we are looking at is indexed right
		fs_create_index(volume.Device(), "CD:key", B_INT32_TYPE, 0);

		BQuery query;
		query.SetVolume(&volume);
		query.SetPredicate(predicate.String());
		if (query.Fetch() != B_OK)
			continue;

		if (query.GetNextRef(&ref) == B_OK) 
			break;
	}

	status_t status = fCDData.Load(ref);
	if (status == B_NO_INIT) {
		// We receive this error when the Load() function couldn't load the
		// track times This just means that we get it from the SCSI data given
		// to us in SetToCD
		vector<CDAudioTime> times;
		GetTrackTimes(&fSCSIData,times);

		for (int32 i = 0; i < fCDData.CountTracks(); i++) {
			CDAudioTime *item = fCDData.TrackTimeAt(i);
			*item = times[i + 1] - times[i];
		}

		status = B_OK;
	}

	return status;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:51,代码来源:CDDBSupport.cpp

示例6:

void
POP3Protocol::CheckForDeletedMessages()
{
	{
		// Delete things from the manifest no longer on the server
		BStringList list;
		NotHere(fUniqueIDs, fManifest, &list);
		fManifest.Remove(list);
	}

	if (!fSettings.FindBool("delete_remote_when_local")
		|| fManifest.CountStrings() == 0)
		return;

	BStringList toDelete;

	BStringList queryContents;
	BVolumeRoster volumes;
	BVolume volume;

	while (volumes.GetNextVolume(&volume) == B_OK) {
		BQuery fido;
		entry_ref entry;

		fido.SetVolume(&volume);
		fido.PushAttr(B_MAIL_ATTR_ACCOUNT_ID);
		fido.PushInt32(fAccountSettings.AccountID());
		fido.PushOp(B_EQ);

		fido.Fetch();

		BString uid;
		while (fido.GetNextRef(&entry) == B_OK) {
			BNode(&entry).ReadAttrString("MAIL:unique_id", &uid);
			queryContents.Add(uid);
		}
	}
	NotHere(queryContents, fManifest, &toDelete);

	for (int32 i = 0; i < toDelete.CountStrings(); i++) {
		printf("delete mail on server uid %s\n", toDelete.StringAt(i).String());
		Delete(fUniqueIDs.IndexOf(toDelete.StringAt(i)));
	}

	// Don't remove ids from fUniqueIDs, the indices have to stay the same when
	// retrieving new messages.
	fManifest.Remove(toDelete);

	// TODO: at some point the purged manifest should be written to disk
	// otherwise it will grow forever
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:51,代码来源:POP3.cpp

示例7: n

void
QueryView::GetInitialEntries()
{	
	fEntryCount = 0;	
	entry_ref ref;

//	slaad
	BNode n(&ref);
	vollist vols;
	
	ExtractQueryVolumes(&n, &vols);
	vollist::iterator vIt;
	
	for (vIt = vols.begin(); vIt != vols.end(); vIt++) {
		BQuery *query = new BQuery();
		query->SetVolume(&(*vIt));
		query->SetPredicate(fPredicate.String());
		query->SetTarget(this);
		query->Fetch();
	
		while( query->GetNextRef(&ref) == B_OK )
		{
			// eiman
			BEntry entry(&ref);
			node_ref node;
			entry.GetNodeRef(&node);
			
			BMessage msg;
			msg.AddInt32("opcode",B_ENTRY_CREATED);
			msg.AddString("name",ref.name);
			msg.AddInt64("directory",ref.directory);
			msg.AddInt32("device",ref.device);
			msg.AddInt64("node",node.node);
			if ( !ShouldIgnore(&msg) )
			{
				fEntryCount++;
			}
		}
		
		fQueries.push_back(query);
	};
	
	#ifdef DEBUG
	BeDC dc("QueryWatcher");
	BString str;
	str<<Name()<<" initial count: "<<fEntryCount;
	dc.SendMessage(str.String());
	#endif

	UpdateDisplay();
}
开发者ID:marmida,项目名称:QueryWatcher,代码行数:51,代码来源:App.cpp

示例8: filePath

status_t
TeamWindow::_RetrieveMatchingSourceEntries(const BString& path,
	BStringList* _entries)
{
	BPath filePath(path);
	status_t error = filePath.InitCheck();
	if (error != B_OK)
		return error;

	_entries->MakeEmpty();

	BQuery query;
	BString predicate;
	query.PushAttr("name");
	query.PushString(filePath.Leaf());
	query.PushOp(B_EQ);

	error = query.GetPredicate(&predicate);
	if (error != B_OK)
		return error;

	BVolumeRoster roster;
	BVolume volume;
	while (roster.GetNextVolume(&volume) == B_OK) {
		if (!volume.KnowsQuery())
			continue;

		if (query.SetVolume(&volume) != B_OK)
			continue;

		error = query.SetPredicate(predicate.String());
		if (error != B_OK)
			continue;

		if (query.Fetch() != B_OK)
			continue;

		entry_ref ref;
		while (query.GetNextRef(&ref) == B_OK) {
			filePath.SetTo(&ref);
			_entries->Add(filePath.Path());
		}

		query.Clear();
	}

	return B_OK;
}
开发者ID:MaddTheSane,项目名称:haiku,代码行数:48,代码来源:TeamWindow.cpp

示例9: file

int32
add_query_menu_items(BMenu* menu, const char* attribute, uint32 what,
	const char* format, bool popup)
{
	BVolume	volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.PushAttr(attribute);
	query.PushString("*");
	query.PushOp(B_EQ);
	query.Fetch();

	int32 index = 0;
	BEntry entry;
	while (query.GetNextEntry(&entry) == B_OK) {
		BFile file(&entry, B_READ_ONLY);
		if (file.InitCheck() == B_OK) {
			BMessage* message = new BMessage(what);

			entry_ref ref;
			entry.GetRef(&ref);
			message->AddRef("ref", &ref);

			BString value;
			if (file.ReadAttrString(attribute, &value) < B_OK)
				continue;

			message->AddString("attribute", value.String());

			BString name;
			if (format != NULL)
				name.SetToFormat(format, value.String());
			else
				name = value;

			if (index < 9 && !popup)
				menu->AddItem(new BMenuItem(name, message, '1' + index));
			else
				menu->AddItem(new BMenuItem(name, message));
			index++;
		}
	}

	return index;
}
开发者ID:DonCN,项目名称:haiku,代码行数:47,代码来源:MailSupport.cpp

示例10: BPopUpMenu

BPopUpMenu*
TPrefsWindow::_BuildSignatureMenu(char* sig)
{
	char name[B_FILE_NAME_LENGTH];
	BEntry entry;
	BFile file;
	BMenuItem* item;
	BMessage* msg;
	BQuery query;
	BVolume vol;
	BVolumeRoster volume;

	BPopUpMenu* menu = new BPopUpMenu("");

	msg = new BMessage(P_SIG);
	msg->AddString("signature", B_TRANSLATE("None"));
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("None"), msg));
	if (!strcmp(sig, B_TRANSLATE("None")))
		item->SetMarked(true);

	msg = new BMessage(P_SIG);
	msg->AddString("signature", B_TRANSLATE("Random"));
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Random"), msg));
	if (!strcmp(sig, B_TRANSLATE("Random")))
		item->SetMarked(true);
	menu->AddSeparatorItem();

	volume.GetBootVolume(&vol);
	query.SetVolume(&vol);
	query.SetPredicate("_signature = *");
	query.Fetch();

	while (query.GetNextEntry(&entry) == B_NO_ERROR) {
		file.SetTo(&entry, O_RDONLY);
		if (file.InitCheck() == B_NO_ERROR) {
			msg = new BMessage(P_SIG);
			file.ReadAttr("_signature", B_STRING_TYPE, 0, name, sizeof(name));
			msg->AddString("signature", name);
			menu->AddItem(item = new BMenuItem(name, msg));
			if (!strcmp(sig, name))
				item->SetMarked(true);
		}
	}
	return menu;
}
开发者ID:simonsouth,项目名称:haiku,代码行数:45,代码来源:Prefs.cpp

示例11:

void
Feeder::AddQuery(BVolume *volume)
{
	fVolumeList.AddItem((void*)volume) ;

	BQuery *query = new BQuery ;	
	query->SetVolume(volume) ;
	
	// query->SetPredicate("name = *.txt") ;
	query->SetPredicate("last_modified > %now%") ;
	query->SetTarget(this) ;
	
	if (query->Fetch() == B_OK) {
		RetrieveStaticRefs(query) ;
		fQueryList.AddItem((void *)query) ;
	} else
		delete query ;
}
开发者ID:HaikuArchives,项目名称:Beacon,代码行数:18,代码来源:Feeder.cpp

示例12:

bool
TStatusWindow::_Exists(const char* status)
{
	BVolume volume;
	BVolumeRoster().GetBootVolume(&volume);

	BQuery query;
	query.SetVolume(&volume);
	query.PushAttr(INDEX_STATUS);
	query.PushString(status);
	query.PushOp(B_EQ);
	query.Fetch();

	BEntry entry;
	if (query.GetNextEntry(&entry) == B_NO_ERROR)
		return true;

	return false;
}
开发者ID:DonCN,项目名称:haiku,代码行数:19,代码来源:Status.cpp

示例13:

uint32
FetchQuery(query_op op, const char* selection, vector<BString>& results,
			bool caseSensitive = false)
{
	BQuery query;

	query.PushAttr("BEOS:TYPE");
	query.PushString("application/x-vnd.Be-doc_bookmark");
	query.PushOp(B_EQ);
	query.PushAttr("name");
	query.PushString(selection, caseSensitive);
	query.PushOp(op);
	query.PushOp(B_AND);

	BVolume vol;
	BVolumeRoster roster;

	roster.GetBootVolume(&vol);
	query.SetVolume(&vol);

	if (B_NO_INIT == query.Fetch())
		return 0;

	BEntry entry;
	BPath path;
	int32 counter = 0;

	while (query.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
		if (entry.InitCheck() == B_OK) {
			entry.GetPath(&path);

			if (path.InitCheck() == B_OK) {
				results.push_back(path.Path());
				counter++;
			}
		}
	}

	return counter;
}
开发者ID:jscipione,项目名称:Paladin,代码行数:40,代码来源:BeBookFetch.cpp

示例14:

void
MusicCollectionWindow::_StartNewQuery()
{
	fQueryReader->Reset();
	fQueryHandler->Reset();

	BString orgString = fQueryField->Text();
	((ListViewListener<FileListItem>*)fEntryViewInterface)->SetQueryString(
		orgString);

	BVolume volume;
	//BVolumeRoster().GetBootVolume(&volume);
	BVolumeRoster roster;
	while (roster.GetNextVolume(&volume) == B_OK) {
		if (!volume.KnowsQuery())
			continue;
		BQuery* query = _CreateQuery(orgString);
		query->SetVolume(&volume);
		fQueryReader->AddQuery(query);
	}

	fQueryReader->Run();
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:23,代码来源:MusicCollectionWindow.cpp

示例15: volume

int
main(int argc, char** argv)
{
	if (argc < 2) {
		fprintf(stderr, "usage: %s <message-code>\n", __progname);
		return -1;
	}

	int32 number = atol(argv[1]);

	BQuery query;
	query.SetPredicate("name=ServerProtocol.h");

	// search on current volume only
	dev_t device = dev_for_path(".");
	BVolume volume(device);

	query.SetVolume(&volume);
	query.Fetch();

	status_t status;
	BEntry entry;
	while ((status = query.GetNextEntry(&entry)) == B_OK) {
		BPath path(&entry);
		puts(path.Path());
		if (strstr(path.Path(), "headers/private/app/ServerProtocol.h") != NULL) {
			print_code(path, number);
			break;
		}
	}

	if (status != B_OK) {
		fprintf(stderr, "%s: could not find ServerProtocol.h", __progname);
		return -1;
	}
	return 0;
}
开发者ID:mmanley,项目名称:Antares,代码行数:37,代码来源:code_to_name.cpp


注:本文中的BQuery::SetVolume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。