rem: else { tuple->state = PS_ONLINE; tuple->expires = INT_MAX;
add: if (!tuple->is_published) {	 orig = tuple->state; if (state == 0) { tuple->state = PS_OFFLINE; tuple->expires = act_time + 2 * timer_interval; } else { tuple->state = PS_ONLINE; tuple->expires = INT_MAX;   } db_update_presentity(presentity);  if (orig != state) { presentity->flags |= PFLAG_PRESENCE_CHANGED; }
context: void callback(str* _user, str *_contact, int state, void* data){	presentity_t *presentity;	get_act_time();	presentity = (struct presentity*)data;	if (presentity && callback_update_db) {		presence_tuple_t *tuple = NULL;		int orig;		LOG(L_ERR, "callback: uri=%.*s contact=%.*s state=%d presentity=%p\n",			presentity->uri.len, presentity->uri.s, (_contact ? _contact->len : 0), (_contact ? _contact->s : ""), state,			presentity);		if (_contact) {			if (callback_lock_pdomain) {				lock_pdomain(presentity->pdomain);			}			find_presence_tuple(_contact, presentity, &tuple);			if (!tuple) {				new_presence_tuple(_contact, act_time + default_expires, presentity, &tuple);				add_presence_tuple(presentity, tuple);			};			orig = tuple->state;			if (state == 0) {				tuple->state = PS_OFFLINE;				tuple->expires = act_time + 2 * timer_interval;			}			else {				tuple->state = PS_ONLINE;				tuple->expires = INT_MAX; /* act_time + default_expires; */				/* hack - re-registrations don't call the callback */			}			db_update_presentity(presentity);			if (orig != state) {				presentity->flags |= PFLAG_PRESENCE_CHANGED;			}			if (callback_lock_pdomain) {				unlock_pdomain(presentity->pdomain);			}		}	}}