Exemple #1
0
  /**
   * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and
   * adds it to the main tabbed pane and plays the ring phone sound to the user.
   */
  public void incomingCallReceived(CallEvent event) {
    Call sourceCall = event.getSourceCall();

    CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL);

    mainFrame.addCallPanel(callPanel);

    if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL);

    if (!mainFrame.isVisible()) mainFrame.setVisible(true);

    mainFrame.toFront();

    this.callButton.setEnabled(true);
    this.hangupButton.setEnabled(true);

    NotificationManager.fireNotification(
        NotificationManager.INCOMING_CALL,
        null,
        "Incoming call recived from: " + sourceCall.getCallParticipants().next());

    activeCalls.put(sourceCall, callPanel);

    this.setCallPanelVisible(true);
  }
Exemple #2
0
 public void dispatchCall(Call call) {
   Employee emp = getHandlerForCall(call);
   if (emp != null) {
     emp.pickCall(call);
     call.setHandler(emp);
   } else {
     call.reply("sorry!");
     callQueues.get(call.getRank()).add(call);
   }
 }
  private void doOperatorTask() throws ClassNotFoundException, IOException {
    BlockingTaskSummaryResponseHandler handler = new BlockingTaskSummaryResponseHandler();
    client.getTasksAssignedAsPotentialOwner("operator", "en-UK", handler);
    List<TaskSummary> sums = handler.getResults();
    assertNotNull(sums);
    assertEquals(1, sums.size());

    BlockingTaskOperationResponseHandler startTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.start(sums.get(0).getId(), "operator", startTaskOperationHandler);

    BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler();
    client.getTask(sums.get(0).getId(), getTaskHandler);
    Task operatorTask = getTaskHandler.getTask();

    BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler();
    client.getContent(operatorTask.getTaskData().getDocumentContentId(), getContentHandler);
    Content content = getContentHandler.getContent();

    assertNotNull(content);

    ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject();
    Call restoredCall = (Call) deserializedContent.get("call");
    persistenceService.storeCall(restoredCall);

    Emergency emergency = new Emergency();

    emergency.setCall(restoredCall);

    emergency.setLocation(new Location(1, 2));
    emergency.setType(Emergency.EmergencyType.HEART_ATTACK);
    emergency.setNroOfPeople(1);
    persistenceService.storeEmergency(emergency);

    trackingService.attachEmergency(restoredCall.getId(), emergency.getId());

    Map<String, Object> info = new HashMap<String, Object>();
    info.put("emergency", emergency);

    ContentData result = new ContentData();
    result.setAccessType(AccessType.Inline);
    result.setType("java.util.Map");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(bos);
    out.writeObject(info);
    out.close();
    result.setContent(bos.toByteArray());

    BlockingTaskOperationResponseHandler completeTaskOperationHandler =
        new BlockingTaskOperationResponseHandler();
    client.complete(sums.get(0).getId(), "operator", result, completeTaskOperationHandler);
  }
