Beispiel #1
0
void
modem_call_service_resume (ModemCallService *self)
{
  GHashTableIter iter[1];
  ModemCall *ci;

  DEBUG ("enter");
  RETURN_IF_NOT_VALID (self);

  /* XXX/KV: no such signal */
#if 0
  g_signal_emit (self, signals[SIGNAL_EMERGENCY_NUMBERS_CHANGED], 0,
      modem_call_get_emergency_numbers (self));
#endif

  g_hash_table_iter_init (iter, self->priv->instances);
  while (g_hash_table_iter_next (iter, NULL, (gpointer)&ci))
    {
      char *remote;
      gboolean terminating = FALSE;
      ModemCallState state;

      g_object_get (ci,
          "state", &state,
          "remote", &remote,
          "terminating", &terminating,
          NULL);

      if (state != MODEM_CALL_STATE_DISCONNECTED &&
          state != MODEM_CALL_STATE_INVALID)
        {

          /* XXX - atm the value of 'terminating' cannot be trusted.
           * oFono should probably provide the direction as a property
           * since we cannot rely on the call state here. */
          if (terminating)
            {
              modem_message (MODEM_LOG_CALL,
                  "incoming [with state %s] call from \"%s\"",
                  modem_call_get_state_name (state), remote);
              DEBUG ("emit \"incoming\"(%s (%p), %s)",
                  modem_call_get_name (ci), ci, remote);
              g_signal_emit (self, signals[SIGNAL_INCOMING], 0, ci, remote);
            }
          else {
            modem_message (MODEM_LOG_CALL,
                "created [with state %s] call to \"%s\"",
                modem_call_get_state_name (state), remote);
            DEBUG ("emit \"created\"(%s (%p), %s)",
                modem_call_get_name (ci), ci, remote);
            g_signal_emit (self, signals[SIGNAL_CREATED], 0, ci, remote);
          }

          g_signal_emit_by_name (ci, "state", state, 0, 0);
        }

      g_free (remote);
    }
}
END_TEST


START_TEST(test_modem_call_state)
{
  guint i;
  for (i = 0; i <= MODEM_CALL_STATE_DISCONNECTED; i++) {
    fail_unless(strcmp(modem_call_get_state_name(i), "UNKNOWN"));
  }
  fail_if(strcmp(modem_call_get_state_name(i), "UNKNOWN"));
}
static void
on_call_state (DBusGProxy *proxy,
               guint state,
               guint causetype,
               guint cause,
               ModemCall *self)
{
  ModemCallPrivate *priv = self->priv;

  g_assert (proxy); g_assert (self); g_assert (priv->proxy == proxy);

  DEBUG ("CallState (%s (%u), %u, %u) from %s%s",
      modem_call_get_state_name (state),
      state, causetype, cause, dbus_g_proxy_get_path (proxy),
      priv->handler ? "" : " (no channel)");

  g_object_set (self, "state", state,
      causetype > MODEM_CALL_CAUSE_TYPE_NETWORK
      /* Unknown causetype, ignore */
      ? NULL
      : "causetype", causetype,
      "cause", cause,
      NULL);

  switch (state)
    {
    case MODEM_CALL_STATE_INCOMING:
      g_object_set (self, "terminating", TRUE, NULL);
      break;
    case MODEM_CALL_STATE_DIALING:
      g_object_set (self, "originating", TRUE, NULL);
      break;

    case MODEM_CALL_STATE_INVALID:
      g_object_set (self,
          "remote", NULL,
          "emergency", NULL,
          "originating", FALSE,
          "terminating", FALSE,
          "onhold", FALSE,
          "multiparty", FALSE,
          NULL);
      break;
    }

  if (priv->handler == NULL)
    {
      switch (state)
        {
        case MODEM_CALL_STATE_DIALING:
        case MODEM_CALL_STATE_ALERTING:
        case MODEM_CALL_STATE_INCOMING:
        case MODEM_CALL_STATE_WAITING:
        case MODEM_CALL_STATE_ACTIVE:
        case MODEM_CALL_STATE_HELD:
          {
            char const *remote = priv->remote ? priv->remote : "";
            if (priv->terminating)
              g_signal_emit_by_name (priv->service, "incoming", self, remote);
            else if (priv->originating)
              g_signal_emit_by_name (priv->service, "created", self, remote);
          }
          break;
        default:
          break;
        }
    }

  g_signal_emit (self, call_signals[SIGNAL_STATE], 0, state, causetype, cause);

  if (state == MODEM_CALL_STATE_TERMINATED)
    {
      g_object_set (self,
          "remote", NULL,
          "emergency", NULL,
          "originating", FALSE,
          "terminating", FALSE,
          "onhold", FALSE,
          "multiparty", FALSE,
          NULL);
    }
}