Esempio n. 1
0
int test_inproc_bind_first (int send_hwm, int recv_hwm)
{
    return count_msg(send_hwm, recv_hwm, BIND_FIRST);
}
Esempio n. 2
0
int test_inproc_connect_first (int send_hwm, int recv_hwm)
{
    return count_msg(send_hwm, recv_hwm, CONNECT_FIRST);
}
Esempio n. 3
0
void
FolderShaper::WaitForOpeningFolder(const entry_ref * a_ref)	
{
	PRINT(("WaitForOpeningFolder()\n"));

	status_t	status;
//	int32		count = 0;
		
	BMessenger	tracker_messgr(FS_TRACKER_SIGNATURE);
	
//	snooze loop for thread
	PRINT(("## snooze loop for thread ##\n"));
	
	BString thread_name;
	BString ref_name;

	int32	cookie = 0;
	bool 	got_thread = false;
			
	team_id  my_team_id  =	tracker_messgr.Team();
	if (my_team_id != B_NAME_NOT_FOUND)
	{
		thread_info	info;
		
		for (int j = 0; j < 250; j++)
		{
			PRINT(("**************************************\n"));
			cookie = 0;
			
			while (get_next_thread_info(my_team_id, &cookie, &info) == B_OK)
			{
				thread_name	= 	info.name;
				ref_name	=	a_ref->name;
				ref_name.Prepend("w>");
				
				PRINT(("thread: %s\n", thread_name.String()));
				
				if (thread_name == ref_name)
				{
					got_thread = true;
					PRINT(("got thread %s\n", thread_name.String()));
					break;
				}	
			}
			
			if (got_thread)
				break;
			snooze(20000);
		}
	}
	else
	{
		PRINT(("Error: Could not set up BMessenger to Tracker!\n"));
		snooze(1000000);	// if no contact, snooze 1/10 sec
		return;				// then return
	}

//	snooze loop for window (Tr. scripting)
	PRINT(("## snooze loop for Tracker window ##\n"));
	
	bool got_window = false;
	
	for (int j = 0; j < 250; j++)
	{
		PRINT(("**************************************\n"));
		PRINT(("window snooze (%d)\n", j));
		
		if (IsFolderOpen(a_ref))
		{
			PRINT(("Tracker window is open.\n"));
			got_window = true;
			break;
		}
			
		snooze(20000);
	}

	if (! got_window)
	{
		PRINT(("Error: Tracker window did not open even though we snoozed quite some time!\n"));
		snooze(1000000);	// if no contact, snooze 1/10 sec
		return;				// then return
	}
	
//	snooze loop for contents loading
	PRINT(("## snooze loop for window contents ##\n"));

	BMessage	get_win_msg(B_GET_PROPERTY);
	BMessage	reply;
	
	entry_ref 	windowRef;
	BDirectory	window_dir;

	int32		dir_entry_count		=	0;
	int32		window_poses_count	=	0;
		
	int32	win_count = 0;
	for(win_count = 1; win_count < 1000; win_count++)
	{
		get_win_msg.MakeEmpty();
		get_win_msg.what = B_GET_PROPERTY;
		get_win_msg.AddSpecifier("Path");
		get_win_msg.AddSpecifier("Poses");
		get_win_msg.AddSpecifier("Window", win_count);
		
		reply.MakeEmpty();
		if((status = tracker_messgr.SendMessage(&get_win_msg, &reply)) != B_OK)
		{	ErrorMessage("Error: Invalid Reply From Tracker!\n", status);	return; }
	
		if((status = reply.FindRef("result", &windowRef)) != B_OK)
		{	PRINT(("(%ld) Error -- no windowRef: %s)\n", win_count, strerror(status))); }		
		
		if(*a_ref == windowRef)
		{
			PRINT(("That's the window! (win_count: %ld)\n", win_count));
			window_dir.SetTo(&windowRef);
			break;
		}
	}

// snooze loop for matching BDir entry count and BWindow poses count

	BMessage count_msg	(B_COUNT_PROPERTIES);
	count_msg.AddSpecifier("Entry");
	count_msg.AddSpecifier("Poses");
	count_msg.AddSpecifier("Window", win_count);

	dir_entry_count	=	window_dir.CountEntries();

	bool got_match = false;
	for (int j = 0; j < 200; j++)
	{
		PRINT(("**************************************\n"));
		PRINT(("try match (%d)\n", j));

		reply.MakeEmpty();	

		if ((status = tracker_messgr.SendMessage(&count_msg, &reply)) != B_OK)
		PRINT(("Error: Invalid Reply From Tracker!\n"));

		if (reply.FindInt32("result", & window_poses_count) == B_OK
			&& window_poses_count	==	dir_entry_count)
		{
			PRINT((" woohoo !\n"));
			got_match = true;
			break;
		}
		
		PRINT(("dir_entry_count: %ld\n", dir_entry_count));
		PRINT(("window_poses_count: %ld\n", window_poses_count));
			
		snooze(100000);
	}

	if (! got_match)
	{
		PRINT(("Error: BDir entries and BWindow poses did not match up.\n"));
		snooze(1000000);	// if no match, snooze 1/10 sec
		return;				// then return
	}
}