Package nu.fw.jeti.jabber

Examples of nu.fw.jeti.jabber.JID


  public GroupchatWindow(Backend backend, JID jid, GroupChatWindows groupchatWindows, JFrame frame)
  {
    //Plugin.addGroupchat(jid,this);
    this.groupchatWindows = groupchatWindows;
    fullRoomJID =jid;
    roomJID = new JID(jid.getUser(),jid.getDomain());
    if(PluginsInfo.isPluginLoaded("groupchatalerter"))
      {
      if(!nu.fw.jeti.plugins.groupchatalerter.Plugin.isMonitoring(jid))
      {
        backend.addPresenceListener(roomJID,this);
View Full Code Here


        if(nick == null) return;

        if(!isMUCRoom)
        {//old groupchat room hack
          me = nick;
          fullRoomJID = new JID(roomJID.getUser(),roomJID.getDomain(),nick);
          btnStatus.setJID(fullRoomJID);
        }

                backend.send(new Presence(new JID(roomJID.getUser(),
                                                  roomJID. getDomain(),
                                                  nick), "available"));
      }
    });
        menuItem.setEnabled(false);
View Full Code Here

          item = new JMenuItem();
          I18N.setTextAndMnemonic("groupchat.Private_message",
                                  item, true);
          item.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                  JID jid = a.getJID();
                  new SendMessage(backend, jid,
                                  jid.getUser() + "/" + jid.getResource()
                      ).setVisible(true);
              }
          });
          actionMenu.add(item);
