Exemplo n.º 1
0
/* received-im-msg */
static void
received_im_msg(PurpleAccount *account, char *sender, char *message, PurpleConversation *conv, PurpleMessageFlags flags) {
	PurpleBuddy *buddy;
	CapStatistics *stats;
	/* guint words = word_count(message); */

	if (flags & PURPLE_MESSAGE_AUTO_RESP)
		return;

	buddy = purple_blist_find_buddy(account, sender);

	if (buddy == NULL)
		return;

	stats = get_stats_for(buddy);

	/* insert_word_count(sender, buddy_name, words); */

	/* If we are waiting for a response from a prior message
	 * then cancel the timeout callback. */
	if(stats->timeout_source_id != 0) {
		purple_debug_info("cap", "Cancelling timeout callback\n");
		purple_timeout_remove(stats->timeout_source_id);
		stats->timeout_source_id = 0;
	}

	insert_cap_success(stats);

	/* Reset the last_message value */
	stats->last_message = -1;
	/* Reset the last status id value */
	stats->last_message_status_id = NULL;
}
Exemplo n.º 2
0
/* buddy-signed-off */
static void buddy_signed_off(PurpleBuddy *buddy) {
	CapStatistics *stats = get_stats_for(buddy);

	/* We don't necessarily want to delete a buddies generated statistics every time they go offline.
	 * Instead we just set the buddy pointer to null so that when they come back online we can look
	 * them up again and continue using their statistics.
	 */
	insert_status_change(stats);
	/* stats->buddy = NULL; */
	stats->last_seen = time(NULL);
}
Exemplo n.º 3
0
/* buddy-signed-on */
static void buddy_signed_on(PurpleBuddy *buddy) {
	CapStatistics *stats = get_stats_for(buddy);

	/* If the statistic object existed but doesn't have a buddy pointer associated
	 * with it then reassociate one with it. The pointer being null is a result
	 * of a buddy with existing stats signing off and Purple sticking around. */
	if(!stats->buddy) {
		stats->buddy = buddy;
	}

	insert_status_change(stats);
}
Exemplo n.º 4
0
/* drawing-tooltip */
static void drawing_tooltip(PurpleBlistNode *node, GString *text, gboolean full) {
	if (PURPLE_IS_BUDDY(node)) {
		PurpleBuddy *buddy = PURPLE_BUDDY(node);
		CapStatistics *stats = get_stats_for(buddy);
		/* get the probability that this buddy will respond and add to the tooltip */
		if(stats->prediction->probability >= 0.0) {
			g_string_append_printf(text, "\n<b>%s</b> %3.0f %%", _("Response Probability:"),
				100 * stats->prediction->probability);
		} else {
			g_string_append_printf(text, "\n<b>%s</b> ???", _("Response Probability:"));
		}
	}
}
Exemplo n.º 5
0
/* sent-im-msg */
static void sent_im_msg(PurpleAccount *account, const char *receiver, const char *message) {
	PurpleBuddy *buddy;
	guint interval, words;
	CapStatistics *stats = NULL;

	buddy = purple_find_buddy(account, receiver);

	if (buddy == NULL)
		return;

	interval = purple_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 60;
	words = word_count(message);

	stats = get_stats_for(buddy);

	insert_word_count(purple_account_get_username(account), receiver, words);
	stats->last_message = time(NULL);
	stats->last_message_status_id = purple_status_get_id(get_status_for(buddy));
	if(stats->timeout_source_id != 0)
		purple_timeout_remove(stats->timeout_source_id);

	stats->timeout_source_id = purple_timeout_add_seconds(interval, max_message_difference_cb, stats);
}
Exemplo n.º 6
0
/* buddy-status-changed */
static void buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old_status, PurpleStatus *status) {
	CapStatistics *stats = get_stats_for(buddy);
	insert_status_change_from_purple_status(stats, status);
}