begin of implementation for ScriptReceived
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17781 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Erik Jaesler ([email protected])
|
* Erik Jaesler ([email protected])
|
||||||
|
* Jerome Duval
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -949,15 +950,88 @@ bool
|
|||||||
BApplication::ScriptReceived(BMessage *message, int32 index,
|
BApplication::ScriptReceived(BMessage *message, int32 index,
|
||||||
BMessage *specifier, int32 what, const char *property)
|
BMessage *specifier, int32 what, const char *property)
|
||||||
{
|
{
|
||||||
// TODO: Implement
|
BMessage reply(B_REPLY);
|
||||||
printf("message:\n");
|
status_t err = B_BAD_SCRIPT_SYNTAX;
|
||||||
message->PrintToStream();
|
|
||||||
printf("index: %ld\n", index);
|
switch (what) {
|
||||||
printf("specifier:\n");
|
case B_GET_PROPERTY:
|
||||||
specifier->PrintToStream();
|
if (strcmp("Loopers", property) == 0) {
|
||||||
printf("what: %ld\n", what);
|
int32 count = CountLoopers();
|
||||||
printf("property: %s\n", property ? property : "");
|
err = B_OK;
|
||||||
|
for (int32 i=0; err == B_OK && i<count; i++) {
|
||||||
|
BMessenger messenger(LooperAt(i));
|
||||||
|
err = reply.AddMessenger("result", messenger);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (strcmp("Windows", property) == 0) {
|
||||||
|
int32 count = CountWindows();
|
||||||
|
err = B_OK;
|
||||||
|
for (int32 i=0; err == B_OK && i<count; i++) {
|
||||||
|
BMessenger messenger(WindowAt(i));
|
||||||
|
err = reply.AddMessenger("result", messenger);
|
||||||
|
}
|
||||||
|
} else if (strcmp("Window", property) == 0) {
|
||||||
|
switch (specifier->what) {
|
||||||
|
case B_INDEX_SPECIFIER: {
|
||||||
|
int32 ind = -1;
|
||||||
|
if (specifier->FindInt32("index", &ind)!=B_OK)
|
||||||
|
break;
|
||||||
|
BWindow *win = WindowAt(ind);
|
||||||
|
if (!win) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BMessenger messenger(win);
|
||||||
|
err = reply.AddMessenger("result", messenger);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_REVERSE_INDEX_SPECIFIER: {
|
||||||
|
int32 rindex;
|
||||||
|
if (specifier->FindInt32("index", &rindex) != B_OK)
|
||||||
|
break;
|
||||||
|
BWindow *win = WindowAt(CountWindows() - rindex);
|
||||||
|
if (!win) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BMessenger messenger(win);
|
||||||
|
err = reply.AddMessenger("result", messenger);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case B_NAME_SPECIFIER: {
|
||||||
|
const char *name;
|
||||||
|
err = specifier->FindString("name", &name);
|
||||||
|
if (err != B_OK)
|
||||||
|
break;
|
||||||
|
err = B_NAME_NOT_FOUND;
|
||||||
|
for (int32 i=0; i<CountWindows(); i++) {
|
||||||
|
BWindow *win = WindowAt(i);
|
||||||
|
if (win && win->Name() && strlen(win->Name()) == strlen(name)
|
||||||
|
&& !strcmp(win->Name(), name)) {
|
||||||
|
BMessenger messenger(win);
|
||||||
|
err = reply.AddMessenger("result", messenger);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_COUNT_PROPERTIES:
|
||||||
|
if (strcmp("Looper", property) == 0) {
|
||||||
|
err = reply.AddInt32("result", CountLoopers());
|
||||||
|
} else if (strcmp("Window", property) == 0) {
|
||||||
|
err = reply.AddInt32("result", CountWindows());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (err == B_BAD_SCRIPT_SYNTAX)
|
||||||
return false;
|
return false;
|
||||||
|
if (err < B_OK) {
|
||||||
|
reply.what = B_ERROR;
|
||||||
|
reply.AddString("message", strerror(err));
|
||||||
|
}
|
||||||
|
reply.AddInt32("error", err);
|
||||||
|
message->SendReply(&reply);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user