aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-11-04 00:15:50 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-04 00:15:50 +0800
commit22c06bcfd832f65fe2de6e44657e22decf2f523d (patch)
tree78a97f274bae9b135d27796187e856cd5f22905e /libempathy
parent2fdf42815677e4e7f41a73f77997af87d5ae5eb2 (diff)
parente31c0e3f3b9a12dcf280a1ec05fc58463a020d71 (diff)
downloadgsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar.gz
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar.bz2
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar.lz
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar.xz
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.tar.zst
gsoc2013-empathy-22c06bcfd832f65fe2de6e44657e22decf2f523d.zip
Merge branch 'irc-command'
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-message.c56
-rw-r--r--libempathy/empathy-message.h1
-rw-r--r--libempathy/empathy-tp-chat.c73
-rw-r--r--libempathy/empathy-tp-chat.h11
4 files changed, 61 insertions, 80 deletions
diff --git a/libempathy/empathy-message.c b/libempathy/empathy-message.c
index a403766e4..705bd224b 100644
--- a/libempathy/empathy-message.c
+++ b/libempathy/empathy-message.c
@@ -234,62 +234,6 @@ message_set_property (GObject *object,
};
}
-static gboolean
-has_prefix_case (const gchar *s,
- const gchar *prefix)
-{
- return g_ascii_strncasecmp (s, prefix, strlen (prefix)) == 0;
-}
-
-/*
- * Constructs an EmpathyMessage based on user input, which may include "/me"
- * and friends.
- *
- * Returns: an #EmpathyMessage if @message could be parsed, or %NULL if
- * @message was an unknown command.
- */
-EmpathyMessage *
-empathy_message_new_from_entry (const gchar *message)
-{
- TpChannelTextMessageType t = TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL;
-
- g_return_val_if_fail (message != NULL, NULL);
-
- if (message[0] == '/') {
- if (g_ascii_strcasecmp (message, "/me") == 0) {
- message = "";
- t = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
- } else if (has_prefix_case (message, "/me ")) {
- message += strlen ("/me ");
- t = TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION;
- } else if (has_prefix_case (message, "/say ")) {
- message += strlen ("/say ");
- } else {
- /* Also allow messages with two slashes before the
- * first space, so it is possible to send a /unix/path.
- * This heuristic is kind of crap.
- */
- gboolean second_slash = FALSE;
- const gchar *m = message + 1;
-
- while (!second_slash && *m != '\0' && *m != ' ') {
- if (*m == '/')
- second_slash = TRUE;
-
- m++;
- }
-
- if (!second_slash)
- return NULL;
- }
- }
-
- return g_object_new (EMPATHY_TYPE_MESSAGE,
- "type", t,
- "body", message,
- NULL);
-}
-
EmpathyMessage *
empathy_message_new (const gchar *body)
{
diff --git a/libempathy/empathy-message.h b/libempathy/empathy-message.h
index 7ca624031..09175e625 100644
--- a/libempathy/empathy-message.h
+++ b/libempathy/empathy-message.h
@@ -52,7 +52,6 @@ struct _EmpathyMessageClass {
};
GType empathy_message_get_type (void) G_GNUC_CONST;
-EmpathyMessage * empathy_message_new_from_entry (const gchar *message);
EmpathyMessage * empathy_message_new (const gchar *body);
TpChannelTextMessageType empathy_message_get_tptype (EmpathyMessage *message);
void empathy_message_set_tptype (EmpathyMessage *message,
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 09077538a..83faaff39 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -58,13 +58,6 @@ typedef struct {
gboolean ready;
} EmpathyTpChatPriv;
-typedef struct {
- gchar *name;
- guint id;
- TpPropertyFlags flags;
- GValue *value;
-} TpChatProperty;
-
static void tp_chat_iface_init (EmpathyContactListIface *iface);
enum {
@@ -493,10 +486,10 @@ tp_chat_property_flags_changed_cb (TpProxy *proxy,
}
for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
- guint id;
- guint flags;
+ GValueArray *prop_struct;
+ EmpathyTpChatProperty *property;
+ guint id;
+ guint flags;
prop_struct = g_ptr_array_index (properties, i);
id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
@@ -531,10 +524,10 @@ tp_chat_properties_changed_cb (TpProxy *proxy,
}
for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
- guint id;
- GValue *src_value;
+ GValueArray *prop_struct;
+ EmpathyTpChatProperty *property;
+ guint id;
+ GValue *src_value;
prop_struct = g_ptr_array_index (properties, i);
id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
@@ -597,11 +590,11 @@ tp_chat_list_properties_cb (TpProxy *proxy,
ids = g_array_sized_new (FALSE, FALSE, sizeof (guint), properties->len);
priv->properties = g_ptr_array_sized_new (properties->len);
for (i = 0; i < properties->len; i++) {
- GValueArray *prop_struct;
- TpChatProperty *property;
+ GValueArray *prop_struct;
+ EmpathyTpChatProperty *property;
prop_struct = g_ptr_array_index (properties, i);
- property = g_slice_new0 (TpChatProperty);
+ property = g_slice_new0 (EmpathyTpChatProperty);
property->id = g_value_get_uint (g_value_array_get_nth (prop_struct, 0));
property->name = g_value_dup_string (g_value_array_get_nth (prop_struct, 1));
property->flags = g_value_get_uint (g_value_array_get_nth (prop_struct, 3));
@@ -628,9 +621,13 @@ empathy_tp_chat_set_property (EmpathyTpChat *chat,
const gchar *name,
const GValue *value)
{
- EmpathyTpChatPriv *priv = GET_PRIV (chat);
- TpChatProperty *property;
- guint i;
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+ EmpathyTpChatProperty *property;
+ guint i;
+
+ if (!priv->had_properties_list) {
+ return;
+ }
for (i = 0; i < priv->properties->len; i++) {
property = g_ptr_array_index (priv->properties, i);
@@ -672,6 +669,36 @@ empathy_tp_chat_set_property (EmpathyTpChat *chat,
}
}
+EmpathyTpChatProperty *
+empathy_tp_chat_get_property (EmpathyTpChat *chat,
+ const gchar *name)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+ EmpathyTpChatProperty *property;
+ guint i;
+
+ if (!priv->had_properties_list) {
+ return NULL;
+ }
+
+ for (i = 0; i < priv->properties->len; i++) {
+ property = g_ptr_array_index (priv->properties, i);
+ if (!tp_strdiff (property->name, name)) {
+ return property;
+ }
+ }
+
+ return NULL;
+}
+
+GPtrArray *
+empathy_tp_chat_get_properties (EmpathyTpChat *chat)
+{
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+
+ return priv->properties;
+}
+
static void
tp_chat_dispose (GObject *object)
{
@@ -727,14 +754,14 @@ tp_chat_finalize (GObject *object)
if (priv->properties) {
for (i = 0; i < priv->properties->len; i++) {
- TpChatProperty *property;
+ EmpathyTpChatProperty *property;
property = g_ptr_array_index (priv->properties, i);
g_free (property->name);
if (property->value) {
tp_g_value_slice_free (property->value);
}
- g_slice_free (TpChatProperty, property);
+ g_slice_free (EmpathyTpChatProperty, property);
}
g_ptr_array_free (priv->properties, TRUE);
}
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index f7d2b58a1..f07f0648f 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -52,6 +52,13 @@ struct _EmpathyTpChatClass {
GObjectClass parent_class;
};
+typedef struct {
+ gchar *name;
+ guint id;
+ TpPropertyFlags flags;
+ GValue *value;
+} EmpathyTpChatProperty;
+
GType empathy_tp_chat_get_type (void) G_GNUC_CONST;
EmpathyTpChat *empathy_tp_chat_new (TpChannel *channel);
void empathy_tp_chat_close (EmpathyTpChat *chat);
@@ -67,6 +74,10 @@ void empathy_tp_chat_set_state (EmpathyTpChat *chat,
void empathy_tp_chat_set_property (EmpathyTpChat *chat,
const gchar *name,
const GValue *value);
+EmpathyTpChatProperty *
+ empathy_tp_chat_get_property (EmpathyTpChat *chat,
+ const gchar *name);
+GPtrArray * empathy_tp_chat_get_properties (EmpathyTpChat *chat);
/* Returns a read-only list of pending messages (should be a copy maybe ?) */
const GList * empathy_tp_chat_get_pending_messages (EmpathyTpChat *chat);