Search in sources :

Example 61 with Contact

use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.

the class TestModule method createFakeActivitiesList.

/**
	 * TODO: fill in the method properly
	 * @return
	 */
public List<ActivityItem> createFakeActivitiesList() {
    List<ActivityItem> activityList = new ArrayList<ActivityItem>();
    for (int i = 0; i < TABLE_SIZE; i++) {
        ActivityItem activityItem = new ActivityItem();
        /** Unique identifier for the activity. This can be empty when setting 
			 * a new activity (the id is generated on the server side) */
        activityItem.activityId = System.currentTimeMillis();
        /** Timestamp representing the time of the activity. 
			 * This may not be related to creation/updated time. */
        activityItem.time = System.currentTimeMillis();
        /** local id for db */
        //			activityItem.mLocalId; set by DB insertion
        //			activityItem.mMoreInfo; //new Hashtable<ActivityItem, String>
        /** The parent activity for 'grouped' or aggregated activities. This must be empty 
			 * for normal activities that can be retrieved normally. Normally, a GetActivities 
			 * without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a mParentActivity set, the 'children' filter must 
			 * be used with a value of the parent Activity's id.*/
        //			activityItem.mParentActivity; // null
        /** Indicates wether this activity 'groups' several child activities. When set, 
			 * there must be child activities set that refer the main activity. Normally, 
			 * a GetActivities without filter will not yield any 'grouped' or 'child' activities. 
			 * To get activities that have a parentactivity set, the 'children' filter 
			 * must be used with a value of the parent Activity's id.*/
        //			activityItem.mHasChildren = false;
        /** Defines a binary preview for the activity. The preview can be a small thumbnail 
			 * of the activity. The type of the binary data is defined into the previewmime field.*/
        //			keep null
        //			activityItem.mPreview = ByteBuffer.allocate(bytes.length);
        //			activityItem.mPreviewMime;
        /** Defines an http url that the client can use to retrieve preview binary data. 
			 * Can be used to embed the url into an IMG HTML tag.*/
        //			activityItem.mPreviewUrl
        /** Name of the store type for this message. This field contains information about the 
			 * originator network (local or external community activity). 
			 * By default, should be set to local*/
        activityItem.store = "local";
        activityItem.title = generateRandomString();
        activityItem.description = activityItem.description + activityItem.store;
        /** Defines the type of the activity. */
        activityItem.type = Type.CONTACT_FRIEND_INVITATION_SENT;
        /** Defines an internal reference (if any) to the source of the activity. 
			 * The format for the uri is "module:identifier".Some examples of valid uri are:
			 * contact:2737b322c9f6476ca152aa6cf3e5ac12 The activity is linked to some 
			 * changes on a contact identified by id=2737b322c9f6476ca152aa6cf3e5ac12.
			 * file:virtual/flickr/2590004126 The activity is linked to some actions 
			 * on a file identified by id=virtual/flickr/2590004126.
			 * message:9efd255359074dd9bd04cc1c8c4743e5 The activity is linked to a message 
			 * identified by id=9efd255359074dd9bd04cc1c8c4743e5 */
        activityItem.uri = "virtual/flickr/2590004126";
        //can be 0		activityItem.mActivityFlags;
        /** Miscellaneous flags.*/
        activityItem.flagList = new ArrayList<Flag>();
        activityItem.flagList.add(Flag.ALREADY_READ);
        /** Defines the contact information of the counter-parties in the activity. 
			 * This field is not mandatory, because some activity types 
			 * are not related to contacts, but required if known.. */
        //keep it simple - empty		activityItem.mContactList = ;
        activityItem.visibility = new ArrayList<Visibility>();
        activityItem.visibility.add(Visibility.ORIGINATOR);
        //keep it 0		activityItem.mVisibilityFlags = 0;
        activityList.add(activityItem);
    }
    return activityList;
}
Also used : ArrayList(java.util.ArrayList) Visibility(com.vodafone360.people.datatypes.ActivityItem.Visibility) Flag(com.vodafone360.people.datatypes.ActivityItem.Flag) ActivityItem(com.vodafone360.people.datatypes.ActivityItem)

