* ResolveSpecifier() used the window's handler name instead of its title for the "Window"
B_NAME_SPECIFIER. This should fix bug #1681. * Improved ResolveSpecifier() code. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23239 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -51,12 +51,21 @@ BResources *BApplication::sAppResources = NULL;
|
|||||||
BLocker BApplication::sAppResourcesLock("_app_resources_lock");
|
BLocker BApplication::sAppResourcesLock("_app_resources_lock");
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
kWindowByIndex,
|
||||||
|
kWindowByName,
|
||||||
|
kLooperByIndex,
|
||||||
|
kLooperByID,
|
||||||
|
kLooperByName,
|
||||||
|
kApplication
|
||||||
|
};
|
||||||
|
|
||||||
static property_info sPropertyInfo[] = {
|
static property_info sPropertyInfo[] = {
|
||||||
{
|
{
|
||||||
"Window",
|
"Window",
|
||||||
{},
|
{},
|
||||||
{B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER},
|
{B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER},
|
||||||
NULL, 0,
|
NULL, kWindowByIndex,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -65,7 +74,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Window",
|
"Window",
|
||||||
{},
|
{},
|
||||||
{B_NAME_SPECIFIER},
|
{B_NAME_SPECIFIER},
|
||||||
NULL, 1,
|
NULL, kWindowByName,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -74,7 +83,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Looper",
|
"Looper",
|
||||||
{},
|
{},
|
||||||
{B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER},
|
{B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER},
|
||||||
NULL, 2,
|
NULL, kLooperByIndex,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -83,7 +92,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Looper",
|
"Looper",
|
||||||
{},
|
{},
|
||||||
{B_ID_SPECIFIER},
|
{B_ID_SPECIFIER},
|
||||||
NULL, 3,
|
NULL, kLooperByID,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -92,7 +101,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Looper",
|
"Looper",
|
||||||
{},
|
{},
|
||||||
{B_NAME_SPECIFIER},
|
{B_NAME_SPECIFIER},
|
||||||
NULL, 4,
|
NULL, kLooperByName,
|
||||||
{},
|
{},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -101,7 +110,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Name",
|
"Name",
|
||||||
{B_GET_PROPERTY},
|
{B_GET_PROPERTY},
|
||||||
{B_DIRECT_SPECIFIER},
|
{B_DIRECT_SPECIFIER},
|
||||||
NULL, 5,
|
NULL, kApplication,
|
||||||
{B_STRING_TYPE},
|
{B_STRING_TYPE},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -110,7 +119,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Window",
|
"Window",
|
||||||
{B_COUNT_PROPERTIES},
|
{B_COUNT_PROPERTIES},
|
||||||
{B_DIRECT_SPECIFIER},
|
{B_DIRECT_SPECIFIER},
|
||||||
NULL, 5,
|
NULL, kApplication,
|
||||||
{B_INT32_TYPE},
|
{B_INT32_TYPE},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -119,7 +128,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Loopers",
|
"Loopers",
|
||||||
{B_GET_PROPERTY},
|
{B_GET_PROPERTY},
|
||||||
{B_DIRECT_SPECIFIER},
|
{B_DIRECT_SPECIFIER},
|
||||||
NULL, 5,
|
NULL, kApplication,
|
||||||
{B_MESSENGER_TYPE},
|
{B_MESSENGER_TYPE},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -128,7 +137,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Windows",
|
"Windows",
|
||||||
{B_GET_PROPERTY},
|
{B_GET_PROPERTY},
|
||||||
{B_DIRECT_SPECIFIER},
|
{B_DIRECT_SPECIFIER},
|
||||||
NULL, 5,
|
NULL, kApplication,
|
||||||
{B_MESSENGER_TYPE},
|
{B_MESSENGER_TYPE},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -137,7 +146,7 @@ static property_info sPropertyInfo[] = {
|
|||||||
"Looper",
|
"Looper",
|
||||||
{B_COUNT_PROPERTIES},
|
{B_COUNT_PROPERTIES},
|
||||||
{B_DIRECT_SPECIFIER},
|
{B_DIRECT_SPECIFIER},
|
||||||
NULL, 5,
|
NULL, kApplication,
|
||||||
{B_INT32_TYPE},
|
{B_INT32_TYPE},
|
||||||
{},
|
{},
|
||||||
{}
|
{}
|
||||||
@@ -622,105 +631,114 @@ BApplication::AboutRequested()
|
|||||||
|
|
||||||
BHandler *
|
BHandler *
|
||||||
BApplication::ResolveSpecifier(BMessage *message, int32 index,
|
BApplication::ResolveSpecifier(BMessage *message, int32 index,
|
||||||
BMessage *specifier, int32 what, const char *property)
|
BMessage *specifier, int32 what, const char *property)
|
||||||
{
|
{
|
||||||
BPropertyInfo propInfo(sPropertyInfo);
|
BPropertyInfo propInfo(sPropertyInfo);
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
uint32 data;
|
uint32 data;
|
||||||
|
|
||||||
if (propInfo.FindMatch(message, 0, specifier, what, property, &data) >=0) {
|
if (propInfo.FindMatch(message, 0, specifier, what, property, &data) >= 0) {
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 0: {
|
case kWindowByIndex:
|
||||||
int32 ind = -1;
|
{
|
||||||
err = specifier->FindInt32("index", &ind);
|
int32 index;
|
||||||
|
err = specifier->FindInt32("index", &index);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (what == B_REVERSE_INDEX_SPECIFIER)
|
if (what == B_REVERSE_INDEX_SPECIFIER)
|
||||||
ind = CountWindows() - ind;
|
index = CountWindows() - index;
|
||||||
err = B_BAD_INDEX;
|
|
||||||
BWindow *win = WindowAt(ind);
|
BWindow *window = WindowAt(index);
|
||||||
if (win) {
|
if (window != NULL) {
|
||||||
if (index <= 0 && message->what == B_GET_PROPERTY)
|
|
||||||
return this;
|
|
||||||
message->PopSpecifier();
|
message->PopSpecifier();
|
||||||
BMessenger(win).SendMessage(message);
|
BMessenger(window).SendMessage(message);
|
||||||
return NULL;
|
} else
|
||||||
}
|
err = B_BAD_INDEX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
|
||||||
|
case kWindowByName:
|
||||||
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
err = specifier->FindString("name", &name);
|
err = specifier->FindString("name", &name);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
err = B_NAME_NOT_FOUND;
|
|
||||||
for (int32 i=0; i<CountWindows(); i++) {
|
for (int32 i = 0;; i++) {
|
||||||
BWindow *win = WindowAt(i);
|
BWindow *window = WindowAt(i);
|
||||||
if (win && win->Name() && strlen(win->Name()) == strlen(name)
|
if (window == NULL) {
|
||||||
&& !strcmp(win->Name(), name)) {
|
err = B_NAME_NOT_FOUND;
|
||||||
if (index <= 0 && message->what == B_GET_PROPERTY)
|
break;
|
||||||
return this;
|
}
|
||||||
message->PopSpecifier();
|
if (window->Title() != NULL && !strcmp(window->Title(), name)) {
|
||||||
BMessenger(win).SendMessage(message);
|
message->PopSpecifier();
|
||||||
return NULL;
|
BMessenger(window).SendMessage(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
|
||||||
int32 ind = -1;
|
case kLooperByIndex:
|
||||||
err = specifier->FindInt32("index", &ind);
|
{
|
||||||
|
int32 index;
|
||||||
|
err = specifier->FindInt32("index", &index);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (what == B_REVERSE_INDEX_SPECIFIER)
|
if (what == B_REVERSE_INDEX_SPECIFIER)
|
||||||
ind = CountLoopers() - ind;
|
index = CountLoopers() - index;
|
||||||
err = B_BAD_INDEX;
|
|
||||||
BLooper *looper = LooperAt(ind);
|
BLooper *looper = LooperAt(index);
|
||||||
if (looper) {
|
if (looper != NULL) {
|
||||||
if (index <= 0)
|
|
||||||
return this;
|
|
||||||
message->PopSpecifier();
|
message->PopSpecifier();
|
||||||
BMessenger(looper).SendMessage(message);
|
BMessenger(looper).SendMessage(message);
|
||||||
return NULL;
|
} else
|
||||||
}
|
err = B_BAD_INDEX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3:
|
|
||||||
//if (index == 0)
|
case kLooperByID:
|
||||||
// return this;
|
// TODO: implement getting looper by ID!
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 4: {
|
|
||||||
|
case kLooperByName:
|
||||||
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
err = specifier->FindString("name", &name);
|
err = specifier->FindString("name", &name);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
break;
|
break;
|
||||||
err = B_NAME_NOT_FOUND;
|
|
||||||
for (int32 i=0; i<CountLoopers(); i++) {
|
for (int32 i = 0;; i++) {
|
||||||
BLooper *looper = LooperAt(i);
|
BLooper *looper = LooperAt(i);
|
||||||
if (looper && looper->Name() && strlen(looper->Name()) == strlen(name)
|
if (looper == NULL) {
|
||||||
&& !strcmp(looper->Name(), name)) {
|
err = B_NAME_NOT_FOUND;
|
||||||
if (index <= 0)
|
break;
|
||||||
return this;
|
}
|
||||||
|
if (looper->Name() != NULL && !strcmp(looper->Name(), name)) {
|
||||||
message->PopSpecifier();
|
message->PopSpecifier();
|
||||||
BMessenger(looper).SendMessage(message);
|
BMessenger(looper).SendMessage(message);
|
||||||
return NULL;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5:
|
|
||||||
|
case kApplication:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return BLooper::ResolveSpecifier(message, index, specifier, what,
|
return BLooper::ResolveSpecifier(message, index, specifier, what,
|
||||||
property);
|
property);
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage reply(B_MESSAGE_NOT_UNDERSTOOD);
|
if (err != B_OK) {
|
||||||
reply.AddInt32("error", err);
|
BMessage reply(B_MESSAGE_NOT_UNDERSTOOD);
|
||||||
reply.AddString("message", strerror(err));
|
reply.AddInt32("error", err);
|
||||||
message->SendReply(&reply);
|
reply.AddString("message", strerror(err));
|
||||||
|
message->SendReply(&reply);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user