Package net.solosky.maplefetion.bean

Examples of net.solosky.maplefetion.bean.Buddy


     
      String receiverTmpl = "<receiver uri=\"{uri}\" />";
      StringBuffer buffer = new StringBuffer();
      Iterator<Buddy> it = receiverList.iterator();
      while(it.hasNext()){
        Buddy b = it.next();
        buffer.append(receiverTmpl.replace("{uri}", b.getUri()));
      }
      body = body.replace("{receiverList}", buffer.toString());
     
      req.setBody(new SipcBody(body));
      return req;
View Full Code Here


    }
    this.dialog.process(receipt);
   
    //检查是否发起会话的好友是否存在,如果不存在建立一个新飞信好友对象,并设置关系为陌生人关系
    FetionStore store = this.context.getFetionStore();
    Buddy buddy = null;
    synchronized(store){
      buddy = store.getBuddyByUri(notify.getFrom());
      if(buddy==null){
        buddy = new Buddy();
        buddy.setUri(notify.getFrom());
        store.addBuddy(buddy);
      }
    }
   
    //检查之前的会话中,是否有BasicChatDialog 如果有,关闭
View Full Code Here

      Iterator it = list.iterator();
      while(it.hasNext()) {
        Element e =  (Element) it.next();
        String uri = e.getAttributeValue("uri");
        String status = e.getAttributeValue("status-code");
        Buddy buddy = context.getFetionStore().getBuddyByUri(uri);
        if(status!=null && status.equals("200") && buddy!=null) {
          //个人信息
          Element p = e.getChild("personal");
          if(p!=null) {
              BeanHelper.toBean(Buddy.class, buddy, p);
View Full Code Here

      Element app = event.getChild("application");
      String uri  = app.getAttributeValue("uri");
      String userId  = app.getAttributeValue("user-id");
      final String desc = app.getAttributeValue("desc");
      //建立一个新好友,并把关系设置为陌生人
      Buddy buddy = UriHelper.createBuddy(uri);
      buddy.setUri(uri);
      buddy.setUserId(Integer.parseInt(userId));
      BeanHelper.setValue(buddy, "relation", Relation.STRANGER);
      context.getFetionStore().addBuddy(buddy);
      //如果是飞信好友,获取陌生人的信息
      if(buddy instanceof Buddy) {
          SipcRequest request = this.dialog.getMessageFactory().createGetContactInfoRequest(uri);
View Full Code Here

      List list = XMLHelper.findAll(event, "/event/contacts/mobile-buddies/*mobile-buddy");
      Iterator it = list.iterator();
      while(it.hasNext()) {
        Element e = (Element) it.next();
        String uri = e.getAttributeValue("uri");
        Buddy buddy = context.getFetionStore().getBuddyByUri(uri);
        if(buddy!=null) {
          //检查用户关系的变化
          Relation relation = ParseHelper.parseRelation(e.getAttributeValue("relation-status"));
          //如果当前好友关系是没有确认,而返回的好友是确认了,表明好友同意了你添加好友的请求
          if(relation==Relation.BUDDY && buddy.getRelation()!=Relation.BUDDY) {
           
            //因为这里是手机好友,没有详细信息,故不再获取详细信息
            logger.debug("Mobile buddy agreed your buddy request:"+buddy.getFetionId());
            this.tryFireNotifyEvent(new BuddyConfirmedEvent(buddy, true));    //通知监听器
           
          }else if(relation==Relation.DECLINED) {  //对方拒绝了请求
           
            logger.debug("buddy declined your buddy request:"+buddy.getDisplayName());
            this.tryFireNotifyEvent(new BuddyConfirmedEvent(buddy, false))//通知监听器
           
          }else {}

            //buddy.setUserId(Integer.parseInt(e.getAttributeValue("user-id")));
View Full Code Here

      List list = XMLHelper.findAll(event, "/event/contacts/buddies/*buddy");
      Iterator it = list.iterator();
      while(it.hasNext()) {
        Element e =  (Element) it.next();
        String uri = e.getAttributeValue("uri");
        final Buddy buddy = context.getFetionStore().getBuddyByUri(uri);
        if(buddy!=null) {
          //检查用户关系的变化
          Relation relation = ParseHelper.parseRelation(e.getAttributeValue("relation-status"));
          //如果当前好友关系是没有确认,而返回的好友是确认了,表明好友同意了你添加好友的请求
          if(relation==Relation.BUDDY && buddy.getRelation()!=Relation.BUDDY) {
           
            //这里还需要获取好友的详细信息
            SipcRequest request = dialog.getMessageFactory().createGetContactInfoRequest(buddy.getUri());
            request.setResponseHandler(new GetContactInfoResponseHandler(context, dialog, ((Buddy) buddy),null));
          dialog.process(request);
         
          }else if(relation==Relation.DECLINED) {  //对方拒绝了请求
            logger.debug("buddy declined your buddy request:"+buddy.getDisplayName());
            this.tryFireNotifyEvent(new BuddyConfirmedEvent( buddy, false))//通知监听器
          }else {}

          //buddy.setUserId(Integer.parseInt(e.getAttributeValue("user-id")));
          buddy.setRelation(relation);
         
          context.getFetionStore().flushBuddy(buddy);
        }
      }
    }
View Full Code Here

      while(it.hasNext()){
        Element e = (Element) it.next();
        String suserId = e.getAttributeValue("user-id")//使用user-id更合理
        if(suserId!=null){
          int    iuserId = Integer.parseInt(suserId);
          Buddy buddy    = store.getBuddyByUserId(iuserId);
          if(buddy!=null){
            store.deleteBuddy(buddy);
            logger.info("Deleted buddy: "+buddy);
          }
        }
View Full Code Here

      while(it.hasNext()){
        Element e = (Element) it.next();
        String uri = e.getAttributeValue("uri");
        if(uri!=null){
          //这里应该都是飞信好友,不过还是做了相应的判断
          Buddy buddy = null;
        buddy = new Buddy();
        BeanHelper.toBean(Buddy.class, buddy, e);
         
          buddy.setRelation(Relation.BUDDY);
        store.addBuddy(buddy);
       
        logger.info("Added Buddy : "+buddy);
        }
      }
View Full Code Here

       * 显示一个组的用户
       */
      public int cord(int cordId, String name,int startId,Collection<Buddy> buddyList)
      {
        Iterator<Buddy> it = buddyList.iterator();
        Buddy buddy = null;
        println("\n-------------------------------");
        println("【"+cordId+"::"+name+"】");
        println("-------------------------------");
        if(buddyList.size()==0) {
          println("暂无好友。。");
        }
      while(it.hasNext()) {
        buddy = it.next();
        this.buddymap.put(Integer.toString(startId), buddy.getUri());
        String impresa = buddy.getImpresa();
        println(Integer.toString(startId)+" "+formatRelation(buddy.getRelation())+" "+fomartString(buddy.getDisplayName(),10)+"\t"
            +buddy.getDisplayPresence()
            +"\t"+(impresa==null?"":impresa));
        startId++;
      }
      return startId;
      }
View Full Code Here

       * 发送消息
       * @throws Exception
       */
      public void to(String uri,final String message)
      {
        final Buddy buddy = this.client.getFetionStore().getBuddyByUri(uri);
        if(buddy!=null) {
          this.send(buddy, message);
        }else {
          println("找不到这个好友,请检查你的输入!");
        }
View Full Code Here

TOP

Related Classes of net.solosky.maplefetion.bean.Buddy

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.