Exemple #4
0
    public void run() {
      ProtocolProviderService pps = call.getProtocolProvider();

      Iterator participants = call.getCallParticipants();

      while (participants.hasNext()) {
        CallParticipant participant = (CallParticipant) participants.next();

        OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps);

        try {
          telephony.answerCallParticipant(participant);
        } catch (OperationFailedException e) {
          logger.error(
              "Could not answer to : " + participant + " caused by the following exception: " + e);
        }
      }
    }
  public void doCall(String method, Object value) throws Exception {
    Call call = new Call();
    call.setTargetObjectURI("http://soapinterop.org/");
    call.setMethodName(method);
    call.setEncodingStyleURI(encodingStyleURI);

    Vector params = new Vector();
    params.addElement(new Parameter("in", value.getClass(), value, null));
    call.setParams(params);

    // make the call: note that the action URI is empty because the
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp = call.invoke(url, "");

    // Check the response.
    if (resp.generatedFault()) {
      Fault fault = resp.getFault();
      System.out.println("Ouch, the call failed: ");
      System.out.println("  Fault Code   = " + fault.getFaultCode());
      System.out.println("  Fault String = " + fault.getFaultString());
    } else {
      Parameter result = resp.getReturnValue();
      System.out.println("Call succeeded: ");
      System.out.println("Result = " + result.getValue());
    }
  }
  private void createBillFor(Customer customer) {
    List<CallEvent> customerEvents = new ArrayList<CallEvent>();
    for (CallEvent callEvent : callLog) {
      if (callEvent.getCaller().equals(customer.getPhoneNumber())) {
        customerEvents.add(callEvent);
      }
    }

    List<Call> calls = new ArrayList<Call>();

    CallEvent start = null;
    for (CallEvent event : customerEvents) {
      if (event instanceof CallStart) {
        start = event;
      }
      if (event instanceof CallEnd && start != null) {
        calls.add(new Call(start, event));
        start = null;
      }
    }

    BigDecimal totalBill = new BigDecimal(0);
    List<LineItem> items = new ArrayList<LineItem>();

    for (Call call : calls) {

      Tariff tariff = CentralTariffDatabase.getInstance().tarriffFor(customer);

      BigDecimal cost;

      DaytimePeakPeriod peakPeriod = new DaytimePeakPeriod();
      if (peakPeriod.offPeak(call.startTime())
          && peakPeriod.offPeak(call.endTime())
          && call.durationSeconds() < 12 * 60 * 60) {
        cost = new BigDecimal(call.durationSeconds()).multiply(tariff.offPeakRate());
      } else {
        cost = new BigDecimal(call.durationSeconds()).multiply(tariff.peakRate());
      }

      cost = cost.setScale(0, RoundingMode.HALF_UP);
      BigDecimal callCost = cost;
      totalBill = totalBill.add(callCost);
      items.add(new LineItem(call, callCost));
    }

    new BillGenerator().send(customer, items, MoneyFormatter.penceToPounds(totalBill));
  }
 /** Build a new fake request corresponding to a given route call */
 public static FakeRequest fakeRequest(Call call) {
   return fakeRequest(call.method(), call.url());
 }
  /** Creates sound level related components. */
  private void createSoundLevelIndicators() {
    TransparentPanel localLevelPanel = new TransparentPanel(new BorderLayout(5, 0));
    TransparentPanel remoteLevelPanel = new TransparentPanel(new BorderLayout(5, 0));

    localLevel =
        new InputVolumeControlButton(
            call, ImageLoader.MICROPHONE, ImageLoader.MUTE_BUTTON, false, false);
    remoteLevel =
        new OutputVolumeControlButton(call.getConference(), ImageLoader.HEADPHONE, false, false)
            .getComponent();

    final SoundLevelIndicator localLevelIndicator =
        new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL);
    final SoundLevelIndicator remoteLevelIndicator =
        new SoundLevelIndicator(SoundLevelChangeEvent.MIN_LEVEL, SoundLevelChangeEvent.MAX_LEVEL);

    localLevelPanel.add(localLevel, BorderLayout.WEST);
    localLevelPanel.add(localLevelIndicator, BorderLayout.CENTER);
    remoteLevelPanel.add(remoteLevel, BorderLayout.WEST);
    remoteLevelPanel.add(remoteLevelIndicator, BorderLayout.CENTER);

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.insets = new Insets(10, 0, 0, 0);

    add(localLevelPanel, constraints);

    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 0;
    constraints.gridy = 6;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.insets = new Insets(5, 0, 10, 0);

    add(remoteLevelPanel, constraints);

    if (!GuiActivator.getConfigurationService()
        .getBoolean(
            "net.java.sip.communicator.impl.gui.main.call." + "DISABLE_SOUND_LEVEL_INDICATORS",
            false)) {
      callPeer.addStreamSoundLevelListener(
          new SoundLevelListener() {
            public void soundLevelChanged(Object source, int level) {
              remoteLevelIndicator.updateSoundLevel(level);
            }
          });
      /*
       * By the time the UI gets to be initialized, the callPeer may have
       * been removed from its Call. As far as the UI is concerned, the
       * callPeer will never have a Call again and there will be no audio
       * levels to display anyway so there is no point in throwing a
       * NullPointerException here.
       */
      if (call != null) {
        call.addLocalUserSoundLevelListener(
            new SoundLevelListener() {
              public void soundLevelChanged(Object source, int level) {
                localLevelIndicator.updateSoundLevel(level);
              }
            });
      }
    }
  }
