Index: channels/chan_dahdi.c
===================================================================
--- channels/chan_dahdi.c	(revision 378319)
+++ channels/chan_dahdi.c	(revision 378320)
@@ -3401,7 +3401,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. */
@@ -3417,7 +3417,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) */
 }
@@ -9888,7 +9888,8 @@
 	if (dashptr) {
 		*dashptr = '\0';
 	}
-	ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name);
+	tmp->flags |= 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 378319)
+++ channels/chan_sip.c	(revision 378320)
@@ -6459,7 +6459,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;
@@ -7658,6 +7658,9 @@
 		ast_jb_configure(tmp, &global_jbconf);
 	}
 
+	if (!i->relatedpeer) {
+		tmp->flags |= AST_FLAG_DISABLE_DEVSTATE_CACHE;
+	}
 	/* Set channel variables for this call from configuration */
 	for (v = i->chanvars ; v ; v = v->next) {
 		char valuebuf[1024];
@@ -14641,7 +14644,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
@@ -15425,8 +15428,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, (p->owner->flags & AST_FLAG_DISABLE_DEVSTATE_CACHE ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE),
+			     "SIP/%s", p->relatedpeer->name);
+
 	return;
 }
 
@@ -15852,7 +15856,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) {
@@ -22052,7 +22056,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);
 		}
@@ -27773,7 +27777,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 378319)
+++ channels/chan_agent.c	(revision 378320)
@@ -617,7 +617,7 @@
 		if (p->chan) {
 			p->chan->_bridge = 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) {
@@ -2143,7 +2143,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) {
@@ -2164,7 +2164,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 {
@@ -2224,7 +2224,7 @@
 						ast_queue_log("NONE", chan->uniqueid, agent, "AGENTLOGOFF", "%s|%ld", chan->name, 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 378319)
+++ channels/chan_iax2.c	(revision 378320)
@@ -5825,7 +5825,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;
@@ -5900,6 +5900,10 @@
 	i->owner = tmp;
 	i->capability = capability;
 
+	if (!cachable) {
+		tmp->flags |= AST_FLAG_DISABLE_DEVSTATE_CACHE;
+	}
+
 	/* Set inherited variables */
 	if (i->vars) {
 		for (v = i->vars ; v ; v = v->next)
@@ -8188,7 +8192,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;
@@ -8742,7 +8746,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);
 
@@ -8797,7 +8801,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) {
@@ -8874,14 +8878,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\nPost: %d\r\nPort: %d\r\n", p->name, ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), 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 */
@@ -10397,7 +10401,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;
@@ -11036,13 +11041,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;
@@ -11286,7 +11291,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;
@@ -11357,7 +11362,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;
@@ -12113,7 +12118,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]);
@@ -12279,7 +12284,7 @@
 	if (cai.found)
 		ast_string_field_set(iaxs[callno], host, pds.peer);
 
-	c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability, requestor ? requestor->linkedid : NULL);
+	c = ast_iax2_new(callno, AST_STATE_DOWN, cai.capability, requestor ? requestor->linkedid : NULL, cai.found);
 
 	ast_mutex_unlock(&iaxsl[callno]);
 
Index: channels/chan_skinny.c
===================================================================
--- channels/chan_skinny.c	(revision 378319)
+++ channels/chan_skinny.c	(revision 378320)
@@ -2109,7 +2109,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;
 			}
@@ -2147,7 +2147,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);
 			}
 		}
 	}
@@ -5900,7 +5900,7 @@
 			ast_verb(1, "RECEIVED UNKNOWN STIMULUS:  %d(%d/%d)\n", event, 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;
 }
@@ -5942,7 +5942,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;
@@ -6009,7 +6009,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);
 
@@ -6339,7 +6339,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:
@@ -6500,8 +6500,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 378319)
+++ channels/chan_local.c	(revision 378320)
@@ -1233,6 +1233,9 @@
 	tmp->tech_pvt = p;
 	tmp2->tech_pvt = p;
 
+	tmp->flags |= AST_FLAG_DISABLE_DEVSTATE_CACHE;
+	tmp2->flags |= AST_FLAG_DISABLE_DEVSTATE_CACHE;
+
 	p->owner = tmp;
 	p->chan = tmp2;
 
Index: apps/app_meetme.c
===================================================================
--- apps/app_meetme.c	(revision 378319)
+++ apps/app_meetme.c	(revision 378320)
@@ -2650,7 +2650,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);
 
