qulogic/pidgin

Add purple_contact_find_dm

5 months ago, Gary Kramlich
eca0c08ed2a3
Add purple_contact_find_dm

This is a common use case and is a bit of code, so it's good to have a helper
like this.

Testing Done:
Created dm's via the contact list and made sure they worked. The previous update /r/2851 broke instant messages for all protocol plugins that are still using PurpleIMConversation which need to be updated anyways.

Reviewed at https://reviews.imfreedom.org/r/2853/
/* pidgin
*
* Pidgin is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#include <purpleconfig.h>
#include <purple.h>
#include "gtkconv.h"
#include "pidgincore.h"
#include "pidgindisplaywindow.h"
/**************************************************************************
* Conversation UI operations
**************************************************************************/
static void
conversation_create(PurpleConversation *conv) {
GtkWidget *window = NULL;
window = pidgin_display_window_get_default();
pidgin_display_window_add(PIDGIN_DISPLAY_WINDOW(window), conv);
}
static PurpleConversationUiOps conversation_ui_ops =
{
.create_conversation = conversation_create,
};
PurpleConversationUiOps *
pidgin_conversations_get_conv_ui_ops(void)
{
return &conversation_ui_ops;
}
/**************************************************************************
* Public conversation utility functions
**************************************************************************/
void *
pidgin_conversations_get_handle(void)
{
static int handle;
return &handle;
}
void
pidgin_conversations_init(void)
{
void *handle = pidgin_conversations_get_handle();
/* Conversations */
purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations");
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting", TRUE);
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", 2);
/**********************************************************************
* Register signals
**********************************************************************/
purple_signal_register(handle, "displaying-im-msg",
purple_marshal_BOOLEAN__POINTER_POINTER,
G_TYPE_BOOLEAN, 2, PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displayed-im-msg",
purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displaying-chat-msg",
purple_marshal_BOOLEAN__POINTER_POINTER,
G_TYPE_BOOLEAN, 2, PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "displayed-chat-msg",
purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2,
PURPLE_TYPE_CONVERSATION, PURPLE_TYPE_MESSAGE);
purple_signal_register(handle, "conversation-displayed",
purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
G_TYPE_POINTER); /* (PidginConversationOld *) */
purple_conversations_set_ui_ops(&conversation_ui_ops);
}
void
pidgin_conversations_uninit(void)
{
purple_prefs_disconnect_by_handle(pidgin_conversations_get_handle());
purple_signals_disconnect_by_handle(pidgin_conversations_get_handle());
purple_signals_unregister_by_instance(pidgin_conversations_get_handle());
}