Index: channels/chan_dahdi.c
===================================================================
--- channels/chan_dahdi.c	(revision 378320)
+++ channels/chan_dahdi.c	(revision 378321)
@@ -3438,7 +3438,7 @@
 	}
 	if (pri->congestion_devstate != new_state) {
 		pri->congestion_devstate = new_state;
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "DAHDI/I%d/congestion", pri->span);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_NOT_CACHABLE, "DAHDI/I%d/congestion", pri->span);
 	}
 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER)
 	/* Update the span threshold device state and report any change. */
@@ -3454,7 +3454,7 @@
 	}
 	if (pri->threshold_devstate != new_state) {
 		pri->threshold_devstate = new_state;
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "DAHDI/I%d/threshold", pri->span);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_NOT_CACHABLE, "DAHDI/I%d/threshold", pri->span);
 	}
 #endif	/* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
 }
@@ -10010,7 +10010,8 @@
 	if (dashptr) {
 		*dashptr = '\0';
 	}
-	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
+	ast_set_flag(ast_channel_flags(tmp), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, AST_DEVSTATE_NOT_CACHABLE, device_name);
 
 	for (v = i->vars ; v ; v = v->next)
 		pbx_builtin_setvar_helper(tmp, v->name, v->value);
Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c	(revision 378320)
+++ channels/chan_sip.c	(revision 378321)
@@ -6795,7 +6795,7 @@
 	}
 
 	if (p) {
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", p->name);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "SIP/%s", p->name);
 		sip_unref_peer(p, "update_call_counter: sip_unref_peer from call counter");
 	}
 	return 0;
@@ -8056,6 +8056,9 @@
 		ast_jb_configure(tmp, &global_jbconf);
 	}
 
+	if (!i->relatedpeer) {
+		ast_set_flag(ast_channel_flags(tmp), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+	}
 	/* Set channel variables for this call from configuration */
 	for (v = i->chanvars ; v ; v = v->next) {
 		char valuebuf[1024];
@@ -15577,7 +15580,7 @@
 
 	manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", peer->name);
 	register_peer_exten(peer, FALSE);	/* Remove regexten */
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "SIP/%s", peer->name);
 
 	/* Do we need to release this peer from memory?
 		Only for realtime peers and autocreated peers
@@ -16362,8 +16365,9 @@
 	ast_atomic_fetchadd_int(&p->relatedpeer->onhold, (hold ? +1 : -1));
 
 	/* Request device state update */
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", p->relatedpeer->name);
-	
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(p->owner), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE),
+			     "SIP/%s", p->relatedpeer->name);
+
 	return;
 }
 
@@ -16886,7 +16890,7 @@
 		} else {
 			update_peer_lastmsgssent(peer, -1, 0);
 		}
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "SIP/%s", peer->name);
 	}
 	if (res < 0) {
 		switch (res) {
@@ -23259,7 +23263,7 @@
 
 		ast_log(LOG_NOTICE, "Peer '%s' is now %s. (%dms / %dms)\n",
 			peer->name, s, pingtime, peer->maxms);
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "SIP/%s", peer->name);
 		if (sip_cfg.peer_rtupdate) {
 			ast_update_realtime(ast_check_realtime("sipregs") ? "sipregs" : "sippeers", "name", peer->name, "lastms", str_lastms, SENTINEL);
 		}
@@ -29161,7 +29165,7 @@
 	/* Don't send a devstate change if nothing changed. */
 	if (peer->lastms > -1) {
 		peer->lastms = -1;
-		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
+		ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "SIP/%s", peer->name);
 	}
 
 	/* Try again quickly */
Index: channels/chan_agent.c
===================================================================
--- channels/chan_agent.c	(revision 378320)
+++ channels/chan_agent.c	(revision 378321)
@@ -618,7 +618,7 @@
 		if (p->chan) {
 			ast_channel_internal_bridged_channel_set(p->chan, NULL);
 			p->chan = NULL;
-			ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent);
+			ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 			p->acknowledged = 0;
 		}
 	} else {
@@ -875,7 +875,7 @@
 	} else {
 		/* Agent hung-up */
 		p->chan = NULL;
-		ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent);
+		ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 	}
 
 	if (!res) {
@@ -995,7 +995,7 @@
 	if (!p->loginstart) {
 		p->logincallerid[0] = '\0';
 	} else {
-		ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent);
+		ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 	}
 
 	if (p->abouttograb) {
@@ -2166,7 +2166,7 @@
 						}
 						ast_mutex_unlock(&p->lock);
 						AST_LIST_UNLOCK(&agents);
-						ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent);
+						ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 						while (res >= 0) {
 							ast_mutex_lock(&p->lock);
 							if (p->deferlogoff && p->chan) {
@@ -2187,7 +2187,7 @@
 								if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > 0) {
 									ast_debug(1, "Wrapup time for %s expired!\n", p->agent);
 									p->lastdisc = ast_tv(0, 0);
-									ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Agent/%s", p->agent);
+									ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 									if (p->ackcall) {
 										check_beep(p, 0);
 									} else {
@@ -2258,7 +2258,7 @@
 						ast_queue_log("NONE", ast_channel_uniqueid(chan), agent, "AGENTLOGOFF", "%s|%ld", ast_channel_name(chan), logintime);
 						ast_verb(2, "Agent '%s' logged out\n", p->agent);
 						/* If there is no owner, go ahead and kill it now */
-						ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Agent/%s", p->agent);
+						ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Agent/%s", p->agent);
 						if (p->dead && !p->owner) {
 							ast_mutex_destroy(&p->lock);
 							ast_cond_destroy(&p->app_complete_cond);
Index: channels/chan_iax2.c
===================================================================
--- channels/chan_iax2.c	(revision 378320)
+++ channels/chan_iax2.c	(revision 378321)
@@ -5798,7 +5798,7 @@
 }
 
 /*! \brief  Create new call, interface with the PBX core */
-static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capability, const char *linkedid)
+static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capability, const char *linkedid, unsigned int cachable)
 {
 	struct ast_channel *tmp;
 	struct chan_iax2_pvt *i;
@@ -5880,6 +5880,10 @@
 	i->owner = tmp;
 	i->capability = capability;
 
+	if (!cachable) {
+		ast_set_flag(ast_channel_flags(tmp), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+	}
+
 	/* Set inherited variables */
 	if (i->vars) {
 		for (v = i->vars ; v ; v = v->next)
@@ -8161,7 +8165,7 @@
 		/* if challenge has been sent, but no challenge response if given, reject. */
 		goto return_unref;
 	}
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "IAX2/%s", p->name); /* Activate notification */
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "IAX2/%s", p->name); /* Activate notification */
 
 	/* either Authentication has taken place, or a REGAUTH must be sent before verifying registration */
 	res = 0;
@@ -8715,7 +8719,7 @@
 	if (!ast_test_flag64(peer, IAX_TEMPONLY))
 		ast_db_del("IAX/Registry", peer->name);
 	register_peer_exten(peer, 0);
-	ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "IAX2/%s", peer->name); /* Activate notification */
+	ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
 	if (iax2_regfunk)
 		iax2_regfunk(peer->name, 0);
 
@@ -8770,7 +8774,7 @@
 		}
 	}
 
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "IAX2/%s", p->name); /* Activate notification */
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "IAX2/%s", p->name); /* Activate notification */
 
 	p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p));
 	if (p->expire == -1) {
@@ -8847,14 +8851,14 @@
 					    ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED", ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
 			manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\nPort: %d\r\n", p->name, ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port));
 			register_peer_exten(p, 1);
-			ast_devstate_changed(AST_DEVICE_UNKNOWN, "IAX2/%s", p->name); /* Activate notification */
+			ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "IAX2/%s", p->name); /* Activate notification */
 		} else if (!ast_test_flag64(p, IAX_TEMPONLY)) {
 			ast_verb(3, "Unregistered IAX2 '%s' (%s)\n", p->name,
 					    ast_test_flag(&iaxs[callno]->state, IAX_STATE_AUTHENTICATED) ? "AUTHENTICATED" : "UNAUTHENTICATED");
 			manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unregistered\r\n", p->name);
 			register_peer_exten(p, 0);
 			ast_db_del("IAX/Registry", p->name);
-			ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "IAX2/%s", p->name); /* Activate notification */
+			ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", p->name); /* Activate notification */
 		}
 		/* Update the host */
 		/* Verify that the host is really there */
