aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-06 14:34:43 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-05 14:30:39 +0800
commitce8a8930c60b7dbb45f14ed49e8473c4f78e9686 (patch)
treeb88094e7fe729d65273f54d5554bd41ed4e072c7
parent5ead12fb5b53cea0c8a97e8f101e2d729ca47282 (diff)
downloadgsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar.gz
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar.bz2
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar.lz
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar.xz
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.tar.zst
gsoc2013-empathy-ce8a8930c60b7dbb45f14ed49e8473c4f78e9686.zip
Add SMS entry to empathy-individual-menu
-rw-r--r--libempathy-gtk/empathy-images.h1
-rw-r--r--libempathy-gtk/empathy-individual-menu.c65
-rw-r--r--libempathy-gtk/empathy-individual-menu.h5
-rw-r--r--libempathy/empathy-contact.c21
-rw-r--r--libempathy/empathy-contact.h3
5 files changed, 94 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-images.h b/libempathy-gtk/empathy-images.h
index 2c40b2ae7..86f1db641 100644
--- a/libempathy-gtk/empathy-images.h
+++ b/libempathy-gtk/empathy-images.h
@@ -40,6 +40,7 @@ G_BEGIN_DECLS
#define EMPATHY_IMAGE_TYPING "user-typing"
#define EMPATHY_IMAGE_CONTACT_INFORMATION "gtk-info"
#define EMPATHY_IMAGE_GROUP_MESSAGE "system-users"
+#define EMPATHY_IMAGE_SMS "stock_cell-phone"
#define EMPATHY_IMAGE_VOIP "audio-input-microphone"
#define EMPATHY_IMAGE_VIDEO_CALL "camera-web"
#define EMPATHY_IMAGE_LOG "document-open-recent"
diff --git a/libempathy-gtk/empathy-individual-menu.c b/libempathy-gtk/empathy-individual-menu.c
index 3e404c39f..70846c763 100644
--- a/libempathy-gtk/empathy-individual-menu.c
+++ b/libempathy-gtk/empathy-individual-menu.c
@@ -149,6 +149,14 @@ individual_menu_add_personas (GtkMenuShell *menu,
gtk_widget_show (action);
}
+ /* SMS */
+ if (features & EMPATHY_INDIVIDUAL_FEATURE_SMS)
+ {
+ action = empathy_individual_sms_menu_item_new (NULL, contact);
+ gtk_menu_shell_append (GTK_MENU_SHELL (contact_submenu), action);
+ gtk_widget_show (action);
+ }
+
if (features & EMPATHY_INDIVIDUAL_FEATURE_CALL)
{
/* Audio Call */
@@ -238,6 +246,17 @@ constructed (GObject *object)
}
}
+ /* SMS */
+ if (features & EMPATHY_INDIVIDUAL_FEATURE_SMS)
+ {
+ item = empathy_individual_sms_menu_item_new (individual, NULL);
+ if (item != NULL)
+ {
+ gtk_menu_shell_append (shell, item);
+ gtk_widget_show (item);
+ }
+ }
+
if (features & EMPATHY_INDIVIDUAL_FEATURE_CALL)
{
/* Audio Call */
@@ -537,6 +556,52 @@ empathy_individual_chat_menu_item_new (FolksIndividual *individual,
}
static void
+empathy_individual_sms_menu_item_activated (GtkMenuItem *item,
+ EmpathyContact *contact)
+{
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ empathy_dispatcher_sms_contact_id (
+ empathy_contact_get_account (contact),
+ empathy_contact_get_id (contact),
+ gtk_get_current_event_time ());
+}
+
+GtkWidget *
+empathy_individual_sms_menu_item_new (FolksIndividual *individual,
+ EmpathyContact *contact)
+{
+ GtkWidget *item;
+ GtkWidget *image;
+
+ g_return_val_if_fail ((FOLKS_IS_INDIVIDUAL (individual) &&
+ empathy_folks_individual_contains_contact (individual)) ||
+ EMPATHY_IS_CONTACT (contact),
+ NULL);
+
+ item = gtk_image_menu_item_new_with_mnemonic (_("_SMS"));
+ image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_SMS,
+ GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+ gtk_widget_show (image);
+
+ if (contact != NULL)
+ {
+ menu_item_set_contact (item, contact,
+ G_CALLBACK (empathy_individual_sms_menu_item_activated),
+ EMPATHY_ACTION_SMS);
+ }
+ else
+ {
+ menu_item_set_first_contact (item, individual,
+ G_CALLBACK (empathy_individual_sms_menu_item_activated),
+ EMPATHY_ACTION_SMS);
+ }
+
+ return item;
+}
+
+static void
empathy_individual_audio_call_menu_item_activated (GtkMenuItem *item,
EmpathyContact *contact)
{
diff --git a/libempathy-gtk/empathy-individual-menu.h b/libempathy-gtk/empathy-individual-menu.h
index 5b3d220df..c2841ad6d 100644
--- a/libempathy-gtk/empathy-individual-menu.h
+++ b/libempathy-gtk/empathy-individual-menu.h
@@ -36,7 +36,8 @@ typedef enum {
EMPATHY_INDIVIDUAL_FEATURE_INFO = 1 << 4,
EMPATHY_INDIVIDUAL_FEATURE_FAVOURITE = 1 << 5,
EMPATHY_INDIVIDUAL_FEATURE_LINK = 1 << 6,
- EMPATHY_INDIVIDUAL_FEATURE_ALL = (1 << 7) - 1,
+ EMPATHY_INDIVIDUAL_FEATURE_SMS = 1 << 7,
+ EMPATHY_INDIVIDUAL_FEATURE_ALL = (1 << 8) - 1,
} EmpathyIndividualFeatureFlags;
#define EMPATHY_TYPE_INDIVIDUAL_MENU (empathy_individual_menu_get_type ())
@@ -69,6 +70,8 @@ GtkWidget * empathy_individual_menu_new (FolksIndividual *individual,
EmpathyIndividualFeatureFlags features);
GtkWidget * empathy_individual_chat_menu_item_new (FolksIndividual *individual,
EmpathyContact *contact);
+GtkWidget * empathy_individual_sms_menu_item_new (FolksIndividual *individual,
+ EmpathyContact *contact);
GtkWidget * empathy_individual_audio_call_menu_item_new (
FolksIndividual *individual,
EmpathyContact *contact);
diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c
index 680094a54..620c479e2 100644
--- a/libempathy/empathy-contact.c
+++ b/libempathy/empathy-contact.c
@@ -1098,6 +1098,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;
@@ -1189,6 +1201,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;
@@ -1729,6 +1744,12 @@ tp_caps_to_capabilities (TpCapabilities *caps)
TP_PROP_CHANNEL_TYPE_STREAMED_MEDIA_INITIAL_VIDEO, NULL))
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 f9217c108..16b50e500 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,