Search in sources :

Example 36 with User

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;
}
Also used : PersistSettings(com.vodafone360.people.service.PersistSettings) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 37 with User

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()));
}
Also used : SocialNetwork(com.vodafone360.people.engine.presence.NetworkPresence.SocialNetwork)

Example 38 with User

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);
}
Also used : Hashtable(java.util.Hashtable) Identity(com.vodafone360.people.datatypes.Identity)

Example 39 with User

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);
}
Also used : InternetAvail(com.vodafone360.people.service.PersistSettings.InternetAvail) Intent(android.content.Intent)

Example 40 with User

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;
}
Also used : Request(com.vodafone360.people.service.io.Request) QueueManager(com.vodafone360.people.service.io.QueueManager)

Aggregations

ServiceStatus (com.vodafone360.people.service.ServiceStatus)22 Contact (com.vodafone360.people.datatypes.Contact)12 ArrayList (java.util.ArrayList)12 User (com.vodafone360.people.engine.presence.User)11 Hashtable (java.util.Hashtable)9 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)7 Request (com.vodafone360.people.service.io.Request)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 PersistSettings (com.vodafone360.people.service.PersistSettings)6 QueueManager (com.vodafone360.people.service.io.QueueManager)6 SmallTest (android.test.suitebuilder.annotation.SmallTest)4 Identity (com.vodafone360.people.datatypes.Identity)4 ServerIdInfo (com.vodafone360.people.database.DatabaseHelper.ServerIdInfo)3 RegistrationDetails (com.vodafone360.people.datatypes.RegistrationDetails)3 NetworkPresence (com.vodafone360.people.engine.presence.NetworkPresence)3 Cursor (android.database.Cursor)2 SQLiteStatement (android.database.sqlite.SQLiteStatement)2 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)2 AuthSessionHolder (com.vodafone360.people.datatypes.AuthSessionHolder)2 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)2