Ejemplo n.º 1
0
  @Override
  public void sendMessage(final FriendMessage message) {

    HashMap<String, Friend> friends = AccountManager.getInstance().getFriends();
    Friend friend = friends.get(message.getTo());
    Screenname buddy = new Screenname(friend.getUserName());
    Conversation c = (Conversation) friend.getUserInfo();
    if (c == null) {
      c = connection.getIcbmService().getImConversation(buddy);
      friend.setUserInfo(c);
    }
    Message oscarMessage =
        new Message() {

          public boolean isAutoResponse() {
            return false;
          }

          public String getMessageBody() {
            return message.getMessage();
          }
        };
    c.sendMessage(oscarMessage);
    Friend recipient = friends.get(message.getTo());
    accountListener.didReceiveMessageForFriend(message, recipient);
  }
  @Override
  public void conversationResuming(Conversation conversation, HttpServletRequest request) {
    ConversationContext<?> ctx = conversation.getCurrentContext();

    if (ctx.useConversationEntityManager()) {
      if (conversation.getEntityManager() == null) {
        EntityManager em = entityManagerFactory.createEntityManager();
        conversation.setEntityManager(em);
        if (log.isDebugEnabled()) {
          log.debug(
              "conv. "
                  + conversation.getId()
                  + " resuming: conversation's entityManager created: "
                  + em.hashCode());
        }
      }

      if (PrimeFacesUtil.isAjax(request)) {
        String componentId = request.getParameter("javax.faces.source");
        if (componentId != null && ctx.ignoreUseConversationEntityManager(componentId)) {
          // _HACK_ as it is a tricky subject
          if (log.isDebugEnabled()) {
            log.debug(
                "Skip conversation's entityManager binding for ajax request coming from id: "
                    + componentId);
          }
          return;
        }
      }

      bindEntityManager(conversation.getEntityManager());
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Utils.Log("MessageFragment onCreate called");

    if (savedInstanceState != null) {
      conversation = new Conversation();
      conversation.setUsername(savedInstanceState.getString("username", ""));
      conversation.setId(savedInstanceState.getInt("_id", 0));
      conversation.setUnreadMessages(savedInstanceState.getInt("unreadMessages", 0));

      // actionBarChangeRequestListener.OnActionBarChangeRequest(Utils.ACTION_BAR_NAME_CHANGE,
      // conversation.getUsername());
      // actionBarChangeRequestListener.OnActionBarChangeRequest(Utils.ACTION_BAR_ENABLE_BACK_BUTTON, null);
    }

    getActivity().setTitle(conversation.username);

    dbManager = new DBManager(getActivity());
    username = dbManager.getUsername();

    dbManager.resetUnreadMessages(conversation.username);

    setHasOptionsMenu(true);
  }
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Utils.Log("MessageFragment onCreateView called");
    View view = inflater.inflate(R.layout.fragment_messages, container, false);
    messageList = (ListView) view.findViewById(R.id.messages_list);
    messages = dbManager.getMessages(conversation.getUsername());
    adapter =
        new MessagesAdapter(
            getActivity(),
            messages,
            dbManager.getUsername(),
            conversation.getUsername(),
            conversationPass);
    messageList.setAdapter(adapter);

    messageList.setOnItemLongClickListener(messageLongClicked);

    if (savedInstanceState == null) {
      messageList.setSelection(adapter.getCount() - 6);
    }

    sendMessage = (Button) view.findViewById(R.id.btn_message_send);
    sendMessage.setOnClickListener(sendClicked);
    messageText = (MaterialEditText) view.findViewById(R.id.user_message_text);
    return view;
  }
Ejemplo n.º 5
0
 /** Test of getSubject/setSubject method, of class Conversation. */
 @Test
 public void testSubject() {
   ConversationSubject conversationSubject =
       new ConversationSubject(new String[] {"subject-a", "subject-b"});
   conversation.setSubject(conversationSubject);
   assertEquals(conversationSubject, conversation.getSubject());
 }
