Example #1
0
  private SmbFilesManager(Context context) {
    super(context);

    mOperator = SambaManager.getInstance();
    mOperator.initSamba();

    mAudioInfo = AudioInfo.getInstance();
    mFileInfo = VideoInfo.getInstance();
  }
Example #2
0
  public boolean login(String path, String domain, String userName, String userPwd) {
    boolean success = false;
    try {
      SambaManager.login(path, domain, userName, userPwd);
      success = true;
    } catch (SmbAuthException e) {
      MtkLog.w(TAG, "Login SmbAuthException!!");
      e.printStackTrace();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (SmbException e) {
      e.printStackTrace();
    }

    return success;
  }
Example #3
0
  @Override
  public List<FileAdapter> listAllFiles(String path) {
    MtkLog.d(TAG, "------List All login Files : " + path);

    try {
      mFiles.clear();
      int type = SambaManager.TYPE_ALL;

      switch (mContentType) {
        case CONTENT_PHOTO:
          type = SambaManager.TYPE_IMAGE;
          break;
        case CONTENT_AUDIO:
          type = SambaManager.TYPE_AUDIO;
          break;
        case CONTENT_VIDEO:
          type = SambaManager.TYPE_VIDEO;
          break;
        case CONTENT_TEXT:
          type = SambaManager.TYPE_TEXT;
          break;
        case CONTENT_THRDPHOTO:
          type = SambaManager.TYPE_THRIMAGE;
          break;
        default:
          break;
      }

      LinkedList<String> filePaths = mOperator.getSmbFileList(path, type);
      filePaths = mOperator.sortByName(filePaths);

      mFiles = wrapFiles(filePaths);
      logFiles(TAG);

    } catch (SmbAuthException e) {
      e.printStackTrace();
      if (localLOGV) MtkLog.d(TAG, "Try to connect to login : "******"Try to connect to login : ?  GUEST  '' ");
          login(path, "?", "GUEST", "");
          mLoginCount++;
          listAllFiles(path);
        } else if (mLoginCount == 1) {
          if (localLOGV) MtkLog.d(TAG, "Try to connect to login : null null null");
          login(path, null, null, null);
          mLoginCount++;
          listAllFiles(path);
        } else if (mLoginCount == 2) {

          if (localLOGV) MtkLog.d(TAG, " --- User name and Password is not correct. ");
          mLoginCount = 0;
          setChanged();
          notifyObservers(REQUEST_LOGIN);
        }
      } else {
        setChanged();
        notifyObservers(REQUEST_LOGIN);
      }
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (SmbException e) {
      e.printStackTrace();
    } catch (UnknownHostException e) {
      e.printStackTrace();
    }
    System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
    sortFile();
    return mFiles;
  }