Example #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);
    }
}
Example #2
0
ModemRequest *
modem_call_request_dial (ModemCallService *self,
                         char const *destination,
                         ModemClirOverride clir,
                         ModemCallRequestDialReply callback,
                         gpointer user_data)
{
  char const *clir_str;
  ModemRequest *request;
  ModemCallServicePrivate *priv = self->priv;

  DEBUG ("called");

  RETURN_NULL_IF_NOT_VALID (self);
  g_return_val_if_fail (destination != NULL, NULL);
  g_return_val_if_fail (callback != NULL, NULL);

  modem_message (MODEM_LOG_CALL,
      "trying to create call to \"%s\"",
      destination);

  if (clir == MODEM_CLIR_OVERRIDE_DISABLED)
    clir_str = "disabled";
  else if (clir == MODEM_CLIR_OVERRIDE_ENABLED)
    clir_str = "enabled";
  else
    clir_str = "";

  request = modem_request_begin (self, DBUS_PROXY (self),
      "Dial", modem_call_request_dial_reply,
      G_CALLBACK (callback), user_data,
      G_TYPE_STRING, destination,
      G_TYPE_STRING, clir_str,
      G_TYPE_INVALID);


  modem_request_add_cancel_notify (request, request_notify_cancel);

  modem_request_add_data_full (request,
      "call-destination",
      g_strdup (destination),
      g_free);

  g_queue_push_tail (priv->dialing.queue, request);

  return request;
}
static void
on_incoming_message (DBusGProxy *proxy,
                     char const *message,
                     GHashTable *dict,
                     gpointer _self)
{
  char const *smsc = "1234567";
  char const *type = "text/plain";
  char const *originator = "";

  char *token;
  GError *error = NULL;
  GValue *value;
  SMSGDeliver *d;
  ModemSMSService *self = MODEM_SMS_SERVICE (_self);

  DEBUG ("message = \"%s\"", message);

  dump_message_dict (dict);

  value = g_hash_table_lookup (dict, "Sender");
  if (value)
    originator = g_value_get_string (value);

  token = modem_sms_generate_token ();

  d = sms_g_deliver_incoming (message, token, originator,
      smsc, type, NULL, &error);

  if (!d)
    {
      modem_message (MODEM_LOG_SMS,
          "deserializing SMS-DELIVER \"%s\" failed: "
          GERROR_MSG_FMT, token, GERROR_MSG_CODE (error));
      g_clear_error (&error);
    }
  else {
    modem_sms_incoming_deliver (self, d);
    g_object_unref (d);
  }

  g_free (token);
}
Example #4
0
static void
modem_call_request_dial_reply (DBusGProxy *proxy,
                               DBusGProxyCall *call,
                               void *_request)
{
  DEBUG ("enter");

  ModemRequest *request = _request;
  ModemCallService *self = MODEM_CALL_SERVICE (modem_request_object (request));
  ModemCallServicePrivate *priv = self->priv;
  ModemCallRequestDialReply *callback = modem_request_callback (request);
  gpointer user_data = modem_request_user_data (request);
  char *destination = modem_request_get_data (request, "call-destination");
  GError *error = NULL;
  ModemCall *ci = NULL;
  char *object_path = NULL;

  if (dbus_g_proxy_end_call (proxy, call, &error,
          DBUS_TYPE_G_OBJECT_PATH, &object_path,
          G_TYPE_INVALID))
    {
      ci = modem_call_service_get_dialed (self, object_path, destination);
    }
  else
    {
      object_path = NULL;
      modem_error_fix (&error);
    }

  if (ci)
    {
      DEBUG ("%s: instance %s (%p)", MODEM_OFACE_CALL_MANAGER ".Dial",
          object_path, (void *)ci);

      modem_message (MODEM_LOG_CALL,
          "call create request to \"%s\" successful",
          destination);
    }
  else
    {
      char ebuffer[32];

      modem_message (MODEM_LOG_CALL,
          "call create request to \"%s\" failed: %s.%s: %s",
          destination,
          modem_error_domain_prefix (error->domain),
          modem_error_name (error, ebuffer, sizeof ebuffer),
          error->message);

      DEBUG ("%s: " GERROR_MSG_FMT, MODEM_OFACE_CALL_MANAGER ".Dial",
          GERROR_MSG_CODE (error));
    }

  if (modem_request_get_data (request, "call-canceled"))
    {
      if (ci)
        modem_call_request_release (ci, NULL, NULL);
    }
  else
    {
      g_assert (ci || error);
      callback (self, request, ci, error, user_data);
    }

  if (g_queue_find (priv->dialing.queue, request))
    g_queue_remove (priv->dialing.queue, request);

  while (g_queue_is_empty (priv->dialing.queue) &&
      !g_queue_is_empty (priv->dialing.created))
    {
      char *remote;

      ci = g_queue_pop_head (priv->dialing.created);

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

      g_signal_emit (self, signals[SIGNAL_CREATED], 0, ci, remote);

      g_free (remote);
    }

  g_free (object_path);
  g_clear_error (&error);
}
Example #5
0
static void
on_modem_call_state (ModemCall *ci,
                     ModemCallState state,
                     ModemCallService *self)
{
  ModemCallServicePrivate *priv;
  gboolean releasing = FALSE;

  RETURN_IF_NOT_VALID (self);

  priv = self->priv;

  switch (state)
    {
    case MODEM_CALL_STATE_ACTIVE:
      if (priv->hold == ci)
        priv->hold = NULL;
      if (!modem_call_is_member (ci))
        priv->active = ci;
      break;

    case MODEM_CALL_STATE_HELD:
      if (priv->active == ci)
        priv->active = NULL;
      if (!modem_call_is_member (ci))
        priv->hold = ci;
      break;

    case MODEM_CALL_STATE_DISCONNECTED:
      releasing = TRUE;
      /* FALLTHROUGH */
    case MODEM_CALL_STATE_INVALID:
      if (priv->active == ci)
        priv->active = NULL;
      if (priv->hold == ci)
        priv->hold = NULL;
      break;

    default:
      break;
    }

#if nomore
  if (releasing)
    {
      GError *error = modem_call_new_error (causetype, cause, NULL);
      gboolean originating;
      char *remote;
      char const *what;

      g_object_get (ci,
          "originating", &originating,
          "remote", &remote,
          NULL);

      switch (state)
        {
        case MODEM_CALL_STATE_MO_RELEASE:
          what = "mo-released";
          break;
        case MODEM_CALL_STATE_MT_RELEASE:
          what = "mt-released";
          break;
        default:
          what = "terminated";
        }

      gboolean mpty = MODEM_IS_CALL_CONFERENCE (ci);

      modem_message (MODEM_LOG_CALL,
          "%s %s %s%s%s %s.%s: %s",
          what,
          mpty ? "conference"
          : originating ? "outgoing call to"
          : "incoming call from",
          mpty ? "" : "'",
          mpty ? "call" : remote,
          mpty ? "" : "'",
          modem_error_domain_prefix (error->domain),
          modem_error_name (error, NULL, 0),
          error->message);

      g_free (remote);
      g_error_free (error);
    }
#endif
}