Ejemplo n.º 6
0
  /** Test of getChatMessages method, of class Conversation. */
  @Test
  public void testGetMessages() throws InterruptedException {
    ChatMessage[] messages =
        new ChatMessage[] {
          new ChatMessage("JPanneel", "Hey!"),
          new ChatMessage("Wendy", "O dag lieverd"),
          new ChatMessage("JPanneel", "Hoe gaat het met de overkant?"),
          new ChatMessage("Wendy", "Goed, maar ik mis je wel!"),
          new ChatMessage("info", "haha, iz in your code", true),
          new ChatMessage("JPanneel", "Ik weet het :)"),
          new ChatMessage("Wendy", "Doei!")
        };

    assertEquals(0, conversation.getChatMessages(5).length);

    EventPool eventPool = EventPool.getAppPool();

    for (int i = 0; i < 6; i++) {
      EventPool.getAppPool().raiseNetworkEvent(new NewChatMessageEvent(conversation, messages[i]));
      Thread.sleep(100);
    }

    assertEquals(5, conversation.getChatMessages(10).length);
    assertEquals("Hey!", conversation.getChatMessages(5)[0].getText());
    assertEquals("Ik weet het :)", conversation.getChatMessages(5)[4].getText());
    assertEquals(3, conversation.getChatMessages(3).length);
    assertEquals("Hoe gaat het met de overkant?", conversation.getChatMessages(3)[0].getText());

    EventPool.getAppPool().raiseNetworkEvent(new NewChatMessageEvent(conversation, messages[6]));
    Thread.sleep(100);
    assertEquals(5, conversation.getChatMessages(5).length);
    assertEquals(6, conversation.getChatMessages(10).length);
    assertEquals("Hoe gaat het met de overkant?", conversation.getChatMessages(5)[1].getText());
    assertEquals("Doei!", conversation.getChatMessages(5)[4].getText());
  }
  @Override
  public void conversationPausing(Conversation conversation) {
    EntityManager em = conversation.getEntityManager();
    if (em != null) {
      boolean needToReleaseConnection = false;

      if (unbindEntityManager(conversation.getEntityManager())) {
        needToReleaseConnection = true;
      }

      if (!conversation.isEntityManagerStillNeeded()) {
        em.close();
        conversation.setEntityManager(null);
        if (log.isDebugEnabled()) {
          log.debug(
              "conv. "
                  + conversation.getId()
                  + " pausing: conversation's entityManager closed: "
                  + em.hashCode());
        }
      } else if (needToReleaseConnection) {
        // _HACK_ as we depend on Hibernate
        // Note: normally we should not have to do this as we have configured hibernate
        // with hibernate.connection.release_mode=after_transaction
        // But we load some lazy data non transactionnally from the view...
        Session session = em.unwrap(Session.class);
        session.disconnect(); // will be reconnected automatically as needed.
      }
    }
  }
Ejemplo n.º 8
0
  /** Test of equals method, of class Conversation. */
  @Test
  public void testEquals() throws UnknownHostException {
    assertTrue(conversation.equals(conversation)); // identity

    Conversation differentConversation =
        new Conversation(new Contact("Javache", InetAddress.getByName("thinkjavache.be")), true);
    assertFalse(conversation.equals(differentConversation));
  }
Ejemplo n.º 9
0
  /**
   * Test of hashCode method, of class Conversation.
   *
   * @throws UnknownHostException
   */
  @Test
  public void testHashCode() throws UnknownHostException {
    assertEquals(conversation.hashCode(), conversation.hashCode());

    Conversation differentConversation =
        new Conversation(new Contact("Javache", InetAddress.getByName("ugent.be")), true);
    assertNotSame(conversation.hashCode(), differentConversation.hashCode());
  }
Ejemplo n.º 10
0
 /** Test of addMessage method, of class Conversation. */
 @Test
 public void testAddMessage() throws InterruptedException {
   assertEquals(0, conversation.getChatMessages(10).length);
   ChatMessage chatMessage = new ChatMessage("JPanneel", "Hey!");
   NewChatMessageEvent chatMessageEvent = new NewChatMessageEvent(conversation, chatMessage);
   EventPool.getAppPool().raiseNetworkEvent(chatMessageEvent);
   Thread.sleep(100);
   assertEquals(1, conversation.getChatMessages(10).length);
 }
  @Override
  public void onSaveInstanceState(Bundle outState) {

    outState.putString("username", conversation.getUsername());
    outState.putInt("_id", conversation.getId());
    outState.putInt("unreadMessages", conversation.getUnreadMessages());

    super.onSaveInstanceState(outState);
  }
