Example #1
0
  protected void insertRequestReceiveFileMsg(PeerHolder gpeer, GMessageTcp msgTcp) {
    ContentValues cv = new ContentValues();
    long date = System.currentTimeMillis();

    cv.put(MsgTable.FROM, MsgTable.FROM_INCOMING);
    cv.put(MsgTable.TYPE, MsgTable.TYPE_RECEIVE_ATTACH_REQUEST);
    cv.put(MsgTable.STATUS, MsgTable.STATUS_RECEIVE_COMPLETE);
    cv.put(MsgTable.FLAG, msgTcp.flag);
    cv.put(MsgTable.MAC_ADDRESS, gpeer.macAddress);
    cv.put(MsgTable.DATE, date);

    if (UID.curMacAddress != null && UID.curMacAddress.equals(gpeer.macAddress)) {
      cv.put(MsgTable.READ, MsgTable.READ_READED);
    }

    MsgTable.getInstance().insert(cv);

    for (int i = 0; i < msgTcp.msgAttach.length; i++) {
      cv.clear();
      long adate = System.currentTimeMillis();

      cv.put(AttachTable.MAC_ADDRESS, gpeer.macAddress);
      cv.put(AttachTable.FILE_PATH, msgTcp.msgAttach[i].filePath);
      cv.put(AttachTable.TYPE, msgTcp.msgAttach[i].type);
      cv.put(AttachTable.FLAG, msgTcp.msgAttach[i].flag);
      cv.put(AttachTable.ATT_FLAG, msgTcp.msgAttach[i].attflag);
      cv.put(AttachTable.SIZE, msgTcp.msgAttach[i].size);
      cv.put(AttachTable.DATE, adate);
      AttachTable.getInstance().insert(cv);
    }

    //	    MsgCenter.getInstance().loadPeerGDialogAttach(msgTcp.flag);

    refreshDialogAndnotibar(gpeer, date, msgTcp.msgAttach[0].filePath);
  }
Example #2
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);
      }
    }
  }