Exemple #9
0
  /**
   * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("call")) {
      Component selectedPanel = mainFrame.getSelectedTab();

      // call button is pressed over an already open call panel
      if (selectedPanel != null
          && selectedPanel instanceof CallPanel
          && ((CallPanel) selectedPanel).getCall().getCallState()
              == CallState.CALL_INITIALIZATION) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Iterator participantPanels = callPanel.getParticipantsPanels();

        while (participantPanels.hasNext()) {
          CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next();

          panel.setState("Connecting");
        }

        Call call = callPanel.getCall();

        answerCall(call);
      }
      // call button is pressed over the call list
      else if (selectedPanel != null
          && selectedPanel instanceof CallListPanel
          && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) {

        CallListPanel callListPanel = (CallListPanel) selectedPanel;

        GuiCallParticipantRecord callRecord =
            (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue();

        String stringContact = callRecord.getParticipantName();

        createCall(stringContact);
      }
      // call button is pressed over the contact list
      else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) {
        // call button is pressed when a meta contact is selected
        if (isCallMetaContact) {
          Object[] selectedContacts =
              mainFrame.getContactListPanel().getContactList().getSelectedValues();

          Vector telephonyContacts = new Vector();

          for (int i = 0; i < selectedContacts.length; i++) {

            Object o = selectedContacts[i];

            if (o instanceof MetaContact) {

              Contact contact =
                  ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class);

              if (contact != null) telephonyContacts.add(contact);
              else {
                new ErrorDialog(
                        this.mainFrame,
                        Messages.getI18NString("warning").getText(),
                        Messages.getI18NString(
                                "contactNotSupportingTelephony",
                                new String[] {((MetaContact) o).getDisplayName()})
                            .getText())
                    .showDialog();
              }
            }
          }

          if (telephonyContacts.size() > 0) createCall(telephonyContacts);

        } else if (!phoneNumberCombo.isComboFieldEmpty()) {

          // if no contact is selected checks if the user has chosen
          // or has
          // writen something in the phone combo box

          String stringContact = phoneNumberCombo.getEditor().getItem().toString();

          createCall(stringContact);
        }
      } else if (selectedPanel != null && selectedPanel instanceof DialPanel) {
        String stringContact = phoneNumberCombo.getEditor().getItem().toString();
        createCall(stringContact);
      }
    } else if (buttonName.equalsIgnoreCase("hangup")) {
      Component selectedPanel = this.mainFrame.getSelectedTab();

      if (selectedPanel != null && selectedPanel instanceof CallPanel) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
        NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Call call = callPanel.getCall();

        if (removeCallTimers.containsKey(callPanel)) {
          ((Timer) removeCallTimers.get(callPanel)).stop();
          removeCallTimers.remove(callPanel);
        }

        removeCallPanel(callPanel);

        if (call != null) {
          ProtocolProviderService pps = call.getProtocolProvider();

          OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps);

          Iterator participants = call.getCallParticipants();

          while (participants.hasNext()) {
            try {
              // now we hang up the first call participant in the
              // call
              telephony.hangupCallParticipant((CallParticipant) participants.next());
            } catch (OperationFailedException e) {
              logger.error("Hang up was not successful: " + e);
            }
          }
        }
      }
    } else if (buttonName.equalsIgnoreCase("minimize")) {
      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true);

      this.setCallPanelVisible(false);
    } else if (buttonName.equalsIgnoreCase("restore")) {

      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false);

      this.setCallPanelVisible(true);
    }
  }
Exemple #10
0
  public Call semantic_analysis() {
    Call c = new Call(name, null, start, end);

    if (name.equals("scanf")) {
      Expr arg = args.arr.get(0);
      if (arg instanceof SingleIdExpr) {
        SingleIdExpr sarg = (SingleIdExpr) arg;
        STElem ste = get_sym_table_elem(sarg.name);
        ste.get_T(writer);
        writer.println("    READ  MEM(VR(0)@)");
      } else if (arg instanceof ArrayIdExpr) {
        ArrayIdExpr aarg = (ArrayIdExpr) arg;
        STElem ste = get_sym_table_elem(aarg.name);

        aarg.expr.semantic_analysis();
        block_idx++;
        writer.println("    MOVE  VR(0)@ VR(" + block_idx + ")");
        ste.get_T(writer);
        writer.println("    ADD   MEM(VR(0)@)@ VR(" + block_idx + ")@ VR(0)");
        writer.println("    READ  MEM(VR(0)@)");
        block_idx--;
      } else {
        semantic_error(this, "<scanf> should have an argument with Ident form.");
      }
      this.tn = TypeName.INT;
      return this;
    } else if (name.equals("printf")) {
      Expr _arg = args.arr.get(0).semantic_analysis();
      writer.println("    WRITE VR(0)@");

      args.arr.remove(0);
      args.add(_arg);
      this.tn = TypeName.INT;
      return this;
    } else {
      // function existance check
      FuncTable ft = get_fun_table(name);
      int param_size = 0;
      int i;
      if (ft == null) semantic_error(c, "Function " + name + " is not defined.");

      for (i = block_idx; i >= 1; i--) {
        push("VR(" + i + ")@");
      }

      if (args != null) {
        c.args = new ArgList();
        c.args.start = args.start;
        c.args.end = args.end;

        // argument size check
        int arg_size = args.arr.size();
        param_size = ft.arr.size();
        if (arg_size != param_size)
          semantic_error(
              c, "The number of arguments of function " + name + " should be " + param_size);

        // argument type check
        for (i = 0; i < param_size; i++) {
          Expr arg = args.arr.get(i);
          STElem param = ft.arr.get(i);

          Expr _arg = arg.semantic_analysis();
          if (param.is_array()) {
            // array type check
            if (param.typ.typ == TypeName.INT && _arg.tn != TypeName.INT_ARR)
              semantic_error(
                  _arg,
                  "Argument"
                      + (i + 1)
                      + " of the function "
                      + name
                      + " should have int array type.");
            if (param.typ.typ == TypeName.FLOAT && _arg.tn != TypeName.FLOAT_ARR)
              semantic_error(
                  _arg,
                  "Argument"
                      + (i + 1)
                      + " of the function "
                      + name
                      + " should have float array type.");
            push("VR(0)@");
          } else {
            if (param.typ.typ == TypeName.INT && _arg.tn != TypeName.INT) {
              if (_arg.tn == TypeName.FLOAT)
                semantic_warning(_arg, "This expression should have int type.");
              else semantic_error(_arg, "This expression should have int type.");
              _arg = new FloatToInt(_arg);
              writer.println("    F2I   VR(0)@ VR(0)");
            }
            if (param.typ.typ == TypeName.FLOAT && _arg.tn != TypeName.FLOAT) {
              if (_arg.tn == TypeName.INT)
                semantic_warning(_arg, "This expression should have int type.");
              else semantic_error(_arg, "This expression should have int type.");
              _arg = new IntToFloat(_arg);
              writer.println("    I2F   VR(0)@ VR(0)");
            }
            push("VR(0)@");
          }
          c.args.add(_arg);
        }
      }
      int ret_label_num = label_num++;
      push("_L" + ret_label_num);
      push("FP@");
      writer.println("    MOVE  SP@ FP");
      writer.println("    JMP   " + name);
      writer.println("LAB _L" + ret_label_num);
      writer.println("    SUB   SP@ " + (param_size + 1) + " SP");
      for (i = 1; i <= block_idx; i++) {
        pop("VR(" + i + ")");
      }
      c.tn = ft.typ.typ;
    }

    return c;
  }
 public String durationMinutes() {
   return ""
       + call.durationSeconds() / 60
       + ":"
       + String.format("%02d", call.durationSeconds() % 60);
 }
 public String callee() {
   return call.callee();
 }
 public String date() {
   return call.date();
 }
Exemple #14
0
 /** Build a new fake request corresponding to a given route call */
 public static RequestBuilder fakeRequest(Call call) {
   return fakeRequest(call.method(), call.url());
 }
Exemple #15
0
 public static boolean isSafeCall(@NotNull Call call) {
   ASTNode callOperationNode = call.getCallOperationNode();
   return callOperationNode != null && callOperationNode.getElementType() == JetTokens.SAFE_ACCESS;
 }