Ejemplo n.º 12
0
  /**
   * Test of close method, of class Conversation.
   *
   * @throws InterruptedException
   */
  @Test
  public void testClose() throws InterruptedException {
    // wait for the window to be created. (is in another thread)
    // otherwise nullpointers
    Thread.sleep(500);
    JFrame window = conversation.getWindow();
    conversation.close(true);

    Thread.sleep(100);
  }
Ejemplo n.º 13
0
 /**
  * Deletes the customer from the registry
  *
  * @return to showCustomers if the delete was success
  */
 public String action() {
   if (!conv.isTransient()) {
     conv.end();
     Logger.getAnonymousLogger().log(Level.INFO, "CONVERSATION ENDS");
   }
   try {
     String userName = deleteCustomerBackingBean.getUserName();
     customerRegistryBean.remove(userName);
     return "showCustomers?faces-redirect=true"; // Go back
   } catch (Exception e) {
     // Not implemented
     // return "error?faces-redirect=true&amp;cause=" + e.getMessage();
     return null;
   }
 }
 ConversationContext(
     Conversation conversation, TelegramBot bot, Map<String, Object> conversationData) {
   this.conversation = conversation;
   this.from = conversation.getForWhom();
   this.bot = bot;
   this.conversationData = conversationData;
 }
