Example #1
0
 public void testWriteOnMultiThread() throws Exception {
   Skype.setDebug(true);
   Application application = Skype.addApplication(APPLICATION_NAME);
   Friend friend = TestData.getFriend();
   try {
     Stream[] streams = application.connect(friend);
     assertEquals(1, streams.length);
     Stream stream = streams[0];
     checkConnectedFriends(application, friend);
     checkWriteOnMultiThread(stream);
     checkDisconnect(application, stream);
   } finally {
     application.finish();
   }
 }
Example #2
0
  private String resolveSkypeIdOf(String to) throws SkypeException {

    for (Friend f : com.skype.Skype.getContactList().getAllFriends()) {
      if (f.getFullName().equals(to) || f.getId().equals(to)) return f.getId();
    }
    throw new IllegalStateException("User " + to + " not found");
  }
  /**
   * This is the main method of this class. For every message user sends it checks if it is
   * "!addlister" and if it then it clears the message from skype and adds one {@link
   * GroupChatListener listener} for this specific chat.
   *
   * <p>Also this method checks if user has activated edit lister. If he has then it also registers
   * and one {@link GroupChatEditListener editListener} for the specific chat.
   *
   * @see com.skype.ChatMessageListener#chatMessageSent(com.skype.ChatMessage)
   */
  @Override
  public void chatMessageSent(ChatMessage sent) throws SkypeException {
    if (!sent.getContent().equalsIgnoreCase("!addlistener")) return;

    Chat chat = sent.getChat();
    if (!registeredChats.contains(chat)) {
      sent.setContent("");

      GroupChatListener group = new GroupChatListener(chat);
      Skype.addChatMessageListener(group);

      // System.out.println(chat.getWindowTitle());

      if (Config.EnableEdits) Skype.addChatMessageEditListener(group.getEditListener());

      registeredChats.add(chat);
    }
  }
Example #4
0
 @Override
 public void sendMessage(String[] ids, Selection selection) throws SenderException {
   try {
     Chat chat = Skype.chat(ids);
     doSendMessage(chat, selection);
   } catch (Exception e) {
     throw new SenderException(e.getMessage());
   }
 }
Example #5
0
 private boolean internalIsKnownUser(String user) {
   try {
     for (Friend f : com.skype.Skype.getContactList().getAllFriends()) {
       if (f.getFullName().equals(user) || f.getId().equals(user)) return true;
     }
   } catch (SkypeException e) {
     throw new UnhandledException(e);
   }
   return false;
 }
Example #6
0
 private MyRobot() {
   super();
   memory = new Memory();
   face = new RobotFace();
   faceController = new RobotFaceController();
   this.speechSynth = new SpeechSynth();
   try {
     Skype.addChatMessageListener(new ChatMessageAdapterDisp());
   } catch (SkypeException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   }
 }
Example #7
0
  public void onCommand() {
    try {
      Skype.addChatMessageListener(
          new ChatMessageListener() {
            @Override
            public void chatMessageReceived(ChatMessage chatMessage) throws SkypeException {
              CommandsManager.runCommand(chatMessage);
            }

            @Override
            public void chatMessageSent(ChatMessage chatMessage) throws SkypeException {
              CommandsManager.runCommand(chatMessage);
            }
          });
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
Example #8
0
 private void add(String arg) throws SkypeException {
   Skype.getContactList().addFriend(arg, "Hello, I'd like to add you as a contact");
 }