Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#3087 closed bug (fixed)

r28361 broke replicant handling functionality.

Reported by: siarzhuk Owned by: anevilyak
Priority: normal Milestone: R1
Component: Kits/Interface Kit Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

After updating to hrev28361 the 3rd-party application "Keymap Switcher" stopped to function correctly. It cannot switch keymaps on the shortcut. The is in SwitchFilter.cpp code: http://switcher.cvs.sourceforge.net/viewvc/switcher/keymapswitcher(haiku)/SwitchFilter.cpp?view=markup

The function:

//
int32 SwitchFilter::GetReplicantAt(BMessenger target, int32 index) const
{
	/*
	 So here we want to get the Unique ID of the replicant at the given index
	 in the target Shelf.
	 */
	 
	BMessage	request(B_GET_PROPERTY);		// We're getting the ID property
	BMessage	reply;
	status_t	err;
	
	request.AddSpecifier("ID");					// want the ID
	request.AddSpecifier("Replicant", index);	// of the index'th replicant
	
	if ((err = target.SendMessage(&request, &reply)) != B_OK)
		return err;
	
	int32	uid;
	if ((err = reply.FindInt32("result", &uid)) != B_OK) 
		return err;
	
	return uid;
}

The SendMessage call is returned correctly but returned message contains no "result".

Roll back to hrev28360 restore correct function of this application.

Change History (8)

comment:1 Changed 11 years ago by anevilyak

Status: newassigned

Will look into it, thanks for the note!

comment:2 Changed 11 years ago by anevilyak

Milestone: UnscheduledR1

comment:3 Changed 11 years ago by anevilyak

Could you please try again with hrev28571?

comment:4 Changed 11 years ago by siarzhuk

on hrev28572 I have observed following behavior:

Note that I have 2 replicants in Deskbar: 1) Process controller and 2) Switcher indicator.

SwitchFilter::GetReplicantAt() returns uid 1 for "Process Controller" and uid 2 for "Switcher indicator". The names of both replicants are obtained by SwitchFilter::GetReplicantName for corespondent uids correctly. But an attempt to call SwitchFilter::GetReplicantView fails with error 80002008 "Bad script syntax" in "result" filed of returned BMessage.

// Gets Indicator's BMessenger
BMessenger* SwitchFilter::GetIndicatorMessenger() {
	const char *REPLICANT_NAME = "Switcher/Deskbar";
	BMessenger *indicator = 0;

	BMessage	request(B_GET_PROPERTY);
	BMessenger	to;
	BMessenger	status;

	request.AddSpecifier("Messenger");
	request.AddSpecifier("Shelf");
	
	// In the Deskbar the Shelf is in the View "Status" in Window "Deskbar"
//	request.AddSpecifier("View", REPLICANT_NAME);
	request.AddSpecifier("View", "Status");
	request.AddSpecifier("Window", "Deskbar");
	to = BMessenger("application/x-vnd.Be-TSKB", -1);
	
	BMessage	reply;
	
	if (to.SendMessage(&request, &reply) == B_OK) {
		if(reply.FindMessenger("result", &status) == B_OK) {

			// enum replicant in Status view
			int32	index = 0;
			int32	uid;
			while ((uid = GetReplicantAt(status, index++)) >= B_OK) {
				BMessage	rep_info;
				if (GetReplicantName(status, uid, &rep_info) != B_OK) {
					continue;
				}
				const char *name;
				if (rep_info.FindString("result", &name) == B_OK) {
					if(strcmp(name, REPLICANT_NAME)==0) {
						BMessage rep_view;
						if (GetReplicantView(status, uid, &rep_view)==0) {
							BMessenger result;
							if (rep_view.FindMessenger("result", &result) == B_OK) {
								indicator = new BMessenger(result);
							}
						} 
					}
				}
			}
		}
	}
	return indicator;
}

//
status_t SwitchFilter::GetReplicantName(BMessenger target, int32 uid, BMessage *reply) const
{
	/*
	 We send a message to the target shelf, asking it for the Name of the 
	 replicant with the given unique id.
	 */
	 
	BMessage	request(B_GET_PROPERTY);
	BMessage	uid_specifier(B_ID_SPECIFIER);	// specifying via ID
	status_t	err;
	status_t	e;
	
	request.AddSpecifier("Name");		// ask for the Name of the replicant
	
	// IDs are specified using code like the following 3 lines:
	uid_specifier.AddInt32("id", uid);
	uid_specifier.AddString("property", "Replicant");
	request.AddSpecifier(&uid_specifier);
	
	if ((err = target.SendMessage(&request, reply)) != B_OK)
		return err;
	
	if (((err = reply->FindInt32("error", &e)) != B_OK) || (e != B_OK))
		return err ? err : e;
	
	return B_OK;
}

//
status_t SwitchFilter::GetReplicantView(BMessenger target, int32 uid, BMessage *reply) const
{
	/*
	 We send a message to the target shelf, asking it for the Name of the 
	 replicant with the given unique id.
	 */
	 
	BMessage	request(B_GET_PROPERTY);
	BMessage	uid_specifier(B_ID_SPECIFIER);	// specifying via ID
	status_t	err;
	status_t	e;
	
	request.AddSpecifier("View");		// ask for the Name of the replicant
	
	// IDs are specified using code like the following 3 lines:
	uid_specifier.AddInt32("id", uid);
	uid_specifier.AddString("property", "Replicant");
	request.AddSpecifier(&uid_specifier);
	
	if ((err = target.SendMessage(&request, reply)) != B_OK)
		return err;
	
	if (((err = reply->FindInt32("error", &e)) != B_OK) || (e != B_OK))
		return err ? err : e;
	
	return B_OK;
}

comment:5 Changed 11 years ago by anevilyak

GetReplicantView() worked prior to 28361? As far as I can see the Shelf never actually handled the View specifier at all.

comment:6 Changed 11 years ago by anevilyak

Never mind, after further reading I've finally understood how all this is (correctly) supposed to work. Please try with hrev28588 and let me know if that fixes it. If not, please let me know what response you get back.

comment:7 Changed 11 years ago by siarzhuk

Resolution: fixed
Status: assignedclosed

Looks like it's working now. Thanks.

comment:8 Changed 11 years ago by anevilyak

Thanks for altering me to that problem, at the time I didn't really have too many testcases available for more advanced shelf scripting. Appreciate your patience :)

Note: See TracTickets for help on using tickets.