@@ -10420,7 +10424,8 @@
 		    (f.frametype == AST_FRAME_IAX)) {
 			if (ast_test_flag64(iaxs[fr->callno], IAX_DELAYPBXSTART)) {
 				ast_clear_flag64(iaxs[fr->callno], IAX_DELAYPBXSTART);
-				if (!ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->chosenformat, NULL)) {
+				if (!ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->chosenformat, NULL,
+						  ast_test_flag(&iaxs[fr->callno]->state, IAX_STATE_AUTHENTICATED))) {
 					ast_variables_destroy(ies.vars);
 					ast_mutex_unlock(&iaxsl[fr->callno]);
 					return 1;
@@ -11062,13 +11067,13 @@
 						if (iaxs[fr->callno]->pingtime <= peer->maxms) {
 							ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE! Time: %d\n", peer->name, iaxs[fr->callno]->pingtime);
 							manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Reachable\r\nTime: %d\r\n", peer->name, iaxs[fr->callno]->pingtime); 
-							ast_devstate_changed(AST_DEVICE_NOT_INUSE, "IAX2/%s", peer->name); /* Activate notification */
+							ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
 						}
 					} else if ((peer->historicms > 0) && (peer->historicms <= peer->maxms)) {
 						if (iaxs[fr->callno]->pingtime > peer->maxms) {
 							ast_log(LOG_NOTICE, "Peer '%s' is now TOO LAGGED (%d ms)!\n", peer->name, iaxs[fr->callno]->pingtime);
 							manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Lagged\r\nTime: %d\r\n", peer->name, iaxs[fr->callno]->pingtime); 
-							ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "IAX2/%s", peer->name); /* Activate notification */
+							ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
 						}
 					}
 					peer->lastms = iaxs[fr->callno]->pingtime;
@@ -11312,7 +11317,7 @@
 											using_prefs);
 
 							ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
-							if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, NULL)))
+							if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, format, NULL, 1)))
 								iax2_destroy(fr->callno);
 							else if (ies.vars) {
 								struct ast_datastore *variablestore;
@@ -11383,7 +11388,7 @@
 							iax2_getformatname_multiple(tmp, sizeof(tmp), iaxs[fr->callno]->peerformat));
 						ast_set_flag(&iaxs[fr->callno]->state, IAX_STATE_STARTED);
 						send_command(iaxs[fr->callno], AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, 0, NULL, 0, -1);
-						if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat, NULL)))
+						if (!(c = ast_iax2_new(fr->callno, AST_STATE_RING, iaxs[fr->callno]->peerformat, NULL, 1)))
 							iax2_destroy(fr->callno);
 						else if (ies.vars) {
 							struct ast_datastore *variablestore;
@@ -12150,7 +12155,7 @@
 	if (peer->lastms > -1) {
 		ast_log(LOG_NOTICE, "Peer '%s' is now UNREACHABLE! Time: %d\n", peer->name, peer->lastms);
 		manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: IAX2\r\nPeer: IAX2/%s\r\nPeerStatus: Unreachable\r\nTime: %d\r\n", peer->name, peer->lastms);
-		ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "IAX2/%s", peer->name); /* Activate notification */
+		ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "IAX2/%s", peer->name); /* Activate notification */
 	}
 	if ((callno = peer->callno) > 0) {
 		ast_mutex_lock(&iaxsl[callno]);
@@ -12324,7 +12329,8 @@
 		ast_string_field_set(iaxs[callno], host, pds.peer);
 	}
 
-	c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability, requestor ? ast_channel_linkedid(requestor) : NULL);
+	c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability, requestor ? ast_channel_linkedid(requestor) : NULL, cai.found);
+
 	ast_mutex_unlock(&iaxsl[callno]);
 
 	if (c) {
Index: channels/chan_skinny.c
===================================================================
--- channels/chan_skinny.c	(revision 378320)
+++ channels/chan_skinny.c	(revision 378321)
@@ -2132,7 +2132,7 @@
 				AST_LIST_TRAVERSE(&l->sublines, subline, list) {
 					ast_extension_state_add(subline->context, subline->exten, skinny_extensionstate_cb, subline->container);
 				}
-				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s", l->name);
+				ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 				--instance;
 			}
 			break;
@@ -2167,7 +2167,7 @@
 				l->instance = 0;
 				manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: Skinny\r\nPeer: Skinny/%s@%s\r\nPeerStatus: Unregistered\r\n", l->name, d->name);
 				unregister_exten(l);
-				ast_devstate_changed(AST_DEVICE_UNAVAILABLE, "Skinny/%s", l->name);
+				ast_devstate_changed(AST_DEVICE_UNAVAILABLE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 			}
 		}
 	}
@@ -5934,7 +5934,7 @@
 			event, d->name, instance, callreference);
 		break;
 	}
-	ast_devstate_changed(AST_DEVICE_UNKNOWN, "Skinny/%s", l->name);
+	ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 
 	return 1;
 }
@@ -5974,7 +5974,7 @@
 	transmit_ringer_mode(d, SKINNY_RING_OFF);
 	d->hookstate = SKINNY_OFFHOOK;
 
-	ast_devstate_changed(AST_DEVICE_INUSE, "Skinny/%s", l->name);
+	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 
 	if (sub && sub->substate == SUBSTATE_HOLD) {
 		return 1;
@@ -6041,7 +6041,7 @@
 		return 0;
 	}
 	
-	ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s", l->name);
+	ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 	
 	dumpsub(sub, 0);
 
@@ -6377,7 +6377,7 @@
 		return 0;
 	}
 
-	ast_devstate_changed(AST_DEVICE_INUSE, "Skinny/%s", l->name);
+	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
 
 	switch(event) {
 	case SOFTKEY_NONE:
@@ -6531,8 +6531,8 @@
 			return 0;
 		}
 	
-		ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Skinny/%s", l->name);
-	
+		ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Skinny/%s", l->name);
+
 		if (sub) {
 			dumpsub(sub, 1);
 		} else { /* No sub, maybe an SLA call */
Index: channels/chan_local.c
===================================================================
--- channels/chan_local.c	(revision 378320)
+++ channels/chan_local.c	(revision 378321)
@@ -1277,6 +1277,9 @@
 	ast_channel_tech_pvt_set(tmp, p);
 	ast_channel_tech_pvt_set(tmp2, p);
 
+	ast_set_flag(ast_channel_flags(tmp), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+	ast_set_flag(ast_channel_flags(tmp2), AST_FLAG_DISABLE_DEVSTATE_CACHE);
+
 	p->owner = tmp;
 	p->chan = tmp2;
 
Index: apps/app_meetme.c
===================================================================
--- apps/app_meetme.c	(revision 378320)
+++ apps/app_meetme.c	(revision 378321)
@@ -2696,7 +2696,7 @@
 
 	/* This device changed state now - if this is the first user */
 	if (conf->users == 1)
-		ast_devstate_changed(AST_DEVICE_INUSE, "meetme:%s", conf->confno);
+		ast_devstate_changed(AST_DEVICE_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno);
 
 	ast_mutex_unlock(&conf->playlock);
 
@@ -4087,7 +4087,7 @@
 
 		/* Change any states */
 		if (!conf->users) {
-			ast_devstate_changed(AST_DEVICE_NOT_INUSE, "meetme:%s", conf->confno);
+			ast_devstate_changed(AST_DEVICE_NOT_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno);
 		}
 
  		/* This flag is meant to kill a conference with only one participant remaining.  */
@@ -5582,8 +5582,8 @@
 				|| trunk_ref == exclude)
 				continue;
 			trunk_ref->state = state;
-			ast_devstate_changed(sla_state_to_devstate(state), 
-				"SLA:%s_%s", station->name, trunk->name);
+			ast_devstate_changed(sla_state_to_devstate(state), AST_DEVSTATE_CACHABLE,
+					     "SLA:%s_%s", station->name, trunk->name);
 			break;
 		}
 	}
