/soc/2013/ankitkv/gobjectification: dea8dd8343d5: Added GObject ...
Ankit Vani
a at nevitus.org
Sat Jul 20 13:30:35 EDT 2013
Changeset: dea8dd8343d59444da54eb3e176a917d74756a3b
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-20 23:00 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/dea8dd8343d5
Description:
Added GObject code to presenses.c.
* purple_presence_compare() is now purple_buddy_presence_compare()
* Added a virtual method update_idle to PurplePresenceClass to update idle state to logs and UI, according to subclass
diffstat:
libpurple/blistnodetypes.c | 5 +-
libpurple/plugins/perl/common/Presence.xs | 48 +-
libpurple/presences.c | 907 +++++++++++++++++++++--------
libpurple/presences.h | 32 +-
4 files changed, 684 insertions(+), 308 deletions(-)
diffs (truncated from 1188 to 300 lines):
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -799,8 +799,9 @@ purple_contact_compute_priority_buddy(Pu
{
int cmp = 1;
if (purple_account_is_connected(purple_buddy_get_account(new_priority)))
- cmp = purple_presence_compare(purple_buddy_get_presence(new_priority),
- purple_buddy_get_presence(buddy));
+ cmp = purple_buddy_presence_compare(
+ PURPLE_BUDDY_PRESENCE(purple_buddy_get_presence(new_priority)),
+ PURPLE_BUDDY_PRESENCE(purple_buddy_get_presence(buddy)));
if (cmp > 0 || (cmp == 0 &&
purple_prefs_get_bool("/purple/contact/last_match")))
diff --git a/libpurple/plugins/perl/common/Presence.xs b/libpurple/plugins/perl/common/Presence.xs
--- a/libpurple/plugins/perl/common/Presence.xs
+++ b/libpurple/plugins/perl/common/Presence.xs
@@ -3,19 +3,6 @@
MODULE = Purple::Presence PACKAGE = Purple::Presence PREFIX = purple_presence_
PROTOTYPES: ENABLE
-gint
-purple_presence_compare(presence1, presence2)
- Purple::Presence presence1
- Purple::Presence presence2
-
-Purple::Account
-purple_account_presence_get_account(presence)
- Purple::AccountPresence presence
-
-Purple::BuddyList::Buddy
-purple_buddy_presence_get_buddy(presence)
- Purple::BuddyPresence presence
-
Purple::Status
purple_presence_get_active_status(presence)
Purple::Presence presence
@@ -65,14 +52,6 @@ purple_presence_is_status_primitive_acti
Purple::Presence presence
Purple::StatusPrimitive primitive
-Purple::AccountPresence
-purple_account_presence_new(account)
- Purple::Account account
-
-Purple::BuddyPresence
-purple_buddy_presence_new(buddy)
- Purple::BuddyList::Buddy buddy
-
void
purple_presence_set_idle(presence, idle, idle_time)
Purple::Presence presence
@@ -94,3 +73,30 @@ void
purple_presence_switch_status(presence, status_id)
Purple::Presence presence
const char *status_id
+
+MODULE = Purple::Presence PACKAGE = Purple::AccountPresence PREFIX = purple_account_presence_
+PROTOTYPES: ENABLE
+
+Purple::Account
+purple_account_presence_get_account(presence)
+ Purple::AccountPresence presence
+
+Purple::AccountPresence
+purple_account_presence_new(account)
+ Purple::Account account
+
+MODULE = Purple::Presence PACKAGE = Purple::BuddyPresence PREFIX = purple_buddy_presence_
+PROTOTYPES: ENABLE
+
+gint
+purple_buddy_presence_compare(presence1, presence2)
+ Purple::BuddyPresence presence1
+ Purple::BuddyPresence presence2
+
+Purple::BuddyList::Buddy
+purple_buddy_presence_get_buddy(presence)
+ Purple::BuddyPresence presence
+
+Purple::BuddyPresence
+purple_buddy_presence_new(buddy)
+ Purple::BuddyList::Buddy buddy
diff --git a/libpurple/presences.c b/libpurple/presences.c
--- a/libpurple/presences.c
+++ b/libpurple/presences.c
@@ -18,6 +18,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
+#include "internal.h"
+#include "debug.h"
#include "presences.h"
#define PURPLE_PRESENCE_GET_PRIVATE(obj) \
@@ -51,109 +53,51 @@ struct _PurplePresencePrivate
PurpleStatus *active_status;
};
+/* Presence property enums */
+enum
+{
+ PRES_PROP_0,
+ PRES_PROP_IDLE,
+ PRES_PROP_IDLE_TIME,
+ PRES_PROP_LOGIN_TIME,
+ PRES_PROP_STATUSES,
+ PRES_PROP_ACTIVE_STATUS,
+ PRES_PROP_LAST
+};
+
/** Private data for an account presence */
struct _PurpleAccountPresencePrivate
{
PurpleAccount *account;
};
+/* Account presence property enums */
+enum
+{
+ ACPRES_PROP_0,
+ ACPRES_PROP_ACCOUNT,
+ ACPRES_PROP_LAST
+};
+
/** Private data for a buddy presence */
struct _PurpleBuddyPresencePrivate
{
PurpleBuddy *buddy;
};
+/* Buddy presence property enums */
+enum
+{
+ BUDPRES_PROP_0,
+ BUDPRES_PROP_BUDDY,
+ BUDPRES_PROP_LAST
+};
+
+static GObjectClass *parent_class;
+
/**************************************************************************
* PurplePresence API
**************************************************************************/
-PurplePresence *
-purple_presence_new(PurplePresenceContext context)
-{
- PurplePresence *presence;
-
- g_return_val_if_fail(context != PURPLE_PRESENCE_CONTEXT_UNSET, NULL);
-
- presence = g_new0(PurplePresence, 1);
- PURPLE_DBUS_REGISTER_POINTER(presence, PurplePresence);
-
- presence->context = context;
-
- presence->status_table =
- g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, NULL);
-
- return presence;
-}
-
-PurplePresence *
-purple_account_presence_new(PurpleAccount *account)
-{
- PurplePresence *presence = NULL;
- g_return_val_if_fail(account != NULL, NULL);
-
- presence = purple_presence_new(PURPLE_PRESENCE_CONTEXT_ACCOUNT);
- presence->u.account = account;
- presence->statuses = purple_prpl_get_statuses(account, presence);
-
- return presence;
-}
-
-PurplePresence *
-purple_conversation_presence_new(PurpleConversation *conv)
-{
- PurplePresence *presence;
-
- g_return_val_if_fail(conv != NULL, NULL);
-
- presence = purple_presence_new(PURPLE_PRESENCE_CONTEXT_CONV);
- presence->u.chat.conv = conv;
- /* presence->statuses = purple_prpl_get_statuses(purple_conversation_get_account(conv), presence); ? */
-
- return presence;
-}
-
-PurplePresence *
-purple_buddy_presence_new(PurpleBuddy *buddy)
-{
- PurplePresence *presence;
- PurpleAccount *account;
-
- g_return_val_if_fail(buddy != NULL, NULL);
- account = purple_buddy_get_account(buddy);
-
- presence = purple_presence_new(PURPLE_PRESENCE_CONTEXT_BUDDY);
-
- presence->u.buddy.name = g_strdup(purple_buddy_get_name(buddy));
- presence->u.buddy.account = account;
- presence->statuses = purple_prpl_get_statuses(account, presence);
-
- presence->u.buddy.buddy = buddy;
-
- return presence;
-}
-
-void
-purple_presence_destroy(PurplePresence *presence)
-{
- g_return_if_fail(presence != NULL);
-
- if (purple_presence_get_context(presence) == PURPLE_PRESENCE_CONTEXT_BUDDY)
- {
- g_free(presence->u.buddy.name);
- }
- else if (purple_presence_get_context(presence) == PURPLE_PRESENCE_CONTEXT_CONV)
- {
- g_free(presence->u.chat.user);
- }
-
- g_list_foreach(presence->statuses, (GFunc)purple_status_destroy, NULL);
- g_list_free(presence->statuses);
-
- g_hash_table_destroy(presence->status_table);
-
- PURPLE_DBUS_UNREGISTER_POINTER(presence);
- g_free(presence);
-}
void
purple_presence_set_status_active(PurplePresence *presence, const char *status_id,
@@ -192,132 +136,23 @@ purple_presence_switch_status(PurplePres
purple_presence_set_status_active(presence, status_id, TRUE);
}
-static void
-update_buddy_idle(PurpleBuddy *buddy, PurplePresence *presence,
- time_t current_time, gboolean old_idle, gboolean idle)
-{
- PurpleBListUiOps *ops = purple_blist_get_ui_ops();
- PurpleAccount *account = purple_buddy_get_account(buddy);
-
- if (!old_idle && idle)
- {
- if (purple_prefs_get_bool("/purple/logging/log_system"))
- {
- PurpleLog *log = purple_account_get_log(account, FALSE);
-
- if (log != NULL)
- {
- char *tmp, *tmp2;
- tmp = g_strdup_printf(_("%s became idle"),
- purple_buddy_get_alias(buddy));
- tmp2 = g_markup_escape_text(tmp, -1);
- g_free(tmp);
-
- purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
- purple_buddy_get_alias(buddy), current_time, tmp2);
- g_free(tmp2);
- }
- }
- }
- else if (old_idle && !idle)
- {
- if (purple_prefs_get_bool("/purple/logging/log_system"))
- {
- PurpleLog *log = purple_account_get_log(account, FALSE);
-
- if (log != NULL)
- {
- char *tmp, *tmp2;
- tmp = g_strdup_printf(_("%s became unidle"),
- purple_buddy_get_alias(buddy));
- tmp2 = g_markup_escape_text(tmp, -1);
- g_free(tmp);
-
- purple_log_write(log, PURPLE_MESSAGE_SYSTEM,
- purple_buddy_get_alias(buddy), current_time, tmp2);
- g_free(tmp2);
- }
- }
- }
-
- if (old_idle != idle)
- purple_signal_emit(purple_blist_get_handle(), "buddy-idle-changed", buddy,
- old_idle, idle);
-
- purple_contact_invalidate_priority_buddy(purple_buddy_get_contact(buddy));
-
- /* Should this be done here? It'd perhaps make more sense to
- * connect to buddy-[un]idle signals and update from there
- */
-
- if (ops != NULL && ops->update != NULL)
- ops->update(purple_blist_get_buddy_list(), (PurpleBListNode *)buddy);
More information about the Commits
mailing list