empathy r601 - in trunk: docs/libempathy libempathy libempathy-gtk python python/pyempathy python/pyempathygtk
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r601 - in trunk: docs/libempathy libempathy libempathy-gtk python python/pyempathy python/pyempathygtk
- Date: Thu, 24 Jan 2008 16:33:34 +0000 (GMT)
Author: xclaesse
Date: Thu Jan 24 16:33:33 2008
New Revision: 601
URL: http://svn.gnome.org/viewvc/empathy?rev=601&view=rev
Log:
Remove EmpathyPresence object and have "presence" and "presence-message" properties directly in EmpathyContact
Added:
trunk/python/pyempathy.patch
Removed:
trunk/libempathy/empathy-presence.c
trunk/libempathy/empathy-presence.h
Modified:
trunk/docs/libempathy/libempathy-docs.sgml
trunk/docs/libempathy/libempathy.types
trunk/libempathy-gtk/empathy-chat-window.c
trunk/libempathy-gtk/empathy-contact-list-store.c
trunk/libempathy-gtk/empathy-contact-widget.c
trunk/libempathy-gtk/empathy-presence-chooser.c
trunk/libempathy-gtk/empathy-presence-chooser.h
trunk/libempathy-gtk/empathy-status-icon.c
trunk/libempathy-gtk/empathy-ui-utils.c
trunk/libempathy-gtk/empathy-ui-utils.h
trunk/libempathy/Makefile.am
trunk/libempathy/empathy-contact.c
trunk/libempathy/empathy-contact.h
trunk/libempathy/empathy-idle.c
trunk/libempathy/empathy-status-presets.c
trunk/libempathy/empathy-status-presets.h
trunk/libempathy/empathy-tp-contact-factory.c
trunk/libempathy/empathy-utils.c
trunk/libempathy/empathy-utils.h
trunk/python/README
trunk/python/pyempathy/pyempathy.defs
trunk/python/pyempathy/pyempathy.override
trunk/python/pyempathygtk/pyempathygtk.defs
Modified: trunk/docs/libempathy/libempathy-docs.sgml
==============================================================================
--- trunk/docs/libempathy/libempathy-docs.sgml (original)
+++ trunk/docs/libempathy/libempathy-docs.sgml Thu Jan 24 16:33:33 2008
@@ -30,7 +30,6 @@
<xi:include href="xml/empathy-idle.xml"/>
<xi:include href="xml/empathy-log-manager.xml"/>
<xi:include href="xml/empathy-message.xml"/>
- <xi:include href="xml/empathy-presence.xml"/>
<xi:include href="xml/empathy-status-presets.xml"/>
<xi:include href="xml/empathy-time.xml"/>
<xi:include href="xml/empathy-tp-call.xml"/>
Modified: trunk/docs/libempathy/libempathy.types
==============================================================================
--- trunk/docs/libempathy/libempathy.types (original)
+++ trunk/docs/libempathy/libempathy.types Thu Jan 24 16:33:33 2008
@@ -8,7 +8,6 @@
empathy_idle_get_type
empathy_log_manager_get_type
empathy_message_get_gtype
-empathy_presence_get_type
empathy_tp_call_get_type
empathy_tp_chat_get_type
empathy_tp_chatroom_get_type
Modified: trunk/libempathy-gtk/empathy-chat-window.c
==============================================================================
--- trunk/libempathy-gtk/empathy-chat-window.c (original)
+++ trunk/libempathy-gtk/empathy-chat-window.c Thu Jan 24 16:33:33 2008
@@ -781,21 +781,21 @@
chat_window_show_contacts_toggled_cb,
window);
} else {
- EmpathyPrivateChat *chat;
- EmpathyContact *contact;
- EmpathyPresence *presence;
+ EmpathyPrivateChat *chat;
+ EmpathyContact *contact;
+ McPresence presence;
chat = EMPATHY_PRIVATE_CHAT (priv->current_chat);
/* Show / Hide widgets */
gtk_widget_hide (priv->menu_room);
- /* presence==NULL means this contact refuses to send us his
+ /* Unset presence means this contact refuses to send us his
* presence. By adding the contact we ask the contact to accept
* to send his presence. */
contact = empathy_private_chat_get_contact (chat);
presence = empathy_contact_get_presence (contact);
- if (!presence) {
+ if (presence == MC_PRESENCE_UNSET) {
gtk_widget_show (priv->menu_conv_add_contact);
} else {
gtk_widget_hide (priv->menu_conv_add_contact);
Modified: trunk/libempathy-gtk/empathy-contact-list-store.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-list-store.c (original)
+++ trunk/libempathy-gtk/empathy-contact-list-store.c Thu Jan 24 16:33:33 2008
@@ -820,6 +820,9 @@
g_signal_connect (contact, "notify::presence",
G_CALLBACK (contact_list_store_contact_updated_cb),
store);
+ g_signal_connect (contact, "notify::presence-message",
+ G_CALLBACK (contact_list_store_contact_updated_cb),
+ store);
g_signal_connect (contact, "notify::name",
G_CALLBACK (contact_list_store_contact_updated_cb),
store);
@@ -1351,8 +1354,8 @@
gint ret_val = 0;
gchar *name_a, *name_b;
gboolean is_separator_a, is_separator_b;
- EmpathyContact *contact_a, *contact_b;
- EmpathyPresence *presence_a, *presence_b;
+ EmpathyContact *contact_a, *contact_b;
+ guint presence_a, presence_b;
gtk_tree_model_get (model, iter_a,
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a,
@@ -1389,32 +1392,17 @@
* the presences.
*/
presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a));
+ presence_a = contact_list_store_ordered_presence (presence_a);
presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b));
+ presence_b = contact_list_store_ordered_presence (presence_b);
- if (!presence_a && presence_b) {
- ret_val = 1;
- } else if (presence_a && !presence_b) {
+ if (presence_a < presence_b) {
ret_val = -1;
- } else if (!presence_a && !presence_b) {
- /* Both offline, sort by name */
- ret_val = g_utf8_collate (name_a, name_b);
+ } else if (presence_a > presence_b) {
+ ret_val = 1;
} else {
- guint state_a, state_b;
-
- state_a = empathy_presence_get_state (presence_a);
- state_b = empathy_presence_get_state (presence_b);
-
- state_a = contact_list_store_ordered_presence (state_a);
- state_b = contact_list_store_ordered_presence (state_b);
-
- if (state_a < state_b) {
- ret_val = -1;
- } else if (state_a > state_b) {
- ret_val = 1;
- } else {
- /* Fallback: compare by name */
- ret_val = g_utf8_collate (name_a, name_b);
- }
+ /* Fallback: compare by name */
+ ret_val = g_utf8_collate (name_a, name_b);
}
free_and_out:
Modified: trunk/libempathy-gtk/empathy-contact-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-widget.c (original)
+++ trunk/libempathy-gtk/empathy-contact-widget.c Thu Jan 24 16:33:33 2008
@@ -429,6 +429,9 @@
g_signal_connect_swapped (information->contact, "notify::presence",
G_CALLBACK (contact_widget_presence_notify_cb),
information);
+ g_signal_connect_swapped (information->contact, "notify::presence-message",
+ G_CALLBACK (contact_widget_presence_notify_cb),
+ information);
g_signal_connect_swapped (information->contact, "notify::avatar",
G_CALLBACK (contact_widget_avatar_notify_cb),
information);
Modified: trunk/libempathy-gtk/empathy-presence-chooser.c
==============================================================================
--- trunk/libempathy-gtk/empathy-presence-chooser.c (original)
+++ trunk/libempathy-gtk/empathy-presence-chooser.c Thu Jan 24 16:33:33 2008
@@ -381,7 +381,7 @@
/* If we didn't get any match at all, it means the last state
* was a custom one. Just switch to the first one.
*/
- status = empathy_presence_state_get_default_status (states[0]);
+ status = empathy_presence_get_default_message (states[0]);
presence_chooser_reset_scroll_timeout (chooser);
empathy_idle_set_presence (priv->idle, states[0], status);
@@ -404,7 +404,7 @@
StateAndStatus *sas;
const gchar *status;
- status = empathy_presence_state_get_default_status (states[i]);
+ status = empathy_presence_get_default_message (states[i]);
sas = presence_chooser_state_and_status_new (states[i], status);
list = g_list_prepend (list, sas);
@@ -455,7 +455,7 @@
}
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- empathy_icon_name_for_presence_state (state),
+ empathy_icon_name_for_presence (state),
GTK_ICON_SIZE_MENU);
on = !on;
@@ -500,7 +500,7 @@
}
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- empathy_icon_name_for_presence_state (state),
+ empathy_icon_name_for_presence (state),
GTK_ICON_SIZE_MENU);
priv->last_state = state;
@@ -665,7 +665,7 @@
for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
GList *list, *l;
- status = empathy_presence_state_get_default_status (states[i]);
+ status = empathy_presence_get_default_message (states[i]);
presence_chooser_menu_add_item (menu,
status,
states[i]);
@@ -714,7 +714,7 @@
const gchar *icon_name;
item = gtk_image_menu_item_new_with_label (str);
- icon_name = empathy_icon_name_for_presence_state (state);
+ icon_name = empathy_icon_name_for_presence (state);
g_signal_connect (item, "activate",
G_CALLBACK (presence_chooser_noncustom_activate_cb),
@@ -891,8 +891,8 @@
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- COL_ICON, empathy_icon_name_for_presence_state (states[i]),
- COL_LABEL, empathy_presence_state_get_default_status (states[i]),
+ COL_ICON, empathy_icon_name_for_presence (states[i]),
+ COL_LABEL, empathy_presence_get_default_message (states[i]),
COL_PRESENCE, states[i],
-1);
}
Modified: trunk/libempathy-gtk/empathy-presence-chooser.h
==============================================================================
--- trunk/libempathy-gtk/empathy-presence-chooser.h (original)
+++ trunk/libempathy-gtk/empathy-presence-chooser.h Thu Jan 24 16:33:33 2008
@@ -27,8 +27,6 @@
#include <gtk/gtk.h>
-#include <libempathy/empathy-presence.h>
-
G_BEGIN_DECLS
#define EMPATHY_TYPE_PRESENCE_CHOOSER (empathy_presence_chooser_get_type ())
Modified: trunk/libempathy-gtk/empathy-status-icon.c
==============================================================================
--- trunk/libempathy-gtk/empathy-status-icon.c (original)
+++ trunk/libempathy-gtk/empathy-status-icon.c Thu Jan 24 16:33:33 2008
@@ -372,7 +372,7 @@
if (flash_state != MC_PRESENCE_UNSET) {
const gchar *icon_name;
- icon_name = empathy_icon_name_for_presence_state (flash_state);
+ icon_name = empathy_icon_name_for_presence (flash_state);
if (!priv->flash_state_event) {
/* We are now flashing */
priv->flash_state_event = status_icon_event_new (icon, icon_name, NULL);
@@ -429,7 +429,7 @@
priv = GET_PRIV (icon);
state = empathy_idle_get_state (priv->idle);
- icon_name = empathy_icon_name_for_presence_state (state);
+ icon_name = empathy_icon_name_for_presence (state);
gtk_status_icon_set_from_icon_name (priv->icon, icon_name);
}
Modified: trunk/libempathy-gtk/empathy-ui-utils.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.c (original)
+++ trunk/libempathy-gtk/empathy-ui-utils.c Thu Jan 24 16:33:33 2008
@@ -220,9 +220,9 @@
}
const gchar *
-empathy_icon_name_for_presence_state (McPresence state)
+empathy_icon_name_for_presence (McPresence presence)
{
- switch (state) {
+ switch (presence) {
case MC_PRESENCE_AVAILABLE:
return EMPATHY_IMAGE_AVAILABLE;
case MC_PRESENCE_DO_NOT_DISTURB:
@@ -244,32 +244,15 @@
}
const gchar *
-empathy_icon_name_for_presence (EmpathyPresence *presence)
-{
- McPresence state;
-
- g_return_val_if_fail (EMPATHY_IS_PRESENCE (presence),
- EMPATHY_IMAGE_OFFLINE);
-
- state = empathy_presence_get_state (presence);
-
- return empathy_icon_name_for_presence_state (state);
-}
-
-const gchar *
empathy_icon_name_for_contact (EmpathyContact *contact)
{
- EmpathyPresence *presence;
+ McPresence presence;
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact),
EMPATHY_IMAGE_OFFLINE);
presence = empathy_contact_get_presence (contact);
- if (presence) {
- return empathy_icon_name_for_presence (presence);
- }
-
- return EMPATHY_IMAGE_UNKNOWN;
+ return empathy_icon_name_for_presence (presence);
}
GdkPixbuf *
Modified: trunk/libempathy-gtk/empathy-ui-utils.h
==============================================================================
--- trunk/libempathy-gtk/empathy-ui-utils.h (original)
+++ trunk/libempathy-gtk/empathy-ui-utils.h Thu Jan 24 16:33:33 2008
@@ -37,7 +37,6 @@
#include <libmissioncontrol/mc-account.h>
#include <libmissioncontrol/mc-profile.h>
-#include <libempathy/empathy-presence.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-avatar.h>
@@ -68,8 +67,7 @@
...);
/* Pixbufs */
const gchar * empathy_icon_name_from_account (McAccount *account);
-const gchar * empathy_icon_name_for_presence_state (McPresence state);
-const gchar * empathy_icon_name_for_presence (EmpathyPresence *presence);
+const gchar * empathy_icon_name_for_presence (McPresence presence);
const gchar * empathy_icon_name_for_contact (EmpathyContact *contact);
GdkPixbuf * empathy_pixbuf_from_data (gchar *data,
gsize data_size);
Modified: trunk/libempathy/Makefile.am
==============================================================================
--- trunk/libempathy/Makefile.am (original)
+++ trunk/libempathy/Makefile.am Thu Jan 24 16:33:33 2008
@@ -18,7 +18,6 @@
libempathy_la_SOURCES = \
empathy-avatar.c \
empathy-time.c \
- empathy-presence.c \
empathy-status-presets.c \
empathy-debug.c \
empathy-utils.c \
@@ -55,7 +54,6 @@
libempathy_headers = \
empathy-avatar.h \
empathy-time.h \
- empathy-presence.h \
empathy-status-presets.h \
empathy-debug.h \
empathy-utils.h \
Modified: trunk/libempathy/empathy-contact.c
==============================================================================
--- trunk/libempathy/empathy-contact.c (original)
+++ trunk/libempathy/empathy-contact.c Thu Jan 24 16:33:33 2008
@@ -29,6 +29,8 @@
#include <glib/gi18n.h>
+#include <telepathy-glib/util.h>
+
#include "empathy-contact.h"
#include "empathy-utils.h"
#include "empathy-debug.h"
@@ -45,7 +47,8 @@
gchar *name;
EmpathyAvatar *avatar;
McAccount *account;
- EmpathyPresence *presence;
+ McPresence presence;
+ gchar *presence_message;
guint handle;
EmpathyCapabilities capabilities;
gboolean is_user;
@@ -72,6 +75,7 @@
PROP_AVATAR,
PROP_ACCOUNT,
PROP_PRESENCE,
+ PROP_PRESENCE_MESSAGE,
PROP_GROUPS,
PROP_SUBSCRIPTION,
PROP_HANDLE,
@@ -124,13 +128,22 @@
g_object_class_install_property (object_class,
PROP_PRESENCE,
- g_param_spec_object ("presence",
- "Contact presence",
- "Presence of contact",
- EMPATHY_TYPE_PRESENCE,
- G_PARAM_READWRITE));
+ g_param_spec_uint ("presence",
+ "Contact presence",
+ "Presence of contact",
+ MC_PRESENCE_UNSET,
+ LAST_MC_PRESENCE,
+ MC_PRESENCE_UNSET,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
+ PROP_PRESENCE_MESSAGE,
+ g_param_spec_string ("presence-message",
+ "Contact presence message",
+ "Presence message of contact",
+ NULL,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
PROP_HANDLE,
g_param_spec_uint ("handle",
"Contact Handle",
@@ -176,15 +189,12 @@
g_free (priv->name);
g_free (priv->id);
+ g_free (priv->presence_message);
if (priv->avatar) {
empathy_avatar_unref (priv->avatar);
}
- if (priv->presence) {
- g_object_unref (priv->presence);
- }
-
if (priv->account) {
g_object_unref (priv->account);
}
@@ -218,7 +228,10 @@
g_value_set_object (value, priv->account);
break;
case PROP_PRESENCE:
- g_value_set_object (value, priv->presence);
+ g_value_set_uint (value, priv->presence);
+ break;
+ case PROP_PRESENCE_MESSAGE:
+ g_value_set_string (value, priv->presence_message);
break;
case PROP_HANDLE:
g_value_set_uint (value, priv->handle);
@@ -264,7 +277,11 @@
break;
case PROP_PRESENCE:
empathy_contact_set_presence (EMPATHY_CONTACT (object),
- EMPATHY_PRESENCE (g_value_get_object (value)));
+ g_value_get_uint (value));
+ break;
+ case PROP_PRESENCE_MESSAGE:
+ empathy_contact_set_presence_message (EMPATHY_CONTACT (object),
+ g_value_get_string (value));
break;
case PROP_HANDLE:
empathy_contact_set_handle (EMPATHY_CONTACT (object),
@@ -451,12 +468,12 @@
g_object_notify (G_OBJECT (contact), "account");
}
-EmpathyPresence *
+McPresence
empathy_contact_get_presence (EmpathyContact *contact)
{
EmpathyContactPriv *priv;
- g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), MC_PRESENCE_UNSET);
priv = GET_PRIV (contact);
@@ -464,8 +481,8 @@
}
void
-empathy_contact_set_presence (EmpathyContact *contact,
- EmpathyPresence *presence)
+empathy_contact_set_presence (EmpathyContact *contact,
+ McPresence presence)
{
EmpathyContactPriv *priv;
@@ -477,16 +494,39 @@
return;
}
- if (priv->presence) {
- g_object_unref (priv->presence);
- priv->presence = NULL;
- }
+ priv->presence = presence;
+
+ g_object_notify (G_OBJECT (contact), "presence");
+}
+
+const gchar *
+empathy_contact_get_presence_message (EmpathyContact *contact)
+{
+ EmpathyContactPriv *priv;
- if (presence) {
- priv->presence = g_object_ref (presence);
+ g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
+
+ priv = GET_PRIV (contact);
+
+ return priv->presence_message;
+}
+
+void
+empathy_contact_set_presence_message (EmpathyContact *contact,
+ const gchar *message)
+{
+ EmpathyContactPriv *priv = GET_PRIV (contact);
+
+ g_return_if_fail (EMPATHY_IS_CONTACT (contact));
+
+ if (!tp_strdiff (message, priv->presence_message)) {
+ return;
}
- g_object_notify (G_OBJECT (contact), "presence");
+ g_free (priv->presence_message);
+ priv->presence_message = g_strdup (message);
+
+ g_object_notify (G_OBJECT (contact), "presence-message");
}
guint
@@ -591,11 +631,7 @@
priv = GET_PRIV (contact);
- if (!priv->presence) {
- return FALSE;
- }
-
- return (empathy_presence_get_state (priv->presence) > MC_PRESENCE_OFFLINE);
+ return (priv->presence > MC_PRESENCE_OFFLINE);
}
const gchar *
@@ -607,21 +643,11 @@
priv = GET_PRIV (contact);
- if (priv->presence) {
- const gchar *status;
-
- status = empathy_presence_get_status (priv->presence);
- if (!status) {
- McPresence state;
-
- state = empathy_presence_get_state (priv->presence);
- status = empathy_presence_state_get_default_status (state);
- }
-
- return status;
+ if (priv->presence_message) {
+ return priv->presence_message;
}
- return empathy_presence_state_get_default_status (MC_PRESENCE_OFFLINE);
+ return empathy_presence_get_default_message (priv->presence);
}
gboolean
Modified: trunk/libempathy/empathy-contact.h
==============================================================================
--- trunk/libempathy/empathy-contact.h (original)
+++ trunk/libempathy/empathy-contact.h Thu Jan 24 16:33:33 2008
@@ -29,9 +29,9 @@
#include <glib-object.h>
#include <libmissioncontrol/mc-account.h>
+#include <libmissioncontrol/mission-control.h>
#include "empathy-avatar.h"
-#include "empathy-presence.h"
G_BEGIN_DECLS
@@ -75,9 +75,12 @@
McAccount * empathy_contact_get_account (EmpathyContact *contact);
void empathy_contact_set_account (EmpathyContact *contact,
McAccount *account);
-EmpathyPresence * empathy_contact_get_presence (EmpathyContact *contact);
+McPresence empathy_contact_get_presence (EmpathyContact *contact);
void empathy_contact_set_presence (EmpathyContact *contact,
- EmpathyPresence *presence);
+ McPresence presence);
+const gchar * empathy_contact_get_presence_message (EmpathyContact *contact);
+void empathy_contact_set_presence_message (EmpathyContact *contact,
+ const gchar *message);
guint empathy_contact_get_handle (EmpathyContact *contact);
void empathy_contact_set_handle (EmpathyContact *contact,
guint handle);
Modified: trunk/libempathy/empathy-idle.c
==============================================================================
--- trunk/libempathy/empathy-idle.c (original)
+++ trunk/libempathy/empathy-idle.c Thu Jan 24 16:33:33 2008
@@ -345,7 +345,7 @@
priv = GET_PRIV (idle);
if (!priv->status) {
- return empathy_presence_state_get_default_status (priv->state);
+ return empathy_presence_get_default_message (priv->state);
}
return priv->status;
@@ -407,7 +407,7 @@
}
/* Do not set translated default messages */
- default_status = empathy_presence_state_get_default_status (state);
+ default_status = empathy_presence_get_default_message (state);
if (status && strcmp (status, default_status) == 0) {
status = NULL;
}
Modified: trunk/libempathy/empathy-status-presets.c
==============================================================================
--- trunk/libempathy/empathy-status-presets.c (original)
+++ trunk/libempathy/empathy-status-presets.c Thu Jan 24 16:33:33 2008
@@ -130,7 +130,7 @@
state_str = (gchar *) xmlGetProp (node, "presence");
if (state_str) {
- state = empathy_presence_state_from_str (state_str);
+ state = empathy_presence_from_str (state_str);
if (is_default) {
empathy_debug (DEBUG_DOMAIN,
@@ -215,7 +215,7 @@
xmlNodePtr subnode;
xmlChar *state;
- state = (gchar*) empathy_presence_state_to_str (default_preset->state);
+ state = (gchar*) empathy_presence_to_str (default_preset->state);
subnode = xmlNewTextChild (root, NULL, "default",
default_preset->status);
@@ -228,7 +228,7 @@
xmlChar *state;
sp = l->data;
- state = (gchar*) empathy_presence_state_to_str (sp->state);
+ state = (gchar*) empathy_presence_to_str (sp->state);
count[sp->state]++;
if (count[sp->state] > STATUS_PRESETS_MAX_EACH) {
Modified: trunk/libempathy/empathy-status-presets.h
==============================================================================
--- trunk/libempathy/empathy-status-presets.h (original)
+++ trunk/libempathy/empathy-status-presets.h Thu Jan 24 16:33:33 2008
@@ -23,7 +23,7 @@
#ifndef __EMPATHY_STATUS_PRESETS_H__
#define __EMPATHY_STATUS_PRESETS_H__
-#include "empathy-presence.h"
+#include <libmissioncontrol/mission-control.h>
G_BEGIN_DECLS
Modified: trunk/libempathy/empathy-tp-contact-factory.c
==============================================================================
--- trunk/libempathy/empathy-tp-contact-factory.c (original)
+++ trunk/libempathy/empathy-tp-contact-factory.c Thu Jan 24 16:33:33 2008
@@ -109,30 +109,19 @@
}
static void
-tp_contact_factory_presences_table_foreach (const gchar *state_str,
- GHashTable *presences_table,
- EmpathyPresence **presence)
+tp_contact_factory_presences_table_foreach (const gchar *state_str,
+ GHashTable *presences_table,
+ EmpathyContact *contact)
{
- McPresence state;
const GValue *message;
- state = empathy_presence_state_from_str (state_str);
- if (state == MC_PRESENCE_UNSET) {
- return;
- }
-
- if (*presence) {
- g_object_unref (*presence);
- *presence = NULL;
- }
-
- *presence = empathy_presence_new ();
- empathy_presence_set_state (*presence, state);
-
+ empathy_contact_set_presence (contact,
+ empathy_presence_from_str (state_str));
+
message = g_hash_table_lookup (presences_table, "message");
if (message != NULL) {
- empathy_presence_set_status (*presence,
- g_value_get_string (message));
+ empathy_contact_set_presence_message (contact,
+ g_value_get_string (message));
}
}
@@ -143,7 +132,6 @@
{
GHashTable *presences_table;
EmpathyContact *contact;
- EmpathyPresence *presence = NULL;
contact = tp_contact_factory_find_by_handle (tp_factory, handle);
if (!contact) {
@@ -154,16 +142,13 @@
g_hash_table_foreach (presences_table,
(GHFunc) tp_contact_factory_presences_table_foreach,
- &presence);
+ contact);
empathy_debug (DEBUG_DOMAIN, "Changing presence for contact %s (%d) to %s (%d)",
empathy_contact_get_id (contact),
handle,
- presence ? empathy_presence_get_status (presence) : "unset",
- presence ? empathy_presence_get_state (presence) : MC_PRESENCE_UNSET);
-
- empathy_contact_set_presence (contact, presence);
- g_object_unref (presence);
+ empathy_contact_get_presence_message (contact),
+ empathy_contact_get_presence (contact));
}
static void
@@ -699,7 +684,7 @@
{
EmpathyContact *contact = data;
- empathy_contact_set_presence (contact, NULL);
+ empathy_contact_set_presence (contact, MC_PRESENCE_UNSET);
empathy_contact_set_handle (contact, 0);
}
@@ -910,15 +895,9 @@
priv->contacts = g_list_prepend (priv->contacts, contact);
if (!priv->presence_iface) {
- EmpathyPresence *presence;
-
/* We have no presence iface, set default presence
* to available */
- presence = empathy_presence_new_full (MC_PRESENCE_AVAILABLE,
- NULL);
-
- empathy_contact_set_presence (contact, presence);
- g_object_unref (presence);
+ empathy_contact_set_presence (contact, MC_PRESENCE_AVAILABLE);
}
empathy_debug (DEBUG_DOMAIN, "Contact added: %s (%d)",
Modified: trunk/libempathy/empathy-utils.c
==============================================================================
--- trunk/libempathy/empathy-utils.c (original)
+++ trunk/libempathy/empathy-utils.c Thu Jan 24 16:33:33 2008
@@ -485,3 +485,74 @@
g_object_unref (mc);
}
+
+const gchar *
+empathy_presence_get_default_message (McPresence presence)
+{
+ switch (presence) {
+ case MC_PRESENCE_AVAILABLE:
+ return _("Available");
+ case MC_PRESENCE_DO_NOT_DISTURB:
+ return _("Busy");
+ case MC_PRESENCE_AWAY:
+ case MC_PRESENCE_EXTENDED_AWAY:
+ return _("Away");
+ case MC_PRESENCE_HIDDEN:
+ return _("Hidden");
+ case MC_PRESENCE_OFFLINE:
+ case MC_PRESENCE_UNSET:
+ return _("Offline");
+ default:
+ g_assert_not_reached ();
+ }
+
+ return NULL;
+}
+
+const gchar *
+empathy_presence_to_str (McPresence presence)
+{
+ switch (presence) {
+ case MC_PRESENCE_AVAILABLE:
+ return "available";
+ case MC_PRESENCE_DO_NOT_DISTURB:
+ return "busy";
+ case MC_PRESENCE_AWAY:
+ return "away";
+ case MC_PRESENCE_EXTENDED_AWAY:
+ return "ext_away";
+ case MC_PRESENCE_HIDDEN:
+ return "hidden";
+ case MC_PRESENCE_OFFLINE:
+ return "offline";
+ case MC_PRESENCE_UNSET:
+ return "unset";
+ default:
+ g_assert_not_reached ();
+ }
+
+ return NULL;
+}
+
+McPresence
+empathy_presence_from_str (const gchar *str)
+{
+ if (strcmp (str, "available") == 0) {
+ return MC_PRESENCE_AVAILABLE;
+ } else if ((strcmp (str, "dnd") == 0) || (strcmp (str, "busy") == 0)) {
+ return MC_PRESENCE_DO_NOT_DISTURB;
+ } else if ((strcmp (str, "away") == 0) || (strcmp (str, "brb") == 0)) {
+ return MC_PRESENCE_AWAY;
+ } else if ((strcmp (str, "xa") == 0) || (strcmp (str, "ext_away") == 0)) {
+ return MC_PRESENCE_EXTENDED_AWAY;
+ } else if (strcmp (str, "hidden") == 0) {
+ return MC_PRESENCE_HIDDEN;
+ } else if (strcmp (str, "offline") == 0) {
+ return MC_PRESENCE_OFFLINE;
+ } else if (strcmp (str, "unset") == 0) {
+ return MC_PRESENCE_UNSET;
+ }
+
+ return MC_PRESENCE_AVAILABLE;
+}
+
Modified: trunk/libempathy/empathy-utils.h
==============================================================================
--- trunk/libempathy/empathy-utils.h (original)
+++ trunk/libempathy/empathy-utils.h Thu Jan 24 16:33:33 2008
@@ -92,6 +92,9 @@
void empathy_chat_with_contact (EmpathyContact *contact);
void empathy_chat_with_contact_id (McAccount *account,
const gchar *contact_id);
+const gchar * empathy_presence_get_default_message (McPresence presence);
+const gchar * empathy_presence_to_str (McPresence presence);
+McPresence empathy_presence_from_str (const gchar *str);
G_END_DECLS
Modified: trunk/python/README
==============================================================================
--- trunk/python/README (original)
+++ trunk/python/README Thu Jan 24 16:33:33 2008
@@ -15,5 +15,7 @@
ContactManager, TpChatroom and TpContactList implements ContactList interface:
(implements "EmpathyContactList")
+That can be done by applying pyempathy.patch
+
3)
Manually update headers in pyempathy.override and pyempathygtk.override.
Added: trunk/python/pyempathy.patch
==============================================================================
--- (empty file)
+++ trunk/python/pyempathy.patch Thu Jan 24 16:33:33 2008
@@ -0,0 +1,35 @@
+--- pyempathy.defs 2008-01-24 16:03:39.000000000 +0100
++++ pyempathy/pyempathy.defs 2008-01-24 16:04:34.000000000 +0100
+@@ -35,7 +35,7 @@
+ (gtype-id "EMPATHY_TYPE_CONTACT_FACTORY")
+ )
+
+-(define-object ContactList
++(define-interface ContactList
+ (in-module "Empathy")
+ (c-name "EmpathyContactList")
+ (gtype-id "EMPATHY_TYPE_CONTACT_LIST")
+@@ -44,6 +44,7 @@
+ (define-object ContactManager
+ (in-module "Empathy")
+ (parent "GObject")
++ (implements "EmpathyContactList")
+ (c-name "EmpathyContactManager")
+ (gtype-id "EMPATHY_TYPE_CONTACT_MANAGER")
+ )
+@@ -93,6 +94,7 @@
+ (define-object TpChatroom
+ (in-module "Empathy")
+ (parent "EmpathyTpChat")
++ (implements "EmpathyContactList")
+ (c-name "EmpathyTpChatroom")
+ (gtype-id "EMPATHY_TYPE_TP_CHATROOM")
+ )
+@@ -107,6 +109,7 @@
+ (define-object TpContactList
+ (in-module "Empathy")
+ (parent "GObject")
++ (implements "EmpathyContactList")
+ (c-name "EmpathyTpContactList")
+ (gtype-id "EMPATHY_TYPE_TP_CONTACT_LIST")
+ )
Modified: trunk/python/pyempathy/pyempathy.defs
==============================================================================
--- trunk/python/pyempathy/pyempathy.defs (original)
+++ trunk/python/pyempathy/pyempathy.defs Thu Jan 24 16:33:33 2008
@@ -77,13 +77,6 @@
(gtype-id "EMPATHY_TYPE_MESSAGE")
)
-(define-object Presence
- (in-module "Empathy")
- (parent "GObject")
- (c-name "EmpathyPresence")
- (gtype-id "EMPATHY_TYPE_PRESENCE")
-)
-
(define-object TpCall
(in-module "Empathy")
(parent "GObject")
@@ -602,7 +595,7 @@
(define-method get_presence
(of-object "EmpathyContact")
(c-name "empathy_contact_get_presence")
- (return-type "EmpathyPresence*")
+ (return-type "McPresence")
)
(define-method set_presence
@@ -610,7 +603,22 @@
(c-name "empathy_contact_set_presence")
(return-type "none")
(parameters
- '("EmpathyPresence*" "presence")
+ '("McPresence" "presence")
+ )
+)
+
+(define-method get_presence_message
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_get_presence_message")
+ (return-type "const-gchar*")
+)
+
+(define-method set_presence_message
+ (of-object "EmpathyContact")
+ (c-name "empathy_contact_set_presence_message")
+ (return-type "none")
+ (parameters
+ '("const-gchar*" "message")
)
)
@@ -1205,93 +1213,6 @@
-;; From empathy-presence.h
-
-(define-function empathy_presence_get_type
- (c-name "empathy_presence_get_type")
- (return-type "GType")
-)
-
-(define-function empathy_presence_new
- (c-name "empathy_presence_new")
- (is-constructor-of "EmpathyPresence")
- (return-type "EmpathyPresence*")
-)
-
-(define-function empathy_presence_new_full
- (c-name "empathy_presence_new_full")
- (return-type "EmpathyPresence*")
- (parameters
- '("McPresence" "state")
- '("const-gchar*" "status")
- )
-)
-
-(define-method get_state
- (of-object "EmpathyPresence")
- (c-name "empathy_presence_get_state")
- (return-type "McPresence")
-)
-
-(define-method get_status
- (of-object "EmpathyPresence")
- (c-name "empathy_presence_get_status")
- (return-type "const-gchar*")
-)
-
-(define-method set_state
- (of-object "EmpathyPresence")
- (c-name "empathy_presence_set_state")
- (return-type "none")
- (parameters
- '("McPresence" "state")
- )
-)
-
-(define-method set_status
- (of-object "EmpathyPresence")
- (c-name "empathy_presence_set_status")
- (return-type "none")
- (parameters
- '("const-gchar*" "status")
- )
-)
-
-(define-function empathy_presence_sort_func
- (c-name "empathy_presence_sort_func")
- (return-type "gint")
- (parameters
- '("gconstpointer" "a")
- '("gconstpointer" "b")
- )
-)
-
-(define-function empathy_presence_state_get_default_status
- (c-name "empathy_presence_state_get_default_status")
- (return-type "const-gchar*")
- (parameters
- '("McPresence" "state")
- )
-)
-
-(define-function empathy_presence_state_to_str
- (c-name "empathy_presence_state_to_str")
- (return-type "const-gchar*")
- (parameters
- '("McPresence" "state")
- )
-)
-
-(define-function empathy_presence_state_from_str
- (c-name "empathy_presence_state_from_str")
- (return-type "McPresence")
- (parameters
- '("const-gchar*" "str")
- )
-)
-
-
-
;; From empathy-status-presets.h
(define-function empathy_status_presets_get_all
@@ -2058,6 +1979,30 @@
)
)
+(define-function empathy_presence_get_default_message
+ (c-name "empathy_presence_get_default_message")
+ (return-type "const-gchar*")
+ (parameters
+ '("McPresence" "presence")
+ )
+)
+
+(define-function empathy_presence_to_str
+ (c-name "empathy_presence_to_str")
+ (return-type "const-gchar*")
+ (parameters
+ '("McPresence" "presence")
+ )
+)
+
+(define-function empathy_presence_from_str
+ (c-name "empathy_presence_from_str")
+ (return-type "McPresence")
+ (parameters
+ '("const-gchar*" "str")
+ )
+)
+
;; From tp-stream-engine-gen.h
Modified: trunk/python/pyempathy/pyempathy.override
==============================================================================
--- trunk/python/pyempathy/pyempathy.override (original)
+++ trunk/python/pyempathy/pyempathy.override Thu Jan 24 16:33:33 2008
@@ -15,7 +15,6 @@
#include "empathy-idle.h"
#include "empathy-log-manager.h"
#include "empathy-message.h"
-#include "empathy-presence.h"
#include "empathy-status-presets.h"
#include "empathy-time.h"
#include "empathy-tp-chat.h"
Modified: trunk/python/pyempathygtk/pyempathygtk.defs
==============================================================================
--- trunk/python/pyempathygtk/pyempathygtk.defs (original)
+++ trunk/python/pyempathygtk/pyempathygtk.defs Thu Jan 24 16:33:33 2008
@@ -1349,6 +1349,15 @@
)
)
+(define-function empathy_contact_widget_set_contact
+ (c-name "empathy_contact_widget_set_contact")
+ (return-type "none")
+ (parameters
+ '("GtkWidget*" "widget")
+ '("EmpathyContact*" "contact")
+ )
+)
+
(define-function empathy_contact_widget_set_account_filter
(c-name "empathy_contact_widget_set_account_filter")
(return-type "none")
@@ -1921,19 +1930,11 @@
)
)
-(define-function empathy_icon_name_for_presence_state
- (c-name "empathy_icon_name_for_presence_state")
- (return-type "const-gchar*")
- (parameters
- '("McPresence" "state")
- )
-)
-
(define-function empathy_icon_name_for_presence
(c-name "empathy_icon_name_for_presence")
(return-type "const-gchar*")
(parameters
- '("EmpathyPresence*" "presence")
+ '("McPresence" "presence")
)
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]