@@ -3967,7 +3967,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);
 		}
 
 		/* Return the number of seconds the user was in the conf */
@@ -5457,8 +5457,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;
 		}
 	}
@@ -5956,8 +5956,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);
 
@@ -6466,8 +6466,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 378319)
+++ apps/confbridge/conf_state_empty.c	(revision 378320)
@@ -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 378319)
+++ apps/app_confbridge.c	(revision 378320)
@@ -982,7 +982,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 378319)
+++ apps/app_queue.c	(revision 378320)
@@ -3186,7 +3186,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)) {
Index: funcs/func_devstate.c
===================================================================
--- funcs/func_devstate.c	(revision 378319)
+++ funcs/func_devstate.c	(revision 378320)
@@ -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 378319)
+++ include/asterisk/event_defs.h	(revision 378320)
@@ -288,8 +288,14 @@
 	AST_EVENT_IE_USING_PASSWORD      = 0x0037,
 	AST_EVENT_IE_ATTEMPTED_TRANSPORT = 0x0038,
 
+	/*!
+	 * \brief Event non-cachability flag
+	 * Used by: All events
+	 * Payload type: UINT
+	 */
+	AST_EVENT_IE_CACHABLE            = 0x0039,
 	/*! \brief Must be the last IE value +1 */
-	AST_EVENT_IE_TOTAL               = 0x0039,
+	AST_EVENT_IE_TOTAL               = 0x003a,
 };
 
 /*!
Index: include/asterisk/channel.h
===================================================================
--- include/asterisk/channel.h	(revision 378319)
+++ include/asterisk/channel.h	(revision 378320)
@@ -942,6 +942,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 378319)
+++ include/asterisk/devicestate.h	(revision 378320)
@@ -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 378319)
+++ main/channel.c	(revision 378320)
@@ -297,6 +297,7 @@
 	ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN));
 	ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT));
 	ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS));
+	ast_data_add_bool(tree, "DISABLE_DEVSTATE_CACHE", ast_test_flag(chan, AST_FLAG_DISABLE_DEVSTATE_CACHE));
 }
 
 #if defined(KEEP_TILL_CHANNEL_PARTY_NUMBER_INFO_NEEDED)
@@ -2543,7 +2544,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, (chan->flags & AST_FLAG_DISABLE_DEVSTATE_CACHE ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), device_name);
 	}
 
 	chan->nativeformats = ast_format_cap_destroy(chan->nativeformats);
@@ -7272,7 +7273,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, (chan->flags & AST_FLAG_DISABLE_DEVSTATE_CACHE ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), name);
 
 	/* setstate used to conditionally report Newchannel; this is no more */
 	ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate",
Index: main/features.c
===================================================================
--- main/features.c	(revision 378319)
+++ main/features.c	(revision 378320)
@@ -1094,7 +1094,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 378319)
+++ main/event.c	(revision 378320)
@@ -272,7 +272,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 378319)
+++ main/ccss.c	(revision 378320)
@@ -637,7 +637,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 378319)
+++ main/devicestate.c	(revision 378320)
@@ -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: res/res_calendar.c
===================================================================
--- res/res_calendar.c	(revision 378319)
+++ res/res_calendar.c	(revision 378320)
@@ -599,9 +599,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);
 		}
 	}
 
@@ -859,9 +859,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 378319)
+++ res/res_jabber.c	(revision 378320)
@@ -350,7 +350,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);
@@ -364,7 +364,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);
@@ -3268,6 +3268,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)))
 	{
@@ -3279,7 +3280,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);
 }
 
@@ -3319,11 +3321,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");
@@ -3338,11 +3342,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")) {
@@ -3362,7 +3369,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;
 }
 
