Examples of Buddy


Examples of net.solosky.maplefetion.bean.Buddy

         Element personal = contact.getChild("p");
         Element presence = contact.getChild("pr");
          Integer userId = Integer.parseInt(contact.getAttributeValue("id"));
         
          //查找这个好友
          Buddy buddy = context.getFetionStore().getBuddyByUserId(userId);
          //这里可能是用户自己
          if(buddy==null && context.getFetionUser().getUserId()==userId) {
            buddy = context.getFetionUser();     
          }         
         
          //判断用户是不是飞信好友
          if(buddy!=null) {
        //好友信息改变
              if(personal!=null) {
                String nickname = personal.getAttributeValue("n");
                String impresa  = personal.getAttributeValue("i");
                if(nickname!=null && nickname.length()>0) buddy.setNickName(nickname);
                if(impresa!=null && impresa.length()>0)   buddy.setImpresa(impresa);
               
                String m = personal.getAttributeValue("m");
                if(m!=null && m.length()>0)
                  buddy.setMobile(Long.parseLong(m));
           
                String sms = personal.getAttributeValue("sms");
                if(sms!=null) {
                  buddy.getSMSPolicy().parse(sms);
                }
              }

        //状态改变
              if(presence!=null) {
                  int oldpresense = buddy.getPresence().getValue();
                  int curpresense = Integer.parseInt(presence.getAttributeValue("b"))
                  BeanHelper.toBean(Presence.class, buddy.getPresence(), presence);
                  if(oldpresense!=curpresense) {
                    //注意,如果好友上线了,并且当前打开了手机聊天对话框,需要关闭这个手机聊天对话框
                    if(curpresense == Presence.AWAY   || curpresense == Presence.BUSY ||
                       curpresense == Presence.ONLINE || curpresense == Presence.ROBOT ) {
                      ChatDialog chatDialog = this.context.getDialogFactory().findChatDialog(buddy);
                      if(chatDialog!=null && chatDialog instanceof BasicChatDialog) {
                        chatDialog.closeDialog();
                      }
                    }
                   
                    //通知监听器,好友状态已经改变
                    this.tryFireNotifyEvent(new BuddyPresenceEvent(buddy));
                  }
              }

              //刷新数据
              context.getFetionStore().flushBuddy(buddy);
              logger.debug("PresenceChanged:"+buddy.toString()+" - "+buddy.getPresence());
              //TODO ..这里只处理了好友状态改变,本来还应该处理其他信息改变,如好友个性签名和昵称的改变,以后添加。。
          }else{
            logger.warn("Unknown Buddy in PresenceChanged notify:"+userId);
          }
      }
View Full Code Here

Examples of net.solosky.maplefetion.bean.Buddy

     * @see net.solosky.maplefetion.client.NotifyHandler#handle(net.solosky.maplefetion.sipc.SipcNotify)
     */
    @Override
    public void handle(SipcNotify notify) throws FetionException
    {
      Buddy buddy = this.context.getFetionStore().getBuddyByUri(notify.getFrom());
      boolean isCorrect = false;
      if(buddy!=null) {
          ChatDialog dialog = this.context.getDialogFactory().findChatDialog(buddy);
          if(dialog!=null && dialog.getState()==DialogState.OPENNING && dialog instanceof LiveV1ChatDialog) {
          LiveV1ChatDialog cd = (LiveV1ChatDialog) dialog;
View Full Code Here

Examples of net.solosky.maplefetion.bean.Buddy

     * @see net.solosky.maplefetion.client.NotifyHandler#handle(net.solosky.maplefetion.sipc.SipcNotify)
     */
    @Override
    public void handle(SipcNotify notify) throws FetionException
    {
      Buddy buddy = this.context.getFetionStore().getBuddyByUri(notify.getFrom());
      if(buddy!=null) {
        ChatDialog dialog = this.context.getDialogFactory().findChatDialog(buddy);
        if(dialog!=null && dialog.getState()!=DialogState.CLOSED) {
          dialog.closeDialog();
        }
View Full Code Here

Examples of net.solosky.maplefetion.bean.Buddy

        if(list!=null){
          Iterator it = list.iterator();
          while(it.hasNext()){
            Element member = (Element) it.next();
            String uri = member.getAttributeValue("uri");
            Buddy buddy = this.context.getFetionStore().getBuddyByUri(uri);
            //可能用户删除了好友,这里就查不到了
            if(buddy==null){
              buddy = UriHelper.createBuddy(uri);
              BeanHelper.setValue(buddy, "relation", Relation.STRANGER);
            }
View Full Code Here

Examples of net.solosky.maplefetion.bean.Buddy

        if(list!=null){
          Iterator it = list.iterator();
          while(it.hasNext()){
            Element member = (Element) it.next();
            String uri = member.getAttributeValue("uri");
            Buddy buddy = this.context.getFetionStore().getBuddyByUri(uri);
            //如果好友不存在,可能用户已经删除了该好友,这里新建一个临时好友对象
            //仅是为了作为参数传递个对话来判断那个好友离开了对话,因为对话保留了一个好友的引用
            if(buddy==null){
              buddy = UriHelper.createBuddy(uri);
            }
View Full Code Here

Examples of net.solosky.maplefetion.bean.Buddy

        if(list!=null){
          Iterator it = list.iterator();
          while(it.hasNext()){
            Element member = (Element) it.next();
            String uri = member.getAttributeValue("uri");
            Buddy buddy = this.context.getFetionStore().getBuddyByUri(uri);
            //如果好友不存在,可能用户已经删除了该好友,这里新建一个临时好友对象
            //仅是为了作为参数传递个对话来判断那个好友离开了对话,因为对话保留了一个好友的引用
            if(buddy==null){
              buddy = UriHelper.createBuddy(uri);
            }
View Full Code Here

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

Examples of net.solosky.maplefetion.bean.Buddy

    }
    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

Examples of net.solosky.maplefetion.bean.Buddy

      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

Examples of net.solosky.maplefetion.bean.Buddy

      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
TOP
Copyright © 2018 www.massapi.com. 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.