Ejemplo n.º 15
0
  public void registerLoadingNextMessage(Message m) {
    try {
      ExperimentManager em = c.getExpManager();
      if (em == null) return;
      if (em.emui == null) return;
      if (em.emui.getJMF() == null) return;

      if (m instanceof MessageChatTextFromClient
          || m instanceof diet.message.MessageWYSIWYGDocumentSyncFromClientInsert
          || m instanceof diet.message.MessageWYSIWYGDocumentSyncFromClientRemove
          || m instanceof diet.message.MessageKeypressed) {
        long turnaroundTime = new Date().getTime() - timeOfReceiptOfMostRecentMessage;
        if (turnaroundTime > this.longestProcessingTimeByServer) {
          longestProcessingTimeByServer = turnaroundTime;
          em.emui.getJMF().jsb.setMaxProcessingTime("" + turnaroundTime + " m.s.");
        }
        if (turnaroundTime > this.c.getController().loggingOverrunTime) {
          numberOfOverruns++;
          em.emui.getJMF().jsb.setOverrun("" + numberOfOverruns);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 16
0
  public void updateParticipants(int numberOfParticipants) {
    ExperimentManager em = c.getExpManager();
    if (em == null) return;
    if (em.emui == null) return;
    if (em.emui.getJMF() == null) return;

    em.emui.getJMF().jsb.setNumberOfParticipants("" + numberOfParticipants);
  }
Ejemplo n.º 17
0
 public void registerDisconnection() {
   numberOfDisconnections = numberOfDisconnections + 1;
   ExperimentManager em = c.getExpManager();
   if (em == null) return;
   if (em.emui == null) return;
   if (em.emui.getJMF() == null) return;
   em.emui.getJMF().jsb.setNumberOfDisconnects("" + numberOfDisconnections);
 }
    /**
     * Adds <tt>minfo</tt> into the list of collected messages.
     *
     * @param c Conversation
     * @param minfo MessageInfo
     */
    public void gotMessage(Conversation c, MessageInfo minfo) {

      logger.debug("Message: [" + minfo.getMessage() + "] received from: " + c.getBuddy());
      synchronized (this) {
        collectedMessageInfo.add(minfo);
        notifyAll();
      }
    }
  @Override
  public void conversationEnding(Conversation conversation) {
    EntityManager em = conversation.getEntityManager();
    if (em != null) {
      unbindEntityManager(em);
      em.close();
      conversation.setEntityManager(null); // not really required, but just for clarity.

      if (log.isDebugEnabled()) {
        log.debug(
            "conv. "
                + conversation.getId()
                + " ending: conversation's entityManager closed: "
                + em.hashCode());
      }
    }
  }
Ejemplo n.º 20
0
  /**
   * Prepares the DeleteCustomerBackingBean with data to show which customer the admin is deleting
   *
   * @param ae
   */
  public void actionListener(ActionEvent ae) {
    Customer customer = (Customer) ae.getComponent().getAttributes().get("customer");
    if (conv.isTransient()) {
      conv.begin();
      Logger.getAnonymousLogger()
          .log(Level.INFO, "CONVERSATION BEGINS: Got customer {0}", customer);
    } else {
    }

    deleteCustomerBackingBean.setFname(customer.getFname());
    deleteCustomerBackingBean.setLname(customer.getLname());
    deleteCustomerBackingBean.setEmail(customer.getEmail());
    deleteCustomerBackingBean.setUserName(customer.getUserName());
    Address address;
    address = customer.getAddress();
    deleteCustomerBackingBean.setAddress(address);
  }
Ejemplo n.º 21
0
 public void registerIncomingMessage(Message m) {
   timeOfReceiptOfMostRecentMessage = new Date().getTime();
   messagesReceived = messagesReceived + 1;
   ExperimentManager em = c.getExpManager();
   if (em == null) return;
   if (em.emui == null) return;
   if (em.emui.getJMF() == null) return;
   em.emui.getJMF().jsb.setMessagesReceived("" + messagesReceived);
 }
Ejemplo n.º 22
0
 public void initAddPageData() {
   Log.i("Init add page data...");
   Context context = getApplicationContext();
   Conversation.init(context);
   RecipientIdCache.init(context);
   Contact.init(context);
   CallLog.init(context);
   Log.i("Init add page data completed.");
   mInitedAddPage = true;
 }
Ejemplo n.º 23
0
  public Conversation next() {
    index++;
    if (files == null || files.length <= index) {
      return null;
    }

    for (; index < files.length; index++) {
      File file = files[index];
      if (!file.isFile()) {
        continue;
      }
      try {
        String name = file.getName();
        long uid = Long.parseLong(name);

        RandomAccessFile f = new RandomAccessFile(file, "r");
        MessageIterator iter = new MessageIterator(f);
        IMessage msg = iter.next();
        if (msg == null) {
          continue;
        }
        Conversation conv = new Conversation();
        conv.type = this.type;
        conv.cid = uid;
        conv.message = msg;
        return conv;
      } catch (NumberFormatException e) {
        e.printStackTrace();
        continue;
      } catch (FileNotFoundException e) {
        e.printStackTrace();
        continue;
      } catch (IOException e) {
        e.printStackTrace();
        continue;
      }
    }
    return null;
  }
Ejemplo n.º 24
0
  public void registerSendingMessage(Message m) {

    if (m instanceof diet.message.MessageChangeClientInterfaceProperties) {
      MessageChangeClientInterfaceProperties mccip = (MessageChangeClientInterfaceProperties) m;
      // System.err.println("CHANGE:    ID:"+mccip.idToConfirm+":
      // IPROPERTIES:"+mccip.getInterfaceproperties()+"   VALUE1"+mccip.getValue());

    }

    messagesSent = messagesSent + 1;
    ExperimentManager em = c.getExpManager();
    if (em == null) return;
    if (em.emui == null) return;
    if (em.emui.getJMF() == null) return;
    em.emui.getJMF().jsb.setMessagesSent("" + messagesSent);
  }
Ejemplo n.º 25
0
  /**
   * Test of handleEvent method, of class Conversation. Tests both local and remote side
   *
   * @throws UnknownHostException
   * @throws InterruptedException
   * @throws IOException
   */
  @Test
  public void testHandleEvent() throws UnknownHostException, IOException, InterruptedException {
    // clear the converstion created in setUp()
    EventPool.getAppPool().removeListener(conversation);

    // get the local app-pool and let it start
    EventPool localPool = EventPool.getAppPool();
    Thread.sleep(100);

    // create a remote eventpool and connect it to the local one
    EventPool remotePool = new EventPool();
    Connection remoteConnection = new Connection(InetAddress.getLocalHost(), remotePool, null);
    Thread.sleep(100);

    // create a contact out of the local user (as seen from the other side)
    Account localAccount = ChatApplication.getInstance().getAccount();
    Contact localContact = new Contact(localAccount.getUsername(), InetAddress.getLocalHost());
    Contact remoteContact = new Contact("Jaspervdj", InetAddress.getLocalHost());

    // add both of these contacts to our list, so we can look them up later
    ContactList contactList = localAccount.getContactList();
    contactList.addContact(localContact);
    contactList.addContact(remoteContact);

    // conversation manager will contain the conversation with the remote user, as
    // well as the conversation with the local one
    ConversationManager conversationManager =
        ChatApplication.getInstance().getConversationManager();
    Conversation localConversation = conversationManager.startConversation(remoteContact, false);
    Conversation remoteConversation = conversationManager.startConversation(localContact, false);

    // register the remoteConversation specifically with the remote pool
    remotePool.addListener(remoteConversation, new ConversationEventFilter(remoteConversation));
    // remove remoteListener from localPool
    localPool.removeListener(remoteConversation);

    // now everything is setup, and a user can type a message
    ChatMessage chatMessage =
        new ChatMessage(localContact.getUsername(), "Dag Javache, jij jij remoteUser!");
    ConversationEvent localEvent = new NewChatMessageEvent(localConversation, chatMessage);

    // raise the event on the local pool, should get sent to remotePool too
    localPool.raiseNetworkEvent(localEvent);
    Thread.sleep(100);

    // let's check the results!
    assertEquals(1, remoteConversation.getChatMessages(10).length);
    assertEquals(
        "Dag Javache, jij jij remoteUser!", remoteConversation.getChatMessages(1)[0].getText());

    assertEquals(1, localConversation.getChatMessages(10).length);
    assertEquals(
        "Dag Javache, jij jij remoteUser!", localConversation.getChatMessages(1)[0].getText());
  }
  /**
   * Download the file offer given a file ID.
   *
   * <p>package-private for testing
   *
   * @param fileId identifier to look up the file offer message
   */
  void downloadFileOffer(String fileId) {
    Map<String, MessageFileOffer> fileOffers = conversation.getFileOfferMessages();
    MessageFileOffer msgWithfileOffer = fileOffers.get(fileId);
    SearchResult file = null;

    try {
      file =
          remoteFileItemFactory.create(
              msgWithfileOffer.getPresence(), msgWithfileOffer.getFileOffer());
      DownloadItem dl = downloader.addDownload(null, Collections.singletonList(file));

      // Track download states by adding listeners to dl item
      addPropertyListener(dl, msgWithfileOffer);

    } catch (DownloadException e) {
      final SearchResult remoteFileItem = file;
      final MessageFileOffer messageFileOffer = msgWithfileOffer;
      downloadExceptionHandler
          .get()
          .handleDownloadException(
              new DownloadAction() {
                @Override
                public void download(File saveFile, boolean overwrite) throws DownloadException {
                  DownloadItem dl =
                      downloader.addDownload(
                          null, Collections.singletonList(remoteFileItem), saveFile, overwrite);
                  addPropertyListener(dl, messageFileOffer);
                }

                @Override
                public void downloadCanceled(DownloadException ignored) {
                  // nothing to do
                }
              },
              e,
              true);
    } catch (InvalidDataException ide) {
      // this means the FileMetaData we received isn't well-formed.
      LOG.error("Unable to access remote file", ide);
      FocusJOptionPane.showMessageDialog(
          null,
          I18n.tr("Unable to access remote file"),
          I18n.tr("Hyperlink"),
          JOptionPane.WARNING_MESSAGE);
    }
  }
  private void handleLinkClick(String linkDescription, URL url) {

    if (ChatDocumentBuilder.LIBRARY_LINK.equals(linkDescription)) {
      ChatFriend libraryChatFriend = conversation.getChatFriend();
      LOG.debugf("Opening a view to {0}'s library", libraryChatFriend.getName());
      //            libraryNavigator.selectFriendLibrary(libraryChatFriend.getFriend());
      throw new IllegalStateException("action does't exist");

    } else if (ChatDocumentBuilder.MY_LIBRARY_LINK.equals(linkDescription)) {
      LOG.debugf("Opening a view to my library");
      //            libraryNavigator.selectLibrary();
      throw new IllegalStateException("action does't exist");
    } else {
      LOG.debugf("Hyperlink clicked: {0}", linkDescription);
      if (linkDescription.startsWith("magnet")) {
        // TODO: Need to do something with magnet links

      } else if (url != null) {
        NativeLaunchUtils.openURL(url.toString());
      }
    }
  }
        @Override
        public void onClick(View view) {

          Utils.Log("Send clicked");

          // If the message field is not empty
          if (!messageText.getText().toString().isEmpty()) {

            final Message message = new Message();
            message.setSender(username);
            message.setRecipient(conversation.getUsername());

            // If DHKE was completed and a key exists
            if (!dbManager.getAESKey(conversation.getUsername()).isEmpty()) {
              String signature = "";
              String key = dbManager.getAESKey(conversation.getUsername());
              byte[] iv = Crypto.GenerateRandomIV();
              final String plainText = messageText.getText().toString();
              final String cipherText = Crypto.AESencrypt(key, plainText, iv);
              final String base64IV = Base64.encodeToString(iv, Base64.NO_WRAP);

              try {
                PrivateKey RSAKeySign =
                    Crypto.RSAStringToPrivateKey(dbManager.getRSAKeySignaturePrivate());

                signature =
                    Base64.encodeToString(
                        Crypto.RSASign(Base64.decode(cipherText, Base64.NO_WRAP), RSAKeySign),
                        Base64.NO_WRAP);

              } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
              } catch (InvalidKeySpecException e) {
                e.printStackTrace();
              } catch (NoSuchProviderException e) {
                e.printStackTrace();
              } catch (InvalidKeyException e) {
                e.printStackTrace();
              } catch (SignatureException e) {
                e.printStackTrace();
              }

              message.setMessage(cipherText);
              message.setIv(base64IV);
              message.setSignature(signature);

              new HttpHandler() {
                @Override
                public HttpUriRequest getHttpRequestMethod() {
                  HttpPost httpPost = new HttpPost(Utils.SERVER_SEND_MESSAGE);

                  List<NameValuePair> nameValuePairs = new ArrayList<>();
                  nameValuePairs.add(new BasicNameValuePair("sender", message.getSender()));
                  nameValuePairs.add(new BasicNameValuePair("recipient", message.getRecipient()));
                  nameValuePairs.add(new BasicNameValuePair("message", message.getMessage()));
                  nameValuePairs.add(new BasicNameValuePair("iv", message.getIv()));
                  nameValuePairs.add(new BasicNameValuePair("signature", message.getSignature()));

                  try {
                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                  } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                  }

                  return httpPost;
                }

                @Override
                public void onResponse(String result) {
                  Utils.Log("HttpResult: " + result);

                  if (conversation.isEncrypted().equals("true")) {
                    message.setMessage(
                        Crypto.AESencrypt(
                            conversationPass,
                            plainText,
                            Base64.decode(message.getIv(), Base64.NO_WRAP)));
                    message.setEncrypted(true);

                    dbManager.addMessage(message);

                    message.setEncrypted(false);
                    message.setMessage(plainText);

                    messages.add(message);
                    adapter.notifyDataSetChanged();

                  } else {
                    message.setMessage(plainText);
                    message.setEncrypted(false);

                    dbManager.addMessage(message);

                    messages.add(message);
                    adapter.notifyDataSetChanged();
                  }

                  messageList.setSelection(messages.size() + 1);
                }
              }.execute();

              messageText.setText("");

            }

            // DHKE was not complete yet, store messages unencrypted temporarily
            // and then encrypt and send them once the exchange is complete
            else {
              message.setEncrypted(false);
              message.setMessage(messageText.getText().toString());
              message.setIv(Base64.encodeToString(Crypto.GenerateRandomIV(), Base64.NO_WRAP));

              dbManager.addMessage(message);

              messages.add(message);
              adapter.notifyDataSetChanged();

              messageList.setSelection(adapter.getCount() - 1);
              messageText.setText("");
            }
          }
        }
Ejemplo n.º 29
0
 public Category(Conversation conv) {
   pattern = conv.getQuestion().toUpperCase();
   template = new TemplateTag(conv.getAnswer());
 }
Ejemplo n.º 30
0
  public void checkInput(String input) {
    if (currentConvo != null) {
      if (input.equalsIgnoreCase("cancel")) {
        currentConvo = null;
        player.currentLoc.look();
      } else {
        currentConvo.talk(input);
      }
      return;
    }
    System.out.println(input);
    Pattern lookPattern = Pattern.compile("^look(\\s|$)");
    Pattern getPattern = Pattern.compile("^get(\\s|$)");
    Pattern dropPattern = Pattern.compile("^drop(\\s|$)");
    Pattern usePattern = Pattern.compile("^use(\\s|$)");
    Pattern movePattern = Pattern.compile("^move(\\s|$)");
    Pattern talkPattern = Pattern.compile("^talk(\\s|$)");
    Pattern argumentPattern = Pattern.compile("\\s\\w+($|\\s)");
    Pattern twoArgumentPattern =
        Pattern.compile(
            "\\s(\\w+|\\w+\\s\\w+)\\son\\s(\\w+|\\w+\\s\\w+)($|\\s)"); // makes UseOn work
    Pattern savePattern = Pattern.compile("^save(\\s|$)");
    Pattern loadPattern = Pattern.compile("^load(\\s|$)");
    Matcher argumentMatcher = argumentPattern.matcher(input);
    Matcher twoArgumentMatcher = twoArgumentPattern.matcher(input);

    // LOOK
    if (lookPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.look(input.substring(argumentMatcher.start() + 1, input.length()));
      } else {
        player.look("");
      }
      return;
    }
    // END LOOK

    // TALK
    if (talkPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.talk(input.substring(argumentMatcher.start() + 1, input.length()));
      } else {
        Gui.setOutputText("You talk to yourself for a while, it was a rivetting conversation");
      }
      return;
    }

    // GET/PICK UP
    if (getPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        System.out.println("found argument");
        player.pickUp(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("You can't pick up nothing, f****t.");
        return;
      }
    }
    // END GET

    // USE ON
    if (twoArgumentMatcher
        .find()) { // checks for two arguments so "use cat picture on joint" should call useOn?
      input = input.substring(twoArgumentMatcher.start() + 1, input.length());
      Pattern findOnPattern = Pattern.compile("\\son\\s");
      Matcher findOnMatcher = findOnPattern.matcher(input);
      findOnMatcher.find();
      String firstArg = input.substring(0, findOnMatcher.start()); // item 1
      String secondArg = input.substring(findOnMatcher.end(), input.length()); // item 2
      player.useOn(firstArg, secondArg);
      return;
    }
    // END USE ON

    // USE
    if (usePattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.use(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("There's nothing like that to use.");
        return;
      }
    }
    // END USE

    // DROP
    if (dropPattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        player.drop(input.substring(argumentMatcher.start() + 1, input.length()));
        return;
      } else {
        Gui.setOutputText("You have dropped nothing.");
        return;
      }
    }
    // END DROP

    // MOVE
    if (movePattern.matcher(input).find()) {
      if (argumentMatcher.find()) {
        String destination = input.substring(argumentMatcher.start() + 1, input.length());
        for (Location l : player.currentLoc.getLinks()) {
          if (destination.equalsIgnoreCase(l.getName()) && l.isDiscovered()) {
            player.move(l);
            return;
          }
        }
        Gui.setOutputText("Invalid location");
        return;
      } else {
        Gui.setOutputText("You shuffled around a little bit");
        return;
      }
    }
    // END MOVE

    // SAVE
    if (savePattern.matcher(input).find()) {
      Gui.setOutputText(TextAdventure.saveWorld());
    }
    // END SAVE

    // LOAD
    if (loadPattern.matcher(input).find()) {
      Gui.setOutputText(TextAdventure.loadWorld());
    }
    // END LOAD

    // NONE OF THE ABOVE
    Gui.setOutputText(
        (String) TextAdventure.pick(TextAdventure.invalidVerb)); // prints out invalid verb
    return;
  }