Example 62 with Contact

use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.

the class TestModule method generateFakeTimeLinesList.

/**
	 * TODO: fill in the method properly
	 * @return
	 */
public static ArrayList<TimelineSummaryItem> generateFakeTimeLinesList() {
    ArrayList<TimelineSummaryItem> timeList = new ArrayList<TimelineSummaryItem>();
    ArrayList<String> uniqueContactNames = new ArrayList<String>();
    ArrayList<Long> uniqueLocalContactIds = new ArrayList<Long>();
    for (int i = 0; i < TABLE_SIZE; i++) {
        TimelineSummaryItem item = new TimelineSummaryItem();
        item.mTimestamp = System.currentTimeMillis();
        item.mNativeItemId = generateRandomInt();
        // the same as in fetch
        item.mNativeItemType = TimelineNativeTypes.SmsLog.ordinal();
        item.mType = Type.MESSAGE_SMS_RECEIVED;
        item.mNativeThreadId = generateRandomInt();
        item.mContactAddress = "some local address";
        item.mDescription = generateRandomString();
        item.mTitle = DateFormat.getDateInstance().format(new Date(item.mTimestamp));
        //item.mLocalActivityId = i; // Set on databae insert.
        //the below fields are originally set under condition
        item.mContactId = generateRandomLong();
        item.mLocalContactId = generateRandomLong();
        item.mUserId = generateRandomLong();
        item.mContactName = generateRandomString() + i;
        item.mContactNetwork = generateRandomString();
        item.mIncoming = TimelineSummaryItem.Type.INCOMING;
        // then contact isn't included in ActivitiesTable.fetchTimelineEventList
        if (!uniqueContactNames.contains(item.mContactName) && !uniqueLocalContactIds.contains(item.mLocalContactId)) {
            uniqueContactNames.add(item.mContactName);
            uniqueLocalContactIds.add(item.mLocalContactId);
            timeList.add(item);
        }
    }
    Log.e("UNIQUE TIMELINE NAMES:", uniqueContactNames.toString());
    return timeList;
}
Also used : ArrayList(java.util.ArrayList) TimelineSummaryItem(com.vodafone360.people.database.tables.ActivitiesTable.TimelineSummaryItem) Date(java.util.Date)

Example 63 with Contact

use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.

the class TestModule method createDummyNativeContactData.

public Contact createDummyNativeContactData() {
    Contact contact = createDummyContactData();
    for (ContactDetail cd : contact.details) {
        cd.nativeContactId = generateRandomInt();
        cd.nativeDetailId = generateRandomInt();
        cd.nativeVal1 = generateRandomString();
        cd.nativeVal2 = generateRandomString();
        cd.nativeVal3 = generateRandomString();
    }
    return contact;
}
Also used : ContactDetail(com.vodafone360.people.datatypes.ContactDetail) Contact(com.vodafone360.people.datatypes.Contact)

Example 64 with Contact

use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.

the class HessianDecoder method decodeResponse.

/**
     * 
     * 
     * 
     * @param is
     * @param requestId
     * @param type
     * @param isZipped
     * @param engineId
     * 
     * @return
     * 
     * @throws IOException
     */
