@Override public void setStatusFromConfig() {// 设置自己的当前状态,供外部服务调用 boolean messageCarbons = PreferenceUtils.getPrefBoolean(mService, PreferenceConstants.MESSAGE_CARBONS, true); String statusMode = PreferenceUtils.getPrefString(mService, PreferenceConstants.STATUS_MODE, PreferenceConstants.AVAILABLE); String statusMessage = PreferenceUtils.getPrefString(mService, PreferenceConstants.STATUS_MESSAGE, mService.getString(R.string.status_online)); int priority = PreferenceUtils.getPrefInt(mService, PreferenceConstants.PRIORITY, 0); if (messageCarbons) CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled( true); Presence presence = new Presence(Presence.Type.available); Mode mode = Mode.valueOf(statusMode); presence.setMode(mode); presence.setStatus(statusMessage); presence.setPriority(priority); mXMPPConnection.sendPacket(presence); }
public void setStatusFromConfig() { // TODO: only call this when carbons changed, not on every presence change CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled(mConfig.messageCarbons); Presence presence = new Presence(Presence.Type.available); Mode mode = Mode.valueOf(mConfig.statusMode); presence.setMode(mode); presence.setStatus(mConfig.statusMessage); presence.setPriority(mConfig.priority); mXMPPConnection.sendPacket(presence); mConfig.presence_required = false; }