コード例 #1
0
 /**
  * This method stores removes a busy state of engine and males the change available to UI through
  * the ApplicationCache. This method is normally called before setting new state of the engine.
  *
  * @param requestId int - the request Id for network communications, or the ServiceUIRequest
  *     ordinal for fetching/updating timelines
  * @param requestType one of UPDATING_STATUSES, FETCHING_OLDER_STATUSES, FETCHING_OLDER_TIMELINE
  */
 private void dequeueRequest(int requestId) {
   synchronized (mQueueMutex) {
     ActivitiesState requestType = mActiveRequests.get(requestId);
     if (requestType != null) {
       mActiveRequests.remove(requestId);
       LogUtils.logE("ActivityEngine.dequeueRequest:" + requestId + ", " + requestType);
       cacheRequestType(requestType, false);
     } else {
       LogUtils.logE(
           "ActivityEngine.dequeueRequest: the request is not in the queue!"
               + requestId
               + ", "
               + requestType);
     }
   }
 }
コード例 #2
0
  /**
   * This method stores the current busy state of engine in ApplicationCache to make it available to
   * UI. This method is normally called before setting new state of the engine.
   *
   * @param requestId int - the request Id for network communications, or the ServiceUIRequest
   *     ordinal for fetching/updating timelines
   * @param requestType one of UPDATING_STATUSES, FETCHING_OLDER_STATUSES, FETCHING_OLDER_TIMELINE
   */
  private void enqueueRequest(int requestId, ActivitiesState requestType) {
    synchronized (mQueueMutex) {
      if (!mActiveRequests.containsKey(requestId)) {
        LogUtils.logE("ActivityEngine.enqueueRequest:" + requestId + ", " + requestType);
        mActiveRequests.put(requestId, requestType);
        cacheRequestType(requestType, true);

      } else {
        LogUtils.logE(
            "ActivityEngine.enqueueRequest: already have this type!"
                + requestId
                + ", "
                + requestType);
      }
    }
  }
コード例 #3
0
 /**
  * This method is necessary for the tests. It catches the InvalidParameterException coming from
  * EngineManager.getInstance(), when the instance is null
  *
  * @return boolean - TRUE if ContactSyncEngine is not null
  */
 private boolean isContactSyncReady() {
   try {
     return (EngineManager.getInstance() != null)
         && (EngineManager.getInstance().getContactSyncEngine() != null);
   } catch (InvalidParameterException ipe) {
     LogUtils.logE(ipe.toString());
     return false;
   }
 }
コード例 #4
0
 /**
  * Handle GetActivities response message received from Server
  *
  * @param reqId Request ID contained in response. This should match an ID of a request we have
  *     issued to the Server.
  * @param data List array of ActivityItem items returned from Server.
  */
 private void handleGetActivitiesResponse(List<BaseDataType> data) {
   /** Array of Activities retrieved from Server. */
   ArrayList<ActivityItem> activityList = new ArrayList<ActivityItem>();
   ServiceStatus errorStatus = getResponseStatus(BaseDataType.ACTIVITY_ITEM_DATA_TYPE, data);
   LogUtils.logE(
       "ActivityEngine.handleGetActivitiesResponse status from generic = " + errorStatus);
   if (ServiceStatus.SUCCESS == errorStatus) {
     for (BaseDataType item : data) {
       if (item.getType() == BaseDataType.ACTIVITY_ITEM_DATA_TYPE) {
         activityList.add((ActivityItem) item);
       } else {
         LogUtils.logE(
             "ActivityEngine.handleGetActivitiesResponse will not handle strange type = "
                 + item.getType());
       }
     }
     errorStatus = updateDatabase(activityList);
     // we set timeout for the next execution
   }
   // this method will then call completeUiRequest(status, null);
   onSyncHelperComplete(errorStatus);
 }
コード例 #5
0
 @SuppressWarnings("unchecked")
 private void setValue(Tags key, Object value) {
   switch (key) {
     case PAYLOAD:
       Hashtable payload = (Hashtable) value;
       if (payload.containsKey(CONVERSATION_ID)) {
         mConversationId = (String) payload.get(CONVERSATION_ID);
       }
       if (payload.containsKey(TOS)) {
         mTos = (List<String>) payload.get(TOS);
       }
       break;
     case USERID:
       mUserId = (Long) value;
       break;
     case TYPE:
       mType = (String) value;
       break;
     default:
       LogUtils.logE(
           "Conversation.setValue() key[" + key + "] value[" + value + "] Unsupported KEY");
   }
 }
コード例 #6
0
  /**
   * Sets the value of the member data item associated with the specified tag.
   *
   * @param tag Current tag.
   * @param val Value associated with the tag.
   */
  private void setValue(Tags tag, Object val) {
    switch (tag) {
      case AUTH_TYPE:
        mAuthType = (String) val;
        break;

      case ICON_MIME:
        mIconMime = (String) val;
        break;

      case ICON2_MIME:
        // TODO: Remove TAG value?
        // mIcon2Mime = (String)val;
        break;

      case ICON_URL:
        try {
          mIconUrl = new URL((String) val);
        } catch (MalformedURLException e) {
          LogUtils.logE("Wrong icon url: '" + val + "'");
          mIconUrl = null;
        }
        break;

      case ICON2_URL:
        try {
          mIcon2Url = new URL((String) val);
        } catch (MalformedURLException e) {
          LogUtils.logE("Wrong icon url: '" + val + "'");
          mIcon2Url = null;
        }
        break;

      case IDENTITY_CAPABILITY_LIST:
        /** Create id capability list. */
        @SuppressWarnings("unchecked")
        Vector<Hashtable<String, Object>> v = (Vector<Hashtable<String, Object>>) val;
        if (mCapabilities == null) {
          mCapabilities = new ArrayList<IdentityCapability>();
        }
        for (Hashtable<String, Object> obj : v) {
          IdentityCapability cap = new IdentityCapability();
          cap.createFromHashtable(obj);

          mCapabilities.add(cap);
        }
        break;

      case IDENTITY_MAIN_TAG:
        // Not currently handled.
        break;

      case NAME:
        mName = (String) val;
        break;

      case NETWORK:
        mNetwork = (String) val;
        break;

      case NETWORK_URL:
        try {
          mNetworkUrl = new URL((String) val);
        } catch (MalformedURLException e) {
          LogUtils.logE("Wrong network url: '" + val + "'");
          mNetworkUrl = null;
        }
        break;

      case ORDER:
        mOrder = (Integer) val;
        break;

      case PLUGIN_ID:
        mPluginId = (String) val;
        break;

      case ACTIVE:
        mActive = (Boolean) val;
        break;

      case CREATED:
        mCreated = (Long) val;
        break;

      case DISPLAY_NAME:
        mDisplayName = (String) val;
        break;

      case IDENTITY_ID:
        mIdentityId = (String) val;
        break;

      case IDENTITY_TYPE:
        mIdentityType = (String) val;
        break;

      case UPDATED:
        mUpdated = (Long) val;
        break;

      case USER_ID:
        mUserId = ((Long) val).intValue();
        break;

      case USER_NAME:
        mUserName = (String) val;
        break;

      case COUNTRY_LIST:
        if (mCountryList == null) {
          mCountryList = new ArrayList<String>();
        }
        break;

      default:
        // Do nothing.
        break;
    }
  }