@SuppressWarnings("unchecked")
private DecodedResponse decodeResponse(InputStream is, int requestId, Request.Type type, boolean isZipped, EngineId engineId) throws IOException {
    boolean usesReplyTag = false;
    int responseType = DecodedResponse.ResponseType.UNKNOWN.ordinal();
    List<BaseDataType> resultList = new ArrayList<BaseDataType>();
    mMicroHessianInput.init(is);
    // skip start
    // initial map tag or fail
    int tag = is.read();
    if (tag == 'r') {
        // reply / response
        // read major and minor
        is.read();
        is.read();
        // read next tag
        tag = is.read();
        usesReplyTag = true;
    }
    if (tag == -1) {
        return null;
    }
    // read reason string and throw exception
    if (tag == 'f') {
        ServerError zybErr = new ServerError(mMicroHessianInput.readFault().errString());
        resultList.add(zybErr);
        DecodedResponse decodedResponse = new DecodedResponse(requestId, resultList, engineId, DecodedResponse.ResponseType.SERVER_ERROR.ordinal());
        return decodedResponse;
    }
    // this is not wrapped up in a hashtable
    if (type == Request.Type.EXTERNAL_RPG_RESPONSE) {
        LogUtils.logV("HessianDecoder.decodeResponse() EXTERNAL_RPG_RESPONSE");
        if (tag != 'I') {
            LogUtils.logE("HessianDecoder.decodeResponse() " + "tag!='I' Unexpected Hessian type:" + tag);
        }
        parseExternalResponse(resultList, is, tag);
        DecodedResponse decodedResponse = new DecodedResponse(requestId, resultList, engineId, DecodedResponse.ResponseType.SERVER_ERROR.ordinal());
        return decodedResponse;
    }
    // internal response: should contain a Map type - i.e. Hashtable
    if (tag != 'M') {
        LogUtils.logE("HessianDecoder.decodeResponse() tag!='M' Unexpected Hessian type:" + tag);
        throw new IOException("Unexpected Hessian type");
    } else if (// if we have a common request or sign in request
    (type == Request.Type.COMMON) || (type == Request.Type.SIGN_IN) || (type == Request.Type.GET_MY_IDENTITIES) || (type == Request.Type.GET_AVAILABLE_IDENTITIES)) {
        Hashtable<String, Object> map = (Hashtable<String, Object>) mMicroHessianInput.readHashMap(tag);
        if (null == map) {
            return null;
        }
        if (map.containsKey(KEY_SESSION)) {
            AuthSessionHolder auth = new AuthSessionHolder();
            Hashtable<String, Object> authHash = (Hashtable<String, Object>) map.get(KEY_SESSION);
            resultList.add(auth.createFromHashtable(authHash));
            responseType = DecodedResponse.ResponseType.LOGIN_RESPONSE.ordinal();
        } else if (map.containsKey(KEY_CONTACT_LIST)) {
            // contact list
            getContacts(resultList, ((Vector<?>) map.get(KEY_CONTACT_LIST)));
            responseType = DecodedResponse.ResponseType.GET_CONTACTCHANGES_RESPONSE.ordinal();
        } else if (map.containsKey(KEY_USER_PROFILE_LIST)) {
            Vector<Hashtable<String, Object>> upVect = (Vector<Hashtable<String, Object>>) map.get(KEY_USER_PROFILE_LIST);
            for (Hashtable<String, Object> obj : upVect) {
                resultList.add(UserProfile.createFromHashtable(obj));
            }
            responseType = DecodedResponse.ResponseType.GETME_RESPONSE.ordinal();
        } else if (map.containsKey(KEY_USER_PROFILE)) {
            Hashtable<String, Object> userProfileHash = (Hashtable<String, Object>) map.get(KEY_USER_PROFILE);
            resultList.add(UserProfile.createFromHashtable(userProfileHash));
            responseType = DecodedResponse.ResponseType.GETME_RESPONSE.ordinal();
        } else if (// we have identity items in the map which we can parse 
        (map.containsKey(KEY_IDENTITY_LIST)) || (map.containsKey(KEY_AVAILABLE_IDENTITY_LIST))) {
            int identityType = 0;
            Vector<Hashtable<String, Object>> idcap = null;
            if (map.containsKey(KEY_IDENTITY_LIST)) {
                idcap = (Vector<Hashtable<String, Object>>) map.get(KEY_IDENTITY_LIST);
                identityType = BaseDataType.MY_IDENTITY_DATA_TYPE;
                responseType = DecodedResponse.ResponseType.GET_MY_IDENTITIES_RESPONSE.ordinal();
            } else {
                idcap = (Vector<Hashtable<String, Object>>) map.get(KEY_AVAILABLE_IDENTITY_LIST);
                identityType = BaseDataType.AVAILABLE_IDENTITY_DATA_TYPE;
                responseType = DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal();
            }
            for (Hashtable<String, Object> obj : idcap) {
                Identity id = new Identity(identityType);
                resultList.add(id.createFromHashtable(obj));
            }
        } else if (type == Request.Type.GET_AVAILABLE_IDENTITIES) {
            // we have an available identities response, but it is empty
            responseType = DecodedResponse.ResponseType.GET_AVAILABLE_IDENTITIES_RESPONSE.ordinal();
        } else if (type == Request.Type.GET_MY_IDENTITIES) {
            // we have a my identities response, but it is empty 
            responseType = DecodedResponse.ResponseType.GET_MY_IDENTITIES_RESPONSE.ordinal();
        } else if (map.containsKey(KEY_ACTIVITY_LIST)) {
            Vector<Hashtable<String, Object>> activityList = (Vector<Hashtable<String, Object>>) map.get(KEY_ACTIVITY_LIST);
            for (Hashtable<String, Object> obj : activityList) {
                resultList.add(ActivityItem.createFromHashtable(obj));
            }
            responseType = DecodedResponse.ResponseType.GET_ACTIVITY_RESPONSE.ordinal();
        }
    } else if ((type != Request.Type.COMMON) && (type != Request.Type.SIGN_IN)) {
        // get initial hash table
        // TODO: we cast every response to a Map, losing e.g. push event
        // "c0" which only contains a string - to fix
        Hashtable<String, Object> hash = (Hashtable<String, Object>) mMicroHessianInput.decodeType(tag);
        responseType = decodeResponseByRequestType(resultList, hash, type);
    }
    if (usesReplyTag) {
        // read the last 'z'
        is.read();
    }
    DecodedResponse decodedResponse = new DecodedResponse(requestId, resultList, engineId, responseType);
    return decodedResponse;
}
Also used : DecodedResponse(com.vodafone360.people.service.io.ResponseQueue.DecodedResponse) ServerError(com.vodafone360.people.datatypes.ServerError) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AuthSessionHolder(com.vodafone360.people.datatypes.AuthSessionHolder) BaseDataType(com.vodafone360.people.datatypes.BaseDataType) ExternalResponseObject(com.vodafone360.people.datatypes.ExternalResponseObject) Identity(com.vodafone360.people.datatypes.Identity) Vector(java.util.Vector)