@@ -6081,8 +6081,8 @@
 {
 	ast_atomic_fetchadd_int((int *) &event->trunk_ref->trunk->hold_stations, 1);
 	event->trunk_ref->state = SLA_TRUNK_STATE_ONHOLD_BYME;
-	ast_devstate_changed(AST_DEVICE_ONHOLD, "SLA:%s_%s", 
-		event->station->name, event->trunk_ref->trunk->name);
+	ast_devstate_changed(AST_DEVICE_ONHOLD, AST_DEVSTATE_CACHABLE, "SLA:%s_%s",
+			     event->station->name, event->trunk_ref->trunk->name);
 	sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD, 
 		INACTIVE_TRUNK_REFS, event->trunk_ref);
 
@@ -6591,8 +6591,8 @@
 			sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL);
 		else {
 			trunk_ref->state = SLA_TRUNK_STATE_UP;
-			ast_devstate_changed(AST_DEVICE_INUSE, 
-				"SLA:%s_%s", station->name, trunk_ref->trunk->name);
+			ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE,
+					     "SLA:%s_%s", station->name, trunk_ref->trunk->name);
 		}
 	} else if (trunk_ref->state == SLA_TRUNK_STATE_RINGING) {
 		struct sla_ringing_trunk *ringing_trunk;
Index: apps/confbridge/conf_state_empty.c
===================================================================
--- apps/confbridge/conf_state_empty.c	(revision 378320)
+++ apps/confbridge/conf_state_empty.c	(revision 378321)
@@ -81,6 +81,6 @@
 static void transition_to_empty(struct conference_bridge_user *cbu)
 {
 	/* Set device state to "not in use" */
-	ast_devstate_changed(AST_DEVICE_NOT_INUSE, "confbridge:%s", cbu->conference_bridge->name);
+	ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", cbu->conference_bridge->name);
 	conf_ended(cbu->conference_bridge);
 }
Index: apps/app_confbridge.c
===================================================================
--- apps/app_confbridge.c	(revision 378320)
+++ apps/app_confbridge.c	(revision 378321)
@@ -1034,7 +1034,7 @@
 
 void conf_handle_first_join(struct conference_bridge *conference_bridge)
 {
-	ast_devstate_changed(AST_DEVICE_INUSE, "confbridge:%s", conference_bridge->name);
+	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", conference_bridge->name);
 }
 
 void conf_handle_second_active(struct conference_bridge *conference_bridge)
Index: apps/app_queue.c
===================================================================
--- apps/app_queue.c	(revision 378320)
+++ apps/app_queue.c	(revision 378321)
@@ -1787,9 +1787,9 @@
 		if (found_member) {
 			found = 1;
 			if (avail) {
-				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
+				ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 			} else {
-				ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
+				ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 			}
 		}
 
@@ -2079,7 +2079,7 @@
 	 * AST_DEVICE_INUSE indicates no members are available.
 	 * AST_DEVICE_NOT_INUSE indicates a member is available.
 	 */
-	ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
+	ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 }
 
 static void clear_queue(struct call_queue *q)
@@ -2959,7 +2959,7 @@
 		ast_copy_string(qe->context, q->context, sizeof(qe->context));
 		q->count++;
 		if (q->count == 1) {
-			ast_devstate_changed(AST_DEVICE_RINGING, "Queue:%s", q->name);
+			ast_devstate_changed(AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name);
 		}
 
 		res = 0;
@@ -3267,7 +3267,7 @@
 			char posstr[20];
 			q->count--;
 			if (!q->count) {
-				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s", q->name);
+				ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name);
 			}
 
 			/* Take us out of the queue */
@@ -3540,7 +3540,7 @@
 			if (newstate != tmp->member->status) {
 				ast_log(LOG_WARNING, "Found a channel matching iterface %s while status was %s changed to %s\n",
 					tmp->member->interface, ast_devstate2str(tmp->member->status), ast_devstate2str(newstate));
-				ast_devstate_changed_literal(newstate, tmp->member->interface);
+				ast_devstate_changed_literal(newstate, AST_DEVSTATE_CACHABLE, tmp->member->interface);
 			}
 		}
 		if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
@@ -6016,7 +6016,7 @@
 			}
 
 			if (!num_available_members(q)) {
-				ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
+				ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 			}
 
 			res = RES_OKAY;
@@ -6093,7 +6093,7 @@
 				new_member->status, new_member->paused);
 
 			if (is_member_available(new_member)) {
-				ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
+				ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 			}
 
 			ao2_ref(new_member, -1);
@@ -6159,9 +6159,9 @@
 				}
 
 				if (is_member_available(mem)) {
-					ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
+					ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 				} else if (!num_available_members(q)) {
-					ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
+					ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
 				}
 
 				ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, ""));
Index: funcs/func_devstate.c
===================================================================
--- funcs/func_devstate.c	(revision 378320)
+++ funcs/func_devstate.c	(revision 378321)
@@ -132,7 +132,7 @@
 
 	ast_db_put(astdb_family, data, value);
 
-	ast_devstate_changed(state_val, "Custom:%s", data);
+	ast_devstate_changed(state_val, AST_DEVSTATE_CACHABLE, "Custom:%s", data);
 
 	return 0;
 }
@@ -295,7 +295,7 @@
 
 	ast_db_put(astdb_family, dev, state);
 
-	ast_devstate_changed(state_val, "Custom:%s", dev);
+	ast_devstate_changed(state_val, AST_DEVSTATE_CACHABLE, "Custom:%s", dev);
 
 	return CLI_SUCCESS;
 }
@@ -341,7 +341,7 @@
 		if (dev_name <= (const char *) 1)
 			continue;
 		ast_devstate_changed(ast_devstate_val(db_entry->data),
-			"Custom:%s\n", dev_name);
+			AST_DEVSTATE_CACHABLE, "Custom:%s\n", dev_name);
 	}
 	ast_db_freetree(db_tree);
 	db_tree = NULL;
Index: include/asterisk/event_defs.h
===================================================================
--- include/asterisk/event_defs.h	(revision 378320)
+++ include/asterisk/event_defs.h	(revision 378321)
@@ -298,8 +298,14 @@
 	AST_EVENT_IE_PRESENCE_SUBTYPE    = 0x003b,
 	AST_EVENT_IE_PRESENCE_MESSAGE    = 0x003c,
 
+	/*!
+	 * \brief Event non-cachability flag
+	 * Used by: All events
+	 * Payload type: UINT
+	 */
+	AST_EVENT_IE_CACHABLE            = 0x003d,
 	/*! \brief Must be the last IE value +1 */
-	AST_EVENT_IE_TOTAL               = 0x003d,
+	AST_EVENT_IE_TOTAL               = 0x003e,
 };
 
 /*!
Index: include/asterisk/channel.h
===================================================================
--- include/asterisk/channel.h	(revision 378320)
+++ include/asterisk/channel.h	(revision 378321)
@@ -888,6 +888,12 @@
 	 *  some non-traditional dialplans (like AGI) to continue to function.
 	 */
 	AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
+	/*! Disable device state event caching.  This allows allows channel
+	 * drivers to selectively prevent device state events from being cached
+	 * by certain channels such as anonymous calls which have no persistent
+	 * represenatation that can be tracked.
+	 */
+	AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21),
 };
 
 /*! \brief ast_bridge_config flags */
Index: include/asterisk/devicestate.h
===================================================================
--- include/asterisk/devicestate.h	(revision 378320)
+++ include/asterisk/devicestate.h	(revision 378321)
@@ -61,6 +61,14 @@
 	AST_DEVICE_TOTAL,        /*/ Total num of device states, used for testing */
 };
 
