Package iqq.im.bean.content

Examples of iqq.im.bean.content.CFaceItem


  protected void onHttpStatusOK(QQHttpResponse response) throws QQException, JSONException {
    // {'ret':0,'msg':'5F7E31F0001EF4310865F1FF4549B12B.jPg'}

    Pattern p = Pattern.compile(QQConstants.REGXP_JSON_SINGLE_RESULT);
    Matcher m = p.matcher(response.getResponseString());
    CFaceItem pic = new CFaceItem();
    JSONObject obj = null;
    if (m.find()) {
      try {
        String regResult = m.group().replaceAll("[\\r]?[\\n]", " ").replaceAll("[\r]?[\n]", " ");
        obj = new JSONObject(regResult);
        LOG.debug("cface result: " + obj.toString());

        int retcode = obj.getInt("ret");
        if (retcode == 0) {
          pic.setSuccess(true);
          pic.setFileName(obj.getString("msg"));
          notifyActionEvent(QQActionEvent.Type.EVT_OK, pic);

          getContext().getStore().addPicItem(pic);
          return;
        } else if (retcode == 4) {
          // {'ret':4,'msg':'D81AB7A7627ED673FDCD4DD24220C192.jPg
          // -6102 upload cface failed'}
          String prefix = "\"msg\":\"";
          String suffix = ".jPg";
          Pattern p4 = Pattern.compile(prefix + "([\\s\\S]*)" + suffix, Pattern.CASE_INSENSITIVE);
          Matcher m4 = p4.matcher(obj.toString());
          if (m4.find()) {
            String r = m4.group().replaceAll(prefix, "");
            LOG.debug("ret 4: " + r);
            pic.setSuccess(true);
            pic.setFileName(r);
            notifyActionEvent(QQActionEvent.Type.EVT_OK, pic);
            return;
          }
        } else {
          LOG.debug("ret: " + retcode);
        }
      } catch (Exception e) {
        LOG.warn(e.getMessage(), e);
      }
    }
    // 失败后返回路径
    pic.setFileName(file.getPath());
    pic.setSuccess(false);
    notifyActionEvent(QQActionEvent.Type.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE));

    LOG.debug("CFace: " + response.getResponseString());
  }
View Full Code Here


          JSONArray items = (JSONArray) value;
          ContentItem.Type type = ContentItem.Type.valueOfRaw(items.getString(0));
          switch (type) {
            case FACE:    addContentItem(new FaceItem(items.toString())); break;
            case FONT:    addContentItem(new FontItem(items.toString())); break;
            case CFACE:   addContentItem(new CFaceItem(items.toString())); break;
            case OFFPIC: addContentItem(new OffPicItem(items.toString())); break;
            default:
          }
        }else if( value instanceof String){
          addContentItem(new TextItem((String) value));
View Full Code Here

TOP

Related Classes of iqq.im.bean.content.CFaceItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.