Changeset be15256 in mainline


Ignore:
Timestamp:
2019-11-05T08:00:18Z (5 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b2d1df3
Parents:
b3c185b6
git-author:
Jiri Svoboda <jiri@…> (2019-10-04 19:00:15)
git-committer:
Jiri Svoboda <jiri@…> (2019-11-05 08:00:18)
Message:

ds_client should not have reverse dependency on libdisplay's display_srv

Breaks layering and hampers testability

Location:
uspace/srv/hid/display
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/client.c

    rb3c185b6 rbe15256  
    3434 */
    3535
    36 #include <disp_srv.h>
    3736#include <errno.h>
    3837#include <stdlib.h>
     
    4443 *
    4544 * @param display Parent display
     45 * @param cb Client callbacks
     46 * @param cb_arg Callback argument
    4647 * @param rclient Place to store pointer to new client.
    4748 * @return EOK on success, ENOMEM if out of memory
    4849 */
    49 errno_t ds_client_create(ds_display_t *display, display_srv_t *srv,
    50     ds_client_t **rclient)
     50errno_t ds_client_create(ds_display_t *display, ds_client_cb_t *cb,
     51    void *cb_arg, ds_client_t **rclient)
    5152{
    5253        ds_client_t *client;
     
    5859        list_initialize(&client->windows);
    5960        prodcons_initialize(&client->events);
    60         client->srv = srv;
     61        client->cb = cb;
     62        client->cb_arg = cb_arg;
    6163
    6264        ds_display_add_client(display, client);
     
    195197        /* Notify the client */
    196198        // TODO Do not send more than once until client drains the queue
    197         display_srv_ev_pending(client->srv);
     199        client->cb->ev_pending(client->cb_arg);
    198200
    199201        return EOK;
  • uspace/srv/hid/display/client.h

    rb3c185b6 rbe15256  
    3737#define CLIENT_H
    3838
    39 #include <disp_srv.h>
    4039#include "types/display/client.h"
    4140#include "types/display/display.h"
    4241
    43 extern errno_t ds_client_create(ds_display_t *, display_srv_t *, ds_client_t **);
     42extern errno_t ds_client_create(ds_display_t *, ds_client_cb_t *, void *,
     43    ds_client_t **);
    4444extern void ds_client_destroy(ds_client_t *);
    4545extern errno_t ds_client_add_window(ds_client_t *, ds_window_t *);
  • uspace/srv/hid/display/main.c

    rb3c185b6 rbe15256  
    5252
    5353static void display_client_conn(ipc_call_t *, void *);
     54static void display_client_ev_pending(void *);
     55
     56static ds_client_cb_t display_client_cb = {
     57        .ev_pending = display_client_ev_pending
     58};
    5459
    5560static void display_kbd_event(void *arg, kbd_event_t *event)
     
    5964        printf("display_kbd_event\n");
    6065        ds_display_post_kbd_event(disp, event);
     66}
     67
     68static void display_client_ev_pending(void *arg)
     69{
     70        display_srv_t *srv = (display_srv_t *) arg;
     71        printf("display_client_ev_pending\n");
     72        display_srv_ev_pending(srv);
    6173}
    6274
     
    137149        if (svc_id != 0) {
    138150                /* Create client object */
    139                 rc = ds_client_create(disp, &srv, &client);
     151                rc = ds_client_create(disp, &display_client_cb, &srv, &client);
    140152                if (rc != EOK) {
    141153                        async_answer_0(icall, ENOMEM);
  • uspace/srv/hid/display/test/display.c

    rb3c185b6 rbe15256  
    3939PCUT_TEST_SUITE(display);
    4040
     41static void test_ds_ev_pending(void *);
     42
     43static ds_client_cb_t test_ds_client_cb = {
     44        .ev_pending = test_ds_ev_pending
     45};
     46
     47static void test_ds_ev_pending(void *arg)
     48{
     49        printf("test_ds_ev_pending\n");
     50}
     51
     52
    4153/** Display creation and destruction. */
    4254PCUT_TEST(display_create_destroy)
     
    6274        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    6375
    64         rc = ds_client_create(disp, NULL, &client);
     76        rc = ds_client_create(disp, &test_ds_client_cb, NULL, &client);
    6577        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    6678
  • uspace/srv/hid/display/test/window.c

    rb3c185b6 rbe15256  
    4747        errno_t rc;
    4848
    49         rc = ds_client_create(NULL, NULL, &client);
     49        rc = ds_client_create(NULL, NULL, NULL, &client);
    5050        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
    5151
  • uspace/srv/hid/display/types/display/client.h

    rb3c185b6 rbe15256  
    3939#include <adt/list.h>
    4040#include <adt/prodcons.h>
    41 #include <disp_srv.h>
    4241
    4342typedef sysarg_t ds_wnd_id_t;
     43
     44/** Display server client callbacks */
     45typedef struct {
     46        void (*ev_pending)(void *);
     47} ds_client_cb_t;
    4448
    4549/** Display server client */
     
    4751        /** Parent display */
    4852        struct ds_display *display;
    49         /** Display protocol per-connection structure */
    50         display_srv_t *srv;
     53        /** Callbacks */
     54        ds_client_cb_t *cb;
     55        /** Callback argument */
     56        void *cb_arg;
    5157        /** Link to @c display->clients */
    5258        link_t lclients;
Note: See TracChangeset for help on using the changeset viewer.