+/*! \brief Device State Cachability
+ *  \note This is used to define the cachability of a device state when set.
+ */
+enum ast_devstate_cache {
+	AST_DEVSTATE_NOT_CACHABLE,  /*!< This device state is not cachable */
+	AST_DEVSTATE_CACHABLE,      /*!< This device state is cachable */
+};
+
 /*! \brief Devicestate provider call back */
 typedef enum ast_device_state (*ast_devstate_prov_cb_type)(const char *data);
 
@@ -129,6 +137,7 @@
  * \brief Tells Asterisk the State for Device is changed
  *
  * \param state the new state of the device
+ * \param cachable whether this device state is cachable
  * \param fmt device name like a dial string with format parameters
  *
  * The new state of the device will be sent off to any subscribers
@@ -138,13 +147,14 @@
  * \retval 0 on success
  * \retval -1 on failure
  */
-int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
-	__attribute__((format(printf, 2, 3)));
+int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt, ...)
+	__attribute__((format(printf, 3, 4)));
 
 /*!
  * \brief Tells Asterisk the State for Device is changed
  *
  * \param state the new state of the device
+ * \param cachable whether this device state is cachable
  * \param device device name like a dial string with format parameters
  *
  * The new state of the device will be sent off to any subscribers
@@ -154,7 +164,7 @@
  * \retval 0 on success
  * \retval -1 on failure
  */
-int ast_devstate_changed_literal(enum ast_device_state state, const char *device);
+int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device);
 
 /*!
  * \brief Tells Asterisk the State for Device is changed.
Index: main/channel.c
===================================================================
--- main/channel.c	(revision 378320)
+++ main/channel.c	(revision 378321)
@@ -2434,7 +2434,7 @@
 		 * instance is dead, we don't know the state of all other possible
 		 * instances.
 		 */
-		ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
+		ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), device_name);
 	}
 
 	ast_channel_nativeformats_set(chan, ast_format_cap_destroy(ast_channel_nativeformats(chan)));
@@ -7353,7 +7353,7 @@
 	/* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
 	 * for this channel is using the callback method for device state. If we pass in an actual state here
 	 * we override what they are saying the state is and things go amuck. */
-	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name);
+	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), name);
 
 	/* setstate used to conditionally report Newchannel; this is no more */
 	/*** DOCUMENTATION
Index: main/features.c
===================================================================
--- main/features.c	(revision 378320)
+++ main/features.c	(revision 378321)
@@ -1248,7 +1248,7 @@
 	ast_debug(4, "Notification of state change to metermaids %s@%s\n to state '%s'",
 		exten, context, ast_devstate2str(state));
 
-	ast_devstate_changed(state, "park:%s@%s", exten, context);
+	ast_devstate_changed(state, AST_DEVSTATE_CACHABLE, "park:%s@%s", exten, context);
 }
 
 /*! \brief metermaids callback from devicestate.c */
Index: main/event.c
===================================================================
--- main/event.c	(revision 378320)
+++ main/event.c	(revision 378321)
@@ -279,7 +279,7 @@
 	[AST_EVENT_IE_RECEIVED_HASH]       = { AST_EVENT_IE_PLTYPE_STR,  "ReceivedHash" },
 	[AST_EVENT_IE_USING_PASSWORD]      = { AST_EVENT_IE_PLTYPE_UINT, "UsingPassword" },
 	[AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR,  "AttemptedTransport" },
-
+	[AST_EVENT_IE_CACHABLE]            = { AST_EVENT_IE_PLTYPE_UINT,  "Cachable" },
 };
 
 const char *ast_event_get_type_name(const struct ast_event *event)
Index: main/ccss.c
===================================================================
--- main/ccss.c	(revision 378320)
+++ main/ccss.c	(revision 378321)
@@ -638,7 +638,7 @@
 		"Notification of CCSS state change to '%s', device state '%s' for device '%s'\n",
 		cc_state_to_string(state), ast_devstate2str(devstate), device);
 
-	ast_devstate_changed(devstate, "ccss:%s", device);
+	ast_devstate_changed(devstate, AST_DEVSTATE_CACHABLE, "ccss:%s", device);
 }
 
 #define CC_OFFER_TIMER_DEFAULT			20		/* Seconds */
Index: main/devicestate.c
===================================================================
--- main/devicestate.c	(revision 378320)
+++ main/devicestate.c	(revision 378321)
@@ -174,6 +174,7 @@
 
 struct state_change {
 	AST_LIST_ENTRY(state_change) list;
+	enum ast_devstate_cache cachable;
 	char device[1];
 };
 
@@ -191,6 +192,7 @@
 	AST_LIST_ENTRY(devstate_change) entry;
 	uint32_t state;
 	struct ast_eid eid;
+	enum ast_devstate_cache cachable;
 	char device[1];
 };
 
@@ -424,7 +426,7 @@
 	return res;
 }
 
-static void devstate_event(const char *device, enum ast_device_state state)
+static void devstate_event(const char *device, enum ast_device_state state, int cachable)
 {
 	struct ast_event *event;
 	enum ast_event_type event_type;
@@ -440,18 +442,23 @@
 	ast_debug(3, "device '%s' state '%d'\n", device, state);
 
 	if (!(event = ast_event_new(event_type,
-			AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
-			AST_EVENT_IE_STATE, AST_EVENT_IE_PLTYPE_UINT, state,
-			AST_EVENT_IE_END))) {
+				    AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
+				    AST_EVENT_IE_STATE, AST_EVENT_IE_PLTYPE_UINT, state,
+				    AST_EVENT_IE_CACHABLE, AST_EVENT_IE_PLTYPE_UINT, cachable,
+				    AST_EVENT_IE_END))) {
 		return;
 	}
 
-	ast_event_queue_and_cache(event);
+	if (cachable) {
+		ast_event_queue_and_cache(event);
+	} else {
+		ast_event_queue(event);
+	}
 }
 
 /*! Called by the state change thread to find out what the state is, and then
  *  to queue up the state change event */
-static void do_state_change(const char *device)
+static void do_state_change(const char *device, int cachable)
 {
 	enum ast_device_state state;
 
@@ -459,10 +466,10 @@
 
 	ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, ast_devstate2str(state));
 
-	devstate_event(device, state);
+	devstate_event(device, state, cachable);
 }
 
-int ast_devstate_changed_literal(enum ast_device_state state, const char *device)
+int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
 {
 	struct state_change *change;
 
@@ -483,14 +490,15 @@
 	 */
 
 	if (state != AST_DEVICE_UNKNOWN) {
-		devstate_event(device, state);
+		devstate_event(device, state, cachable);
 	} else if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
-		do_state_change(device);
+		do_state_change(device, cachable);
 	} else {
 		/* queue the change */
 		strcpy(change->device, device);
+		change->cachable = cachable;
 		AST_LIST_LOCK(&state_changes);
 		AST_LIST_INSERT_TAIL(&state_changes, change, list);
 		ast_cond_signal(&change_pending);
@@ -502,10 +510,10 @@
 
 int ast_device_state_changed_literal(const char *dev)
 {
-	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev);
+	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, dev);
 }
 
-int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
+int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt, ...)
 {
 	char buf[AST_MAX_EXTENSION];
 	va_list ap;
@@ -514,7 +522,7 @@
 	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
-	return ast_devstate_changed_literal(state, buf);
+	return ast_devstate_changed_literal(state, cachable, buf);
 }
 
 int ast_device_state_changed(const char *fmt, ...)
@@ -526,7 +534,7 @@
 	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
-	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf);
+	return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, buf);
 }
 
 /*! \brief Go through the dev state change queue and update changes in the dev state thread */
@@ -546,7 +554,7 @@
 		/* Process each state change */
 		while ((current = next)) {
 			next = AST_LIST_NEXT(current, list);
-			do_state_change(current->device);
+			do_state_change(current->device, current->cachable);
 			ast_free(current);
 		}
 	}
@@ -590,7 +598,7 @@
 	collection->num_states++;
 }
 
-static void process_collection(const char *device, struct change_collection *collection)
+static void process_collection(const char *device, enum ast_devstate_cache cachable, struct change_collection *collection)
 {
 	int i;
 	struct ast_devstate_aggregate agg;
@@ -641,7 +649,11 @@
 		return;
 	}
 
