/**
   * 解析Intent获取数据源。
   *
   * @param intent
   */
  private void parseIntent(Intent intent) {
    Bundle bundle = intent.getExtras();
    if (bundle == null) {
      valid = false;
      return;
    }

    String path = bundle.getString(IntentData.PATH);
    if (path != null) {
      curStatus = STATUS_PREVIEW;
      filePath = path;

      File file = FileUtil.newFile(path);
      fileName = file.getName();
      totalSizeStr = FileUtil.makeUpSizeShow(file.length());
      return;
    }

    Object file = bundle.get(IntentData.GROUP_ZONE_FILE);
    if (file instanceof GroupFile) {
      curStatus = STATUS_GROUP_ZONE;
      groupFile = (GroupFile) file;
      fileName = groupFile.getFileName();
      totalSizeStr = FileUtil.makeUpSizeShow(groupFile.getFileSize());

      /*message = InstantMessageDao.getImById(groupFile.getInstantMessageId());
      if (message != null)
      {
          resource = message.getMediaRes();
          if (resource == null)
          {
              valid = false;
              return;
          }
      }*/

      return;
    }

    Object tag = bundle.get(IntentData.MEDIA_RESOURCE);
    Object tag1 = bundle.get(IntentData.IM);
    if (tag instanceof MediaResource && tag1 instanceof InstantMessage) {
      curStatus = STATUS_UM;

      message = (InstantMessage) tag1;
      resource = (MediaResource) tag;

      fileName = resource.getName();
      totalSizeStr = FileUtil.makeUpSizeShow(resource.getSize());

      if (ContactLogic.getIns().getAbility().isSupportGroupZone()) {
        int id = new GroupZoneFileRelationDao().query((int) message.getId(), false);
        groupFile = new GroupZoneFileDao().query(id);
      }

      return;
    }

    valid = false;
  }
 public void cancelTransfer() {
   if (curStatus == STATUS_UM) {
     AutoCancelStack.getIns().cancelAuto(message.getMessageId());
     UmFunc.getIns().cancelTransFile(message.getId(), resource.getMediaId(), false);
   } else if (curStatus == STATUS_GROUP_ZONE) {
     GroupZoneFunc.ins().cancelDownload(groupFile);
   } else if (curStatus == STATUS_PREVIEW) {
     // do nothing
     Logger.error(LocalLog.APPTAG, "local file, don't download.");
   }
 }
  private boolean checkUmState() {
    long mId = message.getId();
    int mediaId = resource.getMediaId();
    if (UmFunc.getIns().isInTransFile(mId, mediaId, false)) {
      FileTransfer.ProgressInfo info = UmFunc.getIns().getTransProcess(mId, mediaId, false);

      if (info != null) {
        updateProgress(info.getCurSize(), info.getTotalSize());
      }
      return false;
    }

    int resType = resource.getResourceType();
    if (MediaResource.RES_LOCAL == resType) {
      String path =
          resource
              .getLocalPath(); // UmUtil.createResPath(MediaResource.MEDIA_FILE, resource.getName(),
      // "");
      return !checkFileExistAndOpen(path);
    }

    return true;
  }