Changeset 651dde7 in mainline
- Timestamp:
- 2025-04-07T22:06:50Z (7 days ago)
- Children:
- f6b29929
- Parents:
- 93de384
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/date_cfg/date_cfg.c
r93de384 r651dde7 100 100 date_cfg_t *date_cfg = (date_cfg_t *) arg; 101 101 errno_t rc; 102 102 103 103 rc = parse_date_time(date_cfg); 104 104 if (rc != EOK) { … … 106 106 return; 107 107 } 108 108 109 109 rc = set_system_time(&date_cfg->current_time); 110 110 if (rc != EOK) { … … 112 112 return; 113 113 } 114 114 115 115 update_time_display(date_cfg); 116 116 } … … 129 129 char *svc_name = NULL; 130 130 errno_t rc; 131 131 132 132 rc = loc_category_get_id("clock", &cat_id, IPC_FLAG_BLOCKING); 133 133 if (rc != EOK) 134 134 return rc; 135 135 136 136 rc = loc_category_get_svcs(cat_id, &svc_ids, &svc_cnt); 137 137 if (rc != EOK) 138 138 return rc; 139 139 140 140 if (svc_cnt == 0) { 141 141 free(svc_ids); 142 142 return ENOENT; 143 143 } 144 144 145 145 rc = loc_service_get_name(svc_ids[0], &svc_name); 146 146 if (rc != EOK) { … … 148 148 return rc; 149 149 } 150 150 151 151 rc = loc_service_get_id(svc_name, &svc_id, 0); 152 152 if (rc != EOK) { … … 155 155 return rc; 156 156 } 157 157 158 158 async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF, 0); 159 159 if (!sess) { … … 162 162 return EIO; 163 163 } 164 164 165 165 rc = clock_dev_time_get(sess, t); 166 166 167 167 free(svc_name); 168 168 free(svc_ids); … … 183 183 char *svc_name = NULL; 184 184 errno_t rc; 185 185 186 186 rc = loc_category_get_id("clock", &cat_id, IPC_FLAG_BLOCKING); 187 187 if (rc != EOK) 188 188 return rc; 189 189 190 190 rc = loc_category_get_svcs(cat_id, &svc_ids, &svc_cnt); 191 191 if (rc != EOK) 192 192 return rc; 193 193 194 194 if (svc_cnt == 0) { 195 195 free(svc_ids); 196 196 return ENOENT; 197 197 } 198 198 199 199 rc = loc_service_get_name(svc_ids[0], &svc_name); 200 200 if (rc != EOK) { … … 202 202 return rc; 203 203 } 204 204 205 205 rc = loc_service_get_id(svc_name, &svc_id, 0); 206 206 if (rc != EOK) { … … 209 209 return rc; 210 210 } 211 211 212 212 async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF, 0); 213 213 if (!sess) { … … 216 216 return EIO; 217 217 } 218 218 219 219 rc = clock_dev_time_set(sess, t); 220 220 221 221 free(svc_name); 222 222 free(svc_ids); … … 232 232 char date_str[32]; 233 233 char time_str[32]; 234 234 235 235 snprintf(date_str, sizeof(date_str), "%02d/%02d/%d", 236 236 date_cfg->current_time.tm_mday, 237 237 date_cfg->current_time.tm_mon + 1, 238 238 1900 + date_cfg->current_time.tm_year); 239 239 240 240 snprintf(time_str, sizeof(time_str), "%02d:%02d:%02d", 241 241 date_cfg->current_time.tm_hour, 242 242 date_cfg->current_time.tm_min, 243 243 date_cfg->current_time.tm_sec); 244 244 245 245 ui_entry_set_text(date_cfg->date_entry, date_str); 246 246 ui_entry_set_text(date_cfg->time_entry, time_str); … … 258 258 int day, month, year; 259 259 int hour, min, sec; 260 260 261 261 if (sscanf(date_str, "%d/%d/%d", &day, &month, &year) != 3) 262 262 return EINVAL; 263 263 264 264 if (sscanf(time_str, "%d:%d:%d", &hour, &min, &sec) != 3) 265 265 return EINVAL; 266 266 267 267 if (day < 1 || day > 31 || month < 1 || month > 12 || year < 1900) 268 268 return EINVAL; 269 269 270 270 if (hour < 0 || hour > 23 || min < 0 || min > 59 || sec < 0 || sec > 59) 271 271 return EINVAL; 272 272 273 273 date_cfg->current_time.tm_mday = day; 274 274 date_cfg->current_time.tm_mon = month - 1; … … 277 277 date_cfg->current_time.tm_min = min; 278 278 date_cfg->current_time.tm_sec = sec; 279 279 280 280 return EOK; 281 281 } … … 310 310 params.rect.p0.x = 0; 311 311 params.rect.p0.y = 0; 312 params.rect.p1.x = 350; 313 params.rect.p1.y = 275; 312 params.rect.p1.x = 350; 313 params.rect.p1.y = 275; 314 314 } 315 315
Note:
See TracChangeset
for help on using the changeset viewer.