-	ast_event_queue_and_cache(event);
+	if (cachable) {
+		ast_event_queue_and_cache(event);
+	} else {
+		ast_event_queue(event);
+	}
 }
 
 static void handle_devstate_change(struct devstate_change *sc)
@@ -667,7 +679,7 @@
 	/* Populate the collection of device states from the cache */
 	ast_event_dump_cache(tmp_sub);
 
-	process_collection(sc->device, &collection);
+	process_collection(sc->device, sc->cachable, &collection);
 
 	ast_event_sub_destroy(tmp_sub);
 }
@@ -696,10 +708,12 @@
 	const char *device;
 	const struct ast_eid *eid;
 	uint32_t state;
+	enum ast_devstate_cache cachable = AST_DEVSTATE_CACHABLE;
 
 	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
 	eid = ast_event_get_ie_raw(event, AST_EVENT_IE_EID);
 	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
+	cachable = ast_event_get_ie_uint(event, AST_EVENT_IE_CACHABLE);
 
 	if (ast_strlen_zero(device) || !eid) {
 		ast_log(LOG_ERROR, "Invalid device state change event received\n");
@@ -712,6 +726,7 @@
 	strcpy(sc->device, device);
 	sc->eid = *eid;
 	sc->state = state;
+	sc->cachable = cachable;
 
 	ast_mutex_lock(&devstate_collector.lock);
 	AST_LIST_INSERT_TAIL(&devstate_collector.devstate_change_q, sc, entry);
Index: main/channel_internal_api.c
===================================================================
--- main/channel_internal_api.c	(revision 378320)
+++ main/channel_internal_api.c	(revision 378321)
@@ -263,6 +263,7 @@
 	ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN));
 	ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_DONT));
 	ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS));
+	ast_data_add_bool(tree, "DISABLE_DEVSTATE_CACHE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE));
 }
 
 int ast_channel_data_add_structure(struct ast_data *tree,
Index: res/res_calendar.c
===================================================================
--- res/res_calendar.c	(revision 378320)
+++ res/res_calendar.c	(revision 378321)
@@ -611,9 +611,9 @@
 	 * but haven't hit the end event yet, go ahead and set the devicestate to the current busy status */
 	if (event->bs_start_sched < 0 && event->bs_end_sched >= 0) {
 		if (!calendar_is_busy(event->owner)) {
-			ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Calendar:%s", event->owner->name);
+			ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Calendar:%s", event->owner->name);
 		} else {
-			ast_devstate_changed(AST_DEVICE_BUSY, "Calendar:%s", event->owner->name);
+			ast_devstate_changed(AST_DEVICE_BUSY, AST_DEVSTATE_CACHABLE, "Calendar:%s", event->owner->name);
 		}
 	}
 
@@ -871,9 +871,9 @@
 	/* We can have overlapping events, so ignore the event->busy_state and check busy state
 	 * based on all events in the calendar */
 	if (!calendar_is_busy(event->owner)) {
-		ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Calendar:%s", event->owner->name);
+		ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Calendar:%s", event->owner->name);
 	} else {
-		ast_devstate_changed(AST_DEVICE_BUSY, "Calendar:%s", event->owner->name);
+		ast_devstate_changed(AST_DEVICE_BUSY, AST_DEVSTATE_CACHABLE, "Calendar:%s", event->owner->name);
 	}
 
 	event = ast_calendar_unref_event(event);
Index: res/res_jabber.c
===================================================================
--- res/res_jabber.c	(revision 378320)
+++ res/res_jabber.c	(revision 378321)
@@ -352,7 +352,7 @@
 static void aji_create_affiliations(struct aji_client *client, const char *node);
 static iks* aji_pubsub_iq_create(struct aji_client *client, const char *type);
 static void aji_publish_device_state(struct aji_client *client, const char * device,
-	const char *device_state);
+				     const char *device_state, unsigned int cachable);
 static int aji_handle_pubsub_error(void *data, ikspak *pak);
 static int aji_handle_pubsub_event(void *data, ikspak *pak);
 static void aji_pubsub_subscribe(struct aji_client *client, const char *node);
@@ -366,7 +366,7 @@
 static void aji_devstate_cb(const struct ast_event *ast_event, void *data);
 static void aji_mwi_cb(const struct ast_event *ast_event, void *data);
 static iks* aji_build_publish_skeleton(struct aji_client *client, const char *node,
-	const char *event_type);
+				       const char *event_type, unsigned int cachable);
 /* No transports in this version */
 /*
 static int aji_create_transport(char *label, struct aji_client *client);
@@ -3266,6 +3266,7 @@
 {
 	const char *device;
 	const char *device_state;
+	unsigned int cachable;
 	struct aji_client *client;
 	if (ast_eid_cmp(&ast_eid_default, ast_event_get_ie_raw(ast_event, AST_EVENT_IE_EID)))
 	{
@@ -3277,7 +3278,8 @@
 	client = ASTOBJ_REF((struct aji_client *) data);
 	device = ast_event_get_ie_str(ast_event, AST_EVENT_IE_DEVICE);
 	device_state = ast_devstate_str(ast_event_get_ie_uint(ast_event, AST_EVENT_IE_STATE));
-	aji_publish_device_state(client, device, device_state);
+	cachable = ast_event_get_ie_uint(ast_event, AST_EVENT_IE_CACHABLE);
+	aji_publish_device_state(client, device, device_state, cachable);
 	ASTOBJ_UNREF(client, ast_aji_client_destroy);
 }
 
@@ -3317,11 +3319,13 @@
  */
 static int aji_handle_pubsub_event(void *data, ikspak *pak)
 {
-	char *item_id, *device_state, *context;
+	char *item_id, *device_state, *context, *cachable_str;
 	int oldmsgs, newmsgs;
 	iks *item, *item_content;
 	struct ast_eid pubsub_eid;
 	struct ast_event *event;
+	unsigned int cachable = AST_DEVSTATE_CACHABLE;
+
 	item = iks_find(iks_find(iks_find(pak->x, "event"), "items"), "item");
 	if (!item) {
 		ast_log(LOG_ERROR, "Could not parse incoming PubSub event\n");
@@ -3336,11 +3340,14 @@
 	}
 	if (!strcasecmp(iks_name(item_content), "state")) {
 		device_state = iks_find_cdata(item, "state");
+		if ((cachable_str = iks_find_cdata(item, "cachable"))) {
+			sscanf(cachable_str, "%30d", &cachable);
+		}
 		if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE_CHANGE,
-			AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, item_id, AST_EVENT_IE_STATE,
-			AST_EVENT_IE_PLTYPE_UINT, ast_devstate_val(device_state), AST_EVENT_IE_EID,
-			AST_EVENT_IE_PLTYPE_RAW, &pubsub_eid, sizeof(pubsub_eid),
-			AST_EVENT_IE_END))) {
+					    AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, item_id, AST_EVENT_IE_STATE,
+					    AST_EVENT_IE_PLTYPE_UINT, ast_devstate_val(device_state), AST_EVENT_IE_EID,
+					    AST_EVENT_IE_PLTYPE_RAW, &pubsub_eid, sizeof(pubsub_eid),
+					    AST_EVENT_IE_END))) {
 			return IKS_FILTER_EAT;
 		}
 	} else if (!strcasecmp(iks_name(item_content), "mailbox")) {
@@ -3360,7 +3367,13 @@
 			iks_name(item_content));
 		return IKS_FILTER_EAT;
 	}
-	ast_event_queue_and_cache(event);
+
+	if (cachable == AST_DEVSTATE_CACHABLE) {
+		ast_event_queue_and_cache(event);
+	} else {
+		ast_event_queue(event);
+	}
+
 	return IKS_FILTER_EAT;
 }
 
@@ -3435,7 +3448,7 @@
  * \return iks *
  */
 static iks* aji_build_publish_skeleton(struct aji_client *client, const char *node,
-	const char *event_type)
+				       const char *event_type, unsigned int cachable)
 {
 	iks *request = aji_pubsub_iq_create(client, "set");
 	iks *pubsub, *publish, *item;
@@ -3449,8 +3462,24 @@
 	}
 	item = iks_insert(publish, "item");
 	iks_insert_attrib(item, "id", node);
