Ejemplo n.º 1
0
    static void
send_message (GObject *object,
        TpMessage *message,
        TpMessageSendingFlags flags)
{
    FetionImChannel *self = FETION_IM_CHANNEL (object);
    TpBaseChannel *base = TP_BASE_CHANNEL (self);
    if (tp_asv_get_string (tp_message_peek (message, 0), "interface") != NULL)
    {
        /* this message is interface-specific - let's not echo it */
        goto finally;
    }

    FetionConnection *conn =
        FETION_CONNECTION (tp_base_channel_get_connection(base));

    HybridAccount *account = conn->priv->account;

    TpHandle from = tp_base_channel_get_target_handle (base);
    const GHashTable *input = tp_message_peek (message, 1);
    const gchar *send_message = tp_asv_get_string (input, "content");
    HybridBuddy *buddy = hybrid_blist_find_buddy_by_handle(account, from);
    hybrid_conv_send_message(account,buddy,send_message);

finally:
    /* "OK, we've sent the message" (after calling this, message must not be
     * dereferenced) */
    tp_message_mixin_sent (object, message, flags, "", NULL);

}
Ejemplo n.º 2
0
    static GObject *
constructor (GType type,
        guint n_props,
        GObjectConstructParam *props)
{
    GObject *object =
        G_OBJECT_CLASS (fetion_im_channel_parent_class)->constructor (type,
                n_props, props);
    FetionImChannel *self = FETION_IM_CHANNEL (object);
    TpBaseChannel *base = TP_BASE_CHANNEL (self);

    static TpChannelTextMessageType const types[] = {
        TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL,
        TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION,
        TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE
    };
    static const char * const content_types[] = { "text/plain", NULL };

    tp_base_channel_register (base);

    tp_message_mixin_init (object, G_STRUCT_OFFSET (FetionImChannel, text),
            tp_base_channel_get_connection (base));

    tp_message_mixin_implement_sending (object, send_message,
            G_N_ELEMENTS (types), types,0,
            TP_DELIVERY_REPORTING_SUPPORT_FLAG_RECEIVE_FAILURES,
            content_types);

    return object;
}
Ejemplo n.º 3
0
GabbleConnection *
gabble_call_member_get_connection (GabbleCallMember *self)
{
  TpBaseChannel *base_chan = TP_BASE_CHANNEL (self->priv->call);

  return GABBLE_CONNECTION (tp_base_channel_get_connection (base_chan));
}
static void
new_content (RakiaCallChannel *self,
    const gchar *name,
    RakiaSipMedia *media,
    TpCallContentDisposition disposition)
{
  TpBaseChannel *bchan = TP_BASE_CHANNEL (self);
  RakiaCallContent *content;
  TpMediaStreamType media_type;
  TpHandle creator;
  gchar *object_path;
  gchar *free_name = NULL;
  const gchar *media_type_name;

  switch (rakia_sip_media_get_media_type (media))
    {
    case TP_MEDIA_STREAM_TYPE_AUDIO:
      media_type = TP_MEDIA_STREAM_TYPE_AUDIO;
      media_type_name = "Audio";
      break;
    case TP_MEDIA_STREAM_TYPE_VIDEO:
      media_type = TP_MEDIA_STREAM_TYPE_VIDEO;
      media_type_name = "Video";
      break;
    default:
      g_assert_not_reached ();
    }

  if (rakia_sip_media_is_created_locally (media))
    creator = tp_base_channel_get_self_handle (bchan);
  else
    creator = tp_base_channel_get_target_handle (bchan);

  object_path = g_strdup_printf ("%s/Content%u",
      tp_base_channel_get_object_path (bchan), ++self->priv->last_content_no);

  if (name == NULL)
    name = free_name = g_strdup_printf ("%s %u", media_type_name,
        self->priv->last_content_no);

  /* We already request bidi for initial media,
   * the client can change it before accepting.
   */
  if (disposition == TP_CALL_CONTENT_DISPOSITION_INITIAL)
    rakia_sip_media_set_requested_direction (media,
        TP_MEDIA_STREAM_DIRECTION_BIDIRECTIONAL);


  content = rakia_call_content_new (self, media, object_path,
      tp_base_channel_get_connection (bchan), name,
      media_type, creator, disposition);

  g_free (free_name);
  g_free (object_path);

  tp_base_call_channel_add_content (TP_BASE_CALL_CHANNEL (self),
      TP_BASE_CALL_CONTENT (content));

  rakia_call_content_add_stream (content);
}
Ejemplo n.º 5
0
static void
lwqq_channel_init (LwqqChannel *self)
{
   LwqqChannelPrivate *priv;

   priv = LWQQ_CHANNEL_GET_PRIVATE (self);
   self->priv = priv;

   TpBaseChannel* base = TP_BASE_CHANNEL(self);
   GObject* obj = G_OBJECT(self);

   static TpChannelTextMessageType const types[] = {
      TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
   };

   static const char* const content_types[] = {"text/plain", NULL};

   tp_base_channel_register(base);

   tp_message_mixin_init(G_OBJECT(self), G_STRUCT_OFFSET(LwqqChannel, text),
         tp_base_channel_get_connection(base));

   tp_message_mixin_implement_sending(obj, send_message, G_N_ELEMENTS(types),
         types, 0, TP_DELIVERY_REPORTING_SUPPORT_FLAG_RECEIVE_FAILURES,
         content_types);
}
Ejemplo n.º 6
0
/** start send message **/
static void
send_message (GObject *object,
        TpMessage *message,
        TpMessageSendingFlags flags)
{
    LwqqChannel* self = LWQQ_CHANNEL(object);
    TpBaseChannel *base = TP_BASE_CHANNEL (self);
    if (tp_asv_get_string (tp_message_peek (message, 0), "interface") != NULL)
    {
        /* this message is interface-specific - let's not echo it */
        goto finally;
    }

    LwqqConnection *conn =
        LWQQ_CONNECTION(tp_base_channel_get_connection(base));

    LwqqClient* lc = conn->lc;

    TpHandle to = tp_base_channel_get_target_handle (base);
    const GHashTable *input = tp_message_peek (message, 1);
    const gchar *send_message = tp_asv_get_string (input, "content");
    LwqqBuddy* buddy = lwqq_find_buddy_by_handle(conn, to);
    lwqq_msg_send_text(lc, LWQQ_MS_BUDDY_MSG, buddy->uin, send_message);

finally:
    /* "OK, we've sent the message" (after calling this, message must not be
* dereferenced) */
    tp_message_mixin_sent (object, message, flags, "", NULL);
}
Ejemplo n.º 7
0
static void
gabble_server_sasl_channel_get_property (GObject *object,
    guint property_id,
    GValue *value,
    GParamSpec *pspec)
{
  TpBaseChannel *channel = TP_BASE_CHANNEL (object);
  GabbleServerSaslChannel *self =
    GABBLE_SERVER_SASL_CHANNEL (object);
  GabbleServerSaslChannelPrivate *priv = self->priv;

  switch (property_id)
    {
    case PROP_SASL_STATUS:
      g_value_set_uint (value, priv->sasl_status);
      break;
    case PROP_SASL_ERROR:
      g_value_set_string (value, priv->sasl_error);
      break;
    case PROP_SASL_ERROR_DETAILS:
      g_value_set_boxed (value, priv->sasl_error_details);
      break;
    case PROP_AUTH_METHOD:
      g_value_set_static_string (value,
          TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION);
      break;
    case PROP_AVAILABLE_MECHANISMS:
      g_value_set_boxed (value, priv->available_mechanisms);
      break;
    case PROP_SECURE:
      g_value_set_boolean (value, priv->secure);
      break;
    case PROP_CAN_TRY_AGAIN:
      /* Wocky can't retry SASL authentication (although XMPP can) */
      g_value_set_boolean (value, FALSE);
      break;
    case PROP_HAS_INITIAL_DATA:
      /* Yes, XMPP has "initial data" in its SASL */
      g_value_set_boolean (value, TRUE);
      break;
    case PROP_AUTHORIZATION_IDENTITY:
      /* As per RFC 3920, the authorization identity for c2s connections
       * is the desired JID. We can't use conn_util_get_bare_self_jid at
       * this stage of the connection process, because it hasn't been
       * initialized yet. */
        {
          gchar *jid, *username, *stream_server;

          g_object_get (tp_base_channel_get_connection (channel),
              "username", &username,
              "stream-server", &stream_server,
              NULL);
          jid = g_strconcat (username, "@", stream_server, NULL);
          g_free (username);
          g_free (stream_server);

          g_value_take_string (value, jid);
        }
      break;
    case PROP_DEFAULT_REALM:
      /* Like WockySaslDigestMd5, we use the stream server as the default
       * realm, for interoperability with servers that fail to supply a
       * realm but expect us to have this default. */
      g_object_get_property (
          G_OBJECT (tp_base_channel_get_connection (channel)), "stream-server",
          value);
      break;
    case PROP_DEFAULT_USERNAME:
      /* In practice, XMPP servers normally want us to authenticate as the
       * local-part of the JID. */
      g_object_get_property (
          G_OBJECT (tp_base_channel_get_connection (channel)), "username",
          value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}