bool machine_t::dialog_response(cookie_t c, int value) { if (events.count(c)==0) { log_error("Invalid cookie [%d] in respond", c.value()) ; return false ; } event_t *e = events[c] ; if (e->state == state_dlg_requ) { if (e->request_watcher) e->request_watcher->detach(e) ; } else if (e->state != state_dlg_user) { log_error("Unexpected response for event [%d] in state '%s'", c.value(), e->state->name()) ; return false ; } if (value < -Maemo::Timed::Number_of_Sys_Buttons) { log_error("Invalid negative value in respond: event [%d], value=%d", c.value(), value) ; return false ; } int b = e->b_attr.size() ; if (value > b) { log_error("Invalid value in respond: event [%d], value=%d, number of buttons: %d", c.value(), value, b) ; return false ; } log_assert(buttons.count(value)>0, "no button with value=%d present", value) ; request_state(e, buttons[value]) ; e->flags &= ~ EventFlags::In_Dialog ; invoke_process_transition_queue() ; return true ; }
cookie_t Timed::add_event(cookie_t remove, const Maemo::Timed::event_io_t &x, const QDBusMessage &message) { if(remove.is_valid() && am->find_event(remove)==NULL) { log_error("[%d]: cookie not found, event can't be replaced", remove.value()) ; return cookie_t() ; } cookie_t c = am->add_event(&x, true, NULL, &message) ; // message is given, but no creds log_debug() ; QMap<QString,QString>::const_iterator test = x.attr.txt.find("TEST") ; log_debug() ; if(test!=x.attr.txt.end()) log_debug("TEST event: '%s', cookie=%d", test.value().toStdString().c_str(), c.value()) ; log_debug() ; if(c.is_valid() && remove.is_valid() && !am->cancel_by_cookie(remove)) log_critical("[%d]: failed to remove event", remove.value()) ; return c ; }
bool machine_t::cancel_by_cookie(cookie_t c) // XXX need some clean up here? { pause_t x(this) ; if(event_t *e = find_event(c)) { cancel_event(e) ; return true ; } else { log_error("[%d]: cookie not found", c.value()) ; return false ; } }
void machine_t::get_event_attributes(cookie_t c, QMap<QString,QVariant> &a) { map<cookie_t,event_t*>::iterator it = events.find(c) ; if(it==events.end()) return ; event_t *e = it->second ; a.insert("STATE", e->state->name()) ; a.insert("COOKIE", QString("%1").arg(c.value())) ; for(attribute_t::const_iterator at=e->attr.txt.begin(); at!=e->attr.txt.end(); at++) { QString key = string_std_to_q(at->first) ; QString val = string_std_to_q(at->second) ; a.insert(key,val) ; } }
bool Timed::dialog_response(cookie_t c, int value) { log_debug("Responded: %d(value=%d)", c.value(), value) ; return am->dialog_response(c, value) ; }