Exemple #1
0
  private void qrcodeSendDownloadFiles(String hostAddress, GMessageTcp msgTcp) {
    String spwd = SPHelper.getInstance().getString(SPHelper.SP_SHARE_PASSWORD);
    String md5pwdNormal = GEncrypt.MD5normal(spwd);

    if (md5pwdNormal != null && md5pwdNormal.equals(msgTcp.sharePassword)) {
      String[] filePaths = UID.downloadtaskMap.get(msgTcp.taskID);

      //			ArrayList<File> fllist = new ArrayList<File>();
      //			for(int i = 0; i < filePaths.length; i++) {
      //				String spath = filePaths[i];
      //				if(spath != null && spath.length() > 0) {
      //					File file = new File(spath);
      //					GUtil.listAllFiles(file, fllist);
      //				}
      //			}
      //
      //			if(fllist.size() > 0) {
      //				File[] dirs = fllist.toArray(new File[0]);
      //				NetFile[] ntdirs = new NetFile[dirs.length];
      //				for(int i = 0; i < fllist.size(); i++) {
      //					ntdirs[i] = new NetFile(dirs[i].getPath());
      //					int itype = AttachTable.getInstance().getType(dirs[i]);
      //					ntdirs[i].setType(itype);
      //				}
      //
      //				GMessageTcp dirTcp = new GMessageTcp();
      //				dirTcp.indicate = D.INDICATE_TCP_REQUEST_DOWNLOAD_FILES_RESULT;
      //				dirTcp.resultDirArray = ntdirs;
      //				MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
      //			}

      if (filePaths != null && filePaths.length > 0) {
        NetFile[] ntdirs = GUtil.getRequestDirarray(filePaths);
        if (ntdirs != null && ntdirs.length > 0) {
          GMessageTcp dirTcp = new GMessageTcp();
          dirTcp.indicate = D.INDICATE_TCP_REQUEST_DOWNLOAD_FILES_RESULT;
          dirTcp.resultDirArray = ntdirs;
          MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
        }
      }

      //			NetFile[] ntdirs = new NetFile[filePaths.length];
      //			for(int i = 0; i < ntdirs.length; i++) {
      //				ntdirs[i] = new NetFile(filePaths[i]);
      //				int itype = AttachTable.getInstance().getType(new File(filePaths[i]));
      //				ntdirs[i].setType(itype);
      //			}
      //
      //			if(ntdirs != null && ntdirs.length > 0) {
      //				GMessageTcp dirTcp = new GMessageTcp();
      //				dirTcp.indicate = D.INDICATE_TCP_QR_CODE_REQUIRE_DOWNLOAD_FILES_RESULT;
      //				dirTcp.resultDirArray = ntdirs;
      //				MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
      //			}
    }
  }
Exemple #2
0
  private void sendDownloadFiles(String hostAddress, GMessageTcp msgTcp) {
    boolean checked = SPHelper.getInstance().getBoolean(SPHelper.SP_IS_CLOSE_SHARE);
    if (checked) {
      GMessageTcp dirTcp = new GMessageTcp();
      dirTcp.indicate = D.INDICATE_TCP_CLOSE_NETWORK_NEIGHBORHOOD;
      MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
    } else {
      String spwd = SPHelper.getInstance().getString(SPHelper.SP_SHARE_PASSWORD);
      String md5pwdNormal = GEncrypt.MD5normal(spwd);

      if (md5pwdNormal != null && md5pwdNormal.equals(msgTcp.sharePassword)) {
        if (msgTcp.sendDirArray != null && msgTcp.sendDirArray.length > 0) {
          //					ArrayList<File> fllist = new ArrayList<File>();
          //					for(int i = 0; i < msgTcp.sendDirArray.length; i++) {
          //						String spath = msgTcp.sendDirArray[i].getFilePath();
          //						if(spath != null && spath.length() > 0) {
          //							File file = new File(spath);
          //							GUtil.listAllFiles(file, fllist);
          //						}
          //					}
          //
          //					if(fllist.size() > 0) {
          //						File[] dirs = fllist.toArray(new File[0]);
          //						NetFile[] ntdirs = new NetFile[dirs.length];
          //						for(int i = 0; i < fllist.size(); i++) {
          //							ntdirs[i] = new NetFile(dirs[i].getPath());
          //							int itype = AttachTable.getInstance().getType(dirs[i]);
          //							ntdirs[i].setType(itype);
          //						}
          //
          //						GMessageTcp dirTcp = new GMessageTcp();
          //						dirTcp.indicate = D.INDICATE_TCP_REQUEST_DOWNLOAD_FILES_RESULT;
          //						dirTcp.resultDirArray = ntdirs;
          //						MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
          //					}

          NetFile[] ntdirs = GUtil.getRequestDirarray(msgTcp.sendDirArray);
          if (ntdirs != null && ntdirs.length > 0) {
            GMessageTcp dirTcp = new GMessageTcp();
            dirTcp.indicate = D.INDICATE_TCP_REQUEST_DOWNLOAD_FILES_RESULT;
            dirTcp.resultDirArray = ntdirs;
            MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
          }
        }
      } else {
        GMessageTcp dirTcp = new GMessageTcp();
        dirTcp.indicate = D.INDICATE_TCP_REQUIRE_INPUT_SHARE_PASSWORD;
        MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
      }
    }
  }
Exemple #3
0
  private void sendDirs(String hostAddress, GMessageTcp msgTcp) {
    boolean checked = SPHelper.getInstance().getBoolean(SPHelper.SP_IS_CLOSE_SHARE);
    if (checked) {
      GMessageTcp dirTcp = new GMessageTcp();
      dirTcp.indicate = D.INDICATE_TCP_CLOSE_NETWORK_NEIGHBORHOOD;
      MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
    } else {
      String spwd = SPHelper.getInstance().getString(SPHelper.SP_SHARE_PASSWORD);
      String md5pwdNormal = GEncrypt.MD5normal(spwd);
      if (md5pwdNormal != null && md5pwdNormal.equals(msgTcp.sharePassword)) {
        NetFile sendDir = msgTcp.sendDir;
        if (sendDir == null) {
          sendDir = new NetFile(D.ENV_STORAGE_PATH);
        }
        File rtFile = new File(sendDir.getFilePath());
        File[] files = GUtil.listFiles(rtFile);
        NetFile[] netfl = null;
        if (files != null && files.length > 0) {
          netfl = new NetFile[files.length];
          for (int i = 0; i < files.length; i++) {
            File tfile = new File(files[i].getPath());
            netfl[i] = new NetFile(files[i].getPath());
            int type = AttachTable.getInstance().getType(tfile);
            netfl[i].setType(type);
          }

          GMessageTcp dirTcp = new GMessageTcp();
          dirTcp.indicate = D.INDICATE_TCP_REQUEST_FILE_DIRS_RESULT;
          dirTcp.sendDir = sendDir;
          dirTcp.resultDirArray = netfl;

          MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
        }
      } else {
        GMessageTcp dirTcp = new GMessageTcp();
        dirTcp.indicate = D.INDICATE_TCP_REQUIRE_INPUT_SHARE_PASSWORD;
        MsgCenter.getInstance().sendSocketMsg(hostAddress, dirTcp);
      }
    }
  }