@@ -3437,7 +3450,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;
@@ -3451,8 +3464,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;
-
 }
 
 /*!
@@ -3463,11 +3492,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");
@@ -3479,6 +3508,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);
@@ -3498,7 +3529,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");

Property changes on: .
___________________________________________________________________
Modified: branch-1.8-merged
   - /branches/1.8:1-279056,279113,279227,279273,279280,279314,279390,279410,279442,279472,279502,279504,279562,279566,279568,279598,279601,279619,279636-279815,279817,279850,279887,279916,279949,279953,280023,280058,280090,280161,280195,280225,280233,280235,280269,280302,280307,280343,280346,280391,280414,280446,280450,280519,280549,280552,280557,280624,280628,280672,280740,280742,280777-280778,280809,280879,280909,280984,281052,281085,281294,281325,281356,281358,281429,281432,281466,281529,281532,281568,281575,281650,281687,281723,281760,281764,281870,281874-281875,281913,281982,282015,282047,282066,282098,282131,282200-282201,282236,282269,282271,282302,282334,282366,282468,282470,282543,282545,282577,282608,282638-282639,282671-282672,282740,282826,282860,282891,282895,282979,283013,283050,283173,283175,283177,283207,283209,283230,283241,283319,283350,283382,283457,283493,283527,283559,283561,283595,283627,283629,283659,283692,283770,283882,283951,284032,284065,284096,284127,284158,284281,284318,284415,284473,284477,284561,284597,284610,284632,284666,284696,284698,284701,284705,284779-284780,284849-284850,284852,284921,284950,284952,284967,285006,285017,285057,285090,285161-285162,285195,285197,285268,285336,285367,285369,285371,285373,285386,285455,285484,285527,285530,285533,285564,285568,285640,285711,285745,285819,285931,285962,286112,286118,286120,286189,286270,286426,286457,286528,286558,286588,286617,286647,286682,286758,286834,286868,286904-286905,286931,287015,287017,287020,287056,287116,287120,287193,287195,287269-287271,287309,287388,287471,287559,287639,287643,287645,287647,287661,287683,287701,287757,287760,287833,287863,287893,287895,287897,287929,287931,287935,288007,288079-288080,288082,288157,288159,288194,288268,288341,288345,288418,288507,288572,288606,288638,288640,288713,288748,288821,288852,288925,288927,292740-292741,292787,292794,292825,292868,292906,292969,293119,293159,293197,293305,293341,293418,293496,293530,293611,293648,293724,293803,293807,293887,293924,293970,294047,294049,294084,294125,294207,294243,294278,294313,294349,294430,294466,294501,294535,294569,294605,294734,294740,294745,294823,294905,294911,294989,295078,295164,295201,295278,295282,295361,295404,295441,295477,295516,295670,295673,295711,295747,295866,295869,295949,296002,296084,296167,296230,296352,296354,296391,296429,296467,296534,296582,296628,296673,296787,296870,296951,296992,297075,297157-297495,297535,297607,297733,297821,297825,297909,297952,297957,297965,298051,298054,298195,298394,298478,298482,298539,298598,298685,298773,298818,298827,298960,299088,299131,299138,299248,299312,299353,299405,299449,299583,299626,299752,299794,299820,299865,299907,299948,299989,300082,300166,300214,300301,300384,300430,300433,300521,300575,300623,300714,300798,300955,301047,301090,301134,301177,301221,301263,301308,301311,301402,301446,301504,301595,301683,302462,302505,302549,302552,302555,302600,302634,302680,302713,302785,302789,302831,302834,302837,302918,302921,303009,303107,303153,303467,303549,303678,303771,303860,303907,303962,304007,304097,304150,304186,304245,304251,304339,304462,304466,304554,304638,304683,304727,304730,304774,304777,304866,304908,304950,304985,305040,305083,305603,305692,305753,305798,305838,305844,305923,306124,306127,306215,306324,306356,306575,306619,306674,306866,306962,306967,306979,306999,307065,307092,307142,307228,307273,307467,307536,307750,307793,307837,307879,307962,308010,308098,308150,308242,308288,308416,308622,308679,308723,308815,308903,308945,308991,309035,309084,309126,309170,309204,309256,309403,309445,309448,309495,309542,309585,309678,309720,309765,309808,309858,309994,310039,310088,310142,310231,310240,310287,310415,310462,310587,310636,310734,310781,310834,310902,310993,310999,311050,311141,311197,311295,311297,311342,311352,311497,311558,311612,311615,311687,311751,311799,311874,311930,312022,312117,312211,312286-312288,312461,312509,312575,312766,312866,312889,312949,313001,313048,313142,313190,313279,313366,313368-313369,313434,313517,313588,313615,313658,313700,313780,313860,314017,314067-314069,314203,314206,314251,314358,314417,314550,314628,314732,314779-314780,314959,315001,315053,315213,315259,315349,315394,315446,315452,315503,315645,315673,315765,315810,315894,316094,316193,316206,316215,316217,316224,316265,316330-316331,316334,316336,316429,316476,316617,316650,316663,316709,316831,316917-316919,317058,317104,317196,317281,317283,317336,317370,317425,317427,317429,317474,317476,317478,317480,317484,317486,317530,317584,317670,317805,317837,317865,317867,317917-317918,317967,317969,318055,318057,318142,318148,318231,318233,318282,318337,318351,318436,318499,318549-318550,318671,318720,318783,318868,318917,318919,318921,319083,319085,319142,319145,319204,319259,319365,319367,319469,319529,319552,319654,319758,319812,319866,319938,319997,320007,320057,320059,320162,320180,320237,320338,320445,320504,320560,320568,320573,320650,320716,320796,320823,320883,320947,321042,321044,321100,321155,321211,321273,321330,321333,321337,321392,321436,321511,321515,321517,321528,321537,321547,321685,321812-321813,321871,321924,321926,322069,322189,322322,322425,322484,322749,322807,322865,322923,322981,323040,323154,323213,323370-323371,323392-323394,323456,323608,323610,323669-323670,323672,323754,323859,323863,323866,323932,323990,324048,324115,324174,324176,324178,324237,324241,324364,324479,324481,324484,324491,324557,324652,324678,324685,324768,324849,324914,324955,325091,325152,325212,325339,325416,325537,325545,325610,325614,325673,325740,325821,325877,325935,326144,326209,326291,326411,326484,326681,326683,326689,326830,326985,327044,327046,327106,327211,327411,327512,327682,327793,327852,327888,327890,327950,328014,328205,328209,328302,328427,328540,328593,328608,328663,328716,328770,328823,328878,328935,328987,329027,329144,329199,329203,329299,329333,329471,329527,329529,329613,329709,329767,329895,329991,329994,330050,330107,330203,330213,330311,330368,330433,330575,330578,330581,330648,330705,330762,330827,330843,331038,331142,331146,331248,331315,331461,331517,331575,331578,331635,331649,331658,331714,331771,331774,331867,331886,331955,332021,332026,332100,332118,332176,332264,332320,332355,332446,332503,332559,332699,332759,332816-332817,332874,332876,332939,333010,333201,333265,333267,333339,333378,333569,333630,333784-333785,333836,333947,334006,334009,334012,334156,334229,334234,334296,334355,334453,334616,334620,334682,334840,334843,334953,335064,335319,335341,335433,335497,335618,335655,335720,335790,335851,335911,335978,336093,336166,336234,336294,336312,336314,336378,336440,336499,336501,336569,336572,336658,336716,336733,336791,336877,336977,337007,337061,337115,337118,337325,337344,337353,337430,337486,337541,337720,337774,337839,337898,337973,338084,338224,338227,338235,338322,338416,338492,338551,338555,338663,338718,338800,339086-339087,339144,339147,339244,339297,339352,339406,339504-339506,339511,339566,339625,339719,339776,339830,339884,339938,340108,340164,340263,340279,340284,340365,340418,340470,340522,340534,340576,340662,340715,340809,340863,340878,340970,341022,341074,341088,341108-341112,341189,341254,341312,341314,341366,341379,341435,341529,341664,341704,341717,341806,341809,342061,342223,342276,342328,342380,342383,342435,342484,342487,342545,342602,342661,342769,342869,342927,342990,343047,343102,343157,343181,343220,343276,343281,343336,343375,343577,343621,343637,343690,343791,343851,343936,344048,344102,344157-344158,344215,344268,344330,344385,344439,344536,344539,344608,344661,344715,344769,344823,344835,344837,344843,344899,344965,345062-345063,345160,345163,345219,345273,345285,345370,345431,345487,345546,345682,345828-345829,345923,345976,346030,346086,346144,346147,346239,346292,346472,346564,346697,346700,346762,346899,346951,346954,347006,347058,347111,347131,347166,347239,347292,347369,347438,347531,347595,347718,347811,347995,348101,348154,348157,348212,348310,348362,348401,348464,348516,348647,348735,348833,348888,348940,348992,349044,349144,349194,349289,349339,349450,349482,349504,349529,349558,349672,349728,349731,349819,349872,349968,350023,350679,350730,350733,350736,350788-350789,350837,350885,350888,350975,351027,351080,351130,351182,351233,351284,351287,351306,351396,351450,351504,351559,351611,351618,351707,351759,351858,351860,352014,352016,352029,352090,352144,352199,352230,352291,352367,352424,352511,352514,352551,352612,352643,352704,352755,352807,352862,352955,352959,353077,353126,353175,353260,353320,353368,353371,353454,353502,353550,353598,353720,353769-353770,353867,353915,353999,354116,354216,354263,354348,354492,354495,354542,354545,354547,354655,354702,354749,354835,354889,354953,355009,355056,355136,355182,355228,355268,355319,355365,355448,355458,355529,355574,355608,355622,355732,355746,355793,355850,355901,355904,355949,355952,355997,356107,356214,356290-356337,356430,356475,356521,356604,356650,356677,356797,356917,356963,357093,357212,357266,357352,357356,357386,357407,357416,357455,357490,357575,357665,357761,357809,357811,357894,357940,357986,358011,358029,358115,358162,358214,358260,358278,358377,358435,358438,358484,358530,358643,358810,358859,358943,358978,359050,359053,359056,359059,359069,359088,359110,359116,359157,359211,359259,359344,359356,359451-359452,359457,359486,359508,359558,359609,359656,359706,359809,359892,359979,360033,360086-360087,360138,360262,360309,360356-360357,360360,360363,360413,360471,360474,360488,360574,360625,360712,360862,360884,360933,360987,361040,361090,361142,361201,361210,361269,361329,361332,361380,361403-361412,361471,361558,361606,361657,361705,361753,361803,361854,361955,361972,362079,362082,362151,362201,362204,362253,362304,362354-362355,362359,362362,362428,362485,362536,362586,362677,362680,362729,362815,362868,362997,363102,363106,363141,363209,363375,363428,363687,363730,363788,363875,363934,363986,364046,364060,364108,364203,364258,364277,364340-364341,364578,364635,364649,364706,364769,364786,364840-364841,364899,364902,365006-365068,365143,365159,365298,365313,365398,365474,365476,365574,365631,365692,365896,365989,366048,366052,366094,366167,366240,366296,366389,366409,366547,366597,366740,366791,366880,366882,366944,367002,367027,367266,367292,367362,367416,367469,367678,367730,367781,367906,367976,367980,368039,368092,368218,368308,368405,368469,368498,368520,368533,368567,368586,368604,368625,368644,368719,368738,368759,368807,368830,368852,368873,368894,368898,368927,369001-369002,369043,369066,369108,369146,369195,369214,369235,369238,369258,369262,369282,369302,369323-369324,369327,369351-369352,369390,369436,369471,369490,369557,369579,369626,369652,369708,369731,369750,369792,369818,369869,369937,369970,369993,370014,370017,370081,370131,370183,370205,370252,370273,370275,370360,370383,370428-370429,370494,370563,370618,370642,370666,370697,370769-370771,370797,370856,370900,370923,370952,370985,370988,371011-371012,371060,371089,371141,371198,371201,371270,371306,371337,371357,371392-371393,371436,371469,371544,371590,371662,371690,371718,371747,371782,371787,371824,371860,371888,371919,371961,371998,372015,372048,372089,372158,372185,372212,372239,372339,372354,372390,372417,372444,372471,372517,372554,372581,372620,372624,372628,372655,372682,372709,372736,372763,372765,372804,372840,372902,372932,372959,373024,373061,373090,373131,373165,373236,373242,373298,373342,373424,373438,373467,373500,373504,373532,373550,373578,373617-373618,373640,373652,373666,373702,373705,373735,373768,373773,373815,373848,373878,373909,373945,373989,374032,374177,374230,374335,374365,374384,374426,374456,374475,374479,374536,374570-374581,374686,374727,374758,374802,374843,374905,374977,375025,375059,375074,375111,375146,375189,375216,375272,375299,375325,375361,375388,375415,375450,375484,375528,375594,375625,375658,375698,375727,375758,375793,375800,375862,375893,375964,375993-375994,376029,376058,376087,376142,376166,376199,376232,376262,376306-376307,376340,376389,376428,376469,376521,376586,376627,376657,376688,376725,376758,376788,376834,376864,376868,376901,376919,376950,377037,377069,377073,377104,377135,377165,377256-377257,377398,377431,377487,377509,377557,377591,377623,377655,377704,377708,377740,377771,377806,377837,377840,377847,377881,377922,377946,378036,378088,378092,378119,378217,378269
   + /branches/1.8:1-279056,279113,279227,279273,279280,279314,279390,279410,279442,279472,279502,279504,279562,279566,279568,279598,279601,279619,279636-279815,279817,279850,279887,279916,279949,279953,280023,280058,280090,280161,280195,280225,280233,280235,280269,280302,280307,280343,280346,280391,280414,280446,280450,280519,280549,280552,280557,280624,280628,280672,280740,280742,280777-280778,280809,280879,280909,280984,281052,281085,281294,281325,281356,281358,281429,281432,281466,281529,281532,281568,281575,281650,281687,281723,281760,281764,281870,281874-281875,281913,281982,282015,282047,282066,282098,282131,282200-282201,282236,282269,282271,282302,282334,282366,282468,282470,282543,282545,282577,282608,282638-282639,282671-282672,282740,282826,282860,282891,282895,282979,283013,283050,283173,283175,283177,283207,283209,283230,283241,283319,283350,283382,283457,283493,283527,283559,283561,283595,283627,283629,283659,283692,283770,283882,283951,284032,284065,284096,284127,284158,284281,284318,284415,284473,284477,284561,284597,284610,284632,284666,284696,284698,284701,284705,284779-284780,284849-284850,284852,284921,284950,284952,284967,285006,285017,285057,285090,285161-285162,285195,285197,285268,285336,285367,285369,285371,285373,285386,285455,285484,285527,285530,285533,285564,285568,285640,285711,285745,285819,285931,285962,286112,286118,286120,286189,286270,286426,286457,286528,286558,286588,286617,286647,286682,286758,286834,286868,286904-286905,286931,287015,287017,287020,287056,287116,287120,287193,287195,287269-287271,287309,287388,287471,287559,287639,287643,287645,287647,287661,287683,287701,287757,287760,287833,287863,287893,287895,287897,287929,287931,287935,288007,288079-288080,288082,288157,288159,288194,288268,288341,288345,288418,288507,288572,288606,288638,288640,288713,288748,288821,288852,288925,288927,292740-292741,292787,292794,292825,292868,292906,292969,293119,293159,293197,293305,293341,293418,293496,293530,293611,293648,293724,293803,293807,293887,293924,293970,294047,294049,294084,294125,294207,294243,294278,294313,294349,294430,294466,294501,294535,294569,294605,294734,294740,294745,294823,294905,294911,294989,295078,295164,295201,295278,295282,295361,295404,295441,295477,295516,295670,295673,295711,295747,295866,295869,295949,296002,296084,296167,296230,296352,296354,296391,296429,296467,296534,296582,296628,296673,296787,296870,296951,296992,297075,297157-297495,297535,297607,297733,297821,297825,297909,297952,297957,297965,298051,298054,298195,298394,298478,298482,298539,298598,298685,298773,298818,298827,298960,299088,299131,299138,299248,299312,299353,299405,299449,299583,299626,299752,299794,299820,299865,299907,299948,299989,300082,300166,300214,300301,300384,300430,300433,300521,300575,300623,300714,300798,300955,301047,301090,301134,301177,301221,301263,301308,301311,301402,301446,301504,301595,301683,302462,302505,302549,302552,302555,302600,302634,302680,302713,302785,302789,302831,302834,302837,302918,302921,303009,303107,303153,303467,303549,303678,303771,303860,303907,303962,304007,304097,304150,304186,304245,304251,304339,304462,304466,304554,304638,304683,304727,304730,304774,304777,304866,304908,304950,304985,305040,305083,305603,305692,305753,305798,305838,305844,305923,306124,306127,306215,306324,306356,306575,306619,306674,306866,306962,306967,306979,306999,307065,307092,307142,307228,307273,307467,307536,307750,307793,307837,307879,307962,308010,308098,308150,308242,308288,308416,308622,308679,308723,308815,308903,308945,308991,309035,309084,309126,309170,309204,309256,309403,309445,309448,309495,309542,309585,309678,309720,309765,309808,309858,309994,310039,310088,310142,310231,310240,310287,310415,310462,310587,310636,310734,310781,310834,310902,310993,310999,311050,311141,311197,311295,311297,311342,311352,311497,311558,311612,311615,311687,311751,311799,311874,311930,312022,312117,312211,312286-312288,312461,312509,312575,312766,312866,312889,312949,313001,313048,313142,313190,313279,313366,313368-313369,313434,313517,313588,313615,313658,313700,313780,313860,314017,314067-314069,314203,314206,314251,314358,314417,314550,314628,314732,314779-314780,314959,315001,315053,315213,315259,315349,315394,315446,315452,315503,315645,315673,315765,315810,315894,316094,316193,316206,316215,316217,316224,316265,316330-316331,316334,316336,316429,316476,316617,316650,316663,316709,316831,316917-316919,317058,317104,317196,317281,317283,317336,317370,317425,317427,317429,317474,317476,317478,317480,317484,317486,317530,317584,317670,317805,317837,317865,317867,317917-317918,317967,317969,318055,318057,318142,318148,318231,318233,318282,318337,318351,318436,318499,318549-318550,318671,318720,318783,318868,318917,318919,318921,319083,319085,319142,319145,319204,319259,319365,319367,319469,319529,319552,319654,319758,319812,319866,319938,319997,320007,320057,320059,320162,320180,320237,320338,320445,320504,320560,320568,320573,320650,320716,320796,320823,320883,320947,321042,321044,321100,321155,321211,321273,321330,321333,321337,321392,321436,321511,321515,321517,321528,321537,321547,321685,321812-321813,321871,321924,321926,322069,322189,322322,322425,322484,322749,322807,322865,322923,322981,323040,323154,323213,323370-323371,323392-323394,323456,323608,323610,323669-323670,323672,323754,323859,323863,323866,323932,323990,324048,324115,324174,324176,324178,324237,324241,324364,324479,324481,324484,324491,324557,324652,324678,324685,324768,324849,324914,324955,325091,325152,325212,325339,325416,325537,325545,325610,325614,325673,325740,325821,325877,325935,326144,326209,326291,326411,326484,326681,326683,326689,326830,326985,327044,327046,327106,327211,327411,327512,327682,327793,327852,327888,327890,327950,328014,328205,328209,328302,328427,328540,328593,328608,328663,328716,328770,328823,328878,328935,328987,329027,329144,329199,329203,329299,329333,329471,329527,329529,329613,329709,329767,329895,329991,329994,330050,330107,330203,330213,330311,330368,330433,330575,330578,330581,330648,330705,330762,330827,330843,331038,331142,331146,331248,331315,331461,331517,331575,331578,331635,331649,331658,331714,331771,331774,331867,331886,331955,332021,332026,332100,332118,332176,332264,332320,332355,332446,332503,332559,332699,332759,332816-332817,332874,332876,332939,333010,333201,333265,333267,333339,333378,333569,333630,333784-333785,333836,333947,334006,334009,334012,334156,334229,334234,334296,334355,334453,334616,334620,334682,334840,334843,334953,335064,335319,335341,335433,335497,335618,335655,335720,335790,335851,335911,335978,336093,336166,336234,336294,336312,336314,336378,336440,336499,336501,336569,336572,336658,336716,336733,336791,336877,336977,337007,337061,337115,337118,337325,337344,337353,337430,337486,337541,337720,337774,337839,337898,337973,338084,338224,338227,338235,338322,338416,338492,338551,338555,338663,338718,338800,339086-339087,339144,339147,339244,339297,339352,339406,339504-339506,339511,339566,339625,339719,339776,339830,339884,339938,340108,340164,340263,340279,340284,340365,340418,340470,340522,340534,340576,340662,340715,340809,340863,340878,340970,341022,341074,341088,341108-341112,341189,341254,341312,341314,341366,341379,341435,341529,341664,341704,341717,341806,341809,342061,342223,342276,342328,342380,342383,342435,342484,342487,342545,342602,342661,342769,342869,342927,342990,343047,343102,343157,343181,343220,343276,343281,343336,343375,343577,343621,343637,343690,343791,343851,343936,344048,344102,344157-344158,344215,344268,344330,344385,344439,344536,344539,344608,344661,344715,344769,344823,344835,344837,344843,344899,344965,345062-345063,345160,345163,345219,345273,345285,345370,345431,345487,345546,345682,345828-345829,345923,345976,346030,346086,346144,346147,346239,346292,346472,346564,346697,346700,346762,346899,346951,346954,347006,347058,347111,347131,347166,347239,347292,347369,347438,347531,347595,347718,347811,347995,348101,348154,348157,348212,348310,348362,348401,348464,348516,348647,348735,348833,348888,348940,348992,349044,349144,349194,349289,349339,349450,349482,349504,349529,349558,349672,349728,349731,349819,349872,349968,350023,350679,350730,350733,350736,350788-350789,350837,350885,350888,350975,351027,351080,351130,351182,351233,351284,351287,351306,351396,351450,351504,351559,351611,351618,351707,351759,351858,351860,352014,352016,352029,352090,352144,352199,352230,352291,352367,352424,352511,352514,352551,352612,352643,352704,352755,352807,352862,352955,352959,353077,353126,353175,353260,353320,353368,353371,353454,353502,353550,353598,353720,353769-353770,353867,353915,353999,354116,354216,354263,354348,354492,354495,354542,354545,354547,354655,354702,354749,354835,354889,354953,355009,355056,355136,355182,355228,355268,355319,355365,355448,355458,355529,355574,355608,355622,355732,355746,355793,355850,355901,355904,355949,355952,355997,356107,356214,356290-356337,356430,356475,356521,356604,356650,356677,356797,356917,356963,357093,357212,357266,357352,357356,357386,357407,357416,357455,357490,357575,357665,357761,357809,357811,357894,357940,357986,358011,358029,358115,358162,358214,358260,358278,358377,358435,358438,358484,358530,358643,358810,358859,358943,358978,359050,359053,359056,359059,359069,359088,359110,359116,359157,359211,359259,359344,359356,359451-359452,359457,359486,359508,359558,359609,359656,359706,359809,359892,359979,360033,360086-360087,360138,360262,360309,360356-360357,360360,360363,360413,360471,360474,360488,360574,360625,360712,360862,360884,360933,360987,361040,361090,361142,361201,361210,361269,361329,361332,361380,361403-361412,361471,361558,361606,361657,361705,361753,361803,361854,361955,361972,362079,362082,362151,362201,362204,362253,362304,362354-362355,362359,362362,362428,362485,362536,362586,362677,362680,362729,362815,362868,362997,363102,363106,363141,363209,363375,363428,363687,363730,363788,363875,363934,363986,364046,364060,364108,364203,364258,364277,364340-364341,364578,364635,364649,364706,364769,364786,364840-364841,364899,364902,365006-365068,365143,365159,365298,365313,365398,365474,365476,365574,365631,365692,365896,365989,366048,366052,366094,366167,366240,366296,366389,366409,366547,366597,366740,366791,366880,366882,366944,367002,367027,367266,367292,367362,367416,367469,367678,367730,367781,367906,367976,367980,368039,368092,368218,368308,368405,368469,368498,368520,368533,368567,368586,368604,368625,368644,368719,368738,368759,368807,368830,368852,368873,368894,368898,368927,369001-369002,369043,369066,369108,369146,369195,369214,369235,369238,369258,369262,369282,369302,369323-369324,369327,369351-369352,369390,369436,369471,369490,369557,369579,369626,369652,369708,369731,369750,369792,369818,369869,369937,369970,369993,370014,370017,370081,370131,370183,370205,370252,370273,370275,370360,370383,370428-370429,370494,370563,370618,370642,370666,370697,370769-370771,370797,370856,370900,370923,370952,370985,370988,371011-371012,371060,371089,371141,371198,371201,371270,371306,371337,371357,371392-371393,371436,371469,371544,371590,371662,371690,371718,371747,371782,371787,371824,371860,371888,371919,371961,371998,372015,372048,372089,372158,372185,372212,372239,372339,372354,372390,372417,372444,372471,372517,372554,372581,372620,372624,372628,372655,372682,372709,372736,372763,372765,372804,372840,372902,372932,372959,373024,373061,373090,373131,373165,373236,373242,373298,373342,373424,373438,373467,373500,373504,373532,373550,373578,373617-373618,373640,373652,373666,373702,373705,373735,373768,373773,373815,373848,373878,373909,373945,373989,374032,374177,374230,374335,374365,374384,374426,374456,374475,374479,374536,374570-374581,374686,374727,374758,374802,374843,374905,374977,375025,375059,375074,375111,375146,375189,375216,375272,375299,375325,375361,375388,375415,375450,375484,375528,375594,375625,375658,375698,375727,375758,375793,375800,375862,375893,375964,375993-375994,376029,376058,376087,376142,376166,376199,376232,376262,376306-376307,376340,376389,376428,376469,376521,376586,376627,376657,376688,376725,376758,376788,376834,376864,376868,376901,376919,376950,377037,377069,377073,377104,377135,377165,377256-377257,377398,377431,377487,377509,377557,377591,377623,377655,377704,377708,377740,377771,377806,377837,377840,377847,377881,377922,377946,378036,378088,378092,378119,378217,378269,378303

