Exemple #1
0
static int mwi_subscribe(struct ua *ua)
{
	const char *routev[1];
	struct mwi *mwi;
	int err;

	mwi = mem_zalloc(sizeof(*mwi), destructor);
	if (!mwi)
		return ENOMEM;

	list_append(&mwil, &mwi->le, mwi);
	mwi->ua = mem_ref(ua);

	routev[0] = ua_outbound(ua);

	info("mwi: subscribing to messages for %s\n", ua_aor(ua));

	err = sipevent_subscribe(&mwi->sub, uag_sipevent_sock(), ua_aor(ua),
				 NULL, ua_aor(ua), "message-summary", NULL,
	                         600, ua_cuser(ua),
				 routev, routev[0] ? 1 : 0,
	                         auth_handler, ua_account(ua), true, NULL,
				 notify_handler, close_handler, mwi,
				 "Accept:"
				 " application/simple-message-summary\r\n");
	if (err) {
		warning("mwi: subscribe ERROR: %m\n", err);
	}

	if (err)
		mem_deref(mwi);

	return err;
}
Exemple #2
0
static void tmr_handler(void *arg)
{
	struct le *le;

	(void)arg;

	for (le = list_head(uag_list()); le; le = le->next) {
		struct ua *ua = le->data;
		struct account *acc = ua_account(ua);
		if (account_regint(acc) > 0)
			uag_event_register(ua_event_handler, ua);
		else
			mwi_subscribe(ua);
	}
}
Exemple #3
0
static int publisher_alloc(struct ua *ua)
{
	struct publisher *pub;

	pub = mem_zalloc(sizeof(*pub), destructor);
	if (!pub)
		return ENOMEM;

	pub->ua = mem_ref(ua);
	pub->expires = account_pubint(ua_account(ua));

	tmr_init(&pub->tmr);
	tmr_start(&pub->tmr, 10, tmr_handler, pub);

	list_append(&publ, &pub->le, pub);

	return 0;
}
Exemple #4
0
static void pub_ua_event_handler(struct ua *ua,
				 enum ua_event ev,
				 struct call *call,
				 const char *prm,
				 void *arg )
{
	(void)call;
	(void)prm;
	(void)arg;

	if (account_pubint(ua_account(ua)) == 0)
		return;

	if (ev == UA_EVENT_REGISTER_OK) {
		if (ua_presence_status(ua) == PRESENCE_UNKNOWN) {
			ua_presence_status_set(ua, PRESENCE_OPEN);
			publisher_update_status(ua);
		}
	}
}
Exemple #5
0
int publisher_init(void)
{
	struct le *le;
	int err = 0;

	uag_event_register(pub_ua_event_handler, NULL);

	for (le = list_head(uag_list()); le; le = le->next) {

		struct ua *ua = le->data;
		struct account *acc = ua_account(ua);

		if (account_pubint(acc) == 0)
			continue;

		err |= publisher_alloc(ua);
	}

	if (err)
		return err;

	return 0;
}