Package net.solosky.maplefetion.bean

Examples of net.solosky.maplefetion.bean.Buddy


      if(buddy.getUri().equals(this.mainBuddy.getUri())) {
              this.closeDialog();
      }else {    //移除对应离开的好友
        Iterator<Buddy> it = this.buddyList.iterator();
        while(it.hasNext()) {
          Buddy b = it.next();
          if(b.getUri().equals(buddy.getUri())) {
            it.remove();
            break;
          }
        }
      }
View Full Code Here


  @Override
  public void handle(SipcNotify notify) throws FetionException {
    Element root = XMLHelper.build(notify.getBody().toSendString());
    Element node = XMLHelper.find(root, "/is-composing/state");
    String  state = node.getText();
    Buddy   from  = context.getFetionStore().getBuddyByUri(notify.getFrom());
    ChatDialogProxy chatDialogProxy = this.context.getChatDialogProxyFactoy().create(from);
    if("nudge".equals(state)){
      this.tryFireNotifyEvent(new ChatNudgeEvent(chatDialogProxy));
    }else if("input".equals(state)){
      this.tryFireNotifyEvent(new ChatInputEvent(chatDialogProxy));
View Full Code Here

      .createDefaultReceipt(notify.getFrom(), Integer.toString(notify.getCallID()), notify.getSequence());
      this.dialog.process(receipt);
     
      //查找消息是哪个好友发送的
        FetionStore store = this.context.getFetionStore();
      Buddy from   = store.getBuddyByUri(notify.getFrom());
      String body  = notify.getBody()!=null?notify.getBody().toSendString():""//防止产生NULL错误
      Message msg  = this.parseMessage(notify);
     
      //如果好友没有找到,可能是陌生人发送的信息,
      if(from==null) {
View Full Code Here

     */
    @Override
    public void sendSMS(String uri, final String msg)
    {
      try{
          Buddy buddy = this.client.getFetionStore().getBuddyByUri(uri);
          ChatDialogProxy dialog = this.client.getChatDialogProxyFactory().create(buddy);
        dialog.sendChatMessage(new Message(msg), new DefaultActionListener("发送消息[ "+msg+" ]给"+buddy.getDisplayName()));
        } catch (FetionException e) {
          println("建立对话框时出错"+e.getMessage());
        }
    }
View Full Code Here

         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

     * @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

     * @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

        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

        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

        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

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.