View Full Code Here

              else
              {
                nick = JOptionPane.showInputDialog(this,I18N.gettext("groupchat.Nickname_in_use,_please_choose_another"));
              }
              me = nick;
        fullRoomJID = new JID(roomJID.getUser(),roomJID.getDomain(),nick);
        btnStatus.setJID(fullRoomJID);
        backend.send(new Presence(fullRoomJID, "available"));
            }
            else chatSplitPane.appendSystemMessage(presence.getErrorDescription());
      return;
    }
    final JID jid = presence.getFrom();
    XMUCUser temp=null;
        if(presence.hasExtensions()) {
            for(Iterator i = presence.getExtensions();i.hasNext();) {
        Object o = i.next();
                if(o instanceof XMUCUser) {
          temp =(XMUCUser)o;
          break;
        }
      }
    }
    final XMUCUser xMucUser = temp;
        if (me.equals(jid.getResource())) {
            if(xMucUser!=null && xMucUser.getStatusCode()==303) {//own nickname change
        me = xMucUser.getNick();
                fullRoomJID = new JID(roomJID.getUser(),
                                      roomJID.getDomain(),me);
                btnStatus.setJID(fullRoomJID);
            } else {
                ownPresenceChanged(presence, xMucUser);
                if (xMucUser!=null && xMucUser.getStatusCode()==201) {
                    new IQMUCOwnerConfigure(backend, roomJID, new XData("submit"));
                }
            }
        }
        if(presence.getType().equals("unavailable")) {
          //TODO if(xMucUser!=null && xMucUser.getStatusCode()==303) {nickname change
            Runnable updateAComponent = new Runnable() {
                public void run() {
                     model.removeElement(new Actor(jid));
                    userNames.remove(jid.getResource());
                    if (Preferences.getBoolean("groupchat","showPresence",true)) {
                        String text = MessageFormat.format(
                            I18N.gettext("groupchat.{0}_has_left"),
                            new Object[]{jid.getResource()});
                        chatSplitPane.appendSystemMessage(text);
                    }
                }
            };
            SwingUtilities.invokeLater(updateAComponent);
        } else {
            Runnable updateAComponent = new Runnable() {
                public void run() {
                    Actor status = new Actor(jid);
                    int index = model.indexOf(status);
                    String text;
                    if(index == -1) {
                        status.update(presence,xMucUser);
                        model.addElement(status);
                        userNames.add(jid.getResource());
                        text = I18N.gettext(
                            "groupchat.{0}_has_entered_the_room");
                        text = MessageFormat.format(
                                text, new Object[]{jid.getResource()});
                    } else {
                        status =(Actor) model.getElementAt(index);
                        text = getChangeMessage(status, presence);
                        status.update(presence,xMucUser);
                        model.updateElement(index);
View Full Code Here

  public void startElement(String name,Attributes attributes)
  {
    if(name.equals("log"))
    {
      JID from = JID.jidFromString(attributes.getValue("from"));
      String date = attributes.getValue("date");
      log = new Log(from,date);
    }
  }
View Full Code Here

      return null;
    }
  }

  protected JID stringToJID(String s) {
    JID jid = null;
    try {
      jid = JID.checkedJIDFromString(s);
    } catch (InstantiationException e) {
      Log.notParsedXML("CreationMessage: Shape's author is not JID, but "
          + s);
View Full Code Here

  public void process(String command) throws Exception
  {
//    TODO im and pres protocols
    System.out.println(command);
    if(command.startsWith("xmpp:")) command = command.substring(5,command.length());
    JID authJID=null;
    if(command.startsWith("//"))
    {//auth component
      command = command.substring(2,command.length());
      String authJidText=null;
      int questionIndex = command.indexOf("?");
      int slashIndex = command.indexOf("/");
      if(slashIndex<questionIndex)
      {
        authJidText =command.substring(0,slashIndex);
        command = command.substring(slashIndex+1,command.length());
      }
      else if(questionIndex!=-1)
      {
        authJidText =command.substring(0,questionIndex);
        command = command.substring(questionIndex,command.length());
      }
      else
      {
        authJidText =command;
        command = "";
      }
      authJidText = URLDecoder.decode(authJidText,"UTF-8");
      try
      {
        authJID = JID.checkedJIDFromString(authJidText);
      } catch (InstantiationException e)
      {
        Log.notParsedXML("Wrong JID from link " +  e.getMessage());
      }
    }
    //JID part
    String jidText=null;
    int questionIndex = command.indexOf("?");
    if(questionIndex!=-1)
    {
      jidText = command.substring(0,questionIndex);
      command = command.substring(questionIndex+1,command.length());
    }
    else
    {
      jidText =command;
      command = "";
    }
    jidText = URLDecoder.decode(jidText,"UTF-8");
    JID jid = null;
    try
    {
      jid = JID.checkedJIDFromString(jidText);
    } catch (InstantiationException e)
    {
      Log.notParsedXML("Wrong JID from link " +  e.getMessage());
    }
    String queryText=null;
    if(command.length()!=0)
    {//Query part
      int hashIndex = command.indexOf("#");
      if(hashIndex!=-1)
      {
        queryText = command.substring(0,hashIndex);
        command = command.substring(hashIndex+1,command.length());
      }
      else queryText = command;
    }//add fragment part? (#)
   
    //TODO login with authJID if not yet logged in
    System.out.println(authJID);
    System.out.println(jid);
    System.out.println(queryText);
   
    if(jid!=null)
    {
      JIDStatus jidStatus = backend.getJIDStatus(jid);
      if(jidStatus==null)jidStatus = new UnknownJIDStatus(jid);
      if(queryText==null)
      {
        backend.getMain().chat(jidStatus);
      }
      else
      {
        if(queryText.startsWith("message"))
        {
          messageAction(queryText, jidStatus);
        }
        else if(queryText.startsWith("roster"))
        {
          rosterAction(jid, queryText);
        }
        else if(queryText.startsWith("join"))
        {
          groupchatAction(jid);
        }
        else if(queryText.startsWith("invite;"))
        {//If the joining user is not yet in the room, the application MUST send two stanzas: the first to join the room and the second to invite the other individual. If the joining user is in the room already, the application shall send only the invitation stanza.
          //TODO make this
          if(true)return;
          if(PluginsInfo.isPluginLoaded("groupchat"))
          {//todo open groupchat + check if already open
            queryText = queryText.substring(7,queryText.length());
            String[] keyvalues = queryText.split(";");
            for(int i=0;i<keyvalues.length;i++)
            {
              String keyvalue = keyvalues[i];
              String value = getValue(keyvalue);
              if(value!=null)
              {
                if(keyvalue.startsWith("jid"))
                {
                  try
                  {//TODO invite user
                    JID invitee = JID.checkedJIDFromString(value);
                  } catch (InstantiationException e)
                  {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                  }
View Full Code Here

      }
      String nick = JOptionPane.showInputDialog(
          backend.getMainWindow(),I18N.gettext(
              "groupchat.Please_enter_your_nickname"));
      if(!nick.equals("")) {
        JID j = new JID(jid.getUser(),jid.getUser(), nick);
        nu.fw.jeti.plugins.groupchat.Plugin.startGroupchat(j,backend);
        }
    }
    else JOptionPane.showMessageDialog(backend.getMainWindow(),I18N.gettext(
      "xmppuri.Please_enable_the_groupchat_plugin_to_groupchat"));
View Full Code Here

            {
              ((VCard)iqe).execute(iq, backend);
            }
            else if (iq.getType().equals("result"))
            {
              JID jid = iq.getFrom();
              if(jid.equals(backend.getMyJID()))
              {
                new VCardEdit(new HashMap(),new HashMap(),new LinkedList(),new LinkedList(),backend);
              }
            }
          }
View Full Code Here

      I18N.setTextAndMnemonic("search.Add_to_Roster",button);
      button.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          JID jid=null;
          String nick=null;
          for(Iterator i = xDataPanel.getCurrentField();i.hasNext();)
          {
            XDataField data = (XDataField)i.next();
            if("jid".equals(data.getVar()))
            {
              jid = JID.jidFromString(data.getValue());
            }
            else if("nick".equals(data.getVar()))nick  = data.getValue();
          }
          if(jid!=null)new AddContact(jid,nick,null,backend).setVisible(true);
     
        }
      });
      panel.add(button);
      button = new JButton();
      I18N.setTextAndMnemonic("search.Chat",button);
      button.addActionListener(new ActionListener()
      {
        public void actionPerformed(ActionEvent e)
        {
          for(Iterator i = xDataPanel.getCurrentField();i.hasNext();)
          {
            XDataField data = (XDataField)i.next();
            if("jid".equals(data.getVar()))
            {
              JID jid = JID.jidFromString(data.getValue());
              backend.getMain().startChat(jid);
            }
          }
        }
      });
View Full Code Here

TOP

Related Classes of nu.fw.jeti.jabber.JID

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.