pidgin/pidgin

Remove the buddy pounces api

2021-01-02, Gary Kramlich
dcc53af7a4fb
Parents edbc992e77be
Children a0c11a532ee7
Remove the buddy pounces api

This feature has more or less been stalkerware since its inception and the
only useful feature that came of it was offline message emulation which isn't
necessary for most networks nowadays.

Testing Done:
Compiled and ran locally.

Reviewed at https://reviews.imfreedom.org/r/322/
--- a/ChangeLog.API Sat Jan 02 21:58:08 2021 -0600
+++ b/ChangeLog.API Sat Jan 02 22:05:09 2021 -0600
@@ -373,6 +373,7 @@
* PurpleEventLoopUiOps. Manually drive the GLib event loop
yourself. See GLib Main Event Loop docs.
* purple_fd_get_ip. Use GSocket instead.
+ * purple_find_pounce
* purple_get_host_name. Use g_get_host_name, instead.
* purple_get_tzoff_str(). Use g_date_time_format, instead.
* purple_ip_address_is_valid, purple_ipv4_address_is_valid, and
@@ -436,7 +437,39 @@
* purple_plugins_unregister_unload_notify_cb
* purple_plugins_unload
* purple_plugins_unload_all
+ * purple_pounce_action_get_attribute
+ * purple_pounce_action_is_enabled
+ * purple_pounce_action_register
+ * purple_pounce_action_set_attribute
+ * purple_pounce_action_set_enabled
+ * purple_pounce_destroy
+ * purple_pounce_destroy_all_by_account
+ * purple_pounce_destroy_all_by_buddy
+ * purple_pounce_execute
+ * purple_pounce_get_data
+ * purple_pounce_get_events
+ * purple_pounce_get_options
+ * purple_pounce_get_pouncee
+ * purple_pounce_get_pouncer
+ * purple_pounce_get_save
+ * purple_pounce_new
+ * purple_pounce_set_data
+ * purple_pounce_set_events
+ * purple_pounce_set_options
+ * purple_pounce_set_pouncee
+ * purple_pounce_set_pouncer
+ * purple_pounce_set_save
+ * purple_pounces_get_all
+ * purple_pounces_get_all_for_ui
+ * purple_pounces_get_handle
+ * purple_pounces_init
* purple_pounces_load
+ * purple_pounces_register_handler
+ * purple_pounces_uninit
+ * purple_pounces_unregister_handler
+ * PurplePounceCb
+ * PurplePounceEvent
+ * PurplePounceOption
* PurpleProxyConnectData
* PurpleProxyConnectFunction
* purple_proxy_connect
@@ -665,6 +698,11 @@
* pidgin_menu_position_func_helper
* pidgin_mini_dialog_links_supported
* pidgin_pixbuf_toolbar_button_from_stock
+ * pidgin_pounce_editor_show
+ * pidgin_pounces_get_handle
+ * pidgin_pounces_init
+ * pidgin_pounces_manager_hide
+ * pidgin_pounces_manager_show
* pidgin_protocol_option_menu_get_selected
* pidgin_set_custom_buddy_icon
* pidgin_set_sensitive_if_input
@@ -705,6 +743,12 @@
* gnt_ui_uninit renamed to finch_ui_uninit
Removed:
+ * finch_pounce_editor_show
+ * finch_pounces_get_handle
+ * finch_pounces_init
+ * finch_pounces_manager_hide
+ * finch_pounces_manager_show
+ * finch_pounces_uninit
* finch_sound_get_active_profile
* finch_sound_get_profiles
* finch_sound_get_ui_ops
--- a/doc/finch3.1.in Sat Jan 02 21:58:08 2021 -0600
+++ b/doc/finch3.1.in Sat Jan 02 22:05:09 2021 -0600
@@ -212,7 +212,7 @@
into this workspace. These are matched as substrings. Window titles take precedence over
names.
.br
-window-titles = Preferences;Pounce
+window-titles = Preferences
.br
.br
--- a/doc/pidgin3.1.in Sat Jan 02 21:58:08 2021 -0600
+++ b/doc/pidgin3.1.in Sat Jan 02 22:05:09 2021 -0600
@@ -116,11 +116,6 @@
Sends a file to the selected buddy (only available on protocols that support
file transfer).
.TP
-.B Add Buddy Pounce
-A Buddy Pounce is a configurable automated action to be performed when the
-buddy's state changes. This will open the \fBBuddy Pounce\fR dialog, which
-will be discussed later.
-.TP
.B View Log
Pidgin is capable of automatically logging messages. These logs are
either plain text files (with a .txt extension) or html files (with a
@@ -479,19 +474,6 @@
button allows creation of a new saved status, and the \fIClose\fR button closes
the window.
-.SH BUDDY POUNCE
-A Buddy Pounce is an automated trigger that occurs when a buddy returns to
-a normal state from an away state. The \fBBuddy Pounce\fR dialog box
-can be activated by selecting the \fIBuddy Pounce\fR option from the
-\fBTools\fR menu. From this dialog, new pounces can be created with the
-\fBAdd\fR button and existing pounces can be removed with the \fBDelete\fR
-button. A pounce can be set to occur on any combination of the
-events listed, and any combination of actions can result. If \fIPounce
-only when my status is not Available\fR is checked, the pounce will occur
-only if the user is set to a non-available status, such as invisible, do not
-disturb, away, etc. If \fIRecurring\fR is checked, the pounce will remain
-until removed by the \fBDelete\fR button.
-
.SH CUSTOM SMILIES
Pidgin 2.5.0 introduced support for custom smilies on those protocols for which
interested contributors have developed support. The custom smiley manager can
@@ -530,8 +512,6 @@
.br
\fI~/.purple/accounts.xml\fR: information about the user's accounts.
.br
- \fI~/.purple/pounces.xml\fR: stores the user's buddy pounces.
-.br
\fI~/.purple/prefs.xml\fR: Pidgin's configuration file.
.br
\fI~/.purple/status.xml\fR: stores the user's away messages.
--- a/doc/reference/finch/finch-docs.xml Sat Jan 02 21:58:08 2021 -0600
+++ b/doc/reference/finch/finch-docs.xml Sat Jan 02 22:05:09 2021 -0600
@@ -25,7 +25,6 @@
<xi:include href="xml/gntaccount.xml" />
<xi:include href="xml/gntblist.xml" />
- <xi:include href="xml/gntpounce.xml" />
<xi:include href="xml/gntconn.xml" />
<xi:include href="xml/gntconv.xml" />
<xi:include href="xml/gntdebug.xml" />
--- a/doc/reference/libpurple/libpurple-docs.xml Sat Jan 02 21:58:08 2021 -0600
+++ b/doc/reference/libpurple/libpurple-docs.xml Sat Jan 02 22:05:09 2021 -0600
@@ -35,7 +35,6 @@
<xi:include href="xml/buddy.xml" />
<xi:include href="xml/buddylist.xml" />
<xi:include href="xml/buddyicon.xml" />
- <xi:include href="xml/pounce.xml" />
<xi:include href="xml/chat.xml" />
<xi:include href="xml/circularbuffer.xml" />
<xi:include href="xml/contact.xml" />
--- a/doc/reference/pidgin/pidgin-docs.xml Sat Jan 02 21:58:08 2021 -0600
+++ b/doc/reference/pidgin/pidgin-docs.xml Sat Jan 02 22:05:09 2021 -0600
@@ -35,7 +35,6 @@
<xi:include href="xml/gtknickcolors.xml" />
<xi:include href="xml/gtknotify.xml" />
<xi:include href="xml/gtkpluginpref.xml" />
- <xi:include href="xml/gtkpounce.xml" />
<xi:include href="xml/gtkprefs.xml" />
<xi:include href="xml/gtkprivacy.xml" />
<xi:include href="xml/gtkrequest.xml" />
--- a/finch/gntblist.c Sat Jan 02 21:58:08 2021 -0600
+++ b/finch/gntblist.c Sat Jan 02 22:05:09 2021 -0600
@@ -34,7 +34,6 @@
#include "gntconv.h"
#include "gntlog.h"
#include "gntmenuutil.h"
-#include "gntpounce.h"
#include "gntstatus.h"
#define PREF_ROOT "/finch/blist"
@@ -1106,17 +1105,6 @@
}
static void
-finch_blist_pounce_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node)
-{
- PurpleBuddy *b;
- if (PURPLE_IS_CONTACT(node))
- b = purple_contact_get_priority_buddy((PurpleContact *)node);
- else
- b = (PurpleBuddy *)node;
- finch_pounce_editor_show(purple_buddy_get_account(b), purple_buddy_get_name(b), NULL);
-}
-
-static void
toggle_block_buddy(GntMenuItem *item, gpointer buddy)
{
gboolean block = gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item));
@@ -1154,9 +1142,6 @@
PURPLE_CALLBACK(finch_blist_get_buddy_info_cb), buddy);
}
- add_custom_action(menu, _("Add Buddy Pounce"),
- PURPLE_CALLBACK(finch_blist_pounce_node_cb), buddy);
-
if (PURPLE_IS_PROTOCOL_XFER(protocol))
{
if (purple_protocol_xfer_can_receive(
--- a/finch/gntconv.c Sat Jan 02 21:58:08 2021 -0600
+++ b/finch/gntconv.c Sat Jan 02 22:05:09 2021 -0600
@@ -37,7 +37,6 @@
#include "gntlog.h"
#include "gntmenuutil.h"
#include "gntplugin.h"
-#include "gntpounce.h"
#include "gntprefs.h"
#include "gntrequest.h"
#include "gntstatus.h"
@@ -406,15 +405,6 @@
}
static void
-add_pounce_cb(GntMenuItem *item, gpointer ggconv)
-{
- FinchConv *ggc = ggconv;
- finch_pounce_editor_show(
- purple_conversation_get_account(ggc->active_conv),
- purple_conversation_get_name(ggc->active_conv), NULL);
-}
-
-static void
get_info_cb(GntMenuItem *item, gpointer ggconv)
{
FinchConv *ggc = ggconv;
@@ -614,10 +604,6 @@
gnt_menuitem_set_callback(item, get_info_cb, ggc);
}
- item = gnt_menuitem_new(_("Add Buddy Pounce..."));
- gnt_menu_add_item(GNT_MENU(sub), item);
- gnt_menuitem_set_callback(item, add_pounce_cb, ggc);
-
if (PURPLE_IS_PROTOCOL_XFER(protocol) &&
purple_protocol_xfer_can_receive(
PURPLE_PROTOCOL_XFER(protocol),
--- a/finch/gntpounce.c Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,964 +0,0 @@
-/*
- * finch
- *
- * Finch 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 <glib/gi18n-lib.h>
-
-#include <purple.h>
-
-#include NCURSES_HEADER
-
-#include <gnt.h>
-
-#include "gntpounce.h"
-#include "libfinch.h"
-
-
-typedef struct
-{
- /* Pounce data */
- PurplePounce *pounce;
- PurpleAccount *account;
-
- /* The window */
- GntWidget *window;
-
- /* Pounce on Whom */
- GntWidget *account_menu;
- GntWidget *buddy_entry;
-
- /* Pounce options */
- GntWidget *on_away;
-
- /* Pounce When Buddy... */
- GntWidget *signon;
- GntWidget *signoff;
- GntWidget *away;
- GntWidget *away_return;
- GntWidget *idle;
- GntWidget *idle_return;
- GntWidget *typing;
- GntWidget *typed;
- GntWidget *stop_typing;
- GntWidget *message_recv;
-
- /* Action */
- GntWidget *open_win;
- GntWidget *popup;
- GntWidget *popup_entry;
- GntWidget *send_msg;
- GntWidget *send_msg_entry;
- GntWidget *exec_cmd;
- GntWidget *exec_cmd_entry;
-
- GntWidget *save_pounce;
-
- /* Buttons */
- GntWidget *save_button;
-
-} PurpleGntPounceDialog;
-
-typedef struct
-{
- GntWidget *window;
- GntWidget *tree;
- GntWidget *modify_button;
- GntWidget *delete_button;
-} PouncesManager;
-
-static PouncesManager *pounces_manager = NULL;
-
-/**************************************************************************
- * Callbacks
- **************************************************************************/
-static gint
-delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
-{
- gnt_widget_destroy(dialog->window);
- g_free(dialog);
-
- return TRUE;
-}
-
-static void
-cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
-{
- gnt_widget_destroy(dialog->window);
-}
-
-static void
-add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce)
-{
- PurpleAccount *account;
- const char *pouncer;
- const char *pouncee;
-
- account = purple_pounce_get_pouncer(pounce);
- pouncer = purple_account_get_username(account);
- pouncee = purple_pounce_get_pouncee(pounce);
- gnt_tree_add_row_last(tree, pounce,
- gnt_tree_create_row(tree, pouncer, pouncee), NULL);
-}
-
-static void
-populate_pounces_list(PouncesManager *dialog)
-{
- GList *pounces;
-
- gnt_tree_remove_all(GNT_TREE(dialog->tree));
-
- for (pounces = purple_pounces_get_all_for_ui(FINCH_UI); pounces != NULL;
- pounces = g_list_delete_link(pounces, pounces))
- {
- add_pounce_to_treeview(GNT_TREE(dialog->tree), pounces->data);
- }
-}
-
-static void
-update_pounces(void)
-{
- /* Rebuild the pounces list if the pounces manager is open */
- if (pounces_manager != NULL)
- {
- populate_pounces_list(pounces_manager);
- }
-}
-
-static void
-signed_on_off_cb(PurpleConnection *gc, gpointer user_data)
-{
- update_pounces();
-}
-
-static void
-setup_buddy_list_suggestion(GntEntry *entry, gboolean offline)
-{
- PurpleBlistNode *node = purple_blist_get_default_root();
- for (; node; node = purple_blist_node_next(node, offline)) {
- if (!PURPLE_IS_BUDDY(node))
- continue;
- gnt_entry_add_suggest(entry, purple_buddy_get_name((PurpleBuddy*)node));
- }
-}
-
-static void
-save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
-{
- const char *name;
- const char *message, *command, *reason;
- PurplePounceEvent events = PURPLE_POUNCE_NONE;
- PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE;
-
- name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry));
-
- if (*name == '\0')
- {
- purple_notify_error(NULL, NULL,
- _("Please enter a buddy to pounce."), NULL, NULL);
- return;
- }
-
- /* Options */
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->on_away)))
- options |= PURPLE_POUNCE_OPTION_AWAY;
-
- /* Events */
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signon)))
- events |= PURPLE_POUNCE_SIGNON;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->signoff)))
- events |= PURPLE_POUNCE_SIGNOFF;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away)))
- events |= PURPLE_POUNCE_AWAY;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->away_return)))
- events |= PURPLE_POUNCE_AWAY_RETURN;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle)))
- events |= PURPLE_POUNCE_IDLE;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->idle_return)))
- events |= PURPLE_POUNCE_IDLE_RETURN;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typing)))
- events |= PURPLE_POUNCE_TYPING;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->typed)))
- events |= PURPLE_POUNCE_TYPED;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->stop_typing)))
- events |= PURPLE_POUNCE_TYPING_STOPPED;
-
- if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv)))
- events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
-
- /* Data fields */
- message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry));
- command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry));
- reason = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry));
-
- if (*reason == '\0') reason = NULL;
- if (*message == '\0') message = NULL;
- if (*command == '\0') command = NULL;
-
- if (dialog->pounce == NULL) {
- dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account,
- name, events, options);
- } else {
- purple_pounce_set_events(dialog->pounce, events);
- purple_pounce_set_options(dialog->pounce, options);
- purple_pounce_set_pouncer(dialog->pounce, dialog->account);
- purple_pounce_set_pouncee(dialog->pounce, name);
- }
-
- /* Actions */
- purple_pounce_action_set_enabled(dialog->pounce, "open-window",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win)));
- purple_pounce_action_set_enabled(dialog->pounce, "popup-notify",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup)));
- purple_pounce_action_set_enabled(dialog->pounce, "send-message",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg)));
- purple_pounce_action_set_enabled(dialog->pounce, "execute-command",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd)));
-
- purple_pounce_action_set_attribute(dialog->pounce, "send-message",
- "message", message);
- purple_pounce_action_set_attribute(dialog->pounce, "execute-command",
- "command", command);
- purple_pounce_action_set_attribute(dialog->pounce, "popup-notify",
- "reason", reason);
-
- /* Set the defaults for next time. */
- purple_prefs_set_bool("/finch/pounces/default_actions/open-window",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->open_win)));
- purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->popup)));
- purple_prefs_set_bool("/finch/pounces/default_actions/send-message",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->send_msg)));
- purple_prefs_set_bool("/finch/pounces/default_actions/execute-command",
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->exec_cmd)));
-
- purple_pounce_set_save(dialog->pounce,
- gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->save_pounce)));
-
- purple_pounce_set_pouncer(dialog->pounce,
- (PurpleAccount *)gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->account_menu)));
-
- update_pounces();
-
- gnt_widget_destroy(dialog->window);
-}
-
-
-void
-finch_pounce_editor_show(PurpleAccount *account, const char *name,
- PurplePounce *cur_pounce)
-{
- PurpleGntPounceDialog *dialog;
- GntWidget *window;
- GntWidget *bbox;
- GntWidget *hbox, *vbox;
- GntWidget *button;
- GntWidget *combo;
- GList *list;
-
- g_return_if_fail((cur_pounce != NULL) ||
- (account != NULL) ||
- (purple_accounts_get_all() != NULL));
-
- dialog = g_new0(PurpleGntPounceDialog, 1);
-
- if (cur_pounce != NULL) {
- dialog->pounce = cur_pounce;
- dialog->account = purple_pounce_get_pouncer(cur_pounce);
- } else if (account != NULL) {
- dialog->pounce = NULL;
- dialog->account = account;
- } else {
- GList *connections = purple_connections_get_all();
- PurpleConnection *gc;
-
- if (connections != NULL) {
- gc = (PurpleConnection *)connections->data;
- dialog->account = purple_connection_get_account(gc);
- } else
- dialog->account = purple_accounts_get_all()->data;
-
- dialog->pounce = NULL;
- }
-
- /* Create the window. */
- dialog->window = window = gnt_vbox_new(FALSE);
- gnt_box_set_pad(GNT_BOX(window), 0);
- gnt_box_set_toplevel(GNT_BOX(window), TRUE);
- gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT);
- gnt_box_set_title(GNT_BOX(window),
- (cur_pounce == NULL
- ? _("New Buddy Pounce") : _("Edit Buddy Pounce")));
-
- g_signal_connect(G_OBJECT(window), "destroy",
- G_CALLBACK(delete_win_cb), dialog);
-
- gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce on Whom"), GNT_TEXT_FLAG_BOLD));
-
- /* Account: */
- gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Account:")));
- dialog->account_menu = combo = gnt_combo_box_new();
- list = purple_accounts_get_all();
- for (; list; list = list->next)
- {
- PurpleAccount *account;
- char *text;
-
- account = list->data;
- text = g_strdup_printf("%s (%s)",
- purple_account_get_username(account),
- purple_account_get_protocol_name(account));
- gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
- g_free(text);
- }
- if (dialog->account)
- gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), dialog->account);
-
- gnt_box_add_widget(GNT_BOX(window), combo);
-
- /* Buddy: */
- hbox = gnt_hbox_new(FALSE);
- gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:")));
-
- dialog->buddy_entry = gnt_entry_new(NULL);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry);
-
- setup_buddy_list_suggestion(GNT_ENTRY(dialog->buddy_entry), TRUE);
-
- gnt_box_add_widget(GNT_BOX(window), hbox);
-
- if (cur_pounce != NULL) {
- gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry),
- purple_pounce_get_pouncee(cur_pounce));
- } else if (name != NULL) {
- gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name);
- }
-
- /* Create the event frame */
- gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
- gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Pounce When Buddy..."), GNT_TEXT_FLAG_BOLD));
-
- dialog->signon = gnt_check_box_new(_("Signs on"));
- dialog->signoff = gnt_check_box_new(_("Signs off"));
- dialog->away = gnt_check_box_new(_("Goes away"));
- dialog->away_return = gnt_check_box_new(_("Returns from away"));
- dialog->idle = gnt_check_box_new(_("Becomes idle"));
- dialog->idle_return = gnt_check_box_new(_("Is no longer idle"));
- dialog->typing = gnt_check_box_new(_("Starts typing"));
- dialog->typed = gnt_check_box_new(_("Pauses while typing"));
- dialog->stop_typing = gnt_check_box_new(_("Stops typing"));
- dialog->message_recv = gnt_check_box_new(_("Sends a message"));
-
- hbox = gnt_hbox_new(TRUE);
- gnt_box_set_pad(GNT_BOX(hbox), 2);
-
- vbox = gnt_vbox_new(FALSE);
- gnt_box_set_pad(GNT_BOX(vbox), 0);
- gnt_box_add_widget(GNT_BOX(hbox), vbox);
-
- gnt_box_add_widget(GNT_BOX(vbox), dialog->signon);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->away);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->idle);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->typing);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->stop_typing);
-
- vbox = gnt_vbox_new(FALSE);
- gnt_box_set_pad(GNT_BOX(vbox), 0);
- gnt_box_add_widget(GNT_BOX(hbox), vbox);
-
- gnt_box_add_widget(GNT_BOX(vbox), dialog->signoff);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->away_return);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->idle_return);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->typed);
- gnt_box_add_widget(GNT_BOX(vbox), dialog->message_recv);
-
- gnt_box_add_widget(GNT_BOX(window), hbox);
-
- /* Create the "Action" frame. */
- gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
- gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Action"), GNT_TEXT_FLAG_BOLD));
-
- dialog->open_win = gnt_check_box_new(_("Open an IM window"));
- dialog->popup = gnt_check_box_new(_("Pop up a notification"));
- dialog->send_msg = gnt_check_box_new(_("Send a message"));
- dialog->exec_cmd = gnt_check_box_new(_("Execute a command"));
-
- dialog->send_msg_entry = gnt_entry_new(NULL);
- dialog->exec_cmd_entry = gnt_entry_new(NULL);
- dialog->popup_entry = gnt_entry_new(NULL);
- dialog->exec_cmd_entry = gnt_entry_new(NULL);
-
- hbox = gnt_hbox_new(FALSE);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win);
- gnt_box_add_widget(GNT_BOX(window), hbox);
- hbox = gnt_hbox_new(FALSE);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->popup);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry);
- gnt_box_add_widget(GNT_BOX(window), hbox);
- hbox = gnt_hbox_new(FALSE);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry);
- gnt_box_add_widget(GNT_BOX(window), hbox);
- hbox = gnt_hbox_new(FALSE);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd);
- gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry);
- gnt_box_add_widget(GNT_BOX(window), hbox);
-
- gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
- gnt_box_add_widget(GNT_BOX(window), gnt_label_new_with_format(_("Options"), GNT_TEXT_FLAG_BOLD));
- dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not Available"));
- gnt_box_add_widget(GNT_BOX(window), dialog->on_away);
- dialog->save_pounce = gnt_check_box_new(_("Recurring"));
- gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce);
-
-
- gnt_box_add_widget(GNT_BOX(window), gnt_line_new(FALSE));
- /* Now the button box! */
- bbox = gnt_hbox_new(FALSE);
-
- /* Cancel button */
- button = gnt_button_new(_("Cancel"));
- gnt_box_add_widget(GNT_BOX(bbox), button);
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(cancel_cb), dialog);
-
- /* Save button */
- dialog->save_button = button = gnt_button_new(_("Save"));
- gnt_box_add_widget(GNT_BOX(bbox), button);
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(save_pounce_cb), dialog);
-
- gnt_box_add_widget(GNT_BOX(window), bbox);
-
-
- /* Set the values of stuff. */
- if (cur_pounce != NULL)
- {
- PurplePounceEvent events = purple_pounce_get_events(cur_pounce);
- PurplePounceOption options = purple_pounce_get_options(cur_pounce);
- const char *value;
-
- /* Options */
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->on_away),
- (options & PURPLE_POUNCE_OPTION_AWAY));
-
- /* Events */
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signon),
- (events & PURPLE_POUNCE_SIGNON));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->signoff),
- (events & PURPLE_POUNCE_SIGNOFF));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away),
- (events & PURPLE_POUNCE_AWAY));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->away_return),
- (events & PURPLE_POUNCE_AWAY_RETURN));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle),
- (events & PURPLE_POUNCE_IDLE));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->idle_return),
- (events & PURPLE_POUNCE_IDLE_RETURN));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typing),
- (events & PURPLE_POUNCE_TYPING));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->typed),
- (events & PURPLE_POUNCE_TYPED));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->stop_typing),
- (events & PURPLE_POUNCE_TYPING_STOPPED));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->message_recv),
- (events & PURPLE_POUNCE_MESSAGE_RECEIVED));
-
- /* Actions */
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win),
- purple_pounce_action_is_enabled(cur_pounce, "open-window"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup),
- purple_pounce_action_is_enabled(cur_pounce, "popup-notify"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg),
- purple_pounce_action_is_enabled(cur_pounce, "send-message"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd),
- purple_pounce_action_is_enabled(cur_pounce, "execute-command"));
-
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->save_pounce),
- purple_pounce_get_save(cur_pounce));
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "send-message",
- "message")) != NULL)
- {
- gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value);
- }
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "popup-notify",
- "reason")) != NULL)
- {
- gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value);
- }
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "execute-command",
- "command")) != NULL)
- {
- gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value);
- }
- }
- else
- {
- PurpleBuddy *buddy = NULL;
-
- if (name != NULL)
- buddy = purple_blist_find_buddy(account, name);
-
- /* Set some defaults */
- if (buddy == NULL) {
- gnt_check_box_set_checked(
- GNT_CHECK_BOX(dialog->signon), TRUE);
- } else {
- if (!PURPLE_BUDDY_IS_ONLINE(buddy)) {
- gnt_check_box_set_checked(
- GNT_CHECK_BOX(dialog->signon), TRUE);
- } else {
- gboolean default_set = FALSE;
- PurplePresence *presence = purple_buddy_get_presence(buddy);
-
- if (purple_presence_is_idle(presence))
- {
- gnt_check_box_set_checked(
- GNT_CHECK_BOX(dialog->idle_return), TRUE);
-
- default_set = TRUE;
- }
-
- if (!purple_presence_is_available(presence))
- {
- gnt_check_box_set_checked(
- GNT_CHECK_BOX(dialog->away_return), TRUE);
-
- default_set = TRUE;
- }
-
- if (!default_set)
- {
- gnt_check_box_set_checked(
- GNT_CHECK_BOX(dialog->signon), TRUE);
- }
- }
- }
-
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->open_win),
- purple_prefs_get_bool("/finch/pounces/default_actions/open-window"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->popup),
- purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->send_msg),
- purple_prefs_get_bool("/finch/pounces/default_actions/send-message"));
- gnt_check_box_set_checked(GNT_CHECK_BOX(dialog->exec_cmd),
- purple_prefs_get_bool("/finch/pounces/default_actions/execute-command"));
- }
-
- gnt_widget_show(window);
-}
-
-
-
-static gboolean
-pounces_manager_destroy_cb(GntWidget *widget, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
-
- dialog->window = NULL;
- finch_pounces_manager_hide();
-
- return FALSE;
-}
-
-
-static void
-pounces_manager_add_cb(GntButton *button, gpointer user_data)
-{
- if (purple_accounts_get_all() == NULL) {
- purple_notify_error(NULL, _("Cannot create pounce"),
- _("You do not have any accounts."),
- _("You must create an account first before you can create a pounce."), NULL);
- return;
- }
- finch_pounce_editor_show(NULL, NULL, NULL);
-}
-
-
-static void
-pounces_manager_modify_cb(GntButton *button, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- PurplePounce *pounce = gnt_tree_get_selection_data(GNT_TREE(dialog->tree));
- if (pounce)
- finch_pounce_editor_show(NULL, NULL, pounce);
-}
-
-static void
-pounces_manager_delete_confirm_cb(PurplePounce *pounce)
-{
- gnt_tree_remove(GNT_TREE(pounces_manager->tree), pounce);
-
- purple_request_close_with_handle(pounce);
- purple_pounce_destroy(pounce);
-}
-
-
-static void
-pounces_manager_delete_cb(GntButton *button, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- PurplePounce *pounce;
- PurpleAccount *account;
- const char *pouncer, *pouncee;
- char *buf;
-
- pounce = (PurplePounce *)gnt_tree_get_selection_data(GNT_TREE(dialog->tree));
- if (pounce == NULL)
- return;
-
- account = purple_pounce_get_pouncer(pounce);
- pouncer = purple_account_get_username(account);
- pouncee = purple_pounce_get_pouncee(pounce);
- buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer);
- purple_request_action(pounce, NULL, buf, NULL, 0,
- purple_request_cpar_from_account(account), pounce, 2,
- _("Delete"), pounces_manager_delete_confirm_cb,
- _("Cancel"), NULL);
- g_free(buf);
-}
-
-static void
-pounces_manager_close_cb(GntButton *button, gpointer user_data)
-{
- finch_pounces_manager_hide();
-}
-
-
-void
-finch_pounces_manager_show(void)
-{
- PouncesManager *dialog;
- GntWidget *bbox;
- GntWidget *button;
- GntWidget *tree;
- GntWidget *win;
-
- if (pounces_manager != NULL) {
- gnt_window_present(pounces_manager->window);
- return;
- }
-
- pounces_manager = dialog = g_new0(PouncesManager, 1);
-
- dialog->window = win = gnt_vbox_new(FALSE);
- gnt_box_set_toplevel(GNT_BOX(win), TRUE);
- gnt_box_set_title(GNT_BOX(win), _("Buddy Pounces"));
- gnt_box_set_pad(GNT_BOX(win), 0);
-
- g_signal_connect(G_OBJECT(win), "destroy",
- G_CALLBACK(pounces_manager_destroy_cb), dialog);
-
- /* List of saved buddy pounces */
- dialog->tree = tree = GNT_WIDGET(gnt_tree_new_with_columns(2));
- gnt_tree_set_column_titles(GNT_TREE(tree), "Account", "Pouncee", NULL);
- gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
-
- gnt_box_add_widget(GNT_BOX(win), tree);
-
- /* Button box. */
- bbox = gnt_hbox_new(FALSE);
-
- /* Add button */
- button = gnt_button_new(_("Add"));
- gnt_box_add_widget(GNT_BOX(bbox), button);
- gnt_util_set_trigger_widget(tree, GNT_KEY_INS, button);
-
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(pounces_manager_add_cb), dialog);
-
- /* Modify button */
- button = gnt_button_new(_("Modify"));
- dialog->modify_button = button;
- gnt_box_add_widget(GNT_BOX(bbox), button);
-
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(pounces_manager_modify_cb), dialog);
-
- /* Delete button */
- button = gnt_button_new(_("Delete"));
- dialog->delete_button = button;
- gnt_box_add_widget(GNT_BOX(bbox), button);
- gnt_util_set_trigger_widget(tree, GNT_KEY_DEL, button);
-
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(pounces_manager_delete_cb), dialog);
-
- /* Close button */
- button = gnt_button_new(_("Close"));
- gnt_box_add_widget(GNT_BOX(bbox), button);
- gnt_widget_show(button);
-
- g_signal_connect(G_OBJECT(button), "activate",
- G_CALLBACK(pounces_manager_close_cb), dialog);
-
- gnt_box_add_widget(GNT_BOX(win), bbox);
-
- gnt_widget_show(win);
- populate_pounces_list(pounces_manager);
-}
-
-void
-finch_pounces_manager_hide(void)
-{
- if (pounces_manager == NULL)
- return;
-
- if (pounces_manager->window != NULL)
- gnt_widget_destroy(pounces_manager->window);
-
- purple_signals_disconnect_by_handle(pounces_manager);
-
- g_free(pounces_manager);
- pounces_manager = NULL;
-}
-
-static void
-pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
-{
- PurpleIMConversation *im;
- PurpleAccount *account;
- PurpleBuddy *buddy;
- const char *pouncee;
- const char *alias;
-
- pouncee = purple_pounce_get_pouncee(pounce);
- account = purple_pounce_get_pouncer(pounce);
-
- buddy = purple_blist_find_buddy(account, pouncee);
- if (buddy != NULL)
- {
- alias = purple_buddy_get_alias(buddy);
- if (alias == NULL)
- alias = pouncee;
- }
- else
- alias = pouncee;
-
- if (purple_pounce_action_is_enabled(pounce, "open-window"))
- {
- if (!purple_conversations_find_im_with_account(pouncee, account))
- purple_im_conversation_new(account, pouncee);
- }
-
- if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
- {
- char *tmp = NULL;
- const char *name_shown;
- const char *reason;
- struct {
- PurplePounceEvent event;
- const char *format;
- } messages[] = {
- {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")},
- {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")},
- {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")},
- {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")},
- {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")},
- {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")},
- {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")},
- {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")},
- {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")},
- {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")},
- {0, NULL}
- };
- int i;
- reason = purple_pounce_action_get_attribute(pounce, "popup-notify",
- "reason");
-
- /*
- * Here we place the protocol name in the pounce dialog to lessen
- * confusion about what protocol a pounce is for.
- */
- for (i = 0; messages[i].format != NULL; i++) {
- if (messages[i].event & events) {
- tmp = g_strdup_printf(messages[i].format, alias,
- purple_account_get_protocol_name(account));
- break;
- }
- }
- if (tmp == NULL)
- tmp = g_strdup(_("Unknown pounce event. Please report this!"));
-
- /*
- * Ok here is where I change the second argument, title, from
- * NULL to the account alias if we have it or the account
- * name if that's all we have
- */
- if ((name_shown = purple_account_get_private_alias(account)) == NULL)
- name_shown = purple_account_get_username(account);
-
- if (reason == NULL)
- {
- purple_notify_info(NULL, name_shown, tmp, purple_date_format_full(NULL), NULL);
- }
- else
- {
- char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL));
- purple_notify_info(NULL, name_shown, tmp, tmp2, NULL);
- g_free(tmp2);
- }
- g_free(tmp);
- }
-
- if (purple_pounce_action_is_enabled(pounce, "send-message"))
- {
- const char *message;
-
- message = purple_pounce_action_get_attribute(pounce, "send-message",
- "message");
-
- if (message != NULL)
- {
- PurpleMessage *pmsg;
- const gchar *me = purple_account_get_name_for_display(account);
-
- im = purple_conversations_find_im_with_account(pouncee, account);
-
- if (im == NULL) {
- im = purple_im_conversation_new(account, pouncee);
- }
-
- pmsg = purple_message_new_outgoing(me, pouncee, message, 0);
- purple_serv_send_im(purple_account_get_connection(account), pmsg);
- purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
- g_object_unref(G_OBJECT(pmsg));
- }
- }
-
- if (purple_pounce_action_is_enabled(pounce, "execute-command"))
- {
-#ifdef _WIN32
- purple_debug_error("gntpounce", "execute-command is not supported on this OS");
-#else
- const char *command;
-
- command = purple_pounce_action_get_attribute(pounce,
- "execute-command", "command");
-
- if (command != NULL)
- {
- char *localecmd = g_locale_from_utf8(command, -1, NULL,
- NULL, NULL);
-
- if (localecmd != NULL)
- {
- int pid = fork();
-
- if (pid == 0) {
- char *args[4];
-
- args[0] = "sh";
- args[1] = "-c";
- args[2] = (char *)localecmd;
- args[3] = NULL;
-
- execvp(args[0], args);
-
- _exit(0);
- }
- g_free(localecmd);
- }
- }
-#endif
- }
-
- if (purple_pounce_action_is_enabled(pounce, "play-beep"))
- {
- beep();
- }
-}
-
-static void
-free_pounce(PurplePounce *pounce)
-{
- update_pounces();
-}
-
-static void
-new_pounce(PurplePounce *pounce)
-{
- purple_pounce_action_register(pounce, "open-window");
- purple_pounce_action_register(pounce, "popup-notify");
- purple_pounce_action_register(pounce, "send-message");
- purple_pounce_action_register(pounce, "execute-command");
- purple_pounce_action_register(pounce, "play-beep");
-
- update_pounces();
-}
-
-void *
-finch_pounces_get_handle()
-{
- static int handle;
-
- return &handle;
-}
-
-void
-finch_pounces_init(void)
-{
- purple_pounces_register_handler(FINCH_UI, pounce_cb, new_pounce,
- free_pounce);
-
- purple_prefs_add_none("/finch/pounces");
- purple_prefs_add_none("/finch/pounces/default_actions");
- purple_prefs_add_bool("/finch/pounces/default_actions/open-window",
- FALSE);
- purple_prefs_add_bool("/finch/pounces/default_actions/popup-notify",
- TRUE);
- purple_prefs_add_bool("/finch/pounces/default_actions/send-message",
- FALSE);
- purple_prefs_add_bool("/finch/pounces/default_actions/execute-command",
- FALSE);
- purple_prefs_add_bool("/finch/pounces/default_actions/play-beep",
- FALSE);
- purple_prefs_add_none("/finch/pounces/dialog");
-
- purple_signal_connect(purple_connections_get_handle(), "signed-on",
- finch_pounces_get_handle(),
- PURPLE_CALLBACK(signed_on_off_cb), NULL);
- purple_signal_connect(purple_connections_get_handle(), "signed-off",
- finch_pounces_get_handle(),
- PURPLE_CALLBACK(signed_on_off_cb), NULL);
-}
-
-/* XXX: There's no such thing in pidgin. Perhaps there should be?
- * For sure, we don't need purple_pounces_unregister_handler -
- * it's wiped in purple_pounces_uninit.
- */
-void finch_pounces_uninit()
-{
- purple_signals_disconnect_by_handle(finch_pounces_get_handle());
-}
--- a/finch/gntpounce.h Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * finch
- *
- * Finch 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
- */
-
-#if !defined(FINCH_GLOBAL_HEADER_INSIDE) && !defined(FINCH_COMPILATION)
-# error "only <finch.h> may be included directly"
-#endif
-
-#ifndef FINCH_POUNCE_H
-#define FINCH_POUNCE_H
-
-/**
- * SECTION:gntpounce
- * @section_id: finch-gntpounce
- * @short_description: <filename>gntpounce.h</filename>
- * @title: Buddy Pounce API
- */
-
-#include <purple.h>
-
-/**
- * finch_pounce_editor_show:
- * @account: The optional account to use.
- * @name: The optional name to pounce on.
- * @cur_pounce: The current buddy pounce, if editing an existing one.
- *
- * Displays a New Buddy Pounce or Edit Buddy Pounce dialog.
- */
-void finch_pounce_editor_show(PurpleAccount *account, const char *name,
- PurplePounce *cur_pounce);
-
-/**
- * finch_pounces_manager_show:
- *
- * Shows the pounces manager window.
- */
-void finch_pounces_manager_show(void);
-
-/**
- * finch_pounces_manager_hide:
- *
- * Hides the pounces manager window.
- */
-void finch_pounces_manager_hide(void);
-
-/**
- * finch_pounces_get_handle:
- *
- * Returns the GNT pounces handle
- *
- * Returns: (transfer none): The handle to the GNT pounces system
- */
-void *finch_pounces_get_handle(void);
-
-/**
- * finch_pounces_init:
- *
- * Initializes the GNT pounces subsystem.
- */
-void finch_pounces_init(void);
-
-/**
- * finch_pounces_uninit:
- *
- * Uninitializes the GNT pounces subsystem.
- */
-void finch_pounces_uninit(void);
-
-#endif /* FINCH_POUNCE_H */
-
--- a/finch/gntui.c Sat Jan 02 21:58:08 2021 -0600
+++ b/finch/gntui.c Sat Jan 02 22:05:09 2021 -0600
@@ -38,7 +38,6 @@
#include "gntmedia.h"
#include "gntnotify.h"
#include "gntplugin.h"
-#include "gntpounce.h"
#include "gntprefs.h"
#include "gntrequest.h"
#include "gntroomlist.h"
@@ -80,9 +79,6 @@
finch_request_init();
purple_request_set_ui_ops(finch_request_get_ui_ops());
- /* Pounce */
- finch_pounces_init();
-
/* Log */
finch_log_init();
@@ -99,7 +95,6 @@
gnt_register_action(_("Accounts"), finch_accounts_show_all);
gnt_register_action(_("Buddy List"), finch_blist_show);
- gnt_register_action(_("Buddy Pounces"), finch_pounces_manager_show);
gnt_register_action(_("Debug Window"), finch_debug_window_show);
gnt_register_action(_("File Transfers"), finch_xfer_dialog_show);
gnt_register_action(_("Plugins"), finch_plugins_show_all);
@@ -131,8 +126,6 @@
purple_request_set_ui_ops(NULL);
finch_request_uninit();
- finch_pounces_uninit();
-
finch_log_uninit();
finch_xfers_uninit();
--- a/finch/meson.build Sat Jan 02 21:58:08 2021 -0600
+++ b/finch/meson.build Sat Jan 02 22:05:09 2021 -0600
@@ -113,7 +113,6 @@
'gntmenuutil.c',
'gntnotify.c',
'gntplugin.c',
- 'gntpounce.c',
'gntprefs.c',
'gntrequest.c',
'gntroomlist.c',
@@ -136,7 +135,6 @@
'gntmenuutil.h',
'gntnotify.h',
'gntplugin.h',
- 'gntpounce.h',
'gntprefs.h',
'gntrequest.h',
'gntroomlist.h',
--- a/libpurple/account.c Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/account.c Sat Jan 02 22:05:09 2021 -0600
@@ -28,7 +28,6 @@
#include "debug.h"
#include "network.h"
#include "notify.h"
-#include "pounce.h"
#include "prefs.h"
#include "purpleaccountpresence.h"
#include "purplecredentialmanager.h"
--- a/libpurple/accounts.c Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/accounts.c Sat Jan 02 22:05:09 2021 -0600
@@ -27,7 +27,6 @@
#include "debug.h"
#include "enums.h"
#include "network.h"
-#include "pounce.h"
#include "purplecredentialmanager.h"
#include "purpleprivate.h"
@@ -659,9 +658,6 @@
g_object_unref(conv);
}
- /* Remove this account's pounces */
- purple_pounce_destroy_all_by_account(account);
-
/* This will cause the deletion of an old buddy icon. */
purple_buddy_icons_set_account_icon(account, NULL, 0);
--- a/libpurple/buddylist.c Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/buddylist.c Sat Jan 02 22:05:09 2021 -0600
@@ -28,7 +28,6 @@
#include "conversation.h"
#include "debug.h"
#include "notify.h"
-#include "pounce.h"
#include "prefs.h"
#include "protocol.h"
#include "purpleprivate.h"
@@ -1495,9 +1494,6 @@
klass->remove_node(purplebuddylist, node);
}
- /* Remove this buddy's pounces */
- purple_pounce_destroy_all_by_buddy(buddy);
-
/* Signal that the buddy has been removed before freeing the memory for it */
purple_signal_emit(purple_blist_get_handle(), "blist-node-removed",
PURPLE_BLIST_NODE(buddy));
--- a/libpurple/core.c Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/core.c Sat Jan 02 22:05:09 2021 -0600
@@ -35,7 +35,6 @@
#include "network.h"
#include "notify.h"
#include "plugins.h"
-#include "pounce.h"
#include "prefs.h"
#include "proxy.h"
#include "purpleprivate.h"
@@ -176,7 +175,6 @@
purple_blist_init();
purple_log_init();
purple_network_init();
- purple_pounces_init();
purple_proxy_init();
purple_stun_init();
purple_xfers_init();
@@ -223,7 +221,6 @@
_purple_smiley_custom_uninit();
_purple_smiley_parser_uninit();
purple_idle_uninit();
- purple_pounces_uninit();
purple_conversations_uninit();
purple_blist_uninit();
purple_notify_uninit();
@@ -373,7 +370,6 @@
MIGRATE_TO_XDG_DIR(purple_config_dir(), "blist.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "fs-codec.conf");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "fs-element.conf");
- MIGRATE_TO_XDG_DIR(purple_config_dir(), "pounces.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "prefs.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "smileys.xml");
MIGRATE_TO_XDG_DIR(purple_config_dir(), "status.xml");
--- a/libpurple/meson.build Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/meson.build Sat Jan 02 22:05:09 2021 -0600
@@ -40,7 +40,6 @@
'options.c',
'plugins.c',
'pluginpref.c',
- 'pounce.c',
'prefs.c',
'proxy.c',
'protocol.c',
@@ -129,7 +128,6 @@
'options.h',
'plugins.h',
'pluginpref.h',
- 'pounce.h',
'prefs.h',
'proxy.h',
'protocol.h',
--- a/libpurple/plugins/meson.build Sat Jan 02 21:58:08 2021 -0600
+++ b/libpurple/plugins/meson.build Sat Jan 02 22:05:09 2021 -0600
@@ -27,11 +27,6 @@
name_prefix : '',
install : true, install_dir : PURPLE_PLUGINDIR)
- offlinemsg = library('offlinemsg', 'offlinemsg.c',
- dependencies : [libpurple_dep],
- name_prefix : '',
- install : true, install_dir : PURPLE_PLUGINDIR)
-
psychic = library('psychic', 'psychic.c',
dependencies : [libpurple_dep],
name_prefix : '',
--- a/libpurple/plugins/offlinemsg.c Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,234 +0,0 @@
-/*
- * Offline Message Emulation - Save messages sent to an offline user as pounce
- * Copyright (C) 2004
- *
- * 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 <glib/gi18n-lib.h>
-
-#define PLUGIN_ID "core-plugin_pack-offlinemsg"
-#define PLUGIN_NAME N_("Offline Message Emulation")
-#define PLUGIN_CATEGORY N_("Utility")
-#define PLUGIN_STATIC_NAME offlinemsg
-#define PLUGIN_SUMMARY N_("Save messages sent to an offline user as pounce.")
-#define PLUGIN_DESCRIPTION N_("Save messages sent to an offline user as pounce.")
-#define PLUGIN_AUTHORS {"Sadrul H Chowdhury <sadrul@users.sourceforge.net>", NULL}
-
-#include <purple.h>
-
-#define PREF_PREFIX "/plugins/core/" PLUGIN_ID
-#define PREF_ALWAYS PREF_PREFIX "/always"
-
-typedef struct _OfflineMsg OfflineMsg;
-
-typedef enum
-{
- OFFLINE_MSG_NONE,
- OFFLINE_MSG_YES,
- OFFLINE_MSG_NO
-} OfflineMessageSetting;
-
-struct _OfflineMsg
-{
- PurpleAccount *account;
- PurpleConversation *conv;
- char *who;
- char *message;
-};
-
-static void
-discard_data(OfflineMsg *offline)
-{
- g_free(offline->who);
- g_free(offline->message);
- g_free(offline);
-}
-
-static void
-cancel_poune(OfflineMsg *offline)
-{
- g_object_set_data(G_OBJECT(offline->conv), "plugin_pack:offlinemsg",
- GINT_TO_POINTER(OFFLINE_MSG_NO));
- purple_conversation_send_with_flags(offline->conv, offline->message, 0);
- discard_data(offline);
-}
-
-static void
-record_pounce(OfflineMsg *offline)
-{
- PurplePounce *pounce;
- PurplePounceEvent event;
- PurplePounceOption option;
- PurpleConversation *conv;
- PurpleMessage *message;
- char *temp;
- const gchar *me;
-
- me = purple_account_get_name_for_display(offline->account);
-
- event = PURPLE_POUNCE_SIGNON;
- option = PURPLE_POUNCE_OPTION_NONE;
-
- pounce = purple_pounce_new(purple_core_get_ui(), offline->account, offline->who,
- event, option);
-
- purple_pounce_action_set_enabled(pounce, "send-message", TRUE);
-
- temp = g_strdup_printf("(%s) %s", _("Offline message"),
- offline->message);
- purple_pounce_action_set_attribute(pounce, "send-message", "message",
- temp);
- g_free(temp);
-
- conv = offline->conv;
- if (!g_object_get_data(G_OBJECT(conv), "plugin_pack:offlinemsg")) {
- purple_conversation_write_system_message(conv,
- _("The rest of the messages will be saved "
- "as pounces. You can edit/delete the pounce from the `Buddy "
- "Pounce' dialog."), 0);
- }
- g_object_set_data(G_OBJECT(conv), "plugin_pack:offlinemsg",
- GINT_TO_POINTER(OFFLINE_MSG_YES));
-
- message = purple_message_new_outgoing(me, offline->who, offline->message, 0);
- purple_conversation_write_message(conv, message);
- g_object_unref(G_OBJECT(message));
-
- discard_data(offline);
-}
-
-static void
-sending_msg_cb(PurpleAccount *account, PurpleMessage *msg, gpointer handle)
-{
- PurpleBuddy *buddy;
- OfflineMsg *offline;
- PurpleConversation *conv;
- OfflineMessageSetting setting;
- const gchar *who = purple_message_get_recipient(msg);
-
- if (purple_message_is_empty(msg))
- return;
-
- buddy = purple_blist_find_buddy(account, who);
- if (!buddy)
- return;
-
- if (purple_presence_is_online(purple_buddy_get_presence(buddy)))
- return;
-
- if (purple_account_supports_offline_message(account, buddy))
- {
- purple_debug_info("offlinemsg", "Account \"%s\" supports offline messages.\n",
- purple_account_get_username(account));
- return;
- }
-
- conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(who, account));
-
- if (!conv)
- return;
-
- setting = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "plugin_pack:offlinemsg"));
- if (setting == OFFLINE_MSG_NO)
- return;
-
- offline = g_new0(OfflineMsg, 1);
- offline->conv = conv;
- offline->account = account;
- offline->who = g_strdup(who);
- offline->message = g_strdup(purple_message_get_contents(msg));
- purple_message_set_contents(msg, NULL);
-
- if (purple_prefs_get_bool(PREF_ALWAYS) || setting == OFFLINE_MSG_YES)
- record_pounce(offline);
- else if (setting == OFFLINE_MSG_NONE)
- {
- char *ask;
- ask = g_strdup_printf(_("\"%s\" is currently offline. Do you want to save the "
- "rest of the messages in a pounce and automatically send them "
- "when \"%s\" logs back in?"), who, who);
-
- purple_request_action(handle, _("Offline Message"), ask,
- _("You can edit/delete the pounce from the `Buddy Pounces' dialog"),
- 0, purple_request_cpar_from_conversation(offline->conv),
- offline, 2,
- _("Yes"), record_pounce,
- _("No"), cancel_poune);
- g_free(ask);
- }
- else
- {
- g_warn_if_reached();
- g_free(offline);
- }
-}
-
-static PurplePluginPrefFrame *
-get_plugin_pref_frame(PurplePlugin *plugin)
-{
- PurplePluginPrefFrame *frame;
- PurplePluginPref *pref;
-
- frame = purple_plugin_pref_frame_new();
-
- pref = purple_plugin_pref_new_with_label(_("Save offline messages in pounce"));
- purple_plugin_pref_frame_add(frame, pref);
-
- pref = purple_plugin_pref_new_with_name_and_label(PREF_ALWAYS,
- _("Do not ask. Always save in pounce."));
- purple_plugin_pref_frame_add(frame, pref);
-
- return frame;
-}
-
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
- const gchar * const authors[] = PLUGIN_AUTHORS;
-
- return purple_plugin_info_new(
- "id", PLUGIN_ID,
- "name", PLUGIN_NAME,
- "version", DISPLAY_VERSION,
- "category", PLUGIN_CATEGORY,
- "summary", PLUGIN_SUMMARY,
- "description", PLUGIN_DESCRIPTION,
- "authors", authors,
- "website", PURPLE_WEBSITE,
- "abi-version", PURPLE_ABI_VERSION,
- "pref-frame-cb", get_plugin_pref_frame,
- NULL
- );
-}
-
-static gboolean
-plugin_load(PurplePlugin *plugin, GError **error)
-{
- purple_prefs_add_none(PREF_PREFIX);
- purple_prefs_add_bool(PREF_ALWAYS, FALSE);
-
- purple_signal_connect_priority(purple_conversations_get_handle(), "sending-im-msg",
- plugin, PURPLE_CALLBACK(sending_msg_cb), plugin, PURPLE_SIGNAL_PRIORITY_HIGHEST);
- return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
- return TRUE;
-}
-
-PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload);
--- a/libpurple/pounce.c Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1206 +0,0 @@
-/* purple
- *
- * Purple 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 "internal.h"
-#include "conversation.h"
-#include "debug.h"
-#include "pounce.h"
-
-#include "debug.h"
-#include "pounce.h"
-#include "util.h"
-
-/*
- * A buddy pounce structure.
- *
- * Buddy pounces are actions triggered by a buddy-related event. For
- * example, a sound can be played or an IM window opened when a buddy
- * signs on or returns from away. Such responses are handled in the
- * UI. The events themselves are done in the core.
- */
-struct _PurplePounce
-{
- char *ui_type; /* The type of UI. */
-
- PurplePounceEvent events; /* The event(s) to pounce on. */
- PurplePounceOption options; /* The pounce options */
- PurpleAccount *pouncer; /* The user who is pouncing. */
-
- char *pouncee; /* The buddy to pounce on. */
-
- GHashTable *actions; /* The registered actions. */
-
- gboolean save; /* Whether or not the pounce should
- be saved after activation. */
- void *data; /* Pounce-specific data. */
-};
-
-typedef struct
-{
- GString *buffer;
-
- PurplePounce *pounce;
- PurplePounceEvent events;
- PurplePounceOption options;
-
- char *ui_name;
- char *pouncee;
- char *protocol_id;
- char *event_type;
- char *option_type;
- char *action_name;
- char *param_name;
- char *account_name;
-
-} PounceParserData;
-
-typedef struct
-{
- char *name;
-
- gboolean enabled;
-
- GHashTable *atts;
-
-} PurplePounceActionData;
-
-typedef struct
-{
- char *ui;
- PurplePounceCb cb;
- void (*new_pounce)(PurplePounce *);
- void (*free_pounce)(PurplePounce *);
-
-} PurplePounceHandler;
-
-
-static GHashTable *pounce_handlers = NULL;
-static GList *pounces = NULL;
-static guint save_timer = 0;
-static gboolean pounces_loaded = FALSE;
-
-
-/*********************************************************************
- * Private utility functions *
- *********************************************************************/
-
-static PurplePounceActionData *
-find_action_data(const PurplePounce *pounce, const char *name)
-{
- PurplePounceActionData *action;
-
- g_return_val_if_fail(pounce != NULL, NULL);
- g_return_val_if_fail(name != NULL, NULL);
-
- action = g_hash_table_lookup(pounce->actions, name);
-
- return action;
-}
-
-static void
-free_action_data(gpointer data)
-{
- PurplePounceActionData *action_data = data;
-
- g_free(action_data->name);
-
- g_hash_table_destroy(action_data->atts);
-
- g_free(action_data);
-}
-
-
-/*********************************************************************
- * Writing to disk *
- *********************************************************************/
-
-static void
-action_parameter_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
-{
- const char *name, *param_value;
- PurpleXmlNode *node, *child;
-
- name = (const char *)key;
- param_value = (const char *)value;
- node = (PurpleXmlNode *)user_data;
-
- child = purple_xmlnode_new_child(node, "param");
- purple_xmlnode_set_attrib(child, "name", name);
- purple_xmlnode_insert_data(child, param_value, -1);
-}
-
-static void
-action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
-{
- const char *action;
- PurplePounceActionData *action_data;
- PurpleXmlNode *node, *child;
-
- action = (const char *)key;
- action_data = (PurplePounceActionData *)value;
- node = (PurpleXmlNode *)user_data;
-
- if (!action_data->enabled)
- return;
-
- child = purple_xmlnode_new_child(node, "action");
- purple_xmlnode_set_attrib(child, "type", action);
-
- g_hash_table_foreach(action_data->atts, action_parameter_to_xmlnode, child);
-}
-
-static void
-add_event_to_xmlnode(PurpleXmlNode *node, const char *type)
-{
- PurpleXmlNode *child;
-
- child = purple_xmlnode_new_child(node, "event");
- purple_xmlnode_set_attrib(child, "type", type);
-}
-
-static void
-add_option_to_xmlnode(PurpleXmlNode *node, const char *type)
-{
- PurpleXmlNode *child;
-
- child = purple_xmlnode_new_child(node, "option");
- purple_xmlnode_set_attrib(child, "type", type);
-}
-
-static PurpleXmlNode *
-pounce_to_xmlnode(PurplePounce *pounce)
-{
- PurpleXmlNode *node, *child;
- PurpleAccount *pouncer;
- PurplePounceEvent events;
- PurplePounceOption options;
-
- pouncer = purple_pounce_get_pouncer(pounce);
- events = purple_pounce_get_events(pounce);
- options = purple_pounce_get_options(pounce);
-
- node = purple_xmlnode_new("pounce");
- purple_xmlnode_set_attrib(node, "ui", pounce->ui_type);
-
- child = purple_xmlnode_new_child(node, "account");
- purple_xmlnode_set_attrib(child, "protocol", purple_account_get_protocol_id(pouncer));
- purple_xmlnode_insert_data(child,
- purple_normalize(pouncer, purple_account_get_username(pouncer)), -1);
-
- child = purple_xmlnode_new_child(node, "pouncee");
- purple_xmlnode_insert_data(child, purple_pounce_get_pouncee(pounce), -1);
-
- /* Write pounce options */
- child = purple_xmlnode_new_child(node, "options");
- if (options & PURPLE_POUNCE_OPTION_AWAY)
- add_option_to_xmlnode(child, "on-away");
-
- /* Write pounce events */
- child = purple_xmlnode_new_child(node, "events");
- if (events & PURPLE_POUNCE_SIGNON)
- add_event_to_xmlnode(child, "sign-on");
- if (events & PURPLE_POUNCE_SIGNOFF)
- add_event_to_xmlnode(child, "sign-off");
- if (events & PURPLE_POUNCE_AWAY)
- add_event_to_xmlnode(child, "away");
- if (events & PURPLE_POUNCE_AWAY_RETURN)
- add_event_to_xmlnode(child, "return-from-away");
- if (events & PURPLE_POUNCE_IDLE)
- add_event_to_xmlnode(child, "idle");
- if (events & PURPLE_POUNCE_IDLE_RETURN)
- add_event_to_xmlnode(child, "return-from-idle");
- if (events & PURPLE_POUNCE_TYPING)
- add_event_to_xmlnode(child, "start-typing");
- if (events & PURPLE_POUNCE_TYPED)
- add_event_to_xmlnode(child, "typed");
- if (events & PURPLE_POUNCE_TYPING_STOPPED)
- add_event_to_xmlnode(child, "stop-typing");
- if (events & PURPLE_POUNCE_MESSAGE_RECEIVED)
- add_event_to_xmlnode(child, "message-received");
-
- /* Write pounce actions */
- child = purple_xmlnode_new_child(node, "actions");
- g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child);
-
- if (purple_pounce_get_save(pounce))
- purple_xmlnode_new_child(node, "save");
-
- return node;
-}
-
-static PurpleXmlNode *
-pounces_to_xmlnode(void)
-{
- PurpleXmlNode *node, *child;
- GList *cur;
-
- node = purple_xmlnode_new("pounces");
- purple_xmlnode_set_attrib(node, "version", "1.0");
-
- for (cur = purple_pounces_get_all(); cur != NULL; cur = cur->next)
- {
- child = pounce_to_xmlnode(cur->data);
- purple_xmlnode_insert_child(node, child);
- }
-
- return node;
-}
-
-static void
-sync_pounces(void)
-{
- PurpleXmlNode *node;
- char *data;
-
- if (!pounces_loaded)
- {
- purple_debug_error("pounce", "Attempted to save buddy pounces before "
- "they were read!\n");
- return;
- }
-
- node = pounces_to_xmlnode();
- data = purple_xmlnode_to_formatted_str(node, NULL);
- purple_util_write_data_to_config_file("pounces.xml", data, -1);
- g_free(data);
- purple_xmlnode_free(node);
-}
-
-static gboolean
-save_cb(gpointer data)
-{
- sync_pounces();
- save_timer = 0;
- return FALSE;
-}
-
-static void
-schedule_pounces_save(void)
-{
- if (save_timer == 0)
- save_timer = g_timeout_add_seconds(5, save_cb, NULL);
-}
-
-
-/*********************************************************************
- * Reading from disk *
- *********************************************************************/
-
-static void
-free_parser_data(gpointer user_data)
-{
- PounceParserData *data = user_data;
-
- if (data->buffer != NULL)
- g_string_free(data->buffer, TRUE);
-
- g_free(data->ui_name);
- g_free(data->pouncee);
- g_free(data->protocol_id);
- g_free(data->event_type);
- g_free(data->option_type);
- g_free(data->action_name);
- g_free(data->param_name);
- g_free(data->account_name);
-
- g_free(data);
-}
-
-static void
-start_element_handler(GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data, GError **error)
-{
- PounceParserData *data = user_data;
- GHashTable *atts;
- int i;
-
- atts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-
- for (i = 0; attribute_names[i] != NULL; i++) {
- g_hash_table_insert(atts, g_strdup(attribute_names[i]),
- g_strdup(attribute_values[i]));
- }
-
- if (data->buffer != NULL) {
- g_string_free(data->buffer, TRUE);
- data->buffer = NULL;
- }
-
- if (purple_strequal(element_name, "pounce")) {
- const char *ui = g_hash_table_lookup(atts, "ui");
-
- if (ui == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'ui' parameter for pounce!\n");
- }
- else
- data->ui_name = g_strdup(ui);
-
- data->events = 0;
- }
- else if (purple_strequal(element_name, "account")) {
- const char *protocol_id = g_hash_table_lookup(atts, "protocol");
-
- if (protocol_id == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'protocol' parameter for account!\n");
- }
- else
- data->protocol_id = g_strdup(protocol_id);
- }
- else if (purple_strequal(element_name, "option")) {
- const char *type = g_hash_table_lookup(atts, "type");
-
- if (type == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'type' parameter for option!\n");
- }
- else
- data->option_type = g_strdup(type);
- }
- else if (purple_strequal(element_name, "event")) {
- const char *type = g_hash_table_lookup(atts, "type");
-
- if (type == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'type' parameter for event!\n");
- }
- else
- data->event_type = g_strdup(type);
- }
- else if (purple_strequal(element_name, "action")) {
- const char *type = g_hash_table_lookup(atts, "type");
-
- if (type == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'type' parameter for action!\n");
- }
- else
- data->action_name = g_strdup(type);
- }
- else if (purple_strequal(element_name, "param")) {
- const char *param_name = g_hash_table_lookup(atts, "name");
-
- if (param_name == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Unset 'name' parameter for param!\n");
- }
- else
- data->param_name = g_strdup(param_name);
- }
-
- g_hash_table_destroy(atts);
-}
-
-static void
-end_element_handler(GMarkupParseContext *context, const gchar *element_name,
- gpointer user_data, GError **error)
-{
- PounceParserData *data = user_data;
- gchar *buffer = NULL;
-
- if (data->buffer != NULL) {
- buffer = g_string_free(data->buffer, FALSE);
- data->buffer = NULL;
- }
-
- if (purple_strequal(element_name, "account")) {
- g_free(data->account_name);
- data->account_name = g_strdup(buffer);
- }
- else if (purple_strequal(element_name, "pouncee")) {
- g_free(data->pouncee);
- data->pouncee = g_strdup(buffer);
- }
- else if (purple_strequal(element_name, "option")) {
- if (purple_strequal(data->option_type, "on-away"))
- data->options |= PURPLE_POUNCE_OPTION_AWAY;
-
- g_free(data->option_type);
- data->option_type = NULL;
- }
- else if (purple_strequal(element_name, "event")) {
- if (purple_strequal(data->event_type, "sign-on"))
- data->events |= PURPLE_POUNCE_SIGNON;
- else if (purple_strequal(data->event_type, "sign-off"))
- data->events |= PURPLE_POUNCE_SIGNOFF;
- else if (purple_strequal(data->event_type, "away"))
- data->events |= PURPLE_POUNCE_AWAY;
- else if (purple_strequal(data->event_type, "return-from-away"))
- data->events |= PURPLE_POUNCE_AWAY_RETURN;
- else if (purple_strequal(data->event_type, "idle"))
- data->events |= PURPLE_POUNCE_IDLE;
- else if (purple_strequal(data->event_type, "return-from-idle"))
- data->events |= PURPLE_POUNCE_IDLE_RETURN;
- else if (purple_strequal(data->event_type, "start-typing"))
- data->events |= PURPLE_POUNCE_TYPING;
- else if (purple_strequal(data->event_type, "typed"))
- data->events |= PURPLE_POUNCE_TYPED;
- else if (purple_strequal(data->event_type, "stop-typing"))
- data->events |= PURPLE_POUNCE_TYPING_STOPPED;
- else if (purple_strequal(data->event_type, "message-received"))
- data->events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
-
- g_free(data->event_type);
- data->event_type = NULL;
- }
- else if (purple_strequal(element_name, "action")) {
- if (data->pounce != NULL) {
- purple_pounce_action_register(data->pounce, data->action_name);
- purple_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
- }
-
- g_free(data->action_name);
- data->action_name = NULL;
- }
- else if (purple_strequal(element_name, "param")) {
- if (data->pounce != NULL) {
- purple_pounce_action_set_attribute(data->pounce, data->action_name,
- data->param_name, buffer);
- }
-
- g_free(data->param_name);
- data->param_name = NULL;
- }
- else if (purple_strequal(element_name, "events")) {
- PurpleAccount *account;
-
- account = purple_accounts_find(data->account_name, data->protocol_id);
-
- g_free(data->account_name);
- g_free(data->protocol_id);
-
- data->account_name = NULL;
- data->protocol_id = NULL;
-
- if (account == NULL) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Account for pounce not found!\n");
- /*
- * This pounce has effectively been removed, so make
- * sure that we save the changes to pounces.xml
- */
- schedule_pounces_save();
- }
- else {
- purple_debug(PURPLE_DEBUG_INFO, "pounce",
- "Creating pounce: %s, %s\n", data->ui_name,
- data->pouncee);
-
- data->pounce = purple_pounce_new(data->ui_name, account,
- data->pouncee, data->events,
- data->options);
- }
-
- g_free(data->pouncee);
- data->pouncee = NULL;
- }
- else if (purple_strequal(element_name, "save")) {
- if (data->pounce != NULL)
- purple_pounce_set_save(data->pounce, TRUE);
- }
- else if (purple_strequal(element_name, "pounce")) {
- data->pounce = NULL;
- data->events = 0;
- data->options = 0;
-
- g_free(data->ui_name);
- g_free(data->pouncee);
- g_free(data->protocol_id);
- g_free(data->event_type);
- g_free(data->option_type);
- g_free(data->action_name);
- g_free(data->param_name);
- g_free(data->account_name);
-
- data->ui_name = NULL;
- data->pouncee = NULL;
- data->protocol_id = NULL;
- data->event_type = NULL;
- data->option_type = NULL;
- data->action_name = NULL;
- data->param_name = NULL;
- data->account_name = NULL;
- }
-
- g_free(buffer);
-}
-
-static void
-text_handler(GMarkupParseContext *context, const gchar *text,
- gsize text_len, gpointer user_data, GError **error)
-{
- PounceParserData *data = user_data;
-
- if (data->buffer == NULL)
- data->buffer = g_string_new_len(text, text_len);
- else
- g_string_append_len(data->buffer, text, text_len);
-}
-
-static GMarkupParser pounces_parser =
-{
- start_element_handler,
- end_element_handler,
- text_handler,
- NULL,
- NULL
-};
-
-static gboolean
-purple_pounces_load(void)
-{
- gchar *filename = g_build_filename(purple_config_dir(), "pounces.xml", NULL);
- gchar *contents = NULL;
- gsize length;
- GMarkupParseContext *context;
- GError *error = NULL;
- PounceParserData *parser_data;
-
- if (filename == NULL) {
- pounces_loaded = TRUE;
- return FALSE;
- }
-
- if (!g_file_get_contents(filename, &contents, &length, &error)) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce",
- "Error reading pounces: %s\n", error->message);
-
- g_free(filename);
- g_error_free(error);
-
- pounces_loaded = TRUE;
- return FALSE;
- }
-
- parser_data = g_new0(PounceParserData, 1);
-
- context = g_markup_parse_context_new(&pounces_parser, 0,
- parser_data, free_parser_data);
-
- if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
- g_markup_parse_context_free(context);
- g_free(contents);
- g_free(filename);
-
- pounces_loaded = TRUE;
-
- return FALSE;
- }
-
- if (!g_markup_parse_context_end_parse(context, NULL)) {
- purple_debug(PURPLE_DEBUG_ERROR, "pounce", "Error parsing %s\n",
- filename);
-
- g_markup_parse_context_free(context);
- g_free(contents);
- g_free(filename);
- pounces_loaded = TRUE;
-
- return FALSE;
- }
-
- g_markup_parse_context_free(context);
- g_free(contents);
- g_free(filename);
-
- pounces_loaded = TRUE;
-
- return TRUE;
-}
-
-
-PurplePounce *
-purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
- const char *pouncee, PurplePounceEvent event,
- PurplePounceOption option)
-{
- PurplePounce *pounce;
- PurplePounceHandler *handler;
-
- g_return_val_if_fail(ui_type != NULL, NULL);
- g_return_val_if_fail(pouncer != NULL, NULL);
- g_return_val_if_fail(pouncee != NULL, NULL);
- g_return_val_if_fail(event != 0, NULL);
-
- pounce = g_new0(PurplePounce, 1);
-
- pounce->ui_type = g_strdup(ui_type);
- pounce->pouncer = pouncer;
- pounce->pouncee = g_strdup(pouncee);
- pounce->events = event;
- pounce->options = option;
-
- pounce->actions = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, free_action_data);
-
- handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
-
- if (handler != NULL && handler->new_pounce != NULL)
- handler->new_pounce(pounce);
-
- pounces = g_list_append(pounces, pounce);
-
- schedule_pounces_save();
-
- return pounce;
-}
-
-void
-purple_pounce_destroy(PurplePounce *pounce)
-{
- PurplePounceHandler *handler;
-
- g_return_if_fail(pounce != NULL);
-
- handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
-
- pounces = g_list_remove(pounces, pounce);
-
- g_free(pounce->ui_type);
- g_free(pounce->pouncee);
-
- g_hash_table_destroy(pounce->actions);
-
- if (handler != NULL && handler->free_pounce != NULL)
- handler->free_pounce(pounce);
-
- g_free(pounce);
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_destroy_all_by_account(PurpleAccount *account)
-{
- PurpleAccount *pouncer;
- PurplePounce *pounce;
- GList *l, *l_next;
-
- g_return_if_fail(account != NULL);
-
- for (l = purple_pounces_get_all(); l != NULL; l = l_next)
- {
- pounce = (PurplePounce *)l->data;
- l_next = l->next;
-
- pouncer = purple_pounce_get_pouncer(pounce);
- if (pouncer == account)
- purple_pounce_destroy(pounce);
- }
-}
-
-void
-purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy)
-{
- const char *pouncee, *bname;
- PurpleAccount *pouncer, *bacct;
- PurplePounce *pounce;
- GList *l, *l_next;
-
- g_return_if_fail(buddy != NULL);
-
- bacct = purple_buddy_get_account(buddy);
- bname = purple_buddy_get_name(buddy);
-
- for (l = purple_pounces_get_all(); l != NULL; l = l_next) {
- pounce = (PurplePounce *)l->data;
- l_next = l->next;
-
- pouncer = purple_pounce_get_pouncer(pounce);
- pouncee = purple_pounce_get_pouncee(pounce);
-
- if ( (pouncer == bacct) && (purple_strequal(pouncee, bname)) )
- purple_pounce_destroy(pounce);
- }
-}
-
-void
-purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events)
-{
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(events != PURPLE_POUNCE_NONE);
-
- pounce->events = events;
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options)
-{
- g_return_if_fail(pounce != NULL);
-
- pounce->options = options;
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer)
-{
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(pouncer != NULL);
-
- pounce->pouncer = pouncer;
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee)
-{
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(pouncee != NULL);
-
- g_free(pounce->pouncee);
- pounce->pouncee = g_strdup(pouncee);
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_set_save(PurplePounce *pounce, gboolean save)
-{
- g_return_if_fail(pounce != NULL);
-
- pounce->save = save;
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_action_register(PurplePounce *pounce, const char *name)
-{
- PurplePounceActionData *action_data;
-
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(name != NULL);
-
- if (g_hash_table_lookup(pounce->actions, name) != NULL)
- return;
-
- action_data = g_new0(PurplePounceActionData, 1);
-
- action_data->name = g_strdup(name);
- action_data->enabled = FALSE;
- action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, g_free);
-
- g_hash_table_insert(pounce->actions, g_strdup(name), action_data);
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action,
- gboolean enabled)
-{
- PurplePounceActionData *action_data;
-
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(action != NULL);
-
- action_data = find_action_data(pounce, action);
-
- g_return_if_fail(action_data != NULL);
-
- action_data->enabled = enabled;
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action,
- const char *attr, const char *value)
-{
- PurplePounceActionData *action_data;
-
- g_return_if_fail(pounce != NULL);
- g_return_if_fail(action != NULL);
- g_return_if_fail(attr != NULL);
-
- action_data = find_action_data(pounce, action);
-
- g_return_if_fail(action_data != NULL);
-
- if (value == NULL)
- g_hash_table_remove(action_data->atts, attr);
- else
- g_hash_table_insert(action_data->atts, g_strdup(attr),
- g_strdup(value));
-
- schedule_pounces_save();
-}
-
-void
-purple_pounce_set_data(PurplePounce *pounce, void *data)
-{
- g_return_if_fail(pounce != NULL);
-
- pounce->data = data;
-
- schedule_pounces_save();
-}
-
-PurplePounceEvent
-purple_pounce_get_events(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, PURPLE_POUNCE_NONE);
-
- return pounce->events;
-}
-
-PurplePounceOption
-purple_pounce_get_options(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, PURPLE_POUNCE_OPTION_NONE);
-
- return pounce->options;
-}
-
-PurpleAccount *
-purple_pounce_get_pouncer(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, NULL);
-
- return pounce->pouncer;
-}
-
-const char *
-purple_pounce_get_pouncee(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, NULL);
-
- return pounce->pouncee;
-}
-
-gboolean
-purple_pounce_get_save(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, FALSE);
-
- return pounce->save;
-}
-
-gboolean
-purple_pounce_action_is_enabled(const PurplePounce *pounce, const char *action)
-{
- PurplePounceActionData *action_data;
-
- g_return_val_if_fail(pounce != NULL, FALSE);
- g_return_val_if_fail(action != NULL, FALSE);
-
- action_data = find_action_data(pounce, action);
-
- g_return_val_if_fail(action_data != NULL, FALSE);
-
- return action_data->enabled;
-}
-
-const char *
-purple_pounce_action_get_attribute(const PurplePounce *pounce,
- const char *action, const char *attr)
-{
- PurplePounceActionData *action_data;
-
- g_return_val_if_fail(pounce != NULL, NULL);
- g_return_val_if_fail(action != NULL, NULL);
- g_return_val_if_fail(attr != NULL, NULL);
-
- action_data = find_action_data(pounce, action);
-
- g_return_val_if_fail(action_data != NULL, NULL);
-
- return g_hash_table_lookup(action_data->atts, attr);
-}
-
-void *
-purple_pounce_get_data(const PurplePounce *pounce)
-{
- g_return_val_if_fail(pounce != NULL, NULL);
-
- return pounce->data;
-}
-
-void
-purple_pounce_execute(PurpleAccount *pouncer, const char *pouncee,
- PurplePounceEvent events)
-{
- PurplePounce *pounce;
- PurplePounceHandler *handler;
- PurplePresence *presence;
- GList *l, *l_next;
- char *norm_pouncee;
-
- g_return_if_fail(pouncer != NULL);
- g_return_if_fail(pouncee != NULL);
- g_return_if_fail(events != PURPLE_POUNCE_NONE);
-
- norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));
-
- for (l = purple_pounces_get_all(); l != NULL; l = l_next)
- {
- pounce = (PurplePounce *)l->data;
- l_next = l->next;
-
- presence = purple_account_get_presence(pouncer);
-
- if ((purple_pounce_get_events(pounce) & events) &&
- (purple_pounce_get_pouncer(pounce) == pouncer) &&
- !purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
- norm_pouncee) &&
- (pounce->options == PURPLE_POUNCE_OPTION_NONE ||
- (pounce->options & PURPLE_POUNCE_OPTION_AWAY &&
- !purple_presence_is_available(presence))))
- {
- handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
-
- if (handler != NULL && handler->cb != NULL)
- {
- handler->cb(pounce, events, purple_pounce_get_data(pounce));
-
- if (!purple_pounce_get_save(pounce))
- purple_pounce_destroy(pounce);
- }
- }
- }
-
- g_free(norm_pouncee);
-}
-
-PurplePounce *
-purple_find_pounce(PurpleAccount *pouncer, const char *pouncee,
- PurplePounceEvent events)
-{
- PurplePounce *pounce = NULL;
- GList *l;
- char *norm_pouncee;
-
- g_return_val_if_fail(pouncer != NULL, NULL);
- g_return_val_if_fail(pouncee != NULL, NULL);
- g_return_val_if_fail(events != PURPLE_POUNCE_NONE, NULL);
-
- norm_pouncee = g_strdup(purple_normalize(pouncer, pouncee));
-
- for (l = purple_pounces_get_all(); l != NULL; l = l->next)
- {
- pounce = (PurplePounce *)l->data;
-
- if ((purple_pounce_get_events(pounce) & events) &&
- (purple_pounce_get_pouncer(pounce) == pouncer) &&
- !purple_utf8_strcasecmp(purple_normalize(pouncer, purple_pounce_get_pouncee(pounce)),
- norm_pouncee))
- {
- break;
- }
-
- pounce = NULL;
- }
-
- g_free(norm_pouncee);
-
- return pounce;
-}
-
-void
-purple_pounces_register_handler(const char *ui, PurplePounceCb cb,
- void (*new_pounce)(PurplePounce *pounce),
- void (*free_pounce)(PurplePounce *pounce))
-{
- PurplePounceHandler *handler;
-
- g_return_if_fail(ui != NULL);
- g_return_if_fail(cb != NULL);
-
- handler = g_new0(PurplePounceHandler, 1);
-
- handler->ui = g_strdup(ui);
- handler->cb = cb;
- handler->new_pounce = new_pounce;
- handler->free_pounce = free_pounce;
-
- g_hash_table_insert(pounce_handlers, g_strdup(ui), handler);
-}
-
-void
-purple_pounces_unregister_handler(const char *ui)
-{
- g_return_if_fail(ui != NULL);
-
- g_hash_table_remove(pounce_handlers, ui);
-}
-
-GList *
-purple_pounces_get_all(void)
-{
- return pounces;
-}
-
-GList *purple_pounces_get_all_for_ui(const char *ui)
-{
- GList *list = NULL, *iter;
- g_return_val_if_fail(ui != NULL, NULL);
-
- for (iter = pounces; iter; iter = iter->next) {
- PurplePounce *pounce = iter->data;
- if (purple_strequal(pounce->ui_type, ui))
- list = g_list_prepend(list, pounce);
- }
- list = g_list_reverse(list);
- return list;
-}
-
-static void
-free_pounce_handler(gpointer user_data)
-{
- PurplePounceHandler *handler = (PurplePounceHandler *)user_data;
-
- g_free(handler->ui);
- g_free(handler);
-}
-
-static void
-buddy_state_cb(PurpleBuddy *buddy, PurplePounceEvent event)
-{
- PurpleAccount *account = purple_buddy_get_account(buddy);
- const gchar *name = purple_buddy_get_name(buddy);
-
- purple_pounce_execute(account, name, event);
-}
-
-static void
-buddy_status_changed_cb(PurpleBuddy *buddy, PurpleStatus *old_status,
- PurpleStatus *status)
-{
- PurpleAccount *account = purple_buddy_get_account(buddy);
- const gchar *name = purple_buddy_get_name(buddy);
- gboolean old_available, available;
-
- available = purple_status_is_available(status);
- old_available = purple_status_is_available(old_status);
-
- if (available && !old_available)
- purple_pounce_execute(account, name, PURPLE_POUNCE_AWAY_RETURN);
- else if (!available && old_available)
- purple_pounce_execute(account, name, PURPLE_POUNCE_AWAY);
-}
-
-static void
-buddy_idle_changed_cb(PurpleBuddy *buddy, gboolean old_idle, gboolean idle)
-{
- PurpleAccount *account = purple_buddy_get_account(buddy);
- const gchar *name = purple_buddy_get_name(buddy);
-
- if (idle && !old_idle)
- purple_pounce_execute(account, name, PURPLE_POUNCE_IDLE);
- else if (!idle && old_idle)
- purple_pounce_execute(account, name, PURPLE_POUNCE_IDLE_RETURN);
-}
-
-static void
-buddy_typing_cb(PurpleAccount *account, const char *name, void *data)
-{
- PurpleIMConversation *im;
-
- im = purple_conversations_find_im_with_account(name, account);
- if (im != NULL)
- {
- PurpleIMTypingState state;
- PurplePounceEvent event;
-
- state = purple_im_conversation_get_typing_state(im);
- if (state == PURPLE_IM_TYPED)
- event = PURPLE_POUNCE_TYPED;
- else if (state == PURPLE_IM_NOT_TYPING)
- event = PURPLE_POUNCE_TYPING_STOPPED;
- else
- event = PURPLE_POUNCE_TYPING;
-
- purple_pounce_execute(account, name, event);
- }
-}
-
-static void
-received_message_cb(PurpleAccount *account, const char *name, void *data)
-{
- purple_pounce_execute(account, name, PURPLE_POUNCE_MESSAGE_RECEIVED);
-}
-
-void *
-purple_pounces_get_handle(void)
-{
- static int pounce_handle;
-
- return &pounce_handle;
-}
-
-void
-purple_pounces_init(void)
-{
- void *handle = purple_pounces_get_handle();
- void *blist_handle = purple_blist_get_handle();
- void *conv_handle = purple_conversations_get_handle();
-
- pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, free_pounce_handler);
-
- purple_signal_connect(blist_handle, "buddy-idle-changed",
- handle, PURPLE_CALLBACK(buddy_idle_changed_cb), NULL);
- purple_signal_connect(blist_handle, "buddy-status-changed",
- handle, PURPLE_CALLBACK(buddy_status_changed_cb), NULL);
- purple_signal_connect(blist_handle, "buddy-signed-on",
- handle, PURPLE_CALLBACK(buddy_state_cb),
- GINT_TO_POINTER(PURPLE_POUNCE_SIGNON));
- purple_signal_connect(blist_handle, "buddy-signed-off",
- handle, PURPLE_CALLBACK(buddy_state_cb),
- GINT_TO_POINTER(PURPLE_POUNCE_SIGNOFF));
-
- purple_signal_connect(conv_handle, "buddy-typing",
- handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
- purple_signal_connect(conv_handle, "buddy-typed",
- handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
- purple_signal_connect(conv_handle, "buddy-typing-stopped",
- handle, PURPLE_CALLBACK(buddy_typing_cb), NULL);
-
- purple_signal_connect(conv_handle, "received-im-msg",
- handle, PURPLE_CALLBACK(received_message_cb), NULL);
-
- purple_pounces_load();
-}
-
-void
-purple_pounces_uninit()
-{
- if (save_timer != 0)
- {
- g_source_remove(save_timer);
- save_timer = 0;
- sync_pounces();
- }
-
- purple_signals_disconnect_by_handle(purple_pounces_get_handle());
-
- g_hash_table_destroy(pounce_handlers);
- pounce_handlers = NULL;
-}
--- a/libpurple/pounce.h Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,407 +0,0 @@
-/* purple
- *
- * Purple 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
- */
-
-#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
-# error "only <purple.h> may be included directly"
-#endif
-
-#ifndef PURPLE_POUNCE_H
-#define PURPLE_POUNCE_H
-/**
- * SECTION:pounce
- * @section_id: libpurple-pounce
- * @short_description: <filename>pounce.h</filename>
- * @title: Buddy Pounce API
- */
-
-typedef struct _PurplePounce PurplePounce;
-
-#include <glib.h>
-#include "account.h"
-
-/**
- * PurplePounceEvent:
- * @PURPLE_POUNCE_NONE: No events.
- * @PURPLE_POUNCE_SIGNON: The buddy signed on.
- * @PURPLE_POUNCE_SIGNOFF: The buddy signed off.
- * @PURPLE_POUNCE_AWAY: The buddy went away.
- * @PURPLE_POUNCE_AWAY_RETURN: The buddy returned from away.
- * @PURPLE_POUNCE_IDLE: The buddy became idle.
- * @PURPLE_POUNCE_IDLE_RETURN: The buddy is no longer idle.
- * @PURPLE_POUNCE_TYPING: The buddy started typing.
- * @PURPLE_POUNCE_TYPED: The buddy has entered text.
- * @PURPLE_POUNCE_TYPING_STOPPED: The buddy stopped typing.
- * @PURPLE_POUNCE_MESSAGE_RECEIVED: The buddy sent a message.
- *
- * Events that trigger buddy pounces.
- */
-typedef enum
-{
- PURPLE_POUNCE_NONE = 0x000,
- PURPLE_POUNCE_SIGNON = 0x001,
- PURPLE_POUNCE_SIGNOFF = 0x002,
- PURPLE_POUNCE_AWAY = 0x004,
- PURPLE_POUNCE_AWAY_RETURN = 0x008,
- PURPLE_POUNCE_IDLE = 0x010,
- PURPLE_POUNCE_IDLE_RETURN = 0x020,
- PURPLE_POUNCE_TYPING = 0x040,
- PURPLE_POUNCE_TYPED = 0x080,
- PURPLE_POUNCE_TYPING_STOPPED = 0x100,
- PURPLE_POUNCE_MESSAGE_RECEIVED = 0x200
-
-} PurplePounceEvent;
-
-/**
- * PurplePounceOption:
- * @PURPLE_POUNCE_OPTION_NONE: No Option
- * @PURPLE_POUNCE_OPTION_AWAY: Pounce only when away
- */
-typedef enum
-{
- PURPLE_POUNCE_OPTION_NONE = 0x00,
- PURPLE_POUNCE_OPTION_AWAY = 0x01
-} PurplePounceOption;
-
-/**
- * PurplePounceCb:
- * @pounce: The #PurplePounce.
- * @event: The #PurplePounceEvent.
- * @data: user-data.
- *
- * A pounce callback.
- */
-typedef void (*PurplePounceCb)(PurplePounce *pounce, PurplePounceEvent event, void *data);
-
-G_BEGIN_DECLS
-
-/**************************************************************************/
-/* Buddy Pounce API */
-/**************************************************************************/
-
-/**
- * purple_pounce_new:
- * @ui_type: The type of UI the pounce is for.
- * @pouncer: The account that will pounce.
- * @pouncee: The buddy to pounce on.
- * @event: The event(s) to pounce on.
- * @option: Pounce options.
- *
- * Creates a new buddy pounce.
- *
- * Returns: (transfer full): The new buddy pounce structure.
- */
-PurplePounce *purple_pounce_new(const char *ui_type, PurpleAccount *pouncer,
- const char *pouncee, PurplePounceEvent event,
- PurplePounceOption option);
-
-/**
- * purple_pounce_destroy:
- * @pounce: The buddy pounce.
- *
- * Destroys a buddy pounce.
- */
-void purple_pounce_destroy(PurplePounce *pounce);
-
-/**
- * purple_pounce_destroy_all_by_account:
- * @account: The account to remove all pounces from.
- *
- * Destroys all buddy pounces for the account
- */
-void purple_pounce_destroy_all_by_account(PurpleAccount *account);
-
-/**
- * purple_pounce_destroy_all_by_buddy:
- * @buddy: The buddy whose pounces are to be removed
- *
- * Destroys all buddy pounces for a buddy
- */
-void purple_pounce_destroy_all_by_buddy(PurpleBuddy *buddy);
-
-/**
- * purple_pounce_set_events:
- * @pounce: The buddy pounce.
- * @events: The events to watch for.
- *
- * Sets the events a pounce should watch for.
- */
-void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events);
-
-/**
- * purple_pounce_set_options:
- * @pounce: The buddy pounce.
- * @options: The options for the pounce.
- *
- * Sets the options for a pounce.
- */
-void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options);
-
-/**
- * purple_pounce_set_pouncer:
- * @pounce: The buddy pounce.
- * @pouncer: The account that will pounce.
- *
- * Sets the account that will do the pouncing.
- */
-void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer);
-
-/**
- * purple_pounce_set_pouncee:
- * @pounce: The buddy pounce.
- * @pouncee: The buddy to pounce on.
- *
- * Sets the buddy a pounce should pounce on.
- */
-void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee);
-
-/**
- * purple_pounce_set_save:
- * @pounce: The buddy pounce.
- * @save: %TRUE if the pounce should be saved, or %FALSE otherwise.
- *
- * Sets whether or not the pounce should be saved after execution.
- */
-void purple_pounce_set_save(PurplePounce *pounce, gboolean save);
-
-/**
- * purple_pounce_action_register:
- * @pounce: The buddy pounce.
- * @name: The action name.
- *
- * Registers an action type for the pounce.
- */
-void purple_pounce_action_register(PurplePounce *pounce, const char *name);
-
-/**
- * purple_pounce_action_set_enabled:
- * @pounce: The buddy pounce.
- * @action: The name of the action.
- * @enabled: The enabled state.
- *
- * Enables or disables an action for a pounce.
- */
-void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action,
- gboolean enabled);
-
-/**
- * purple_pounce_action_set_attribute:
- * @pounce: The buddy pounce.
- * @action: The action name.
- * @attr: The attribute name.
- * @value: The value.
- *
- * Sets a value for an attribute in an action.
- *
- * If @value is %NULL, the value will be unset.
- */
-void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action,
- const char *attr, const char *value);
-
-/**
- * purple_pounce_set_data:
- * @pounce: The buddy pounce.
- * @data: Data specific to the pounce.
- *
- * Sets the pounce-specific data.
- */
-void purple_pounce_set_data(PurplePounce *pounce, void *data);
-
-/**
- * purple_pounce_get_events:
- * @pounce: The buddy pounce.
- *
- * Returns the events a pounce should watch for.
- *
- * Returns: The events the pounce is watching for.
- */
-PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce);
-
-/**
- * purple_pounce_get_options:
- * @pounce: The buddy pounce.
- *
- * Returns the options for a pounce.
- *
- * Returns: The options for the pounce.
- */
-PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce);
-
-/**
- * purple_pounce_get_pouncer:
- * @pounce: The buddy pounce.
- *
- * Returns the account that will do the pouncing.
- *
- * Returns: (transfer none): The account that will pounce.
- */
-PurpleAccount *purple_pounce_get_pouncer(const PurplePounce *pounce);
-
-/**
- * purple_pounce_get_pouncee:
- * @pounce: The buddy pounce.
- *
- * Returns the buddy a pounce should pounce on.
- *
- * Returns: The buddy to pounce on.
- */
-const char *purple_pounce_get_pouncee(const PurplePounce *pounce);
-
-/**
- * purple_pounce_get_save:
- * @pounce: The buddy pounce.
- *
- * Returns whether or not the pounce should save after execution.
- *
- * Returns: %TRUE if the pounce should be saved after execution, or
- * %FALSE otherwise.
- */
-gboolean purple_pounce_get_save(const PurplePounce *pounce);
-
-/**
- * purple_pounce_action_is_enabled:
- * @pounce: The buddy pounce.
- * @action: The action name.
- *
- * Returns whether or not an action is enabled.
- *
- * Returns: %TRUE if the action is enabled, or %FALSE otherwise.
- */
-gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce,
- const char *action);
-
-/**
- * purple_pounce_action_get_attribute:
- * @pounce: The buddy pounce.
- * @action: The action name.
- * @attr: The attribute name.
- *
- * Returns the value for an attribute in an action.
- *
- * Returns: The attribute value, if it exists, or %NULL.
- */
-const char *purple_pounce_action_get_attribute(const PurplePounce *pounce,
- const char *action,
- const char *attr);
-
-/**
- * purple_pounce_get_data:
- * @pounce: The buddy pounce.
- *
- * Returns the pounce-specific data.
- *
- * Returns: The data specific to a buddy pounce.
- */
-void *purple_pounce_get_data(const PurplePounce *pounce);
-
-/**
- * purple_pounce_execute:
- * @pouncer: The account that will do the pouncing.
- * @pouncee: The buddy that is being pounced.
- * @events: The events that triggered the pounce.
- *
- * Executes a pounce with the specified pouncer, pouncee, and event type.
- */
-void purple_pounce_execute(PurpleAccount *pouncer, const char *pouncee,
- PurplePounceEvent events);
-
-/**************************************************************************/
-/* Buddy Pounce Subsystem API */
-/**************************************************************************/
-
-/**
- * purple_find_pounce:
- * @pouncer: The account to match against.
- * @pouncee: The buddy to match against.
- * @events: The event(s) to match against.
- *
- * Finds a pounce with the specified event(s) and buddy.
- *
- * Returns: (transfer none): The pounce if found, or %NULL otherwise.
- */
-PurplePounce *purple_find_pounce(PurpleAccount *pouncer,
- const char *pouncee, PurplePounceEvent events);
-
-/**
- * purple_pounces_register_handler:
- * @ui: The UI name.
- * @cb: (scope call): The callback function.
- * @new_pounce: The function called when a pounce is created.
- * @free_pounce: The function called when a pounce is freed.
- *
- * Registers a pounce handler for a UI.
- */
-void purple_pounces_register_handler(const char *ui, PurplePounceCb cb,
- void (*new_pounce)(PurplePounce *pounce),
- void (*free_pounce)(PurplePounce *pounce));
-
-/**
- * purple_pounces_unregister_handler:
- * @ui: The UI name.
- *
- * Unregisters a pounce handle for a UI.
- */
-void purple_pounces_unregister_handler(const char *ui);
-
-/**
- * purple_pounces_get_all:
- *
- * Returns a list of all registered buddy pounces.
- *
- * Returns: (element-type PurplePounce) (transfer none): The list of buddy pounces.
- */
-GList *purple_pounces_get_all(void);
-
-/**
- * purple_pounces_get_all_for_ui:
- * @ui: The ID of the UI using the core.
- *
- * Returns a list of registered buddy pounces for the ui-type.
- *
- * Returns: (element-type PurplePounce) (transfer container): The list of buddy pounces.
- */
-GList *purple_pounces_get_all_for_ui(const char *ui);
-
-/**
- * purple_pounces_get_handle:
- *
- * Returns the buddy pounce subsystem handle.
- *
- * Returns: The subsystem handle.
- */
-void *purple_pounces_get_handle(void);
-
-/**
- * purple_pounces_init:
- *
- * Initializes the pounces subsystem.
- */
-void purple_pounces_init(void);
-
-/**
- * purple_pounces_uninit:
- *
- * Uninitializes the pounces subsystem.
- */
-void purple_pounces_uninit(void);
-
-G_END_DECLS
-
-#endif /* PURPLE_POUNCE_H */
--- a/pidgin/gtkblist.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/gtkblist.c Sat Jan 02 22:05:09 2021 -0600
@@ -32,7 +32,6 @@
#include "gtkconv.h"
#include "gtkdialogs.h"
#include "gtkxfer.h"
-#include "gtkpounce.h"
#include "gtkprivacy.h"
#include "gtkroomlist.h"
#include "gtkstatusbox.h"
@@ -713,12 +712,6 @@
gtk_tree_path_free(path);
}
-static void gtk_blist_menu_bp_cb(GtkWidget *w, PurpleBuddy *b)
-{
- pidgin_pounce_editor_show(purple_buddy_get_account(b),
- purple_buddy_get_name(b), NULL);
-}
-
static void gtk_blist_menu_showlog_cb(GtkWidget *w, PurpleBlistNode *node)
{
PurpleLogType type;
@@ -1557,9 +1550,6 @@
}
}
- pidgin_new_menu_item(menu, _("Add Buddy _Pounce..."), NULL,
- G_CALLBACK(gtk_blist_menu_bp_cb), buddy);
-
if (node->parent && node->parent->child->next &&
!sub && !contact_expanded) {
pidgin_new_menu_item(menu, _("View _Log"), NULL,
--- a/pidgin/gtkconv.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/gtkconv.c Sat Jan 02 22:05:09 2021 -0600
@@ -46,7 +46,6 @@
#include "gtkconv.h"
#include "gtkconvwin.h"
#include "gtkdialogs.h"
-#include "gtkpounce.h"
#include "gtkprefs.h"
#include "gtkprivacy.h"
#include "gtkutils.h"
@@ -943,18 +942,6 @@
}
static void
-menu_add_pounce_cb(GtkAction *action, gpointer data)
-{
- PidginConvWindow *win = data;
- PurpleConversation *conv;
-
- conv = pidgin_conv_window_get_active_gtkconv(win)->active_conv;
-
- pidgin_pounce_editor_show(purple_conversation_get_account(conv),
- purple_conversation_get_name(conv), NULL);
-}
-
-static void
menu_alias_cb(GtkAction *action, gpointer data)
{
PidginConvWindow *win = data;
@@ -2423,7 +2410,6 @@
{ "SendFile", PIDGIN_STOCK_TOOLBAR_SEND_FILE, N_("Se_nd File..."), NULL, NULL, G_CALLBACK(menu_send_file_cb) },
{ "GetAttention", PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, N_("Get _Attention"), NULL, NULL, G_CALLBACK(menu_get_attention_cb) },
- { "AddBuddyPounce", NULL, N_("Add Buddy _Pounce..."), NULL, NULL, G_CALLBACK(menu_add_pounce_cb) },
{ "GetInfo", PIDGIN_STOCK_TOOLBAR_USER_INFO, N_("_Get Info"), "<control>O", NULL, G_CALLBACK(menu_get_info_cb) },
{ "Invite", NULL, N_("In_vite..."), NULL, NULL, G_CALLBACK(menu_invite_cb) },
{ "MoreMenu", NULL, N_("M_ore"), NULL, NULL, NULL },
@@ -2467,7 +2453,6 @@
#endif
"<menuitem action='SendFile'/>"
"<menuitem action='GetAttention'/>"
- "<menuitem action='AddBuddyPounce'/>"
"<menuitem action='GetInfo'/>"
"<menuitem action='Invite'/>"
"<menu action='MoreMenu'/>"
@@ -2864,10 +2849,6 @@
gtk_ui_manager_get_action(win->menu->ui,
"/Conversation/ConversationMenu/GetAttention");
- win->menu->add_pounce =
- gtk_ui_manager_get_action(win->menu->ui,
- "/Conversation/ConversationMenu/AddBuddyPounce");
-
/* --- */
win->menu->get_info =
@@ -4848,7 +4829,6 @@
gtk_action_set_visible(win->menu->view_log, TRUE);
gtk_action_set_visible(win->menu->send_file, TRUE);
gtk_action_set_visible(win->menu->get_attention, TRUE);
- gtk_action_set_visible(win->menu->add_pounce, TRUE);
gtk_action_set_visible(win->menu->get_info, TRUE);
gtk_action_set_visible(win->menu->invite, FALSE);
gtk_action_set_visible(win->menu->alias, TRUE);
@@ -4877,7 +4857,6 @@
gtk_action_set_visible(win->menu->view_log, TRUE);
gtk_action_set_visible(win->menu->send_file, FALSE);
gtk_action_set_visible(win->menu->get_attention, FALSE);
- gtk_action_set_visible(win->menu->add_pounce, FALSE);
gtk_action_set_visible(win->menu->get_info, FALSE);
gtk_action_set_visible(win->menu->invite, TRUE);
gtk_action_set_visible(win->menu->alias, TRUE);
@@ -4939,7 +4918,6 @@
/* Deal with menu items */
gtk_action_set_sensitive(win->menu->view_log, TRUE);
- gtk_action_set_sensitive(win->menu->add_pounce, TRUE);
gtk_action_set_sensitive(win->menu->get_info, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, SERVER, get_info)));
gtk_action_set_sensitive(win->menu->invite, (PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, invite)));
gtk_action_set_sensitive(win->menu->insert_link, (features & PURPLE_CONNECTION_FLAG_HTML));
@@ -4981,7 +4959,6 @@
gtk_action_set_sensitive(win->menu->view_log, TRUE);
gtk_action_set_sensitive(win->menu->send_file, FALSE);
gtk_action_set_sensitive(win->menu->get_attention, FALSE);
- gtk_action_set_sensitive(win->menu->add_pounce, TRUE);
gtk_action_set_sensitive(win->menu->get_info, FALSE);
gtk_action_set_sensitive(win->menu->invite, FALSE);
gtk_action_set_sensitive(win->menu->alias, FALSE);
@@ -6464,7 +6441,6 @@
#include "gtkblist.h"
#include "gtkconv.h"
#include "gtkdialogs.h"
-#include "gtkpounce.h"
#include "gtkprefs.h"
#include "gtkprivacy.h"
#include "gtkutils.h"
--- a/pidgin/gtkconvwin.h Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/gtkconvwin.h Sat Jan 02 22:05:09 2021 -0600
@@ -57,7 +57,6 @@
GtkAction *send_file;
GtkAction *get_attention;
- GtkAction *add_pounce;
GtkAction *get_info;
GtkAction *invite;
--- a/pidgin/gtknotify.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/gtknotify.c Sat Jan 02 22:05:09 2021 -0600
@@ -28,7 +28,6 @@
#include "gtkblist.h"
#include "gtknotify.h"
-#include "gtkpounce.h"
#include "gtkutils.h"
#include "pidgincore.h"
#include "pidginstock.h"
@@ -51,14 +50,6 @@
typedef struct
{
PurpleAccount *account;
- PurplePounce *pounce;
- char *pouncee;
-} PidginNotifyPounceData;
-
-
-typedef struct
-{
- PurpleAccount *account;
GtkListStore *model;
GtkWidget *treeview;
GtkWidget *window;
@@ -82,18 +73,6 @@
COLUMNS_PIDGIN_MAIL
};
-enum
-{
- PIDGIN_POUNCE_ICON,
- PIDGIN_POUNCE_ALIAS,
- PIDGIN_POUNCE_EVENT,
- PIDGIN_POUNCE_TEXT,
- PIDGIN_POUNCE_DATE,
- PIDGIN_POUNCE_DATA,
- COLUMNS_PIDGIN_POUNCE
-};
-
-
typedef struct
{
/*
@@ -114,12 +93,10 @@
typedef enum
{
PIDGIN_NOTIFY_MAIL,
- PIDGIN_NOTIFY_POUNCE,
PIDGIN_NOTIFY_TYPES
} PidginNotifyType;
static PidginNotifyDialog *mail_dialog = NULL;
-static PidginNotifyDialog *pounce_dialog = NULL;
static PidginNotifyDialog *pidgin_create_notification_dialog(PidginNotifyType type);
static void *pidgin_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed,
@@ -136,225 +113,6 @@
}
static void
-pounce_response_close(PidginNotifyDialog *dialog)
-{
- GtkTreeIter iter;
- PidginNotifyPounceData *pounce_data;
-
- while (gtk_tree_model_get_iter_first(
- GTK_TREE_MODEL(pounce_dialog->treemodel), &iter)) {
- gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
- PIDGIN_POUNCE_DATA, &pounce_data,
- -1);
- gtk_tree_store_remove(dialog->treemodel, &iter);
-
- g_free(pounce_data->pouncee);
- g_free(pounce_data);
- }
-
- gtk_widget_destroy(pounce_dialog->dialog);
- g_free(pounce_dialog);
- pounce_dialog = NULL;
-}
-
-static void
-delete_foreach(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- PidginNotifyPounceData *pounce_data;
-
- gtk_tree_model_get(model, iter,
- PIDGIN_POUNCE_DATA, &pounce_data,
- -1);
-
- if (pounce_data != NULL) {
- g_free(pounce_data->pouncee);
- g_free(pounce_data);
- }
-}
-
-static void
-open_im_foreach(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- PidginNotifyPounceData *pounce_data;
-
- gtk_tree_model_get(model, iter,
- PIDGIN_POUNCE_DATA, &pounce_data,
- -1);
-
- if (pounce_data != NULL) {
- PurpleIMConversation *im;
-
- im = purple_im_conversation_new(pounce_data->account, pounce_data->pouncee);
- purple_conversation_present(PURPLE_CONVERSATION(im));
- }
-}
-
-static void
-append_to_list(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- GList **list = data;
- *list = g_list_prepend(*list, gtk_tree_path_copy(path));
-}
-
-static void
-pounce_response_dismiss()
-{
- GtkTreeModel *model = GTK_TREE_MODEL(pounce_dialog->treemodel);
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GtkTreeIter new_selection;
- GList *list = NULL;
- gboolean found_selection = FALSE;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
- gtk_tree_selection_selected_foreach(selection, delete_foreach, pounce_dialog);
- gtk_tree_selection_selected_foreach(selection, append_to_list, &list);
-
- g_return_if_fail(list != NULL);
-
- if (list->next == NULL) {
- gtk_tree_model_get_iter(model, &new_selection, list->data);
- if (gtk_tree_model_iter_next(model, &new_selection))
- found_selection = TRUE;
- else {
- /* This is the last thing in the list */
- GtkTreePath *path;
-
- /* Because gtk_tree_model_iter_prev doesn't exist... */
- gtk_tree_model_get_iter(model, &new_selection, list->data);
- path = gtk_tree_model_get_path(model, &new_selection);
- if (gtk_tree_path_prev(path)) {
- gtk_tree_model_get_iter(model, &new_selection, path);
- found_selection = TRUE;
- }
-
- gtk_tree_path_free(path);
- }
- }
-
- while (list) {
- if (gtk_tree_model_get_iter(model, &iter, list->data)) {
- gtk_tree_store_remove(GTK_TREE_STORE(pounce_dialog->treemodel), &iter);
- }
- gtk_tree_path_free(list->data);
- list = g_list_delete_link(list, list);
- }
-
- if (gtk_tree_model_get_iter_first(model, &iter)) {
- if (found_selection)
- gtk_tree_selection_select_iter(selection, &new_selection);
- else
- gtk_tree_selection_select_iter(selection, &iter);
- } else
- pounce_response_close(pounce_dialog);
-}
-
-static void
-pounce_response_open_ims()
-{
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
- gtk_tree_selection_selected_foreach(selection, open_im_foreach, pounce_dialog);
-
- pounce_response_dismiss();
-}
-
-static void
-pounce_response_edit_cb(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer data)
-{
- PidginNotifyPounceData *pounce_data;
- PidginNotifyDialog *dialog = (PidginNotifyDialog*)data;
- GList *list;
-
- list = purple_pounces_get_all();
-
- gtk_tree_model_get(GTK_TREE_MODEL(dialog->treemodel), iter,
- PIDGIN_POUNCE_DATA, &pounce_data,
- -1);
-
- if (g_list_find(list, pounce_data->pounce) != NULL) {
- pidgin_pounce_editor_show(pounce_data->account, NULL, pounce_data->pounce);
- return;
- }
-
- purple_debug_warning("gtknotify", "Pounce was destroyed.\n");
-}
-
-static void
-pounce_response_cb(GtkDialog *dlg, gint id, PidginNotifyDialog *dialog)
-{
- GtkTreeSelection *selection = NULL;
-
- switch (id) {
- case GTK_RESPONSE_CLOSE:
- case GTK_RESPONSE_DELETE_EVENT:
- pounce_response_close(dialog);
- break;
- case GTK_RESPONSE_YES:
- pounce_response_open_ims();
- break;
- case GTK_RESPONSE_NO:
- pounce_response_dismiss();
- break;
- case GTK_RESPONSE_APPLY:
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
- gtk_tree_selection_selected_foreach(selection, pounce_response_edit_cb,
- dialog);
- break;
- }
-}
-
-static void
-pounce_row_selected_cb(GtkTreeView *tv, GtkTreePath *path,
- GtkTreeViewColumn *col, gpointer data)
-{
- GtkTreeSelection *selection;
- int count;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
-
- count = gtk_tree_selection_count_selected_rows(selection);
-
- if (count == 0) {
- gtk_widget_set_sensitive(pounce_dialog->open_button, FALSE);
- gtk_widget_set_sensitive(pounce_dialog->edit_button, FALSE);
- gtk_widget_set_sensitive(pounce_dialog->dismiss_button, FALSE);
- } else if (count == 1) {
- GList *pounces;
- GList *list;
- PidginNotifyPounceData *pounce_data;
- GtkTreeIter iter;
-
- list = gtk_tree_selection_get_selected_rows(selection, NULL);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(pounce_dialog->treemodel),
- &iter, list->data);
- gtk_tree_model_get(GTK_TREE_MODEL(pounce_dialog->treemodel), &iter,
- PIDGIN_POUNCE_DATA, &pounce_data,
- -1);
- g_list_free_full(list, (GDestroyNotify)gtk_tree_path_free);
-
- pounces = purple_pounces_get_all();
- if (g_list_find(pounces, pounce_data->pounce) != NULL) {
- gtk_widget_set_sensitive(pounce_dialog->edit_button, TRUE);
- }
-
- gtk_widget_set_sensitive(pounce_dialog->open_button, TRUE);
- gtk_widget_set_sensitive(pounce_dialog->dismiss_button, TRUE);
- } else {
- gtk_widget_set_sensitive(pounce_dialog->open_button, TRUE);
- gtk_widget_set_sensitive(pounce_dialog->edit_button, FALSE);
- gtk_widget_set_sensitive(pounce_dialog->dismiss_button, TRUE);
- }
-
-
-}
-
-static void
reset_mail_dialog(gpointer unused)
{
g_return_if_fail(mail_dialog != NULL);
@@ -1236,49 +994,6 @@
return NULL;
}
-void
-pidgin_notify_pounce_add(PurpleAccount *account, PurplePounce *pounce,
- const char *alias, const char *event, const char *message, const char *date)
-{
- GdkPixbuf *icon;
- GtkTreeIter iter;
- PidginNotifyPounceData *pounce_data;
- gboolean first = (pounce_dialog == NULL);
-
- if (pounce_dialog == NULL)
- pounce_dialog = pidgin_create_notification_dialog(PIDGIN_NOTIFY_POUNCE);
-
- icon = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_SMALL);
-
- pounce_data = g_new(PidginNotifyPounceData, 1);
-
- pounce_data->account = account;
- pounce_data->pounce = pounce;
- pounce_data->pouncee = g_strdup(purple_pounce_get_pouncee(pounce));
-
- gtk_tree_store_append(pounce_dialog->treemodel, &iter, NULL);
-
- gtk_tree_store_set(pounce_dialog->treemodel, &iter,
- PIDGIN_POUNCE_ICON, icon,
- PIDGIN_POUNCE_ALIAS, alias,
- PIDGIN_POUNCE_EVENT, event,
- PIDGIN_POUNCE_TEXT, (message != NULL)? message : _("No message"),
- PIDGIN_POUNCE_DATE, date,
- PIDGIN_POUNCE_DATA, pounce_data,
- -1);
-
- if (first) {
- GtkTreeSelection *selection =
- gtk_tree_view_get_selection(GTK_TREE_VIEW(pounce_dialog->treeview));
- gtk_tree_selection_select_iter(selection, &iter);
- }
-
- if (icon)
- g_object_unref(icon);
-
- gtk_widget_show_all(pounce_dialog->dialog);
-}
-
static PidginNotifyDialog *
pidgin_create_notification_dialog(PidginNotifyType type)
{
@@ -1300,12 +1015,6 @@
model = gtk_tree_store_new(COLUMNS_PIDGIN_MAIL,
GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
- } else if (type == PIDGIN_NOTIFY_POUNCE) {
- g_return_val_if_fail(pounce_dialog == NULL, pounce_dialog);
-
- model = gtk_tree_store_new(COLUMNS_PIDGIN_POUNCE,
- GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_POINTER);
}
dialog = gtk_dialog_new();
@@ -1368,80 +1077,6 @@
label = gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(label), _("<span weight=\"bold\" size=\"larger\">You have mail!</span>"));
-
- } else if (type == PIDGIN_NOTIFY_POUNCE) {
- gtk_window_set_title(GTK_WINDOW(dialog), _("New Pounces"));
-
- button = gtk_dialog_add_button(GTK_DIALOG(dialog),
- _("IM"), GTK_RESPONSE_YES);
- gtk_widget_set_sensitive(button, FALSE);
- spec_dialog->open_button = button;
-
- button = gtk_dialog_add_button(GTK_DIALOG(dialog),
- PIDGIN_STOCK_MODIFY, GTK_RESPONSE_APPLY);
- gtk_widget_set_sensitive(button, FALSE);
- spec_dialog->edit_button = button;
-
- /* Translators: Make sure you translate "Dismiss" differently than
- "close"! This string is used in the "You have pounced" dialog
- that appears when one of your Buddy Pounces is triggered. In
- this context "Dismiss" means "I acknowledge that I've seen that
- this pounce was triggered--remove it from this list." Translating
- it as "Remove" is acceptable if you can't think of a more precise
- word. */
- button = gtk_dialog_add_button(GTK_DIALOG(dialog), _("Dismiss"),
- GTK_RESPONSE_NO);
- gtk_widget_set_sensitive(button, FALSE);
- spec_dialog->dismiss_button = button;
-
- g_signal_connect(G_OBJECT(dialog), "response",
- G_CALLBACK(pounce_response_cb), spec_dialog);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Buddy"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- rend = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, rend, FALSE);
-
- gtk_tree_view_column_set_attributes(column, rend, "pixbuf", PIDGIN_POUNCE_ICON, NULL);
- rend = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, rend, FALSE);
- gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_ALIAS);
- gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Event"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- rend = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, rend, FALSE);
- gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_EVENT);
- gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Message"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- rend = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, rend, FALSE);
- gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_TEXT);
- gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
-
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Date"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- rend = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, rend, FALSE);
- gtk_tree_view_column_add_attribute(column, rend, "text", PIDGIN_POUNCE_DATE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(spec_dialog->treeview), column);
-
- label = gtk_label_new(NULL);
- gtk_label_set_markup(GTK_LABEL(label), _("<span weight=\"bold\" size=\"larger\">You have pounced!</span>"));
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(spec_dialog->treeview));
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
- g_signal_connect(G_OBJECT(sel), "changed",
- G_CALLBACK(pounce_row_selected_cb), NULL);
- g_signal_connect(G_OBJECT(spec_dialog->treeview), "row-activated",
- G_CALLBACK(pounce_response_open_ims), NULL);
}
gtk_dialog_add_button(GTK_DIALOG(dialog),
--- a/pidgin/gtknotify.h Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/gtknotify.h Sat Jan 02 22:05:09 2021 -0600
@@ -37,20 +37,6 @@
G_BEGIN_DECLS
/**
- * pidgin_notify_pounce_add:
- * @account: The account
- * @pounce: The pounce
- * @alias: The buddy alias
- * @event: Event description
- * @message: Pounce message
- * @date: Pounce date
- *
- * Adds a buddy pounce to the buddy pounce dialog
- */
-void pidgin_notify_pounce_add(PurpleAccount *account, PurplePounce *pounce,
- const char *alias, const char *event, const char *message, const char *date);
-
-/**
* pidgin_notify_get_ui_ops:
*
* Returns the UI operations structure for GTK+ notification functions.
--- a/pidgin/gtkpounce.c Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1485 +0,0 @@
-/* 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 <glib/gi18n-lib.h>
-
-#include <talkatu.h>
-
-#include <purple.h>
-
-#include "gtkblist.h"
-#include "gtkdialogs.h"
-#include "gtkpounce.h"
-#include "gtknotify.h"
-#include "pidginstock.h"
-#include "gtkutils.h"
-#include "pidginaccountchooser.h"
-#include "pidginaccountstore.h"
-#include "pidgincore.h"
-#include "pidgindialog.h"
-#include "pidgintalkatu.h"
-
-#include <gdk/gdkkeysyms.h>
-
-/*
- * These are used for the GtkTreeView when you're scrolling through
- * all your saved pounces.
- */
-enum
-{
- /* Hidden column containing the PurplePounce */
- POUNCES_MANAGER_COLUMN_POUNCE,
- POUNCES_MANAGER_COLUMN_ICON,
- POUNCES_MANAGER_COLUMN_TARGET,
- POUNCES_MANAGER_COLUMN_ACCOUNT,
- POUNCES_MANAGER_COLUMN_RECURRING,
- POUNCES_MANAGER_NUM_COLUMNS
-};
-
-typedef struct
-{
- /* Pounce data */
- PurplePounce *pounce;
- PurpleAccount *account;
-
- /* The window */
- GtkWidget *window;
-
- /* Pounce on Whom */
- GtkWidget *account_menu;
- GtkWidget *buddy_entry;
-
- /* Pounce options */
- GtkWidget *on_away;
-
- /* Pounce When Buddy... */
- GtkWidget *signon;
- GtkWidget *signoff;
- GtkWidget *away;
- GtkWidget *away_return;
- GtkWidget *idle;
- GtkWidget *idle_return;
- GtkWidget *typing;
- GtkWidget *typed;
- GtkWidget *stop_typing;
- GtkWidget *message_recv;
-
- /* Action */
- GtkWidget *open_win;
- GtkWidget *popup;
- GtkWidget *popup_entry;
- GtkWidget *send_msg;
- GtkWidget *send_msg_entry;
- GtkTextBuffer *send_msg_buffer;
- GtkWidget *exec_cmd;
- GtkWidget *exec_cmd_entry;
- GtkWidget *exec_cmd_browse;
-
- GtkWidget *save_pounce;
-
- /* Buttons */
- GtkWidget *save_button;
-
-} PidginPounceDialog;
-
-typedef struct
-{
- GtkWidget *window;
- GtkListStore *model;
- GtkWidget *treeview;
- GtkWidget *modify_button;
- GtkWidget *delete_button;
-} PouncesManager;
-
-static PouncesManager *pounces_manager = NULL;
-
-/**************************************************************************
- * Callbacks
- **************************************************************************/
-static gint
-delete_win_cb(GtkWidget *w, GdkEventAny *e, PidginPounceDialog *dialog)
-{
- gtk_widget_destroy(dialog->window);
- g_free(dialog);
-
- return TRUE;
-}
-
-static void
-cancel_cb(GtkWidget *w, PidginPounceDialog *dialog)
-{
- delete_win_cb(NULL, NULL, dialog);
-}
-
-static void
-pounce_update_entry_fields(void *user_data, const char *filename)
-{
- GtkWidget *entry = (GtkWidget *)user_data;
-
- gtk_entry_set_text(GTK_ENTRY(entry), filename);
-}
-
-static void
-filesel(GtkWidget *widget, gpointer data)
-{
- GtkWidget *entry;
- const gchar *name;
-
- entry = (GtkWidget *)data;
- name = gtk_entry_get_text(GTK_ENTRY(entry));
-
- purple_request_file(entry, _("Select a file"), name, FALSE,
- G_CALLBACK(pounce_update_entry_fields), NULL, NULL, entry);
- g_signal_connect_swapped(G_OBJECT(entry), "destroy",
- G_CALLBACK(purple_request_close_with_handle), entry);
-}
-
-static void
-add_pounce_to_treeview(GtkListStore *model, PurplePounce *pounce)
-{
- GtkTreeIter iter;
- PurpleAccount *account;
- gboolean recurring;
- const char *pouncer;
- const char *pouncee;
- GdkPixbuf *pixbuf;
-
- account = purple_pounce_get_pouncer(pounce);
-
- pixbuf = pidgin_create_protocol_icon(account, PIDGIN_PROTOCOL_ICON_MEDIUM);
-
- pouncer = purple_account_get_username(account);
- pouncee = purple_pounce_get_pouncee(pounce);
- recurring = purple_pounce_get_save(pounce);
-
- gtk_list_store_append(model, &iter);
- gtk_list_store_set(model, &iter,
- POUNCES_MANAGER_COLUMN_POUNCE, pounce,
- POUNCES_MANAGER_COLUMN_ICON, pixbuf,
- POUNCES_MANAGER_COLUMN_TARGET, pouncee,
- POUNCES_MANAGER_COLUMN_ACCOUNT, pouncer,
- POUNCES_MANAGER_COLUMN_RECURRING, recurring,
- -1);
-
- if (pixbuf != NULL)
- g_object_unref(pixbuf);
-}
-
-static void
-populate_pounces_list(PouncesManager *dialog)
-{
- GList *pounces;
-
- gtk_list_store_clear(dialog->model);
-
- for (pounces = purple_pounces_get_all_for_ui(PIDGIN_UI); pounces != NULL;
- pounces = g_list_delete_link(pounces, pounces))
- {
- add_pounce_to_treeview(dialog->model, pounces->data);
- }
-}
-
-static void
-update_pounces(void)
-{
- /* Rebuild the pounces list if the pounces manager is open */
- if (pounces_manager != NULL)
- {
- populate_pounces_list(pounces_manager);
- }
-}
-
-static void
-signed_on_off_cb(PurpleConnection *gc, gpointer user_data)
-{
- update_pounces();
-}
-
-static void
-save_pounce_cb(GtkWidget *w, PidginPounceDialog *dialog)
-{
- const char *name;
- const char *command, *reason;
- char *message;
- PurplePounceEvent events = PURPLE_POUNCE_NONE;
- PurplePounceOption options = PURPLE_POUNCE_OPTION_NONE;
-
- name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry));
-
- if (*name == '\0')
- {
- purple_notify_error(NULL, NULL, _("Please enter a buddy to "
- "pounce."), NULL, NULL);
- return;
- }
-
- /* Options */
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->on_away)))
- options |= PURPLE_POUNCE_OPTION_AWAY;
-
- /* Events */
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signon)))
- events |= PURPLE_POUNCE_SIGNON;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signoff)))
- events |= PURPLE_POUNCE_SIGNOFF;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away)))
- events |= PURPLE_POUNCE_AWAY;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away_return)))
- events |= PURPLE_POUNCE_AWAY_RETURN;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle)))
- events |= PURPLE_POUNCE_IDLE;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle_return)))
- events |= PURPLE_POUNCE_IDLE_RETURN;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typing)))
- events |= PURPLE_POUNCE_TYPING;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typed)))
- events |= PURPLE_POUNCE_TYPED;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing)))
- events |= PURPLE_POUNCE_TYPING_STOPPED;
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->message_recv)))
- events |= PURPLE_POUNCE_MESSAGE_RECEIVED;
-
- /* Data fields */
- message = talkatu_markup_get_html(dialog->send_msg_buffer, NULL);
- command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry));
- reason = gtk_entry_get_text(GTK_ENTRY(dialog->popup_entry));
-
- if (*reason == '\0') reason = NULL;
- if (*message == '\0') {
- g_free(message);
- message = NULL;
- }
- if (*command == '\0') command = NULL;
-
- /* If the pounce has already been triggered, let's pretend it is a new one */
- if (dialog->pounce != NULL
- && g_list_find(purple_pounces_get_all(), dialog->pounce) == NULL) {
- purple_debug_info("gtkpounce", "Saving pounce that no longer exists; creating new pounce.\n");
- dialog->pounce = NULL;
- }
-
- if (dialog->pounce == NULL)
- {
- dialog->pounce = purple_pounce_new(PIDGIN_UI, dialog->account,
- name, events, options);
- }
- else {
- purple_pounce_set_events(dialog->pounce, events);
- purple_pounce_set_options(dialog->pounce, options);
- purple_pounce_set_pouncer(dialog->pounce, dialog->account);
- purple_pounce_set_pouncee(dialog->pounce, name);
- }
-
- /* Actions */
- purple_pounce_action_set_enabled(dialog->pounce, "open-window",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win)));
- purple_pounce_action_set_enabled(dialog->pounce, "popup-notify",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup)));
- purple_pounce_action_set_enabled(dialog->pounce, "send-message",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg)));
- purple_pounce_action_set_enabled(dialog->pounce, "execute-command",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd)));
-
- purple_pounce_action_set_attribute(dialog->pounce, "send-message",
- "message", message);
- purple_pounce_action_set_attribute(dialog->pounce, "execute-command",
- "command", command);
- purple_pounce_action_set_attribute(dialog->pounce, "popup-notify",
- "reason", reason);
-
- /* Set the defaults for next time. */
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/open-window",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win)));
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/popup-notify",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup)));
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/send-message",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg)));
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/execute-command",
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd)));
-
- purple_pounce_set_save(dialog->pounce,
- gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce)));
-
- update_pounces();
- g_free(message);
-
- delete_win_cb(NULL, NULL, dialog);
-}
-
-static gboolean
-entry_key_press_cb(GtkWidget *widget, GdkEventKey *event,
- PidginPounceDialog *dialog)
-{
- if ((event->keyval == GDK_KEY_Return)
- || (event->keyval == GDK_KEY_KP_Enter)) {
- save_pounce_cb(widget, dialog);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-pounce_choose_cb(GtkWidget *w, PidginPounceDialog *dialog)
-{
- PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(w);
- dialog->account = pidgin_account_chooser_get_selected(chooser);
-}
-
-static void
-buddy_changed_cb(GtkEntry *entry, PidginPounceDialog *dialog)
-{
- if (dialog->save_button == NULL)
- return;
-
- gtk_widget_set_sensitive(dialog->save_button,
- *gtk_entry_get_text(entry) != '\0');
-}
-
-static void
-message_recv_toggle(GtkButton *message_recv, GtkWidget *send_msg)
-{
- gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(message_recv));
-
- gtk_widget_set_sensitive(send_msg, !active);
- if (active)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(send_msg), FALSE);
-}
-
-static void
-pounce_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y,
- GtkSelectionData *sd, guint info, guint t, gpointer data)
-{
- PidginPounceDialog *dialog;
- GdkAtom target = gtk_selection_data_get_target(sd);
- const guchar *sd_data = gtk_selection_data_get_data(sd);
-
- if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE))
- {
- PurpleBlistNode *node = NULL;
- PurpleBuddy *buddy;
-
- memcpy(&node, sd_data, sizeof(node));
-
- if (PURPLE_IS_CONTACT(node))
- buddy = purple_contact_get_priority_buddy((PurpleContact *)node);
- else if (PURPLE_IS_BUDDY(node))
- buddy = (PurpleBuddy *)node;
- else
- return;
-
- dialog = (PidginPounceDialog *)data;
-
- gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), purple_buddy_get_name(buddy));
- dialog->account = purple_buddy_get_account(buddy);
- pidgin_account_chooser_set_selected(
- PIDGIN_ACCOUNT_CHOOSER(dialog->account_menu),
- purple_buddy_get_account(buddy));
-
- gtk_drag_finish(dc, TRUE, (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
- }
- else if (target == gdk_atom_intern("application/x-im-contact", FALSE))
- {
- char *protocol = NULL;
- char *username = NULL;
- PurpleAccount *account;
-
- if (pidgin_parse_x_im_contact((const char *)sd_data, FALSE, &account,
- &protocol, &username, NULL))
- {
- if (account == NULL)
- {
- purple_notify_error(NULL, NULL,
- _("You are not currently signed on with an account that "
- "can add that buddy."), NULL, NULL);
- }
- else
- {
- dialog = (PidginPounceDialog *)data;
-
- gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), username);
- dialog->account = account;
- pidgin_account_chooser_set_selected(
- PIDGIN_ACCOUNT_CHOOSER(dialog->account_menu), account);
- }
- }
-
- g_free(username);
- g_free(protocol);
-
- gtk_drag_finish(dc, TRUE, (gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE), t);
- }
-}
-
-static const GtkTargetEntry dnd_targets[] =
-{
- {"PURPLE_BLIST_NODE", GTK_TARGET_SAME_APP, 0},
- {"application/x-im-contact", 0, 1}
-};
-
-static void
-reset_send_msg_entry(PidginPounceDialog *dialog, GtkWidget *dontcare)
-{
- PidginAccountChooser *chooser = PIDGIN_ACCOUNT_CHOOSER(dialog->account_menu);
- PurpleAccount *account = pidgin_account_chooser_get_selected(chooser);
-
- if(GTK_IS_TEXT_BUFFER(dialog->send_msg_buffer)) {
- g_object_unref(dialog->send_msg_buffer);
- }
-
- dialog->send_msg_buffer = NULL;
-
- if(account) {
- PurpleConnection *pc = purple_account_get_connection(account);
-
- if(pc) {
- dialog->send_msg_buffer = pidgin_talkatu_buffer_new_for_connection(pc);
- }
- }
-
- if(dialog->send_msg_buffer == NULL) {
- dialog->send_msg_buffer = talkatu_buffer_new(NULL);
- }
-
- gtk_text_view_set_buffer(GTK_TEXT_VIEW(dialog->send_msg_entry), dialog->send_msg_buffer);
-}
-
-void
-pidgin_pounce_editor_show(PurpleAccount *account, const char *name,
- PurplePounce *cur_pounce)
-{
- PidginPounceDialog *dialog;
- GtkWidget *window;
- GtkWidget *label;
- GtkWidget *vbox1, *vbox2;
- GtkWidget *hbox;
- GtkWidget *button;
- GtkWidget *frame;
- GtkWidget *grid;
- GtkSizeGroup *sg;
- GtkWidget *editor;
- GtkTreeModel *model;
-
- g_return_if_fail((cur_pounce != NULL) ||
- (account != NULL) ||
- (purple_accounts_get_all() != NULL));
-
- dialog = g_new0(PidginPounceDialog, 1);
-
- if (cur_pounce != NULL)
- {
- dialog->pounce = cur_pounce;
- dialog->account = purple_pounce_get_pouncer(cur_pounce);
- }
- else if (account != NULL)
- {
- dialog->pounce = NULL;
- dialog->account = account;
- }
- else
- {
- GList *connections = purple_connections_get_all();
- PurpleConnection *gc;
-
- if (connections != NULL)
- {
- gc = (PurpleConnection *)connections->data;
- dialog->account = purple_connection_get_account(gc);
- }
- else
- dialog->account = purple_accounts_get_all()->data;
-
- dialog->pounce = NULL;
- }
-
- sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
-
- /* Create the window. */
- dialog->window = window = gtk_dialog_new();
- gtk_window_set_title(GTK_WINDOW(window), (cur_pounce == NULL ? _("Add Buddy Pounce") : _("Modify Buddy Pounce")));
- gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce");
-
- g_signal_connect(G_OBJECT(window), "delete_event",
- G_CALLBACK(delete_win_cb), dialog);
-
- /* Get the parent vbox for everything. */
- vbox1 = gtk_dialog_get_content_area(GTK_DIALOG(window));
-
- /* Create the vbox that will contain all the prefs stuff. */
- vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
- gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0);
-
- /* Create the "Pounce on Whom" frame. */
- frame = pidgin_make_frame(vbox2, _("Pounce on Whom"));
-
- /* Account: */
- hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- label = gtk_label_new_with_mnemonic(_("_Account:"));
- gtk_label_set_xalign(GTK_LABEL(label), 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
- gtk_size_group_add_widget(sg, label);
-
- dialog->account_menu = pidgin_account_chooser_new();
- model = GTK_TREE_MODEL(pidgin_account_store_new());
- gtk_combo_box_set_model(GTK_COMBO_BOX(dialog->account_menu), model);
- g_object_unref(G_OBJECT(model));
- pidgin_account_chooser_set_selected(
- PIDGIN_ACCOUNT_CHOOSER(dialog->account_menu), dialog->account);
- g_signal_connect(dialog->account_menu, "changed",
- G_CALLBACK(pounce_choose_cb), dialog);
-
- gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0);
- gtk_widget_show(dialog->account_menu);
- pidgin_set_accessible_label(dialog->account_menu, GTK_LABEL(label));
-
- /* Buddy: */
- hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
-
- label = gtk_label_new_with_mnemonic(_("_Buddy name:"));
- gtk_label_set_xalign(GTK_LABEL(label), 0);
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
- gtk_size_group_add_widget(sg, label);
-
- dialog->buddy_entry = gtk_entry_new();
-
- pidgin_setup_screenname_autocomplete(dialog->buddy_entry, dialog->account_menu, pidgin_screenname_autocomplete_default_filter, GINT_TO_POINTER(FALSE));
-
- gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0);
- gtk_widget_show(dialog->buddy_entry);
-
- g_signal_connect(G_OBJECT(dialog->buddy_entry), "changed",
- G_CALLBACK(buddy_changed_cb), dialog);
- pidgin_set_accessible_label(dialog->buddy_entry, GTK_LABEL(label));
-
- if (cur_pounce != NULL) {
- gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry),
- purple_pounce_get_pouncee(cur_pounce));
- }
- else if (name != NULL) {
- gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), name);
- }
-
- /* Create the "Pounce When Buddy..." frame. */
- frame = pidgin_make_frame(vbox2, _("Pounce When Buddy..."));
-
- grid = gtk_grid_new();
- gtk_container_add(GTK_CONTAINER(frame), grid);
- gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
- gtk_widget_show(grid);
-
- dialog->signon =
- gtk_check_button_new_with_mnemonic(_("Si_gns on"));
- dialog->signoff =
- gtk_check_button_new_with_mnemonic(_("Signs o_ff"));
- dialog->away =
- gtk_check_button_new_with_mnemonic(_("Goes a_way"));
- dialog->away_return =
- gtk_check_button_new_with_mnemonic(_("Ret_urns from away"));
- dialog->idle =
- gtk_check_button_new_with_mnemonic(_("Becomes _idle"));
- dialog->idle_return =
- gtk_check_button_new_with_mnemonic(_("Is no longer i_dle"));
- dialog->typing =
- gtk_check_button_new_with_mnemonic(_("Starts _typing"));
- dialog->typed =
- gtk_check_button_new_with_mnemonic(_("P_auses while typing"));
- dialog->stop_typing =
- gtk_check_button_new_with_mnemonic(_("Stops t_yping"));
- dialog->message_recv =
- gtk_check_button_new_with_mnemonic(_("Sends a _message"));
-
- gtk_widget_set_valign(dialog->message_recv, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->signon, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->signoff, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->away, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->away_return, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->idle, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->idle_return, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->typing, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->typed, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->stop_typing, GTK_ALIGN_CENTER);
-
- gtk_grid_attach(GTK_GRID(grid), dialog->message_recv, 0, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->signon, 0, 1, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->signoff, 0, 2, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->away, 1, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->away_return, 1, 1, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->idle, 1, 2, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->idle_return, 2, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->typing, 2, 1, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->typed, 2, 2, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->stop_typing, 3, 0, 1, 1);
-
- gtk_widget_show(dialog->signon);
- gtk_widget_show(dialog->signoff);
- gtk_widget_show(dialog->away);
- gtk_widget_show(dialog->away_return);
- gtk_widget_show(dialog->idle);
- gtk_widget_show(dialog->idle_return);
- gtk_widget_show(dialog->typing);
- gtk_widget_show(dialog->typed);
- gtk_widget_show(dialog->stop_typing);
- gtk_widget_show(dialog->message_recv);
-
- /* Create the "Action" frame. */
- frame = pidgin_make_frame(vbox2, _("Action"));
-
- grid = gtk_grid_new();
- gtk_container_add(GTK_CONTAINER(frame), grid);
- gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
- gtk_widget_show(grid);
-
- dialog->open_win
- = gtk_check_button_new_with_mnemonic(_("Ope_n an IM window"));
- dialog->popup
- = gtk_check_button_new_with_mnemonic(_("_Pop up a notification"));
- dialog->send_msg
- = gtk_check_button_new_with_mnemonic(_("Send a _message"));
- dialog->exec_cmd
- = gtk_check_button_new_with_mnemonic(_("E_xecute a command"));
-
- editor = talkatu_editor_new();
- dialog->send_msg_entry = talkatu_editor_get_input(TALKATU_EDITOR(editor));
- reset_send_msg_entry(dialog, NULL);
-
- dialog->exec_cmd_entry = gtk_entry_new();
- dialog->popup_entry = gtk_entry_new();
- dialog->exec_cmd_browse = gtk_button_new_with_mnemonic(_("Brows_e..."));
-
- gtk_widget_set_sensitive(editor, FALSE);
- gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE);
- gtk_widget_set_sensitive(dialog->popup_entry, FALSE);
- gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE);
-
- g_object_unref(sg);
-
- sg = gtk_size_group_new(GTK_SIZE_GROUP_VERTICAL);
- gtk_size_group_add_widget(sg, dialog->open_win);
- gtk_size_group_add_widget(sg, dialog->popup);
- gtk_size_group_add_widget(sg, dialog->popup_entry);
- gtk_size_group_add_widget(sg, dialog->exec_cmd);
- gtk_size_group_add_widget(sg, dialog->exec_cmd_entry);
- gtk_size_group_add_widget(sg, dialog->exec_cmd_browse);
-
- g_object_unref(sg);
- sg = NULL;
-
- gtk_widget_set_valign(dialog->open_win, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->popup, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->popup_entry, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->send_msg, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(editor, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->exec_cmd, GTK_ALIGN_CENTER);
- gtk_widget_set_valign(dialog->exec_cmd_entry, GTK_ALIGN_CENTER);
- gtk_widget_set_hexpand(dialog->exec_cmd_browse, TRUE);
- gtk_widget_set_valign(dialog->exec_cmd_browse, GTK_ALIGN_CENTER);
-
- gtk_grid_attach(GTK_GRID(grid), dialog->open_win, 0, 0, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->popup, 0, 1, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->popup_entry, 1, 1, 4, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->send_msg, 0, 2, 5, 1);
- gtk_grid_attach(GTK_GRID(grid), editor, 0, 3, 5, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->exec_cmd, 0, 4, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->exec_cmd_entry, 1, 4, 1, 1);
- gtk_grid_attach(GTK_GRID(grid), dialog->exec_cmd_browse, 2, 4, 1, 1);
-
- gtk_grid_set_row_spacing(GTK_GRID(grid), 3);
-
- gtk_widget_show(dialog->open_win);
- gtk_widget_show(dialog->popup);
- gtk_widget_show(dialog->popup_entry);
- gtk_widget_show(dialog->send_msg);
- gtk_widget_show(editor);
- gtk_widget_show(dialog->exec_cmd);
- gtk_widget_show(dialog->exec_cmd_entry);
- gtk_widget_show(dialog->exec_cmd_browse);
-
- g_signal_connect(G_OBJECT(dialog->message_recv), "clicked",
- G_CALLBACK(message_recv_toggle),
- dialog->send_msg);
-
- g_object_bind_property(dialog->send_msg, "active",
- editor, "sensitive",
- G_BINDING_DEFAULT);
-
- g_object_bind_property(dialog->popup, "active",
- dialog->popup_entry, "sensitive",
- G_BINDING_DEFAULT);
-
- g_object_bind_property(dialog->exec_cmd, "active",
- dialog->exec_cmd_entry, "sensitive",
- G_BINDING_DEFAULT);
- g_object_bind_property(dialog->exec_cmd, "active",
- dialog->exec_cmd_browse, "sensitive",
- G_BINDING_DEFAULT);
- g_signal_connect(G_OBJECT(dialog->exec_cmd_browse), "clicked",
- G_CALLBACK(filesel),
- dialog->exec_cmd_entry);
-
- g_signal_connect_swapped(G_OBJECT(dialog->send_msg_entry), "format-cleared",
- G_CALLBACK(reset_send_msg_entry), dialog);
- g_signal_connect_swapped(G_OBJECT(dialog->account_menu), "changed",
- G_CALLBACK(reset_send_msg_entry), dialog);
-
- g_signal_connect(G_OBJECT(dialog->send_msg_entry), "key-press-event",
- G_CALLBACK(entry_key_press_cb), dialog);
- g_signal_connect(G_OBJECT(dialog->popup_entry), "activate",
- G_CALLBACK(save_pounce_cb), dialog);
- g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate",
- G_CALLBACK(save_pounce_cb), dialog);
-
- /* Create the "Options" frame. */
- frame = pidgin_make_frame(vbox2, _("Options"));
-
- grid = gtk_grid_new();
- gtk_container_add(GTK_CONTAINER(frame), grid);
- gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
- gtk_widget_show(grid);
-
- dialog->on_away =
- gtk_check_button_new_with_mnemonic(_("P_ounce only when my status is not Available"));
- gtk_widget_set_valign(dialog->on_away, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), dialog->on_away, 0, 0, 1, 1);
-
- dialog->save_pounce = gtk_check_button_new_with_mnemonic(
- _("_Recurring"));
- gtk_widget_set_valign(dialog->save_pounce, GTK_ALIGN_CENTER);
- gtk_grid_attach(GTK_GRID(grid), dialog->save_pounce, 0, 1, 1, 1);
-
- gtk_widget_show(dialog->on_away);
- gtk_widget_show(dialog->save_pounce);
-
- /* Cancel button */
- button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(cancel_cb), dialog);
-
- /* Save/Add button */
- dialog->save_button = button = gtk_dialog_add_button(GTK_DIALOG(window),
- (cur_pounce == NULL ? GTK_STOCK_ADD : GTK_STOCK_SAVE),
- GTK_RESPONSE_OK);
- g_signal_connect(G_OBJECT(button), "clicked",
- G_CALLBACK(save_pounce_cb), dialog);
-
- if (*gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)) == '\0')
- gtk_widget_set_sensitive(button, FALSE);
-
- /* Setup drag-and-drop */
- gtk_drag_dest_set(window,
- GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_DROP,
- dnd_targets,
- sizeof(dnd_targets) / sizeof(GtkTargetEntry),
- GDK_ACTION_COPY);
- gtk_drag_dest_set(dialog->buddy_entry,
- GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_DROP,
- dnd_targets,
- sizeof(dnd_targets) / sizeof(GtkTargetEntry),
- GDK_ACTION_COPY);
-
- g_signal_connect(G_OBJECT(window), "drag_data_received",
- G_CALLBACK(pounce_dnd_recv), dialog);
- g_signal_connect(G_OBJECT(dialog->buddy_entry), "drag_data_received",
- G_CALLBACK(pounce_dnd_recv), dialog);
-
- /* Set the values of stuff. */
- if (cur_pounce != NULL)
- {
- PurplePounceEvent events = purple_pounce_get_events(cur_pounce);
- PurplePounceOption options = purple_pounce_get_options(cur_pounce);
- const char *value;
-
- /* Options */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->on_away),
- (options & PURPLE_POUNCE_OPTION_AWAY));
-
- /* Events */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon),
- (events & PURPLE_POUNCE_SIGNON));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff),
- (events & PURPLE_POUNCE_SIGNOFF));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away),
- (events & PURPLE_POUNCE_AWAY));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away_return),
- (events & PURPLE_POUNCE_AWAY_RETURN));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle),
- (events & PURPLE_POUNCE_IDLE));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle_return),
- (events & PURPLE_POUNCE_IDLE_RETURN));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typing),
- (events & PURPLE_POUNCE_TYPING));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typed),
- (events & PURPLE_POUNCE_TYPED));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing),
- (events & PURPLE_POUNCE_TYPING_STOPPED));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->message_recv),
- (events & PURPLE_POUNCE_MESSAGE_RECEIVED));
-
- /* Actions */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win),
- purple_pounce_action_is_enabled(cur_pounce, "open-window"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup),
- purple_pounce_action_is_enabled(cur_pounce, "popup-notify"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg),
- purple_pounce_action_is_enabled(cur_pounce, "send-message"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd),
- purple_pounce_action_is_enabled(cur_pounce, "execute-command"));
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce),
- purple_pounce_get_save(cur_pounce));
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "send-message",
- "message")) != NULL)
- {
- talkatu_markup_set_html(TALKATU_BUFFER(dialog->send_msg_buffer), value, -1);
- }
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "popup-notify",
- "reason")) != NULL)
- {
- gtk_entry_set_text(GTK_ENTRY(dialog->popup_entry), value);
- }
-
- if ((value = purple_pounce_action_get_attribute(cur_pounce,
- "execute-command",
- "command")) != NULL)
- {
- gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), value);
- }
- }
- else
- {
- PurpleBuddy *buddy = NULL;
-
- if (name != NULL)
- buddy = purple_blist_find_buddy(account, name);
-
- /* Set some defaults */
- if (buddy == NULL)
- {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(dialog->signon), TRUE);
- }
- else
- {
- if (!PURPLE_BUDDY_IS_ONLINE(buddy))
- {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(dialog->signon), TRUE);
- }
- else
- {
- gboolean default_set = FALSE;
- PurplePresence *presence = purple_buddy_get_presence(buddy);
-
- if (purple_presence_is_idle(presence))
- {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(dialog->idle_return), TRUE);
-
- default_set = TRUE;
- }
-
- if (!purple_presence_is_available(presence))
- {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(dialog->away_return), TRUE);
-
- default_set = TRUE;
- }
-
- if (!default_set)
- {
- gtk_toggle_button_set_active(
- GTK_TOGGLE_BUTTON(dialog->signon), TRUE);
- }
- }
- }
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/open-window"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/popup-notify"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/send-message"));
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/execute-command"));
- }
-
- gtk_widget_show(vbox2);
- gtk_widget_show(window);
-}
-
-static gboolean
-pounces_manager_configure_cb(GtkWidget *widget, GdkEventConfigure *event, PouncesManager *dialog)
-{
- if (gtk_widget_get_visible(widget)) {
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width", event->width);
- purple_prefs_set_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height", event->height);
- }
-
- return FALSE;
-}
-
-static gboolean
-pounces_manager_find_pounce(GtkTreeIter *iter, PurplePounce *pounce)
-{
- GtkTreeModel *model = GTK_TREE_MODEL(pounces_manager->model);
- PurplePounce *p;
-
- if (!gtk_tree_model_get_iter_first(model, iter))
- return FALSE;
-
- gtk_tree_model_get(model, iter, POUNCES_MANAGER_COLUMN_POUNCE, &p, -1);
- if (pounce == p)
- return TRUE;
-
- while (gtk_tree_model_iter_next(model, iter))
- {
- gtk_tree_model_get(model, iter, POUNCES_MANAGER_COLUMN_POUNCE, &p, -1);
- if (pounce == p)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-pounces_manager_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
-
- dialog->window = NULL;
- pidgin_pounces_manager_hide();
-
- return FALSE;
-}
-
-static void
-pounces_manager_connection_cb(PurpleConnection *gc, GtkWidget *add_button)
-{
- gtk_widget_set_sensitive(add_button, (purple_connections_get_all() != NULL));
-}
-
-static void
-pounces_manager_add_cb(GtkButton *button, gpointer user_data)
-{
- pidgin_pounce_editor_show(NULL, NULL, NULL);
-}
-
-static void
-pounces_manager_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer user_data)
-{
- PurplePounce *pounce;
-
- gtk_tree_model_get(model, iter, POUNCES_MANAGER_COLUMN_POUNCE, &pounce, -1);
- pidgin_pounce_editor_show(NULL, NULL, pounce);
-}
-
-static void
-pounces_manager_modify_cb(GtkButton *button, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
-
- gtk_tree_selection_selected_foreach(selection, pounces_manager_modify_foreach, user_data);
-}
-
-static void
-pounces_manager_delete_confirm_cb(PurplePounce *pounce)
-{
- GtkTreeIter iter;
-
- if (pounces_manager && pounces_manager_find_pounce(&iter, pounce))
- gtk_list_store_remove(pounces_manager->model, &iter);
-
- purple_request_close_with_handle(pounce);
- purple_pounce_destroy(pounce);
-}
-
-static void
-pounces_manager_delete_foreach(GtkTreeModel *model, GtkTreePath *path,
- GtkTreeIter *iter, gpointer user_data)
-{
- PurplePounce *pounce;
- PurpleAccount *account;
- const char *pouncer, *pouncee;
- char *buf;
-
- gtk_tree_model_get(model, iter, POUNCES_MANAGER_COLUMN_POUNCE, &pounce, -1);
- account = purple_pounce_get_pouncer(pounce);
- pouncer = purple_account_get_username(account);
- pouncee = purple_pounce_get_pouncee(pounce);
-
- buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer);
- purple_request_action(pounce, NULL, buf, NULL, 0,
- purple_request_cpar_from_account(account),
- pounce, 2, _("Delete"), pounces_manager_delete_confirm_cb,
- _("Cancel"), NULL);
- g_free(buf);
-}
-
-static void
-pounces_manager_delete_cb(GtkButton *button, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- GtkTreeSelection *selection;
-
- selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
-
- gtk_tree_selection_selected_foreach(selection, pounces_manager_delete_foreach, user_data);
-}
-
-static void
-pounces_manager_close_cb(GtkButton *button, gpointer user_data)
-{
- pidgin_pounces_manager_hide();
-}
-
-static void
-pounce_selected_cb(GtkTreeSelection *sel, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- int num_selected = 0;
-
- num_selected = gtk_tree_selection_count_selected_rows(sel);
-
- gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0));
- gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0));
-}
-
-static gboolean
-pounce_double_click_cb(GtkTreeView *treeview, GdkEventButton *event, gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- GtkTreePath *path;
- GtkTreeIter iter;
- PurplePounce *pounce;
-
- /* Figure out which node was clicked */
- if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dialog->treeview), event->x, event->y, &path, NULL, NULL, NULL))
- return FALSE;
- gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, path);
- gtk_tree_path_free(path);
- gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter, POUNCES_MANAGER_COLUMN_POUNCE, &pounce, -1);
-
- if ((pounce != NULL) && (event->button == GDK_BUTTON_PRIMARY) &&
- (event->type == GDK_2BUTTON_PRESS))
- {
- pidgin_pounce_editor_show(NULL, NULL, pounce);
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-pounces_manager_recurring_cb(GtkCellRendererToggle *renderer, gchar *path_str,
- gpointer user_data)
-{
- PouncesManager *dialog = user_data;
- PurplePounce *pounce;
- gboolean recurring;
- GtkTreeModel *model = GTK_TREE_MODEL(dialog->model);
- GtkTreeIter iter;
-
- gtk_tree_model_get_iter_from_string(model, &iter, path_str);
- gtk_tree_model_get(model, &iter,
- POUNCES_MANAGER_COLUMN_POUNCE, &pounce,
- POUNCES_MANAGER_COLUMN_RECURRING, &recurring,
- -1);
-
- purple_pounce_set_save(pounce, !recurring);
-
- update_pounces();
-}
-
-static gboolean
-search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data)
-{
- gboolean result;
- char *haystack;
-
- gtk_tree_model_get(model, iter, column, &haystack, -1);
-
- result = (purple_strcasestr(haystack, key) == NULL);
-
- g_free(haystack);
-
- return result;
-}
-
-static GtkWidget *
-create_pounces_list(PouncesManager *dialog)
-{
- GtkWidget *treeview;
- GtkTreeSelection *sel;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
-
- /* Create the list model */
- dialog->model = gtk_list_store_new(POUNCES_MANAGER_NUM_COLUMNS,
- G_TYPE_POINTER,
- GDK_TYPE_PIXBUF,
- G_TYPE_STRING,
- G_TYPE_STRING,
- G_TYPE_BOOLEAN
- );
-
- /* Create the treeview */
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
- g_object_unref(G_OBJECT(dialog->model));
- dialog->treeview = treeview;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
- g_signal_connect(G_OBJECT(sel), "changed",
- G_CALLBACK(pounce_selected_cb), dialog);
-
- /* Handle double-clicking */
- g_signal_connect(G_OBJECT(treeview), "button_press_event",
- G_CALLBACK(pounce_double_click_cb), dialog);
- gtk_widget_show(treeview);
-
- /* Pouncee Column */
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Pounce Target"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_min_width(column, 200);
- gtk_tree_view_column_set_sort_column_id(column,
- POUNCES_MANAGER_COLUMN_TARGET);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
-
- /* Icon */
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_add_attribute(column, renderer, "pixbuf",
- POUNCES_MANAGER_COLUMN_ICON);
-
- /* Pouncee */
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_add_attribute(column, renderer, "text",
- POUNCES_MANAGER_COLUMN_TARGET);
-
-
- /* Account Column */
- column = gtk_tree_view_column_new();
- gtk_tree_view_column_set_title(column, _("Account"));
- gtk_tree_view_column_set_resizable(column, TRUE);
- gtk_tree_view_column_set_min_width(column, 200);
- gtk_tree_view_column_set_sort_column_id(column,
- POUNCES_MANAGER_COLUMN_ACCOUNT);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- renderer = gtk_cell_renderer_text_new();
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_add_attribute(column, renderer, "text",
- POUNCES_MANAGER_COLUMN_ACCOUNT);
-
- /* Recurring Column */
- renderer = gtk_cell_renderer_toggle_new();
- column = gtk_tree_view_column_new_with_attributes(_("Recurring"), renderer,
- "active", POUNCES_MANAGER_COLUMN_RECURRING, NULL);
- gtk_tree_view_column_set_sort_column_id(column,
- POUNCES_MANAGER_COLUMN_RECURRING);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- g_signal_connect(G_OBJECT(renderer), "toggled",
- G_CALLBACK(pounces_manager_recurring_cb), dialog);
-
- /* Enable CTRL+F searching */
- gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), POUNCES_MANAGER_COLUMN_TARGET);
- gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(treeview), search_func, NULL, NULL);
-
- /* Sort the pouncee column by default */
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->model),
- POUNCES_MANAGER_COLUMN_TARGET,
- GTK_SORT_ASCENDING);
-
- /* Populate list */
- populate_pounces_list(dialog);
-
- return pidgin_make_scrollable(treeview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, -1);
-}
-
-void
-pidgin_pounces_manager_show(void)
-{
- PouncesManager *dialog;
- GtkWidget *button;
- GtkWidget *list;
- GtkWidget *vbox;
- GtkWidget *win;
- int width, height;
-
- if (pounces_manager != NULL) {
- gtk_window_present(GTK_WINDOW(pounces_manager->window));
- return;
- }
-
- pounces_manager = dialog = g_new0(PouncesManager, 1);
-
- width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width");
- height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height");
-
- dialog->window = win = pidgin_dialog_new(_("Buddy Pounces"), 0, "pounces", TRUE);
-
- gtk_window_set_default_size(GTK_WINDOW(win), width, height);
-
- g_signal_connect(G_OBJECT(win), "delete_event",
- G_CALLBACK(pounces_manager_destroy_cb), dialog);
- g_signal_connect(G_OBJECT(win), "configure_event",
- G_CALLBACK(pounces_manager_configure_cb), dialog);
-
- /* Setup the vbox */
- vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(win), FALSE, 12);
-
- /* List of saved buddy pounces */
- list = create_pounces_list(dialog);
- gtk_box_pack_start(GTK_BOX(vbox), list, TRUE, TRUE, 0);
-
- /* Add button */
- button = pidgin_dialog_add_button(GTK_DIALOG(win), PIDGIN_STOCK_ADD, G_CALLBACK(pounces_manager_add_cb), dialog);
- gtk_widget_set_sensitive(button, (purple_accounts_get_all() != NULL));
-
- purple_signal_connect(purple_connections_get_handle(), "signed-on",
- pounces_manager, PURPLE_CALLBACK(pounces_manager_connection_cb), button);
- purple_signal_connect(purple_connections_get_handle(), "signed-off",
- pounces_manager, PURPLE_CALLBACK(pounces_manager_connection_cb), button);
-
- /* Modify button */
- button = pidgin_dialog_add_button(GTK_DIALOG(win), PIDGIN_STOCK_MODIFY, G_CALLBACK(pounces_manager_modify_cb), dialog);
- gtk_widget_set_sensitive(button, FALSE);
- dialog->modify_button = button;
-
- /* Delete button */
- button = pidgin_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_DELETE, G_CALLBACK(pounces_manager_delete_cb), dialog);
- gtk_widget_set_sensitive(button, FALSE);
- dialog->delete_button = button;
-
- /* Close button */
- pidgin_dialog_add_button(GTK_DIALOG(win), GTK_STOCK_CLOSE, G_CALLBACK(pounces_manager_close_cb), dialog);
-
- gtk_widget_show(win);
-}
-
-void
-pidgin_pounces_manager_hide(void)
-{
- if (pounces_manager == NULL)
- return;
-
- if (pounces_manager->window != NULL)
- gtk_widget_destroy(pounces_manager->window);
-
- purple_signals_disconnect_by_handle(pounces_manager);
-
- g_free(pounces_manager);
- pounces_manager = NULL;
-}
-
-static void
-pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
-{
- PurpleIMConversation *im;
- PurpleAccount *account;
- PurpleBuddy *buddy;
- const char *pouncee;
- const char *alias;
-
- pouncee = purple_pounce_get_pouncee(pounce);
- account = purple_pounce_get_pouncer(pounce);
-
- buddy = purple_blist_find_buddy(account, pouncee);
- if (buddy != NULL)
- {
- alias = purple_buddy_get_alias(buddy);
- if (alias == NULL)
- alias = pouncee;
- }
- else
- alias = pouncee;
-
- if (purple_pounce_action_is_enabled(pounce, "open-window"))
- {
- if (!purple_conversations_find_im_with_account(pouncee, account))
- purple_im_conversation_new(account, pouncee);
- }
-
- if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
- {
- char *tmp;
- const char *reason;
- reason = purple_pounce_action_get_attribute(pounce, "popup-notify",
- "reason");
-
- /*
- * Here we place the protocol name in the pounce dialog to lessen
- * confusion about what protocol a pounce is for.
- */
- tmp = g_strdup(
- (events & PURPLE_POUNCE_TYPING) ?
- _("Started typing") :
- (events & PURPLE_POUNCE_TYPED) ?
- _("Paused while typing") :
- (events & PURPLE_POUNCE_SIGNON) ?
- _("Signed on") :
- (events & PURPLE_POUNCE_IDLE_RETURN) ?
- _("Returned from being idle") :
- (events & PURPLE_POUNCE_AWAY_RETURN) ?
- _("Returned from being away") :
- (events & PURPLE_POUNCE_TYPING_STOPPED) ?
- _("Stopped typing") :
- (events & PURPLE_POUNCE_SIGNOFF) ?
- _("Signed off") :
- (events & PURPLE_POUNCE_IDLE) ?
- _("Became idle") :
- (events & PURPLE_POUNCE_AWAY) ?
- _("Went away") :
- (events & PURPLE_POUNCE_MESSAGE_RECEIVED) ?
- _("Sent a message") :
- _("Unknown.... Please report this!")
- );
-
- pidgin_notify_pounce_add(account, pounce, alias, tmp, reason,
- purple_date_format_full(NULL));
-
- g_free(tmp);
- }
-
- if (purple_pounce_action_is_enabled(pounce, "send-message"))
- {
- const char *message;
-
- message = purple_pounce_action_get_attribute(pounce, "send-message",
- "message");
-
- if (message != NULL)
- {
- PurpleMessage *pmsg;
- const gchar *me;
-
- im = purple_conversations_find_im_with_account(pouncee, account);
- me = purple_account_get_name_for_display(account);
-
- if (im == NULL)
- im = purple_im_conversation_new(account, pouncee);
-
- pmsg = purple_message_new_outgoing(me, pouncee, message, 0);
- purple_serv_send_im(purple_account_get_connection(account), pmsg);
- purple_conversation_write_message(PURPLE_CONVERSATION(im), pmsg);
- g_object_unref(G_OBJECT(pmsg));
- }
- }
-
- if (purple_pounce_action_is_enabled(pounce, "execute-command"))
- {
- const char *command;
-
- command = purple_pounce_action_get_attribute(pounce,
- "execute-command", "command");
-
- if (command != NULL)
- {
- GError *error = NULL;
- if (!g_spawn_command_line_async(command, &error)) {
- purple_debug_error("gtkpounce",
- "pounce command could not be launched: %s\n",
- error->message);
- g_error_free(error);
- }
- }
- }
-}
-
-static void
-free_pounce(PurplePounce *pounce)
-{
- update_pounces();
-}
-
-static void
-new_pounce(PurplePounce *pounce)
-{
- purple_pounce_action_register(pounce, "open-window");
- purple_pounce_action_register(pounce, "popup-notify");
- purple_pounce_action_register(pounce, "send-message");
- purple_pounce_action_register(pounce, "execute-command");
-
- update_pounces();
-}
-
-void *
-pidgin_pounces_get_handle() {
- static int handle;
-
- return &handle;
-}
-
-void
-pidgin_pounces_init(void)
-{
- purple_pounces_register_handler(PIDGIN_UI, pounce_cb, new_pounce,
- free_pounce);
-
- purple_prefs_add_none(PIDGIN_PREFS_ROOT "/pounces");
- purple_prefs_add_none(PIDGIN_PREFS_ROOT "/pounces/default_actions");
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/open-window",
- FALSE);
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/popup-notify",
- TRUE);
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/send-message",
- FALSE);
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/pounces/default_actions/execute-command",
- FALSE);
- purple_prefs_add_none(PIDGIN_PREFS_ROOT "/pounces/dialog");
- purple_prefs_add_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width", 520);
- purple_prefs_add_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height", 321);
-
- purple_signal_connect(purple_connections_get_handle(), "signed-on",
- pidgin_pounces_get_handle(),
- PURPLE_CALLBACK(signed_on_off_cb), NULL);
- purple_signal_connect(purple_connections_get_handle(), "signed-off",
- pidgin_pounces_get_handle(),
- PURPLE_CALLBACK(signed_on_off_cb), NULL);
-}
--- a/pidgin/gtkpounce.h Sat Jan 02 21:58:08 2021 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/* 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
- */
-
-#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
-# error "only <pidgin.h> may be included directly"
-#endif
-
-#ifndef _PIDGINPOUNCE_H_
-#define _PIDGINPOUNCE_H_
-/**
- * SECTION:gtkpounce
- * @section_id: pidgin-gtkpounce
- * @short_description: <filename>gtkpounce.h</filename>
- * @title: Buddy Pounce API
- */
-
-#include <purple.h>
-
-G_BEGIN_DECLS
-
-/**
- * pidgin_pounce_editor_show:
- * @account: The optional account to use.
- * @name: The optional name to pounce on.
- * @cur_pounce: The current buddy pounce, if editing an existing one.
- *
- * Displays a New Buddy Pounce or Edit Buddy Pounce dialog.
- */
-void pidgin_pounce_editor_show(PurpleAccount *account, const char *name,
- PurplePounce *cur_pounce);
-
-/**
- * pidgin_pounces_manager_show:
- *
- * Shows the pounces manager window.
- */
-void pidgin_pounces_manager_show(void);
-
-/**
- * pidgin_pounces_manager_hide:
- *
- * Hides the pounces manager window.
- */
-void pidgin_pounces_manager_hide(void);
-
-/**
- * pidgin_pounces_get_handle:
- *
- * Returns the gtkpounces handle
- *
- * Returns: The handle to the GTK+ pounces system
- */
-void *pidgin_pounces_get_handle(void);
-
-/**
- * pidgin_pounces_init:
- *
- * Initializes the GTK+ pounces subsystem.
- */
-void pidgin_pounces_init(void);
-
-G_END_DECLS
-
-#endif /* _PIDGINPOUNCE_H_ */
--- a/pidgin/libpidgin.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/libpidgin.c Sat Jan 02 22:05:09 2021 -0600
@@ -41,7 +41,6 @@
#include "gtkidle.h"
#include "gtkmedia.h"
#include "gtknotify.h"
-#include "gtkpounce.h"
#include "gtkprefs.h"
#include "gtkprivacy.h"
#include "gtkrequest.h"
@@ -190,7 +189,6 @@
pidgin_blist_init();
pidgin_status_init();
pidgin_conversations_init();
- pidgin_pounces_init();
pidgin_privacy_init();
pidgin_xfers_init();
pidgin_roomlist_init();
--- a/pidgin/meson.build Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/meson.build Sat Jan 02 22:05:09 2021 -0600
@@ -14,7 +14,6 @@
'gtkmedia.c',
'gtknotify.c',
'gtkpluginpref.c',
- 'gtkpounce.c',
'gtkprefs.c',
'gtkprivacy.c',
'gtkrequest.c',
@@ -86,7 +85,6 @@
'gtkpluginpref.h',
'gtkprefs.h',
'gtkprivacy.h',
- 'gtkpounce.h',
'gtkrequest.h',
'gtkroomlist.h',
'gtksavedstatuses.h',
--- a/pidgin/pidginapplication.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/pidginapplication.c Sat Jan 02 22:05:09 2021 -0600
@@ -36,7 +36,6 @@
#include "gtkaccount.h"
#include "gtkblist.h"
#include "gtkdialogs.h"
-#include "gtkpounce.h"
#include "gtkprefs.h"
#include "gtkprivacy.h"
#include "gtkroomlist.h"
@@ -189,13 +188,6 @@
}
static void
-pidgin_application_buddy_pounces(GSimpleAction *simple, GVariant *parameter,
- gpointer data)
-{
- pidgin_pounces_manager_show();
-}
-
-static void
pidgin_application_custom_smiley(GSimpleAction *simple, GVariant *parameter,
gpointer data)
{
@@ -322,9 +314,6 @@
.name = "add-group",
.activate = pidgin_application_add_group,
}, {
- .name = "buddy-pounces",
- .activate = pidgin_application_buddy_pounces,
- }, {
.name = "custom-smiley",
.activate = pidgin_application_custom_smiley,
}, {
--- a/pidgin/pidginstock.c Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/pidginstock.c Sat Jan 02 22:05:09 2021 -0600
@@ -72,7 +72,6 @@
{ PIDGIN_STOCK_MODIFY, NULL, GTK_STOCK_PREFERENCES },
{ PIDGIN_STOCK_ADD, NULL, GTK_STOCK_ADD },
{ PIDGIN_STOCK_PAUSE, NULL, GTK_STOCK_MEDIA_PAUSE },
- { PIDGIN_STOCK_POUNCE, NULL, GTK_STOCK_REDO },
{ PIDGIN_STOCK_OPEN_MAIL, NULL, GTK_STOCK_JUMP_TO },
{ PIDGIN_STOCK_SIGN_ON, NULL, GTK_STOCK_EXECUTE },
{ PIDGIN_STOCK_SIGN_OFF, NULL, GTK_STOCK_CLOSE },
--- a/pidgin/pidginstock.h Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/pidginstock.h Sat Jan 02 22:05:09 2021 -0600
@@ -61,7 +61,6 @@
#define PIDGIN_STOCK_ADD "pidgin-add"
#define PIDGIN_STOCK_OPEN_MAIL "pidgin-stock-open-mail"
#define PIDGIN_STOCK_PAUSE "pidgin-pause"
-#define PIDGIN_STOCK_POUNCE "pidgin-pounce"
#define PIDGIN_STOCK_SIGN_OFF "pidgin-sign-off"
#define PIDGIN_STOCK_SIGN_ON "pidgin-sign-on"
#define PIDGIN_STOCK_TEXT_NORMAL "pidgin-text-normal"
--- a/pidgin/resources/BuddyList/menu.ui Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/resources/BuddyList/menu.ui Sat Jan 02 22:05:09 2021 -0600
@@ -224,15 +224,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkMenuItem" id="buddy_pounces">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="action_name">app.buddy-pounces</property>
- <property name="label" translatable="yes">Buddy _Pounces</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="custom_smileys">
<property name="visible">True</property>
<property name="can_focus">False</property>
--- a/pidgin/resources/Conversations/menu.ui Sat Jan 02 21:58:08 2021 -0600
+++ b/pidgin/resources/Conversations/menu.ui Sat Jan 02 22:05:09 2021 -0600
@@ -63,10 +63,6 @@
<attribute name="action">win.get-attention</attribute>
</item>
<item>
- <attribute name="label" translatable="yes">Add Buddy _Pounce...</attribute>
- <attribute name="action">win.add-buddy-pounce</attribute>
- </item>
- <item>
<attribute name="label" translatable="yes">_Get Info</attribute>
<attribute name="action">win.clear-history</attribute>
<attribute name="accel">&lt;Primary&gt;O</attribute>
--- a/po/POTFILES.in Sat Jan 02 21:58:08 2021 -0600
+++ b/po/POTFILES.in Sat Jan 02 22:05:09 2021 -0600
@@ -10,7 +10,6 @@
finch/gntmenuutil.c
finch/gntnotify.c
finch/gntplugin.c
-finch/gntpounce.c
finch/gntprefs.c
finch/gntrequest.c
finch/gntroomlist.c
@@ -74,10 +73,8 @@
libpurple/plugins/keyrings/secretservice.c
libpurple/plugins/keyrings/wincred.c
libpurple/plugins/log_reader.c
-libpurple/plugins/offlinemsg.c
libpurple/plugins/psychic.c
libpurple/plugins/statenotify.c
-libpurple/pounce.c
libpurple/prefs.c
libpurple/protocol.c
libpurple/protocols/bonjour/bonjour.c
@@ -317,7 +314,6 @@
pidgin/gtkmedia.c
pidgin/gtknotify.c
pidgin/gtkpluginpref.c
-pidgin/gtkpounce.c
pidgin/gtkprefs.c
pidgin/gtkprivacy.c
pidgin/gtkrequest.c