Example 65 with Contact

use of com.vodafone360.people.datatypes.Contact in project 360-Engine-for-Android by 360.

the class NowPlusContactSummaryTest method testAddingContactSummary.

/**
     * Tests adding a contact to the contact summary table.
     */
@SmallTest
public void testAddingContactSummary() {
    Log.i(LOG_TAG, "***** EXECUTING testAddingContactSummary *****");
    Log.i(LOG_TAG, "Create ContactSummaryTable");
    ContactSummaryTable.create(mTestDatabase.getWritableDatabase());
    final Contact contact = mTestModule.createDummyContactData();
    contact.localContactID = new Long(10);
    ContactSummaryTable.addContact(contact, mTestDatabase.getWritableDatabase());
}
Also used : Contact(com.vodafone360.people.datatypes.Contact) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

Contact (com.vodafone360.people.datatypes.Contact)109 ServiceStatus (com.vodafone360.people.service.ServiceStatus)107 ContactDetail (com.vodafone360.people.datatypes.ContactDetail)100 ArrayList (java.util.ArrayList)62 MediumTest (android.test.suitebuilder.annotation.MediumTest)50 Suppress (android.test.suitebuilder.annotation.Suppress)39 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)34 Cursor (android.database.Cursor)31 ContactChange (com.vodafone360.people.engine.contactsync.ContactChange)22 SmallTest (android.test.suitebuilder.annotation.SmallTest)19 ContactSummary (com.vodafone360.people.datatypes.ContactSummary)18 SQLException (android.database.SQLException)15 ContentValues (android.content.ContentValues)14 VCardHelper (com.vodafone360.people.datatypes.VCardHelper)13 Uri (android.net.Uri)11 ContactChangeInfo (com.vodafone360.people.database.tables.ContactChangeLogTable.ContactChangeInfo)11 ContactIdInfo (com.vodafone360.people.database.tables.ContactsTable.ContactIdInfo)11 ContactChanges (com.vodafone360.people.datatypes.ContactChanges)11 SQLiteException (android.database.sqlite.SQLiteException)9 ContactsTable (com.vodafone360.people.database.tables.ContactsTable)9