+
+	if (cachable == AST_DEVSTATE_NOT_CACHABLE) {
+		iks *options, *x, *field_form_type, *field_persist;
+
+		options = iks_insert(pubsub, "publish-options");
+		x = iks_insert(options, "x");
+		iks_insert_attrib(x, "xmlns", "jabber:x:data");
+		iks_insert_attrib(x, "type", "submit");
+		field_form_type = iks_insert(x, "field");
+		iks_insert_attrib(field_form_type, "var", "FORM_TYPE");
+		iks_insert_attrib(field_form_type, "type", "hidden");
+		iks_insert_cdata(iks_insert(field_form_type, "value"), "http://jabber.org/protocol/pubsub#publish-options", 0);
+		field_persist = iks_insert(x, "field");
+		iks_insert_attrib(field_persist, "var", "pubsub#persist_items");
+		iks_insert_cdata(iks_insert(field_persist, "value"), "0", 1);
+	}
+
 	return item;
-
 }
 
 /*!
@@ -3461,11 +3490,11 @@
  * \return void
  */
 static void aji_publish_device_state(struct aji_client *client, const char *device,
-	const char *device_state)
+				     const char *device_state, unsigned int cachable)
 {
-	iks *request = aji_build_publish_skeleton(client, device, "device_state");
+	iks *request = aji_build_publish_skeleton(client, device, "device_state", cachable);
 	iks *state;
-	char eid_str[20];
+	char eid_str[20], cachable_str[2];
 	if (ast_test_flag(&pubsubflags, AJI_PUBSUB_AUTOCREATE)) {
 		if (ast_test_flag(&pubsubflags, AJI_XEP0248)) {
 			aji_create_pubsub_node(client, "leaf", device, "device_state");
@@ -3477,6 +3506,8 @@
 	state = iks_insert(request, "state");
 	iks_insert_attrib(state, "xmlns", "http://asterisk.org");
 	iks_insert_attrib(state, "eid", eid_str);
+	snprintf(cachable_str, sizeof(cachable_str), "%u", cachable);
+	iks_insert_attrib(state, "cachable", cachable_str);
 	iks_insert_cdata(state, device_state, strlen(device_state));
 	ast_aji_send(client, iks_root(request));
 	iks_delete(request);
@@ -3496,7 +3527,7 @@
 	char eid_str[20];
 	iks *mailbox_node, *request;
 	snprintf(full_mailbox, sizeof(full_mailbox), "%s@%s", mailbox, context);
-	request = aji_build_publish_skeleton(client, full_mailbox, "message_waiting");
+	request = aji_build_publish_skeleton(client, full_mailbox, "message_waiting", 1);
 	ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
 	mailbox_node = iks_insert(request, "mailbox");
 	iks_insert_attrib(mailbox_node, "xmlns", "http://asterisk.org");

Index: res/res_xmpp.c
===================================================================
--- res/res_xmpp.c	(revision 378410)
+++ res/res_xmpp.c	(revision 378411)
@@ -919,7 +919,7 @@
  * \return iks *
  */
 static iks* xmpp_pubsub_build_publish_skeleton(struct ast_xmpp_client *client, const char *node,
-					       const char *event_type)
+					       const char *event_type, unsigned int cachable)
 {
 	RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
 	iks *request, *pubsub, *publish, *item;
@@ -935,6 +935,22 @@
 	item = iks_insert(publish, "item");
 	iks_insert_attrib(item, "id", node);
 
+	if (cachable == AST_DEVSTATE_NOT_CACHABLE) {
+		iks *options, *x, *field_form_type, *field_persist;
+
+		options = iks_insert(pubsub, "publish-options");
+		x = iks_insert(options, "x");
+		iks_insert_attrib(x, "xmlns", "jabber:x:data");
+		iks_insert_attrib(x, "type", "submit");
+		field_form_type = iks_insert(x, "field");
+		iks_insert_attrib(field_form_type, "var", "FORM_TYPE");
+		iks_insert_attrib(field_form_type, "type", "hidden");
+		iks_insert_cdata(iks_insert(field_form_type, "value"), "http://jabber.org/protocol/pubsub#publish-options", 0);
+		field_persist = iks_insert(x, "field");
+		iks_insert_attrib(field_persist, "var", "pubsub#persist_items");
+		iks_insert_cdata(iks_insert(field_persist, "value"), "0", 1);
+	}
+
 	return item;
 
 }
@@ -1107,7 +1123,7 @@
 
 	snprintf(full_mailbox, sizeof(full_mailbox), "%s@%s", mailbox, context);
 
-	if (!(request = xmpp_pubsub_build_publish_skeleton(client, full_mailbox, "message_waiting"))) {
+	if (!(request = xmpp_pubsub_build_publish_skeleton(client, full_mailbox, "message_waiting", AST_DEVSTATE_CACHABLE))) {
 		return;
 	}
 
@@ -1131,13 +1147,13 @@
  * \return void
  */
 static void xmpp_pubsub_publish_device_state(struct ast_xmpp_client *client, const char *device,
-					     const char *device_state)
+					     const char *device_state, unsigned int cachable)
 {
 	RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
 	iks *request, *state;
-	char eid_str[20];
+	char eid_str[20], cachable_str[2];
 
-	if (!cfg || !cfg->global || !(request = xmpp_pubsub_build_publish_skeleton(client, device, "device_state"))) {
+	if (!cfg || !cfg->global || !(request = xmpp_pubsub_build_publish_skeleton(client, device, "device_state", cachable))) {
 		return;
 	}
 
@@ -1153,6 +1169,8 @@
 	state = iks_insert(request, "state");
 	iks_insert_attrib(state, "xmlns", "http://asterisk.org");
 	iks_insert_attrib(state, "eid", eid_str);
+	snprintf(cachable_str, sizeof(cachable_str), "%u", cachable);
+	iks_insert_attrib(state, "cachable", cachable_str);
 	iks_insert_cdata(state, device_state, strlen(device_state));
 	ast_xmpp_client_send(client, iks_root(request));
 	iks_delete(request);
@@ -1195,6 +1213,7 @@
 {
 	struct ast_xmpp_client *client = data;
 	const char *device, *device_state;
+	unsigned int cachable;
 
 	if (ast_eid_cmp(&ast_eid_default, ast_event_get_ie_raw(ast_event, AST_EVENT_IE_EID))) {
 		/* If the event didn't originate from this server, don't send it back out. */
@@ -1204,7 +1223,8 @@
 
 	device = ast_event_get_ie_str(ast_event, AST_EVENT_IE_DEVICE);
 	device_state = ast_devstate_str(ast_event_get_ie_uint(ast_event, AST_EVENT_IE_STATE));
-	xmpp_pubsub_publish_device_state(client, device, device_state);
+	cachable = ast_event_get_ie_uint(ast_event, AST_EVENT_IE_CACHABLE);
+	xmpp_pubsub_publish_device_state(client, device, device_state, cachable);
 }
 
 /*!
@@ -1287,11 +1307,12 @@
  */
 static int xmpp_pubsub_handle_event(void *data, ikspak *pak)
 {
-	char *item_id, *device_state, *context;
+	char *item_id, *device_state, *context, *cachable_str;
 	int oldmsgs, newmsgs;
 	iks *item, *item_content;
 	struct ast_eid pubsub_eid;
 	struct ast_event *event;
+	unsigned int cachable = AST_DEVSTATE_CACHABLE;
 	item = iks_find(iks_find(iks_find(pak->x, "event"), "items"), "item");
 	if (!item) {
 		ast_log(LOG_ERROR, "Could not parse incoming PubSub event\n");
@@ -1306,6 +1327,9 @@
 	}
 	if (!strcasecmp(iks_name(item_content), "state")) {
 		device_state = iks_find_cdata(item, "state");
+		if ((cachable_str = iks_find_cdata(item, "cachable"))) {
+			sscanf(cachable_str, "%30d", &cachable);
+		}
 		if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE_CHANGE,
 					    AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, item_id, AST_EVENT_IE_STATE,
 					    AST_EVENT_IE_PLTYPE_UINT, ast_devstate_val(device_state), AST_EVENT_IE_EID,
@@ -1330,7 +1354,13 @@
 			  iks_name(item_content));
 		return IKS_FILTER_EAT;
 	}
-	ast_event_queue_and_cache(event);
+
+	if (cachable == AST_DEVSTATE_CACHABLE) {
+		ast_event_queue_and_cache(event);
+	} else {
+		ast_event_queue(event);
+	}
+
 	return IKS_FILTER_EAT;
 }

Property changes on: .
___________________________________________________________________
Modified: branch-10-merged
   - /branches/10:1-328075,328120,328162,328207,328247,328317,328329,328428-328429,328448,328451,328541,328609,328611,328664,328717,328771,328824,328879,328936,328992,329055,329145,329200,329204,329257,329331,329334,329472,329528,329538,329614,329670,329710,329771,329896,329950,329952,329992,329995,330051,330108,330162,330204,330217,330312,330369,330434,330576,330579,330586,330649,330706,330763,330844,330899,330940,331039,331041,331097,331139,331143,331147-331200,331265,331316,331418,331420,331462,331518,331576,331579,331644,331654,331659,331715,331772,331775,331868,331894,331956,332022,332027,332029,332042,332101,332119,332177,332265,332321,332369,332447,332504,332560,332654,332700,332756,332761,332830,332875-332878,332940,333011,333115,333203,333266,333268,333370,333410,333570,333681,333716,333786,333837,333895,333961-333962,334007,334010,334013,334064,334157,334230,334235,334297,334357,334455,334514,334617,334621,334682,334747,334841,334844,334954,335014,335260,335321,335323,335346,335434,335510,335653,335656,335721,335791,335852,335912,335991,336042,336091,336094,336167,336235,336307,336313,336316,336381,336441,336500,336502,336570,336573,336659,336717,336734,336789,336792,336878,336936,336978,337008,337062,337116,337119,337178,337219,337261,337263,337342,337345,337380,337431,337487,337542,337595-337597,337721,337775,337840,337902,337974,338085,338225,338228,338253,338323,338417,338552,338556,338664,338719,338801,338904,338950,338995,338997,339011,339043,339045,339088-339089,339245,339298,339353,339407,339463-339585,339587-339721,339723-340576,340578-340718,340810,340879,340931,340971,341023,341089,341094,341122,341146,341148,341190,341255,341313,341315,341377,341380,341436,341486,341530,341580,341599,341665,341707,341718,341807,341810,341972,342017,342062,342183,342224,342277,342329,342381,342384,342436,342485,342488,342546,342603,342605,342662,342715,342770,342824,342870,342929,342991,343158,343192,343221,343277,343337,343393,343445,343533,343578,343580,343635,343677,343691,343743,343789,343852,343900,343944,344004,344049,344103,344159,344175,344216,344271,344334,344386,344440,344493,344537,344540,344557,344609,344662,344716,344770,344836,344839,344842,344845,344900,344966,345117,345161,345164,345220,345275,345290,345371,345432,345488,345558,345640,345683,345830,345882,345924,345977,346029,346031,346040,346087,346145,346198,346240,346293,346349,346565,346698,346701,346763,346856,346900,346952,346955,347007,347068,347124,347146,347167,347240,347293,347344,347383,347439,347532,347600,347656,347727,347812,347953,347996,348102,348155,348158,348211,348265,348311,348363,348405,348465,348517,348605,348648,348736,348790,348793,348845-348846,348889,348952,348993,349045,349145,349195,349248,349250,349290,349340,349451,349502,349505,349532,349559,349608,349619,349673,349729,349732,349820,349822,349873,349928,349977,350024,350076,350129,350180,350221,350312,350415,350453,350502,350550,350553,350585,350680,350731,350734,350737,350790,350838,350886,350889,350938,350976,350978,351028,351081,351131,351183,351234,351286,351289,351308,351408,351451,351505,351560,351612,351646,351708,351762,351816,351818,351861,352015,352017,352035,352091,352149,352228,352231,352292,352373,352430,352512,352515-352516,352520,352556,352651,352705,352756,352817,352863,352956,352965,352992,353039,353078,353127,353176,353261,353321,353369,353397,353463,353503,353551,353599,353721,353771,353820,353868,353916,353962,354000,354119,354217,354270,354349,354493,354496,354543,354546,354548,354656,354703,354750,354836,354890,354938,354959,355010,355057,355137,355183,355229,355271,355320,355375,355449,355530,355575,355620,355623,355733,355747,355794,355851,355902,355905,355950,355953,355998,356074,356108,356215,356297,356428,356476,356522,356605,356651,356690,356798,356961,356964,357095,357213,357271,357318,357353,357357,357400,357405,357408,357421,357458,357497,357576,357620,357667,357762,357810,357812,357895,357941,357987,358017,358033,358116,358163,358215,358261,358284,358378,358436,358441,358485,358531,358644,358811,358944,358989,359051,359057,359060,359072,359091,359114,359117,359162,359212,359260,359355,359358,359453-359454,359458,359491,359509,359559,359620,359694,359707,359810,359898,359980,359982,360034,360088,360098,360139,360263,360310,360358,360361,360364,360414,360472,360489,360575,360672,360863,360885,360934,360993,361041,361091,361143,361208,361211,361270,361330,361333,361381,361422,361472,361522,361560,361607,362496,362537,362587,362678,362681,362730,362816,362869,362918,362998,363103,363107,363156,363212,363376,363429,363688,363734,363789,363876,363935,363987,364047,364065,364109,364163,364204,364259,364285,364342,364365-364369,364536,364579,364650,364707,364777,364787,364842,364845,364900,364903,364965,365083,365155,365160,365299,365320,365399,365475,365478,365575,365632,365701,365898,365990,366049,366053,366106,366168,366241,366297,366390,366412,366598,366741,366881,366948,367003,367028,367267,367299,367369,367417,367470,367562,367679,367731,367782,367844,367907,367978,367981,368042,368093,368267,368310,368407,368470,368499,368524,368536,368568,368587,368605,368629,368645,368721,368739,368760,368808,368831,368853,368885,368895,368899,368928,368947,369005,369044,369067,369091,369109,369147,369206,369215,369236,369239,369259,369263,369283,369303,369325,369328,369353,369369,369391,369437,369472,369491,369511,369558,369580,369627,369653,369709,369732,369751,369793,369819,369871,369938,369971,369994,370015,370025,370082,370132,370184,370206,370271,370274,370277,370384,370430,370432,370495,370547,370564,370643,370672,370698,370772,370798,370858,370901,370924,370954,370986,370989,371013,371022,371061,371090,371142,371199,371203,371271,371313,371338,371358,371394,371398,371437,371491,371529,371545,371591,371663,371691,371719,371748,371783,371789,371825,371861,371890,371920,371962,371999,372049,372090,372165,372198,372213,372240,372338,372341,372358,372372,372391,372418,372445,372472,372518,372522,372555,372582,372621,372625,372629,372656,372695,372710,372737,372764,372767,372805,372841,372863,372885,372916,372933,373025,373062,373101,373132,373237,373245,373300,373343,373440,373466,373468,373501,373505,373551,373579,373631,373633,373645,373665,373675,373703,373706,373737,373769,373774,373816,373849,373879,373910,373946,373990,374045,374132,374135,374178,374210,374231,374300,374336,374370,374385,374427,374476,374481,374537,374586,374652,374695,374728,374763,374803,374844,374906,374991,375026,375078,375112,375147,375190,375217,375273,375300,375326,375362,375389,375417,375451,375470,375485,375496,375531,375601,375626,375659,375728,375761,375794,375797,375801,375846,375863,375894,375965,375995,376030,376059,376088,376143,376167,376208,376233,376263,376308,376315,376342,376390,376414,376431,376470,376522,376587,376628,376658,376689,376726,376759,376789,376835,376865,376869,376916,376920,376951,377038,377070,377074,377105,377136,377166,377212,377227,377241,377258,377261,377354,377382,377399,377432,377504,377510,377592,377624,377656,377705,377709,377741,377772,377807,377838,377842,377848,377882,377923,377947,377992,378037,378089,378093,378120,378218,378286
   + /branches/10:1-328075,328120,328162,328207,328247,328317,328329,328428-328429,328448,328451,328541,328609,328611,328664,328717,328771,328824,328879,328936,328992,329055,329145,329200,329204,329257,329331,329334,329472,329528,329538,329614,329670,329710,329771,329896,329950,329952,329992,329995,330051,330108,330162,330204,330217,330312,330369,330434,330576,330579,330586,330649,330706,330763,330844,330899,330940,331039,331041,331097,331139,331143,331147-331200,331265,331316,331418,331420,331462,331518,331576,331579,331644,331654,331659,331715,331772,331775,331868,331894,331956,332022,332027,332029,332042,332101,332119,332177,332265,332321,332369,332447,332504,332560,332654,332700,332756,332761,332830,332875-332878,332940,333011,333115,333203,333266,333268,333370,333410,333570,333681,333716,333786,333837,333895,333961-333962,334007,334010,334013,334064,334157,334230,334235,334297,334357,334455,334514,334617,334621,334682,334747,334841,334844,334954,335014,335260,335321,335323,335346,335434,335510,335653,335656,335721,335791,335852,335912,335991,336042,336091,336094,336167,336235,336307,336313,336316,336381,336441,336500,336502,336570,336573,336659,336717,336734,336789,336792,336878,336936,336978,337008,337062,337116,337119,337178,337219,337261,337263,337342,337345,337380,337431,337487,337542,337595-337597,337721,337775,337840,337902,337974,338085,338225,338228,338253,338323,338417,338552,338556,338664,338719,338801,338904,338950,338995,338997,339011,339043,339045,339088-339089,339245,339298,339353,339407,339463-339585,339587-339721,339723-340576,340578-340718,340810,340879,340931,340971,341023,341089,341094,341122,341146,341148,341190,341255,341313,341315,341377,341380,341436,341486,341530,341580,341599,341665,341707,341718,341807,341810,341972,342017,342062,342183,342224,342277,342329,342381,342384,342436,342485,342488,342546,342603,342605,342662,342715,342770,342824,342870,342929,342991,343158,343192,343221,343277,343337,343393,343445,343533,343578,343580,343635,343677,343691,343743,343789,343852,343900,343944,344004,344049,344103,344159,344175,344216,344271,344334,344386,344440,344493,344537,344540,344557,344609,344662,344716,344770,344836,344839,344842,344845,344900,344966,345117,345161,345164,345220,345275,345290,345371,345432,345488,345558,345640,345683,345830,345882,345924,345977,346029,346031,346040,346087,346145,346198,346240,346293,346349,346565,346698,346701,346763,346856,346900,346952,346955,347007,347068,347124,347146,347167,347240,347293,347344,347383,347439,347532,347600,347656,347727,347812,347953,347996,348102,348155,348158,348211,348265,348311,348363,348405,348465,348517,348605,348648,348736,348790,348793,348845-348846,348889,348952,348993,349045,349145,349195,349248,349250,349290,349340,349451,349502,349505,349532,349559,349608,349619,349673,349729,349732,349820,349822,349873,349928,349977,350024,350076,350129,350180,350221,350312,350415,350453,350502,350550,350553,350585,350680,350731,350734,350737,350790,350838,350886,350889,350938,350976,350978,351028,351081,351131,351183,351234,351286,351289,351308,351408,351451,351505,351560,351612,351646,351708,351762,351816,351818,351861,352015,352017,352035,352091,352149,352228,352231,352292,352373,352430,352512,352515-352516,352520,352556,352651,352705,352756,352817,352863,352956,352965,352992,353039,353078,353127,353176,353261,353321,353369,353397,353463,353503,353551,353599,353721,353771,353820,353868,353916,353962,354000,354119,354217,354270,354349,354493,354496,354543,354546,354548,354656,354703,354750,354836,354890,354938,354959,355010,355057,355137,355183,355229,355271,355320,355375,355449,355530,355575,355620,355623,355733,355747,355794,355851,355902,355905,355950,355953,355998,356074,356108,356215,356297,356428,356476,356522,356605,356651,356690,356798,356961,356964,357095,357213,357271,357318,357353,357357,357400,357405,357408,357421,357458,357497,357576,357620,357667,357762,357810,357812,357895,357941,357987,358017,358033,358116,358163,358215,358261,358284,358378,358436,358441,358485,358531,358644,358811,358944,358989,359051,359057,359060,359072,359091,359114,359117,359162,359212,359260,359355,359358,359453-359454,359458,359491,359509,359559,359620,359694,359707,359810,359898,359980,359982,360034,360088,360098,360139,360263,360310,360358,360361,360364,360414,360472,360489,360575,360672,360863,360885,360934,360993,361041,361091,361143,361208,361211,361270,361330,361333,361381,361422,361472,361522,361560,361607,362496,362537,362587,362678,362681,362730,362816,362869,362918,362998,363103,363107,363156,363212,363376,363429,363688,363734,363789,363876,363935,363987,364047,364065,364109,364163,364204,364259,364285,364342,364365-364369,364536,364579,364650,364707,364777,364787,364842,364845,364900,364903,364965,365083,365155,365160,365299,365320,365399,365475,365478,365575,365632,365701,365898,365990,366049,366053,366106,366168,366241,366297,366390,366412,366598,366741,366881,366948,367003,367028,367267,367299,367369,367417,367470,367562,367679,367731,367782,367844,367907,367978,367981,368042,368093,368267,368310,368407,368470,368499,368524,368536,368568,368587,368605,368629,368645,368721,368739,368760,368808,368831,368853,368885,368895,368899,368928,368947,369005,369044,369067,369091,369109,369147,369206,369215,369236,369239,369259,369263,369283,369303,369325,369328,369353,369369,369391,369437,369472,369491,369511,369558,369580,369627,369653,369709,369732,369751,369793,369819,369871,369938,369971,369994,370015,370025,370082,370132,370184,370206,370271,370274,370277,370384,370430,370432,370495,370547,370564,370643,370672,370698,370772,370798,370858,370901,370924,370954,370986,370989,371013,371022,371061,371090,371142,371199,371203,371271,371313,371338,371358,371394,371398,371437,371491,371529,371545,371591,371663,371691,371719,371748,371783,371789,371825,371861,371890,371920,371962,371999,372049,372090,372165,372198,372213,372240,372338,372341,372358,372372,372391,372418,372445,372472,372518,372522,372555,372582,372621,372625,372629,372656,372695,372710,372737,372764,372767,372805,372841,372863,372885,372916,372933,373025,373062,373101,373132,373237,373245,373300,373343,373440,373466,373468,373501,373505,373551,373579,373631,373633,373645,373665,373675,373703,373706,373737,373769,373774,373816,373849,373879,373910,373946,373990,374045,374132,374135,374178,374210,374231,374300,374336,374370,374385,374427,374476,374481,374537,374586,374652,374695,374728,374763,374803,374844,374906,374991,375026,375078,375112,375147,375190,375217,375273,375300,375326,375362,375389,375417,375451,375470,375485,375496,375531,375601,375626,375659,375728,375761,375794,375797,375801,375846,375863,375894,375965,375995,376030,376059,376088,376143,376167,376208,376233,376263,376308,376315,376342,376390,376414,376431,376470,376522,376587,376628,376658,376689,376726,376759,376789,376835,376865,376869,376916,376920,376951,377038,377070,377074,377105,377136,377166,377212,377227,377241,377258,377261,377354,377382,377399,377432,377504,377510,377592,377624,377656,377705,377709,377741,377772,377807,377838,377842,377848,377882,377923,377947,377992,378037,378089,378093,378120,378218,378286,378320

