use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class SyncMeEngine method setFirstTimeSyncStarted.
/**
* Helper function to update the database when the state of the
* {@link #mFirstTimeMeSyncStarted} flag changes.
* @param value New value to the flag. True indicates that first time sync
* has been started. The flag is never set to false again by the
* engine, it will be only set to false when a remove user data
* is done (and the database is deleted).
* @return SUCCESS or a suitable error code if the database could not be
* updated.
*/
private ServiceStatus setFirstTimeSyncStarted(final boolean value) {
if (mFirstTimeSyncStarted == value) {
return ServiceStatus.SUCCESS;
}
PersistSettings setting = new PersistSettings();
setting.putFirstTimeMeSyncStarted(value);
ServiceStatus status = mDbHelper.setOption(setting);
if (ServiceStatus.SUCCESS == status) {
synchronized (this) {
mFirstTimeSyncStarted = value;
}
}
return status;
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class ChatDbUtils method convertUserIds.
/**
* Set the user ID, network ID and local contact ID values in the given
* ChatMessage.
*
* The original msg.getUserId() is formatted <network>::<userId>, meaning
* if "::" is present the values are split, otherwise the original value is
* used.
*
* @param chatMessage ChatMessage to be altered.
* @param databaseHelper DatabaseHelper with a readable database.
*/
public static void convertUserIds(final ChatMessage chatMessage, final DatabaseHelper databaseHelper) {
/**
* Use original User ID, in case of NumberFormatException (see
* PAND-2356).
*/
final String originalUserId = chatMessage.getUserId();
int index = originalUserId.indexOf(COLUMNS);
if (index > -1) {
/**
* Parse a <networkId>::<userId> formatted user ID. *
*/
chatMessage.setUserId(originalUserId.substring(index + COLUMNS.length()));
String network = originalUserId.substring(0, index);
/**
* Parse the <networkId> component. *
*/
SocialNetwork sn = SocialNetwork.getValue(network);
if (sn != null) {
chatMessage.setNetworkId(sn.ordinal());
} else {
chatMessage.setNetworkId(SocialNetwork.INVALID.ordinal());
LogUtils.logE("ChatUtils.convertUserIds() Invalid Network ID [" + network + "] in [" + originalUserId + "]");
}
}
chatMessage.setLocalContactId(ContactDetailsTable.findLocalContactIdByKey(SocialNetwork.getSocialNetworkValue(chatMessage.getNetworkId()).toString(), chatMessage.getUserId(), ContactDetail.DetailKeys.VCARD_IMADDRESS, databaseHelper.getReadableDatabase()));
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class PresenceEngine method initSetMyAvailabilityRequestAfterLogin.
/**
* Method used to set availability of me profile when user logs in.
* This is primarily used for reacting to login/connection state changes.
*/
private void initSetMyAvailabilityRequestAfterLogin() {
if (ConnectionManager.getInstance().getConnectionState() != STATE_CONNECTED || !isFirstTimeSyncComplete()) {
LogUtils.logD("PresenceEngine.initSetMyAvailabilityRequest():" + " return NO NETWORK CONNECTION or not ready");
return;
}
String meProfileUserId = Long.toString(PresenceDbUtils.getMeProfileUserId(mDbHelper));
Hashtable<String, String> availability = new Hashtable<String, String>();
ArrayList<Identity> identityList = EngineManager.getInstance().getIdentityEngine().getMyChattableIdentities();
if ((identityList.size() != 0)) {
for (int i = 0; i < identityList.size(); i++) {
Identity myIdentity = identityList.get(i);
availability.put(myIdentity.mNetwork, OnlineStatus.ONLINE.toString());
}
}
User meUser = new User(meProfileUserId, availability);
meUser.setLocalContactId(Long.valueOf(meProfileUserId));
updateMyPresenceInDatabase(meUser);
addUiRequestToQueue(ServiceUiRequest.SET_MY_AVAILABILITY, availability);
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class NetworkAgent method processRoaming.
/**
* Displaying notification to the user about roaming
*
* @param InternetAvail value.
*/
private void processRoaming(InternetAvail val) {
InternetAvail internetAvail;
if (val != null) {
internetAvail = val;
} else {
internetAvail = getInternetAvailSetting();
}
Intent intent = new Intent();
if (mContext != null && mIsRoaming && (internetAvail == InternetAvail.ALWAYS_CONNECT) && (mDisableRoamingNotificationUntil == null || mDisableRoamingNotificationUntil < System.currentTimeMillis())) {
LogUtils.logV("NetworkAgent.processRoaming() " + "Displaying notification - DisplayRoaming[" + mIsRoaming + "]");
intent.setAction(Intents.ROAMING_ON);
} else {
/*
* We are not roaming then we should remove notification, if no
* notification were before nothing happens
*/
LogUtils.logV("NetworkAgent.processRoaming() Removing notification - " + " DisplayRoaming[" + mIsRoaming + "]");
intent.setAction(Intents.ROAMING_OFF);
}
mContext.sendBroadcast(intent);
}
use of com.vodafone360.people.engine.presence.User in project 360-Engine-for-Android by 360.
the class Auth method requestActivationCode.
/**
* Implementation of "auth/requestactivationcode" API.
*
* @param engine Handle to LoginEngine which handles requests using this
* API.
* @param username User-name for this account.
* @param mobileNumber Mobile number for this activation code to be sent.
* @return Request ID generated for this request.
* @return -1 when username is NULL.
* @throws NullPointerException when engine is NULL
* @throws NullPointerException when mobileNumber is NULL
*/
public static int requestActivationCode(BaseEngine engine, String username, String mobileNumber) {
if (engine == null) {
throw new NullPointerException("Auth.requestActivationCode() engine cannot be NULL");
}
if (username == null) {
LogUtils.logE("Auth.requestActivationCode() username must be specified");
return -1;
}
if (mobileNumber == null) {
throw new NullPointerException("Auth.requestActivationCode() mobileNumber cannot be NULL");
}
Request request = new Request(FUNCTION_REQUEST_ACTIVATION_CODE, Request.Type.STATUS, engine.engineId(), false, Settings.API_REQUESTS_TIMEOUT_AUTH);
request.addData(USERNAME, username);
request.addData(VALUE, mobileNumber);
request.addData(FLAGS, ACTIVATE_MOBILE_CLIENT_FLAG);
QueueManager queue = QueueManager.getInstance();
int requestId = queue.addRequest(request);
queue.fireQueueStateChanged();
return requestId;
}
Aggregations