implement NameHasOwner
This commit is contained in:
parent
0586219267
commit
18ec9899f7
1 changed files with 17 additions and 6 deletions
23
server.c
23
server.c
|
@ -297,12 +297,9 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
return -1;
|
||||
}
|
||||
|
||||
char *name_str = string_dup(name);
|
||||
if (!name_str) {
|
||||
return -1;
|
||||
}
|
||||
char *name_str = TRYPTR(string_dup(name));
|
||||
|
||||
struct jb_client *target = jb_server_name_find_client(s, destination_field->t.str);
|
||||
struct jb_client *target = jb_server_name_find_client(s, name_str);
|
||||
if (!target || target->unique_name_index < 0) {
|
||||
_reply_error("org.freedesktop.DBus.Error.NameHasNoOwner");
|
||||
return 0;
|
||||
|
@ -311,6 +308,20 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
_reply_begin("s") {
|
||||
TRYPTR(wire_set_string(&reply_ctx, s->names[target->unique_name_index].name));
|
||||
} _reply_end()
|
||||
} else if (strcmp(member, "NameHasOwner") == 0) {
|
||||
char *name = TRYPTR(wire_get_string(&ctx, NULL));
|
||||
int name_len = strlen(name);
|
||||
if (name_len < 1 || name_len > 256) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *name_str = TRYPTR(string_dup(name));
|
||||
|
||||
struct jb_client *target = jb_server_name_find_client(s, name_str);
|
||||
|
||||
_reply_begin("b") {
|
||||
TRYPTR(wire_set_u32(&reply_ctx, target ? 1 : 0));
|
||||
} _reply_end()
|
||||
} else {
|
||||
_reply_error("org.freedesktop.DBus.Error.UnknownMethod");
|
||||
return 0;
|
||||
|
@ -327,7 +338,7 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
|
|||
|
||||
default: {
|
||||
_reply_error("xyz.hippoz.jitterbug.NotImplemented");
|
||||
return -1;
|
||||
return 0;
|
||||
} break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue