diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact.c | 21 | ||||
-rw-r--r-- | libempathy/empathy-contact.h | 3 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.c | 51 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.h | 5 |
4 files changed, 59 insertions, 21 deletions
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 3706658fa..a9503e14a 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -1075,6 +1075,18 @@ empathy_contact_get_status (EmpathyContact *contact) } gboolean +empathy_contact_can_sms (EmpathyContact *contact) +{ + EmpathyContactPriv *priv; + + g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), FALSE); + + priv = GET_PRIV (contact); + + return priv->capabilities & EMPATHY_CAPABILITIES_SMS; +} + +gboolean empathy_contact_can_voip (EmpathyContact *contact) { EmpathyContactPriv *priv; @@ -1166,6 +1178,9 @@ empathy_contact_can_do_action (EmpathyContact *self, case EMPATHY_ACTION_CHAT: sensitivity = TRUE; break; + case EMPATHY_ACTION_SMS: + sensitivity = empathy_contact_can_sms (self); + break; case EMPATHY_ACTION_AUDIO_CALL: sensitivity = empathy_contact_can_voip_audio (self); break; @@ -1697,6 +1712,12 @@ tp_caps_to_capabilities (TpCapabilities *caps) capabilities |= EMPATHY_CAPABILITIES_VIDEO; } } + else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT)) + { + if (tp_asv_get_boolean (fixed_prop, + TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL)) + capabilities |= EMPATHY_CAPABILITIES_SMS; + } } return capabilities; diff --git a/libempathy/empathy-contact.h b/libempathy/empathy-contact.h index 005cf1e7a..1eb493e84 100644 --- a/libempathy/empathy-contact.h +++ b/libempathy/empathy-contact.h @@ -67,6 +67,7 @@ typedef enum { EMPATHY_CAPABILITIES_VIDEO = 1 << 1, EMPATHY_CAPABILITIES_FT = 1 << 2, EMPATHY_CAPABILITIES_RFB_STREAM_TUBE = 1 << 3, + EMPATHY_CAPABILITIES_SMS = 1 << 4, EMPATHY_CAPABILITIES_UNKNOWN = 1 << 7 } EmpathyCapabilities; @@ -94,6 +95,7 @@ void empathy_contact_set_is_user (EmpathyContact *contact, gboolean is_user); gboolean empathy_contact_is_online (EmpathyContact *contact); const gchar * empathy_contact_get_status (EmpathyContact *contact); +gboolean empathy_contact_can_sms (EmpathyContact *contact); gboolean empathy_contact_can_voip (EmpathyContact *contact); gboolean empathy_contact_can_voip_audio (EmpathyContact *contact); gboolean empathy_contact_can_voip_video (EmpathyContact *contact); @@ -102,6 +104,7 @@ gboolean empathy_contact_can_use_rfb_stream_tube (EmpathyContact *contact); typedef enum { EMPATHY_ACTION_CHAT, + EMPATHY_ACTION_SMS, EMPATHY_ACTION_AUDIO_CALL, EMPATHY_ACTION_VIDEO_CALL, EMPATHY_ACTION_VIEW_LOGS, diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index 2a009b34a..b1cc1d267 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -509,9 +509,11 @@ ensure_text_channel_cb (GObject *source, } } -void -empathy_dispatcher_chat_with_contact_id (TpAccount *account, - const gchar *contact_id, +static void +empathy_dispatcher_create_text_channel (TpAccount *account, + TpHandleType target_handle_type, + const gchar *target_id, + gboolean sms_channel, gint64 timestamp) { GHashTable *request; @@ -520,10 +522,14 @@ empathy_dispatcher_chat_with_contact_id (TpAccount *account, request = tp_asv_new ( TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_CONTACT, - TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, contact_id, + TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, target_handle_type, + TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, target_id, NULL); + if (sms_channel) + tp_asv_set_boolean (request, + TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, TRUE); + req = tp_account_channel_request_new (account, request, timestamp); tp_account_channel_request_ensure_channel_async (req, NULL, NULL, @@ -534,27 +540,30 @@ empathy_dispatcher_chat_with_contact_id (TpAccount *account, } void +empathy_dispatcher_chat_with_contact_id (TpAccount *account, + const gchar *contact_id, + gint64 timestamp) +{ + empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_CONTACT, + contact_id, FALSE, timestamp); +} + +void empathy_dispatcher_join_muc (TpAccount *account, const gchar *room_name, gint64 timestamp) { - GHashTable *request; - TpAccountChannelRequest *req; - - request = tp_asv_new ( - TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING, - TP_IFACE_CHANNEL_TYPE_TEXT, - TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT, TP_HANDLE_TYPE_ROOM, - TP_PROP_CHANNEL_TARGET_ID, G_TYPE_STRING, room_name, - NULL); - - req = tp_account_channel_request_new (account, request, timestamp); - - tp_account_channel_request_ensure_channel_async (req, NULL, NULL, - ensure_text_channel_cb, NULL); + empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_ROOM, + room_name, FALSE, timestamp); +} - g_hash_table_unref (request); - g_object_unref (req); +void +empathy_dispatcher_sms_contact_id (TpAccount *account, + const gchar *contact_id, + gint64 timestamp) +{ + empathy_dispatcher_create_text_channel (account, TP_HANDLE_TYPE_CONTACT, + contact_id, TRUE, timestamp); } static gboolean diff --git a/libempathy/empathy-dispatcher.h b/libempathy/empathy-dispatcher.h index cd54fa5d1..19da9dde5 100644 --- a/libempathy/empathy-dispatcher.h +++ b/libempathy/empathy-dispatcher.h @@ -70,6 +70,11 @@ void empathy_dispatcher_join_muc (TpAccount *account, const gchar *roomname, gint64 timestamp); +void +empathy_dispatcher_sms_contact_id (TpAccount *account, + const gchar *contact_id, + gint64 timestamp); + void empathy_dispatcher_find_requestable_channel_classes_async (EmpathyDispatcher *dispatcher, TpConnection *connection, const gchar *channel_type, guint handle_type, |