if (strcmp (msg, "/clear") == 0) {
empathy_chat_view_clear (chat->view);
+ return;
+ } else if (g_str_has_prefix (msg, "/topic")) {
+ EmpathyTpChatProperty *property;
+ GValue value = {0, };
+ gchar *topic;
+
+ property = empathy_tp_chat_get_property (priv->tp_chat, "subject");
+ if (property == NULL) {
+ empathy_chat_view_append_event (chat->view,
+ _("This conversation does not have topic"));
+ return;
+ }
+
+ if (!(property->flags & TP_PROPERTY_FLAG_WRITE)) {
+ empathy_chat_view_append_event (chat->view,
+ _("You need to be a channel operator to do that"));
+ return;
+ }
+
+ topic = g_strstrip (g_strdup (msg + strlen ("/topic")));
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_take_string (&value, topic);
+ empathy_tp_chat_set_property (priv->tp_chat, "subject", &value);
+ g_value_unset (&value);
+
return;
}
chat->input_text_view);
gtk_widget_show (chat->input_text_view);
- /* Create contact list */
- chat_update_contacts_visibility (chat);
-
/* Initialy hide the topic, will be shown if not empty */
gtk_widget_hide (priv->hbox_topic);
{
EmpathyChat *chat = EMPATHY_CHAT (object);
- chat_create_ui (chat);
chat_add_logs (chat);
show_pending_messages (chat);
}
/* Add nick name completion */
priv->completion = g_completion_new ((GCompletionFunc) empathy_contact_get_name);
g_completion_set_compare (priv->completion, chat_contacts_completion_func);
+
+ chat_create_ui (chat);
}
EmpathyChat *
{
EmpathyChatPriv *priv = GET_PRIV (chat);
TpConnection *connection;
+ GPtrArray *properties;
g_return_if_fail (EMPATHY_IS_CHAT (chat));
g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
G_CALLBACK (chat_remote_contact_changed_cb),
chat);
+ /* Get initial value of properties */
+ properties = empathy_tp_chat_get_properties (priv->tp_chat);
+ if (properties != NULL) {
+ guint i;
+
+ for (i = 0; i < properties->len; i++) {
+ EmpathyTpChatProperty *property;
+
+ property = g_ptr_array_index (properties, i);
+ if (property->value == NULL)
+ continue;
+
+ chat_property_changed_cb (priv->tp_chat,
+ property->name,
+ property->value,
+ chat);
+ }
+ }
+
chat_remote_contact_changed_cb (chat);
if (chat->input_text_view) {
gboolean ready;
} EmpathyTpChatPriv;
-typedef struct {
- gchar *name;
- guint id;
- TpPropertyFlags flags;
- GValue *value;
-} TpChatProperty;
-
static void tp_chat_iface_init (EmpathyContactListIface *iface);
enum {
}
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));
}
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));
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));
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);
}
}
+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)
{
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);
}