Changeset 14cbf07 in mainline for uspace/app/display-cfg/display-cfg.c


Ignore:
Timestamp:
2023-05-15T16:19:52Z (17 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2b5628c, 8a4ceaa
Parents:
aace43d8
Message:

Fill in tests seats_list_populate and avail_devices_insert

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/display-cfg/display-cfg.c

    raace43d8 r14cbf07  
    6565 *
    6666 * @param display_spec Display specification
     67 * @param dcfg_svc Display configuration service name or DISPCFG_DEFAULT
    6768 * @param rdcfg Place to store pointer to new display configuration
    6869 * @return EOK on success or an error code
     
    8283                printf("Out of memory.\n");
    8384                return ENOMEM;
    84         }
    85 
    86         rc = dispcfg_open(DISPCFG_DEFAULT, NULL, NULL, &dcfg->dispcfg);
    87         if (rc != EOK) {
    88                 printf("Error opening display configuration service.\n");
    89                 goto error;
    9085        }
    9186
     
    150145        ui_window_add(window, ui_fixed_ctl(dcfg->fixed));
    151146
    152         rc = ui_window_paint(window);
    153         if (rc != EOK) {
    154                 printf("Error painting window.\n");
    155                 return rc;
    156         }
    157 
    158147        *rdcfg = dcfg;
    159148        return EOK;
     
    167156        if (dcfg->ui != NULL)
    168157                ui_destroy(ui);
     158        free(dcfg);
     159        return rc;
     160}
     161
     162/** Open display configuration service.
     163 *
     164 * @param dcfg Display configuration dialog
     165 * @param dcfg_svc Display configuration service name or DISPCFG_DEFAULT
     166 * @return EOK on success or an error code
     167 */
     168errno_t display_cfg_open(display_cfg_t *dcfg, const char *dcfg_svc)
     169{
     170        errno_t rc;
     171
     172        rc = dispcfg_open(dcfg_svc, NULL, NULL, &dcfg->dispcfg);
     173        if (rc != EOK) {
     174                printf("Error opening display configuration service.\n");
     175                goto error;
     176        }
     177
     178        return EOK;
     179error:
     180        return rc;
     181}
     182
     183/** Populate display configuration from isplay configuration service.
     184 *
     185 * @param dcfg Display configuration dialog
     186 * @return EOK on success or an error code
     187 */
     188errno_t display_cfg_populate(display_cfg_t *dcfg)
     189{
     190        errno_t rc;
     191
     192        rc = dcfg_seats_populate(dcfg->seats);
     193        if (rc != EOK)
     194                return rc;
     195
     196        rc = ui_window_paint(dcfg->window);
     197        if (rc != EOK) {
     198                printf("Error painting window.\n");
     199                return rc;
     200        }
     201
     202        return EOK;
     203}
     204
     205/** Destroy display configuration dialog.
     206 *
     207 * @param dcfg Display configuration dialog
     208 */
     209void display_cfg_destroy(display_cfg_t *dcfg)
     210{
    169211        if (dcfg->dispcfg != NULL)
    170212                dispcfg_close(dcfg->dispcfg);
    171         free(dcfg);
    172         return rc;
    173 }
    174 
    175 /** Destroy display configuration dialog.
    176  *
    177  * @param dcfg Display configuration dialog
    178  */
    179 void display_cfg_destroy(display_cfg_t *dcfg)
    180 {
    181213        ui_window_destroy(dcfg->window);
    182214        ui_destroy(dcfg->ui);
Note: See TracChangeset for help on using the changeset viewer.