static int dispatch_msg(dbus_msg_queue *q, dbus_msg *msg) { int i, rv; for (i = 0; i < q->handler_count; ++i) { handler_entry *h = &q->handler_entries[i]; matcher *m = &h->match; if (m->type == MATCH_REPLY_TO && m->match_reply_to.serial == msg->reply_serial) { if (h->replyto_handler) { h->replyto_handler(q,msg); } } switch (msg->type) { case DBUS_TYPE_METHOD_CALL: if (m->type == MATCH_METHOD_CALL && msg->interface && strcmp(msg->interface,m->match_method_call.interface)==0 && msg->method && strcmp(msg->method,m->match_method_call.member)==0) { if (h->method_handler) { dbus_msg *reply = NULL; h->method_handler( q, msg, &reply ); if (reply) { /* queue reply to send */ rv = queue_outgoing(q, reply); if (rv < 0) { return rv; } } } } break; case DBUS_TYPE_SIGNAL: if (m->type == MATCH_SIGNAL && msg->interface && strcmp(msg->interface,m->match_signal.interface)==0 && msg->method && strcmp(msg->method,m->match_signal.member)==0) { if (h->signal_handler) { h->signal_handler( q, msg ); } } break; default: fprintf(stderr, "invalid message type\n"); return -EINVAL; } } return 0; }
static int channel_send(struct mwChannel *chan, struct mwMsgChannelSend *msg) { int ret = 0; /* if the channel is open, send and free the message. Otherwise, queue the message to be sent once the channel is finally opened */ if(chan->state == mwChannel_OPEN) { ret = mwSession_send(chan->session, (struct mwMessage *) msg); mwMessage_free(MW_MESSAGE(msg)); } else { queue_outgoing(chan, msg); } return ret; }
int dbus_msg_queue_send_later(dbus_msg_queue *q, dbus_msg *msg) { return queue_outgoing( q, msg ); }