pidgin  2.13.0
About: Pidgin is a chat program (multi-protocol instant messaging client) which lets you log in to accounts on multiple chat networks simultaneously (old name "gaim").
  Fossies Dox: pidgin-2.13.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

gntpounce.c
Go to the documentation of this file.
1 
6 /* finch
7  *
8  * Finch is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  *
26  */
27 #include <internal.h>
28 
29 #include <gnt.h>
30 #include <gntbox.h>
31 #include <gntbutton.h>
32 #include <gntcheckbox.h>
33 #include <gntcombobox.h>
34 #include <gntentry.h>
35 #include <gntlabel.h>
36 #include <gntline.h>
37 #include <gnttree.h>
38 #include <gntutils.h>
39 
40 #include "finch.h"
41 
42 #include "account.h"
43 #include "conversation.h"
44 #include "debug.h"
45 #include "notify.h"
46 #include "prpl.h"
47 #include "request.h"
48 #include "server.h"
49 #include "util.h"
50 
51 #include "gntpounce.h"
52 
53 
54 typedef struct
55 {
56  /* Pounce data */
59 
60  /* The window */
62 
63  /* Pounce on Whom */
66 
67  /* Pounce options */
69 
70  /* Pounce When Buddy... */
81 
82  /* Action */
91 
93 
94  /* Buttons */
96 
98 
99 typedef struct
100 {
106 
108 
109 /**************************************************************************
110  * Callbacks
111  **************************************************************************/
112 static gint
114 {
115  gnt_widget_destroy(dialog->window);
116  g_free(dialog);
117 
118  return TRUE;
119 }
120 
121 static void
123 {
124  gnt_widget_destroy(dialog->window);
125 }
126 
127 static void
129 {
131  const char *pouncer;
132  const char *pouncee;
133 
136  pouncee = purple_pounce_get_pouncee(pounce);
137  gnt_tree_add_row_last(tree, pounce,
138  gnt_tree_create_row(tree, pouncer, pouncee), NULL);
139 }
140 
141 static void
143 {
144  GList *pounces;
145 
147 
149  pounces = g_list_delete_link(pounces, pounces))
150  {
152  }
153 }
154 
155 static void
156 update_pounces(void)
157 {
158  /* Rebuild the pounces list if the pounces manager is open */
159  if (pounces_manager != NULL)
160  {
162  }
163 }
164 
165 static void
166 signed_on_off_cb(PurpleConnection *gc, gpointer user_data)
167 {
168  update_pounces();
169 }
170 
171 static void
173 {
177  continue;
179  }
180 }
181 
182 static void
184 {
185  const char *name;
186  const char *message, *command, *reason;
189 
190  name = gnt_entry_get_text(GNT_ENTRY(dialog->buddy_entry));
191 
192  if (*name == '\0')
193  {
195  _("Please enter a buddy to pounce."), NULL);
196  return;
197  }
198 
199  /* Options */
202 
203  /* Events */
205  events |= PURPLE_POUNCE_SIGNON;
206 
208  events |= PURPLE_POUNCE_SIGNOFF;
209 
211  events |= PURPLE_POUNCE_AWAY;
212 
214  events |= PURPLE_POUNCE_AWAY_RETURN;
215 
217  events |= PURPLE_POUNCE_IDLE;
218 
220  events |= PURPLE_POUNCE_IDLE_RETURN;
221 
223  events |= PURPLE_POUNCE_TYPING;
224 
226  events |= PURPLE_POUNCE_TYPED;
227 
230 
231  if (gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->message_recv)))
233 
234  /* Data fields */
235  message = gnt_entry_get_text(GNT_ENTRY(dialog->send_msg_entry));
236  command = gnt_entry_get_text(GNT_ENTRY(dialog->exec_cmd_entry));
237  reason = gnt_entry_get_text(GNT_ENTRY(dialog->popup_entry));
238 
239  if (*reason == '\0') reason = NULL;
240  if (*message == '\0') message = NULL;
241  if (*command == '\0') command = NULL;
242 
243  if (dialog->pounce == NULL) {
244  dialog->pounce = purple_pounce_new(FINCH_UI, dialog->account,
245  name, events, options);
246  } else {
247  purple_pounce_set_events(dialog->pounce, events);
249  purple_pounce_set_pouncer(dialog->pounce, dialog->account);
251  }
252 
253  /* Actions */
254  purple_pounce_action_set_enabled(dialog->pounce, "open-window",
256  purple_pounce_action_set_enabled(dialog->pounce, "popup-notify",
258  purple_pounce_action_set_enabled(dialog->pounce, "send-message",
260  purple_pounce_action_set_enabled(dialog->pounce, "execute-command",
262  purple_pounce_action_set_enabled(dialog->pounce, "play-beep",
264 
265  purple_pounce_action_set_attribute(dialog->pounce, "send-message",
266  "message", message);
267  purple_pounce_action_set_attribute(dialog->pounce, "execute-command",
268  "command", command);
269  purple_pounce_action_set_attribute(dialog->pounce, "popup-notify",
270  "reason", reason);
271 
272  /* Set the defaults for next time. */
273  purple_prefs_set_bool("/finch/pounces/default_actions/open-window",
275  purple_prefs_set_bool("/finch/pounces/default_actions/popup-notify",
277  purple_prefs_set_bool("/finch/pounces/default_actions/send-message",
279  purple_prefs_set_bool("/finch/pounces/default_actions/execute-command",
281  purple_prefs_set_bool("/finch/pounces/default_actions/play-beep",
283 
286 
289 
290  update_pounces();
291 
292  gnt_widget_destroy(dialog->window);
293 }
294 
295 
296 void
298  PurplePounce *cur_pounce)
299 {
301  GntWidget *window;
302  GntWidget *bbox;
303  GntWidget *hbox, *vbox;
304  GntWidget *button;
305  GntWidget *combo;
306  GList *list;
307 
308  g_return_if_fail((cur_pounce != NULL) ||
309  (account != NULL) ||
311 
312  dialog = g_new0(PurpleGntPounceDialog, 1);
313 
314  if (cur_pounce != NULL) {
315  dialog->pounce = cur_pounce;
316  dialog->account = purple_pounce_get_pouncer(cur_pounce);
317  } else if (account != NULL) {
318  dialog->pounce = NULL;
319  dialog->account = account;
320  } else {
322  PurpleConnection *gc;
323 
324  if (connections != NULL) {
325  gc = (PurpleConnection *)connections->data;
326  dialog->account = purple_connection_get_account(gc);
327  } else
328  dialog->account = purple_accounts_get_all()->data;
329 
330  dialog->pounce = NULL;
331  }
332 
333  /* Create the window. */
334  dialog->window = window = gnt_vbox_new(FALSE);
339  (cur_pounce == NULL
340  ? _("New Buddy Pounce") : _("Edit Buddy Pounce")));
341 
342  g_signal_connect(G_OBJECT(window), "destroy",
343  G_CALLBACK(delete_win_cb), dialog);
344 
346 
347  /* Account: */
349  dialog->account_menu = combo = gnt_combo_box_new();
350  list = purple_accounts_get_all();
351  for (; list; list = list->next)
352  {
354  char *text;
355 
356  account = list->data;
357  text = g_strdup_printf("%s (%s)",
361  g_free(text);
362  }
363  if (dialog->account)
365 
367 
368  /* Buddy: */
369  hbox = gnt_hbox_new(FALSE);
370  gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Buddy name:")));
371 
372  dialog->buddy_entry = gnt_entry_new(NULL);
373  gnt_box_add_widget(GNT_BOX(hbox), dialog->buddy_entry);
374 
376 
378 
379  if (cur_pounce != NULL) {
380  gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry),
381  purple_pounce_get_pouncee(cur_pounce));
382  } else if (name != NULL) {
383  gnt_entry_set_text(GNT_ENTRY(dialog->buddy_entry), name);
384  }
385 
386  /* Create the event frame */
389 
390  dialog->signon = gnt_check_box_new(_("Signs on"));
391  dialog->signoff = gnt_check_box_new(_("Signs off"));
392  dialog->away = gnt_check_box_new(_("Goes away"));
393  dialog->away_return = gnt_check_box_new(_("Returns from away"));
394  dialog->idle = gnt_check_box_new(_("Becomes idle"));
395  dialog->idle_return = gnt_check_box_new(_("Is no longer idle"));
396  dialog->typing = gnt_check_box_new(_("Starts typing"));
397  dialog->typed = gnt_check_box_new(_("Pauses while typing"));
398  dialog->stop_typing = gnt_check_box_new(_("Stops typing"));
399  dialog->message_recv = gnt_check_box_new(_("Sends a message"));
400 
401  hbox = gnt_hbox_new(TRUE);
402  gnt_box_set_pad(GNT_BOX(hbox), 2);
403 
404  vbox = gnt_vbox_new(FALSE);
405  gnt_box_set_pad(GNT_BOX(vbox), 0);
406  gnt_box_add_widget(GNT_BOX(hbox), vbox);
407 
408  gnt_box_add_widget(GNT_BOX(vbox), dialog->signon);
409  gnt_box_add_widget(GNT_BOX(vbox), dialog->away);
410  gnt_box_add_widget(GNT_BOX(vbox), dialog->idle);
411  gnt_box_add_widget(GNT_BOX(vbox), dialog->typing);
412  gnt_box_add_widget(GNT_BOX(vbox), dialog->stop_typing);
413 
414  vbox = gnt_vbox_new(FALSE);
415  gnt_box_set_pad(GNT_BOX(vbox), 0);
416  gnt_box_add_widget(GNT_BOX(hbox), vbox);
417 
418  gnt_box_add_widget(GNT_BOX(vbox), dialog->signoff);
419  gnt_box_add_widget(GNT_BOX(vbox), dialog->away_return);
420  gnt_box_add_widget(GNT_BOX(vbox), dialog->idle_return);
421  gnt_box_add_widget(GNT_BOX(vbox), dialog->typed);
422  gnt_box_add_widget(GNT_BOX(vbox), dialog->message_recv);
423 
425 
426  /* Create the "Action" frame. */
429 
430  dialog->open_win = gnt_check_box_new(_("Open an IM window"));
431  dialog->popup = gnt_check_box_new(_("Pop up a notification"));
432  dialog->send_msg = gnt_check_box_new(_("Send a message"));
433  dialog->exec_cmd = gnt_check_box_new(_("Execute a command"));
434  dialog->play_sound = gnt_check_box_new(_("Play a sound"));
435 
436  dialog->send_msg_entry = gnt_entry_new(NULL);
437  dialog->exec_cmd_entry = gnt_entry_new(NULL);
438  dialog->popup_entry = gnt_entry_new(NULL);
439  dialog->exec_cmd_entry = gnt_entry_new(NULL);
440 
441  hbox = gnt_hbox_new(FALSE);
442  gnt_box_add_widget(GNT_BOX(hbox), dialog->open_win);
444  hbox = gnt_hbox_new(FALSE);
445  gnt_box_add_widget(GNT_BOX(hbox), dialog->popup);
446  gnt_box_add_widget(GNT_BOX(hbox), dialog->popup_entry);
448  hbox = gnt_hbox_new(FALSE);
449  gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg);
450  gnt_box_add_widget(GNT_BOX(hbox), dialog->send_msg_entry);
452  hbox = gnt_hbox_new(FALSE);
453  gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd);
454  gnt_box_add_widget(GNT_BOX(hbox), dialog->exec_cmd_entry);
456  hbox = gnt_hbox_new(FALSE);
457  gnt_box_add_widget(GNT_BOX(hbox), dialog->play_sound);
459 
462  dialog->on_away = gnt_check_box_new(_("Pounce only when my status is not Available"));
464  dialog->save_pounce = gnt_check_box_new(_("Recurring"));
465  gnt_box_add_widget(GNT_BOX(window), dialog->save_pounce);
466 
467 
469  /* Now the button box! */
470  bbox = gnt_hbox_new(FALSE);
471 
472  /* Cancel button */
473  button = gnt_button_new(_("Cancel"));
474  gnt_box_add_widget(GNT_BOX(bbox), button);
475  g_signal_connect(G_OBJECT(button), "activate",
476  G_CALLBACK(cancel_cb), dialog);
477 
478  /* Save button */
479  dialog->save_button = button = gnt_button_new(_("Save"));
480  gnt_box_add_widget(GNT_BOX(bbox), button);
481  g_signal_connect(G_OBJECT(button), "activate",
482  G_CALLBACK(save_pounce_cb), dialog);
483 
485 
486 
487  /* Set the values of stuff. */
488  if (cur_pounce != NULL)
489  {
490  PurplePounceEvent events = purple_pounce_get_events(cur_pounce);
492  const char *value;
493 
494  /* Options */
497 
498  /* Events */
500  (events & PURPLE_POUNCE_SIGNON));
502  (events & PURPLE_POUNCE_SIGNOFF));
504  (events & PURPLE_POUNCE_AWAY));
506  (events & PURPLE_POUNCE_AWAY_RETURN));
508  (events & PURPLE_POUNCE_IDLE));
510  (events & PURPLE_POUNCE_IDLE_RETURN));
512  (events & PURPLE_POUNCE_TYPING));
514  (events & PURPLE_POUNCE_TYPED));
516  (events & PURPLE_POUNCE_TYPING_STOPPED));
518  (events & PURPLE_POUNCE_MESSAGE_RECEIVED));
519 
520  /* Actions */
522  purple_pounce_action_is_enabled(cur_pounce, "open-window"));
524  purple_pounce_action_is_enabled(cur_pounce, "popup-notify"));
526  purple_pounce_action_is_enabled(cur_pounce, "send-message"));
528  purple_pounce_action_is_enabled(cur_pounce, "execute-command"));
530  purple_pounce_action_is_enabled(cur_pounce, "play-beep"));
531 
533  purple_pounce_get_save(cur_pounce));
534 
535  if ((value = purple_pounce_action_get_attribute(cur_pounce,
536  "send-message",
537  "message")) != NULL)
538  {
539  gnt_entry_set_text(GNT_ENTRY(dialog->send_msg_entry), value);
540  }
541 
542  if ((value = purple_pounce_action_get_attribute(cur_pounce,
543  "popup-notify",
544  "reason")) != NULL)
545  {
546  gnt_entry_set_text(GNT_ENTRY(dialog->popup_entry), value);
547  }
548 
549  if ((value = purple_pounce_action_get_attribute(cur_pounce,
550  "execute-command",
551  "command")) != NULL)
552  {
553  gnt_entry_set_text(GNT_ENTRY(dialog->exec_cmd_entry), value);
554  }
555  }
556  else
557  {
558  PurpleBuddy *buddy = NULL;
559 
560  if (name != NULL)
561  buddy = purple_find_buddy(account, name);
562 
563  /* Set some defaults */
564  if (buddy == NULL) {
566  GNT_CHECK_BOX(dialog->signon), TRUE);
567  } else {
568  if (!PURPLE_BUDDY_IS_ONLINE(buddy)) {
570  GNT_CHECK_BOX(dialog->signon), TRUE);
571  } else {
572  gboolean default_set = FALSE;
573  PurplePresence *presence = purple_buddy_get_presence(buddy);
574 
575  if (purple_presence_is_idle(presence))
576  {
578  GNT_CHECK_BOX(dialog->idle_return), TRUE);
579 
580  default_set = TRUE;
581  }
582 
583  if (!purple_presence_is_available(presence))
584  {
586  GNT_CHECK_BOX(dialog->away_return), TRUE);
587 
588  default_set = TRUE;
589  }
590 
591  if (!default_set)
592  {
594  GNT_CHECK_BOX(dialog->signon), TRUE);
595  }
596  }
597  }
598 
600  purple_prefs_get_bool("/finch/pounces/default_actions/open-window"));
602  purple_prefs_get_bool("/finch/pounces/default_actions/popup-notify"));
604  purple_prefs_get_bool("/finch/pounces/default_actions/send-message"));
606  purple_prefs_get_bool("/finch/pounces/default_actions/execute-command"));
608  purple_prefs_get_bool("/finch/pounces/default_actions/play-beep"));
609  }
610 
612 }
613 
614 
615 
616 static gboolean
617 pounces_manager_destroy_cb(GntWidget *widget, gpointer user_data)
618 {
619  PouncesManager *dialog = user_data;
620 
621  dialog->window = NULL;
623 
624  return FALSE;
625 }
626 
627 
628 static void
629 pounces_manager_add_cb(GntButton *button, gpointer user_data)
630 {
631  if (purple_accounts_get_all() == NULL) {
632  purple_notify_error(NULL, _("Cannot create pounce"),
633  _("You do not have any accounts."),
634  _("You must create an account first before you can create a pounce."));
635  return;
636  }
638 }
639 
640 
641 static void
642 pounces_manager_modify_cb(GntButton *button, gpointer user_data)
643 {
644  PouncesManager *dialog = user_data;
646  if (pounce)
648 }
649 
650 static void
652 {
654 
656  purple_pounce_destroy(pounce);
657 }
658 
659 
660 static void
661 pounces_manager_delete_cb(GntButton *button, gpointer user_data)
662 {
663  PouncesManager *dialog = user_data;
664  PurplePounce *pounce;
666  const char *pouncer, *pouncee;
667  char *buf;
668 
670  if (pounce == NULL)
671  return;
672 
675  pouncee = purple_pounce_get_pouncee(pounce);
676  buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer);
677  purple_request_action(pounce, NULL, buf, NULL, 0,
678  account, pouncee, NULL,
679  pounce, 2,
681  _("Cancel"), NULL);
682  g_free(buf);
683 }
684 
685 static void
686 pounces_manager_close_cb(GntButton *button, gpointer user_data)
687 {
689 }
690 
691 
692 void
694 {
696  GntWidget *bbox;
697  GntWidget *button;
698  GntWidget *tree;
699  GntWidget *win;
700 
701  if (pounces_manager != NULL) {
703  return;
704  }
705 
706  pounces_manager = dialog = g_new0(PouncesManager, 1);
707 
708  dialog->window = win = gnt_vbox_new(FALSE);
710  gnt_box_set_title(GNT_BOX(win), _("Buddy Pounces"));
711  gnt_box_set_pad(GNT_BOX(win), 0);
712 
713  g_signal_connect(G_OBJECT(win), "destroy",
714  G_CALLBACK(pounces_manager_destroy_cb), dialog);
715 
716  /* List of saved buddy pounces */
718  gnt_tree_set_column_titles(GNT_TREE(tree), "Account", "Pouncee", NULL);
720 
722 
723  /* Button box. */
724  bbox = gnt_hbox_new(FALSE);
725 
726  /* Add button */
727  button = gnt_button_new(_("Add"));
728  gnt_box_add_widget(GNT_BOX(bbox), button);
730 
731  g_signal_connect(G_OBJECT(button), "activate",
732  G_CALLBACK(pounces_manager_add_cb), dialog);
733 
734  /* Modify button */
735  button = gnt_button_new(_("Modify"));
736  dialog->modify_button = button;
737  gnt_box_add_widget(GNT_BOX(bbox), button);
738 
739  g_signal_connect(G_OBJECT(button), "activate",
740  G_CALLBACK(pounces_manager_modify_cb), dialog);
741 
742  /* Delete button */
743  button = gnt_button_new(_("Delete"));
744  dialog->delete_button = button;
745  gnt_box_add_widget(GNT_BOX(bbox), button);
747 
748  g_signal_connect(G_OBJECT(button), "activate",
749  G_CALLBACK(pounces_manager_delete_cb), dialog);
750 
751  /* Close button */
752  button = gnt_button_new(_("Close"));
753  gnt_box_add_widget(GNT_BOX(bbox), button);
754  gnt_widget_show(button);
755 
756  g_signal_connect(G_OBJECT(button), "activate",
757  G_CALLBACK(pounces_manager_close_cb), dialog);
758 
759  gnt_box_add_widget(GNT_BOX(win), bbox);
760 
761  gnt_widget_show(win);
763 }
764 
765 void
767 {
768  if (pounces_manager == NULL)
769  return;
770 
771  if (pounces_manager->window != NULL)
773 
775 
776  g_free(pounces_manager);
778 }
779 
780 static void
781 pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
782 {
783  PurpleConversation *conv;
785  PurpleBuddy *buddy;
786  const char *pouncee;
787  const char *alias;
788 
789  pouncee = purple_pounce_get_pouncee(pounce);
791 
792  buddy = purple_find_buddy(account, pouncee);
793  if (buddy != NULL)
794  {
795  alias = purple_buddy_get_alias(buddy);
796  if (alias == NULL)
797  alias = pouncee;
798  }
799  else
800  alias = pouncee;
801 
802  if (purple_pounce_action_is_enabled(pounce, "open-window"))
803  {
806  }
807 
808  if (purple_pounce_action_is_enabled(pounce, "popup-notify"))
809  {
810  char *tmp = NULL;
811  const char *name_shown;
812  const char *reason;
813  struct {
814  PurplePounceEvent event;
815  const char *format;
816  } messages[] = {
817  {PURPLE_POUNCE_TYPING, _("%s has started typing to you (%s)")},
818  {PURPLE_POUNCE_TYPED, _("%s has paused while typing to you (%s)")},
819  {PURPLE_POUNCE_SIGNON, _("%s has signed on (%s)")},
820  {PURPLE_POUNCE_IDLE_RETURN, _("%s has returned from being idle (%s)")},
821  {PURPLE_POUNCE_AWAY_RETURN, _("%s has returned from being away (%s)")},
822  {PURPLE_POUNCE_TYPING_STOPPED, _("%s has stopped typing to you (%s)")},
823  {PURPLE_POUNCE_SIGNOFF, _("%s has signed off (%s)")},
824  {PURPLE_POUNCE_IDLE, _("%s has become idle (%s)")},
825  {PURPLE_POUNCE_AWAY, _("%s has gone away. (%s)")},
826  {PURPLE_POUNCE_MESSAGE_RECEIVED, _("%s has sent you a message. (%s)")},
827  {0, NULL}
828  };
829  int i;
830  reason = purple_pounce_action_get_attribute(pounce, "popup-notify",
831  "reason");
832 
833  /*
834  * Here we place the protocol name in the pounce dialog to lessen
835  * confusion about what protocol a pounce is for.
836  */
837  for (i = 0; messages[i].format != NULL; i++) {
838  if (messages[i].event & events) {
839  tmp = g_strdup_printf(messages[i].format, alias,
841  break;
842  }
843  }
844  if (tmp == NULL)
845  tmp = g_strdup(_("Unknown pounce event. Please report this!"));
846 
847  /*
848  * Ok here is where I change the second argument, title, from
849  * NULL to the account alias if we have it or the account
850  * name if that's all we have
851  */
852  if ((name_shown = purple_account_get_alias(account)) == NULL)
853  name_shown = purple_account_get_username(account);
854 
855  if (reason == NULL)
856  {
858  }
859  else
860  {
861  char *tmp2 = g_strdup_printf("%s\n\n%s", reason, purple_date_format_full(NULL));
862  purple_notify_info(NULL, name_shown, tmp, tmp2);
863  g_free(tmp2);
864  }
865  g_free(tmp);
866  }
867 
868  if (purple_pounce_action_is_enabled(pounce, "send-message"))
869  {
870  const char *message;
871 
872  message = purple_pounce_action_get_attribute(pounce, "send-message",
873  "message");
874 
875  if (message != NULL)
876  {
878 
879  if (conv == NULL)
881 
882  purple_conversation_write(conv, NULL, message,
884 
885  serv_send_im(purple_account_get_connection(account), (char *)pouncee, (char *)message, 0);
886  }
887  }
888 
889  if (purple_pounce_action_is_enabled(pounce, "execute-command"))
890  {
891  const char *command;
892 
894  "execute-command", "command");
895 
896  if (command != NULL)
897  {
898  char *localecmd = g_locale_from_utf8(command, -1, NULL,
899  NULL, NULL);
900 
901  if (localecmd != NULL)
902  {
903  int pid = fork();
904 
905  if (pid == 0) {
906  char *args[4];
907 
908  args[0] = "sh";
909  args[1] = "-c";
910  args[2] = (char *)localecmd;
911  args[3] = NULL;
912 
913  execvp(args[0], args);
914 
915  _exit(0);
916  }
917  g_free(localecmd);
918  }
919  }
920  }
921 
922  if (purple_pounce_action_is_enabled(pounce, "play-beep"))
923  {
924  beep();
925  }
926 }
927 
928 static void
929 free_pounce(PurplePounce *pounce)
930 {
931  update_pounces();
932 }
933 
934 static void
935 new_pounce(PurplePounce *pounce)
936 {
937  purple_pounce_action_register(pounce, "open-window");
938  purple_pounce_action_register(pounce, "popup-notify");
939  purple_pounce_action_register(pounce, "send-message");
940  purple_pounce_action_register(pounce, "execute-command");
941  purple_pounce_action_register(pounce, "play-beep");
942 
943  update_pounces();
944 }
945 
946 void *
948 {
949  static int handle;
950 
951  return &handle;
952 }
953 
954 void
955 finch_pounces_init(void)
956 {
958  free_pounce);
959 
960  purple_prefs_add_none("/finch/pounces");
961  purple_prefs_add_none("/finch/pounces/default_actions");
962  purple_prefs_add_bool("/finch/pounces/default_actions/open-window",
963  FALSE);
964  purple_prefs_add_bool("/finch/pounces/default_actions/popup-notify",
965  TRUE);
966  purple_prefs_add_bool("/finch/pounces/default_actions/send-message",
967  FALSE);
968  purple_prefs_add_bool("/finch/pounces/default_actions/execute-command",
969  FALSE);
970  purple_prefs_add_bool("/finch/pounces/default_actions/play-beep",
971  FALSE);
972  purple_prefs_add_none("/finch/pounces/dialog");
973 
980 }
981 
982 /* XXX: There's no such thing in pidgin. Perhaps there should be? */
984 {
986 
988 }
989 
update_pounces
static void update_pounces(void)
Definition: gntpounce.c:155
dbus-analyze-signals.args
args
Definition: dbus-analyze-signals.py:37
purple_request_action
void * purple_request_action(void *handle, const char *title, const char *primary, const char *secondary, int default_action, PurpleAccount *account, const char *who, PurpleConversation *conv, void *user_data, size_t action_count,...)
Definition: request.c:1300
prpl.h
name
char * name
Definition: gntbindable.c:47
free_pounce
static void free_pounce(PurplePounce *pounce)
Definition: gntpounce.c:928
signed_on_off_cb
static void signed_on_off_cb(PurpleConnection *gc, gpointer user_data)
Definition: gntpounce.c:165
finch_pounces_manager_show
void finch_pounces_manager_show(void)
Definition: gntpounce.c:692
PouncesManager::modify_button
GntWidget * modify_button
Definition: gntpounce.c:103
PURPLE_BUDDY_IS_ONLINE
gboolean PURPLE_BUDDY_IS_ONLINE(PurpleBuddy *buddy)
gnt_box_set_pad
void gnt_box_set_pad(GntBox *box, int pad)
Definition: gntbox.c:695
purple_blist_node_next
PurpleBlistNode * purple_blist_node_next(PurpleBlistNode *node, gboolean offline)
Definition: blist.c:845
account
static PurpleAccount * account
Definition: raw.c:45
purple_notify_error
#define purple_notify_error(handle, title, primary, secondary)
Definition: notify.h:756
PouncesManager::window
GntWidget * window
Definition: gntpounce.c:101
PURPLE_POUNCE_NONE
Definition: pounce.h:39
gnt_entry_set_text
void gnt_entry_set_text(GntEntry *entry, const char *text)
Definition: gntentry.c:1140
purple_prefs_add_bool
void purple_prefs_add_bool(const char *name, gboolean value)
Definition: prefs.c:646
purple_account_get_username
const char * purple_account_get_username(const PurpleAccount *account)
Definition: account.c:2225
gnt_widget_show
void gnt_widget_show(GntWidget *widget)
Definition: gntwidget.c:326
purple_pounce_action_set_enabled
void purple_pounce_action_set_enabled(PurplePounce *pounce, const char *action, gboolean enabled)
Definition: pounce.c:797
PurpleGntPounceDialog::account
PurpleAccount * account
Definition: gntpounce.c:58
PurpleGntPounceDialog::away
GntWidget * away
Definition: gntpounce.c:73
gntbox.h
PurpleGntPounceDialog::send_msg_entry
GntWidget * send_msg_entry
Definition: gntpounce.c:87
purple_pounces_unregister_handler
void purple_pounces_unregister_handler(const char *ui)
Definition: pounce.c:1028
gnt_combo_box_new
GntWidget * gnt_combo_box_new()
Definition: gntcombobox.c:350
account.h
delete_win_cb
static gint delete_win_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
Definition: gntpounce.c:112
purple_find_conversation_with_account
PurpleConversation * purple_find_conversation_with_account(PurpleConversationType type, const char *name, const PurpleAccount *account)
Definition: conversation.c:893
PurpleGntPounceDialog::save_pounce
GntWidget * save_pounce
Definition: gntpounce.c:92
GNT_COMBO_BOX
#define GNT_COMBO_BOX(obj)
Definition: gntcombobox.h:36
notify.h
gntpounce.h
pounces_manager_delete_cb
static void pounces_manager_delete_cb(GntButton *button, gpointer user_data)
Definition: gntpounce.c:660
gnt_label_new
GntWidget * gnt_label_new(const char *text)
Definition: gntlabel.c:186
gnt_tree_remove
void gnt_tree_remove(GntTree *tree, gpointer key)
Definition: gnttree.c:1479
widget
GtkWidget * widget
Definition: pidgintooltip.c:38
purple_signal_connect
gulong purple_signal_connect(void *instance, const char *signal, void *handle, PurpleCallback func, void *data)
Definition: signals.c:305
_GntWidget
Definition: gntwidget.h:98
gnt.h
PouncesManager::tree
GntWidget * tree
Definition: gntpounce.c:102
purple_buddy_get_name
const char * purple_buddy_get_name(const PurpleBuddy *buddy)
Definition: blist.c:1449
window
GntWidget * window
Definition: gntcertmgr.c:45
purple_account_get_alias
const char * purple_account_get_alias(const PurpleAccount *account)
Definition: account.c:2241
PurpleGntPounceDialog::message_recv
GntWidget * message_recv
Definition: gntpounce.c:80
gnt_vbox_new
#define gnt_vbox_new(homo)
Definition: gntbox.h:96
gntutils.h
_PurplePounce
Definition: pounce.h:70
purple_pounce_destroy
void purple_pounce_destroy(PurplePounce *pounce)
Definition: pounce.c:651
PURPLE_CONV_TYPE_IM
Definition: conversation.h:54
PurpleGntPounceDialog::exec_cmd
GntWidget * exec_cmd
Definition: gntpounce.c:88
gnt_combo_box_set_selected
void gnt_combo_box_set_selected(GntComboBox *box, gpointer key)
Definition: gntcombobox.c:370
_
void boot_DynaLoader _((pTHX_ CV *cv))
gnt_util_set_trigger_widget
void gnt_util_set_trigger_widget(GntWidget *wid, const char *text, GntWidget *button)
Definition: gntutils.c:496
gnt_window_present
void gnt_window_present(GntWidget *window)
Definition: gntmain.c:548
GNT_BOX
#define GNT_BOX(obj)
Definition: gntbox.h:34
finch_pounces_uninit
void finch_pounces_uninit()
Definition: gntpounce.c:982
purple_account_get_connection
PurpleConnection * purple_account_get_connection(const PurpleAccount *account)
Definition: account.c:2284
gntentry.h
gnt_box_add_widget
void gnt_box_add_widget(GntBox *b, GntWidget *widget)
Definition: gntbox.c:674
purple_conversation_write
void purple_conversation_write(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime)
Definition: conversation.c:927
gnt_button_new
GntWidget * gnt_button_new(const char *text)
Definition: gntbutton.c:170
handle
static PurplePlugin * handle
Definition: nss-prefs.c:61
PurpleGntPounceDialog::idle_return
GntWidget * idle_return
Definition: gntpounce.c:76
PurpleGntPounceDialog::exec_cmd_entry
GntWidget * exec_cmd_entry
Definition: gntpounce.c:89
gnt_tree_add_row_last
GntTreeRow * gnt_tree_add_row_last(GntTree *tree, void *key, GntTreeRow *row, void *parent)
Definition: gnttree.c:1420
purple_request_close_with_handle
void purple_request_close_with_handle(void *handle)
Definition: request.c:1539
pounces
static GList * pounces
Definition: pounce.c:75
purple_presence_is_idle
gboolean purple_presence_is_idle(const PurplePresence *presence)
Definition: status.c:1544
purple_pounce_action_is_enabled
gboolean purple_pounce_action_is_enabled(const PurplePounce *pounce, const char *action)
Definition: pounce.c:888
purple_pounces_register_handler
void purple_pounces_register_handler(const char *ui, PurplePounceCb cb, void(*new_pounce)(PurplePounce *pounce), void(*free_pounce)(PurplePounce *pounce))
Definition: pounce.c:1008
purple_prefs_set_bool
void purple_prefs_set_bool(const char *name, gboolean value)
Definition: prefs.c:898
purple_blist_get_root
PurpleBlistNode * purple_blist_get_root()
Definition: blist.c:769
connections
static GList * connections
Definition: connection.c:45
finch_pounces_manager_hide
void finch_pounces_manager_hide(void)
Definition: gntpounce.c:765
PurplePounceOption
PurplePounceOption
Definition: pounce.h:53
FINCH_UI
#define FINCH_UI
Definition: finch.h:27
PurpleGntPounceDialog::typing
GntWidget * typing
Definition: gntpounce.c:77
dbus-analyze-types.command
command
Definition: dbus-analyze-types.py:32
purple_find_buddy
PurpleBuddy * purple_find_buddy(PurpleAccount *account, const char *name)
Definition: blist.c:2427
gntlabel.h
finch_pounces_get_handle
void * finch_pounces_get_handle()
Definition: gntpounce.c:946
data
gpointer data
Definition: gntwm.c:1781
GNT_TEXT_FLAG_BOLD
Definition: gnttextview.h:71
PURPLE_POUNCE_OPTION_NONE
Definition: pounce.h:55
finch_pounce_editor_show
void finch_pounce_editor_show(PurpleAccount *account, const char *name, PurplePounce *cur_pounce)
Definition: gntpounce.c:296
PurpleGntPounceDialog::signon
GntWidget * signon
Definition: gntpounce.c:71
pounces_manager_add_cb
static void pounces_manager_add_cb(GntButton *button, gpointer user_data)
Definition: gntpounce.c:628
purple_pounce_get_save
gboolean purple_pounce_get_save(const PurplePounce *pounce)
Definition: pounce.c:880
offline
static PurpleBlistNode offline
Definition: grouping.c:37
NULL
#define NULL
Definition: getopt1.c:52
_GntTree
Definition: gnttree.h:57
purple_signals_disconnect_by_handle
void purple_signals_disconnect_by_handle(void *handle)
Definition: signals.c:417
purple_pounce_set_save
void purple_pounce_set_save(PurplePounce *pounce, gboolean save)
Definition: pounce.c:764
PurpleGntPounceDialog::stop_typing
GntWidget * stop_typing
Definition: gntpounce.c:79
pietray.dialog
dialog
Definition: pietray.py:204
finch_pounces_init
void finch_pounces_init(void)
Definition: gntpounce.c:954
PurpleGntPounceDialog::open_win
GntWidget * open_win
Definition: gntpounce.c:83
GNT_TREE
#define GNT_TREE(obj)
Definition: gnttree.h:37
GNT_CHECK_BOX
#define GNT_CHECK_BOX(obj)
Definition: gntcheckbox.h:36
gnt_check_box_set_checked
void gnt_check_box_set_checked(GntCheckBox *box, gboolean set)
Definition: gntcheckbox.c:164
gnt_tree_set_column_titles
void gnt_tree_set_column_titles(GntTree *tree,...)
Definition: gnttree.c:1763
gntcombobox.h
pounces_manager_modify_cb
static void pounces_manager_modify_cb(GntButton *button, gpointer user_data)
Definition: gntpounce.c:641
gnt_check_box_new
GntWidget * gnt_check_box_new(const char *text)
Definition: gntcheckbox.c:154
gnt_box_set_toplevel
void gnt_box_set_toplevel(GntBox *box, gboolean set)
Definition: gntbox.c:701
PURPLE_CALLBACK
#define PURPLE_CALLBACK(func)
Definition: signals.h:32
PURPLE_POUNCE_IDLE
Definition: pounce.h:44
options
Definition: themeedit-icon.c:59
purple_pounce_action_set_attribute
void purple_pounce_action_set_attribute(PurplePounce *pounce, const char *action, const char *attr, const char *value)
Definition: pounce.c:815
PURPLE_POUNCE_AWAY_RETURN
Definition: pounce.h:43
purple_pounce_set_pouncee
void purple_pounce_set_pouncee(PurplePounce *pounce, const char *pouncee)
Definition: pounce.c:752
pounces_manager_close_cb
static void pounces_manager_close_cb(GntButton *button, gpointer user_data)
Definition: gntpounce.c:685
gnt_check_box_get_checked
gboolean gnt_check_box_get_checked(GntCheckBox *box)
Definition: gntcheckbox.c:173
new_pounce
static void new_pounce(PurplePounce *pounce)
Definition: gntpounce.c:934
purple_connections_get_handle
void * purple_connections_get_handle(void)
Definition: connection.c:734
gntbutton.h
GNT_WIDGET
#define GNT_WIDGET(obj)
Definition: gntwidget.h:37
purple_pounce_action_register
void purple_pounce_action_register(PurplePounce *pounce, const char *name)
Definition: pounce.c:774
TRUE
#define TRUE
Definition: protobuf-c.c:56
PURPLE_POUNCE_SIGNON
Definition: pounce.h:40
PurpleGntPounceDialog::buddy_entry
GntWidget * buddy_entry
Definition: gntpounce.c:65
_PurpleAccount
Definition: account.h:169
PouncesManager
Definition: gntpounce.c:99
_PurpleBlistNode
Definition: blist.h:124
PurpleGntPounceDialog::on_away
GntWidget * on_away
Definition: gntpounce.c:68
purple_conversation_new
PurpleConversation * purple_conversation_new(PurpleConversationType type, PurpleAccount *account, const char *name)
Definition: conversation.c:330
FALSE
#define FALSE
Definition: protobuf-c.c:57
purple_buddy_get_alias
const char * purple_buddy_get_alias(PurpleBuddy *buddy)
Definition: blist.c:2348
add_pounce_to_treeview
static void add_pounce_to_treeview(GntTree *tree, PurplePounce *pounce)
Definition: gntpounce.c:127
purple_pounce_new
PurplePounce * purple_pounce_new(const char *ui_type, PurpleAccount *pouncer, const char *pouncee, PurplePounceEvent event, PurplePounceOption option)
Definition: pounce.c:615
request.h
cancel_cb
static void cancel_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
Definition: gntpounce.c:121
gnt_label_new_with_format
GntWidget * gnt_label_new_with_format(const char *text, GntTextFormatFlags flags)
Definition: gntlabel.c:191
PURPLE_POUNCE_IDLE_RETURN
Definition: pounce.h:45
pounces_manager_destroy_cb
static gboolean pounces_manager_destroy_cb(GntWidget *widget, gpointer user_data)
Definition: gntpounce.c:616
gnt_box_set_title
void gnt_box_set_title(GntBox *b, const char *title)
Definition: gntbox.c:680
purple_prefs_add_none
void purple_prefs_add_none(const char *name)
Definition: prefs.c:638
text
static char * text[]
Definition: zephyr_err.c:10
conversation.h
pounce_cb
static void pounce_cb(PurplePounce *pounce, PurplePounceEvent events, void *data)
Definition: gntpounce.c:780
PURPLE_POUNCE_TYPED
Definition: pounce.h:47
PurpleGntPounceDialog::signoff
GntWidget * signoff
Definition: gntpounce.c:72
PURPLE_POUNCE_TYPING_STOPPED
Definition: pounce.h:48
PurpleGntPounceDialog::typed
GntWidget * typed
Definition: gntpounce.c:78
purple_prefs_get_bool
gboolean purple_prefs_get_bool(const char *name)
Definition: prefs.c:1111
PURPLE_BLIST_NODE_IS_BUDDY
gboolean PURPLE_BLIST_NODE_IS_BUDDY(PurpleBlistNode *node)
setup_buddy_list_suggestion
static void setup_buddy_list_suggestion(GntEntry *entry, gboolean offline)
Definition: gntpounce.c:171
GNT_KEY_DEL
#define GNT_KEY_DEL
Definition: gntkeys.h:66
gnt_combo_box_get_selected_data
gpointer gnt_combo_box_get_selected_data(GntComboBox *box)
Definition: gntcombobox.c:365
purple_connection_get_account
PurpleAccount * purple_connection_get_account(const PurpleConnection *gc)
Definition: connection.c:440
gnt_tree_new_with_columns
GntWidget * gnt_tree_new_with_columns(int col)
Definition: gnttree.c:1694
purple_pounce_set_events
void purple_pounce_set_events(PurplePounce *pounce, PurplePounceEvent events)
Definition: pounce.c:720
purple_notify_info
#define purple_notify_info(handle, title, primary, secondary)
Definition: notify.h:742
purple_account_get_protocol_name
const char * purple_account_get_protocol_name(const PurpleAccount *account)
Definition: account.c:2272
purple_buddy_get_presence
PurplePresence * purple_buddy_get_presence(const PurpleBuddy *buddy)
Definition: blist.c:2612
PurpleGntPounceDialog::send_msg
GntWidget * send_msg
Definition: gntpounce.c:86
tree
GntWidget * tree
Definition: gntcertmgr.c:46
gnt_widget_destroy
void gnt_widget_destroy(GntWidget *obj)
Definition: gntwidget.c:312
save_pounce_cb
static void save_pounce_cb(GntWidget *w, PurpleGntPounceDialog *dialog)
Definition: gntpounce.c:182
PouncesManager::delete_button
GntWidget * delete_button
Definition: gntpounce.c:104
PurpleGntPounceDialog::away_return
GntWidget * away_return
Definition: gntpounce.c:74
purple_pounces_get_all_for_ui
GList * purple_pounces_get_all_for_ui(const char *ui)
Definition: pounce.c:1041
purple_date_format_full
const char * purple_date_format_full(const struct tm *tm)
Definition: util.c:639
PurpleGntPounceDialog::idle
GntWidget * idle
Definition: gntpounce.c:75
gnt_tree_set_show_title
void gnt_tree_set_show_title(GntTree *tree, gboolean set)
Definition: gnttree.c:1777
purple_pounce_get_pouncer
PurpleAccount * purple_pounce_get_pouncer(const PurplePounce *pounce)
Definition: pounce.c:864
purple_accounts_get_all
GList * purple_accounts_get_all(void)
Definition: account.c:3082
gntcheckbox.h
purple_pounce_set_pouncer
void purple_pounce_set_pouncer(PurplePounce *pounce, PurpleAccount *pouncer)
Definition: pounce.c:741
PURPLE_POUNCE_OPTION_AWAY
Definition: pounce.h:56
PurpleGntPounceDialog::save_button
GntWidget * save_button
Definition: gntpounce.c:95
purple_pounce_get_events
PurplePounceEvent purple_pounce_get_events(const PurplePounce *pounce)
Definition: pounce.c:848
gnt_hbox_new
#define gnt_hbox_new(homo)
Definition: gntbox.h:97
_PurpleConversation
Definition: conversation.h:338
PurpleGntPounceDialog::pounce
PurplePounce * pounce
Definition: gntpounce.c:57
gnt_entry_add_suggest
void gnt_entry_add_suggest(GntEntry *entry, const char *text)
Definition: gntentry.c:1249
gnt_entry_get_text
const char * gnt_entry_get_text(GntEntry *entry)
Definition: gntentry.c:1163
PurpleGntPounceDialog::play_sound
GntWidget * play_sound
Definition: gntpounce.c:90
finch.h
purple_pounce_get_pouncee
const char * purple_pounce_get_pouncee(const PurplePounce *pounce)
Definition: pounce.c:872
_GntButton
Definition: gntbutton.h:51
PurpleGntPounceDialog
Definition: gntpounce.c:54
PURPLE_MESSAGE_SEND
Definition: conversation.h:107
gnt_tree_remove_all
void gnt_tree_remove_all(GntTree *tree)
Definition: gnttree.c:1545
PURPLE_POUNCE_AWAY
Definition: pounce.h:42
gntline.h
PurpleGntPounceDialog::window
GntWidget * window
Definition: gntpounce.c:61
_PurpleConnection
Definition: connection.h:245
gnt_line_new
GntWidget * gnt_line_new(gboolean vertical)
Definition: gntline.c:168
value
gpointer value
Definition: gntwm.c:1782
purple_pounce_get_options
PurplePounceOption purple_pounce_get_options(const PurplePounce *pounce)
Definition: pounce.c:856
_PurplePresence
Definition: status.c:69
PurpleGntPounceDialog::popup
GntWidget * popup
Definition: gntpounce.c:84
GNT_ALIGN_LEFT
Definition: gntbox.h:46
server.h
dbus-buddyicons-example.node
node
Definition: dbus-buddyicons-example.py:32
PURPLE_POUNCE_SIGNOFF
Definition: pounce.h:41
gnttree.h
GNT_ENTRY
#define GNT_ENTRY(obj)
Definition: gntentry.h:36
gnt_tree_create_row
GntTreeRow * gnt_tree_create_row(GntTree *tree,...)
Definition: gnttree.c:1728
util.h
purple_presence_is_available
gboolean purple_presence_is_available(const PurplePresence *presence)
Definition: status.c:1482
purple_pounce_action_get_attribute
const char * purple_pounce_action_get_attribute(const PurplePounce *pounce, const char *action, const char *attr)
Definition: pounce.c:903
_PurpleBuddy
Definition: blist.h:138
PURPLE_POUNCE_MESSAGE_RECEIVED
Definition: pounce.h:49
time
time_t time(void)
pounces_manager
static PouncesManager * pounces_manager
Definition: gntpounce.c:107
pounces_manager_delete_confirm_cb
static void pounces_manager_delete_confirm_cb(PurplePounce *pounce)
Definition: gntpounce.c:650
populate_pounces_list
static void populate_pounces_list(PouncesManager *dialog)
Definition: gntpounce.c:141
gnt_combo_box_add_data
void gnt_combo_box_add_data(GntComboBox *box, gpointer key, const char *text)
Definition: gntcombobox.c:357
purple_connections_get_all
GList * purple_connections_get_all(void)
Definition: connection.c:665
gnt_tree_get_selection_data
gpointer gnt_tree_get_selection_data(GntTree *tree)
Definition: gnttree.c:1441
gnt_entry_new
GntWidget * gnt_entry_new(const char *text)
Definition: gntentry.c:1093
GNT_KEY_INS
#define GNT_KEY_INS
Definition: gntkeys.h:67
PurpleGntPounceDialog::account_menu
GntWidget * account_menu
Definition: gntpounce.c:64
gnt_box_set_alignment
void gnt_box_set_alignment(GntBox *box, GntAlignment alignment)
Definition: gntbox.c:775
_GntEntry
Definition: gntentry.h:65
PurplePounceEvent
PurplePounceEvent
Definition: pounce.h:37
serv_send_im
int serv_send_im(PurpleConnection *gc, const char *name, const char *message, PurpleMessageFlags flags)
Definition: server.c:120
purple_pounce_set_options
void purple_pounce_set_options(PurplePounce *pounce, PurplePounceOption options)
Definition: pounce.c:731
PURPLE_POUNCE_TYPING
Definition: pounce.h:46
PurpleGntPounceDialog::popup_entry
GntWidget * popup_entry
Definition: gntpounce.c:85