Changeset f97c1a6 for global.c


Ignore:
Timestamp:
May 23, 2011, 9:09:44 PM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
33b6431b
Parents:
4c7c21f (diff), 1d21d9f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merge branch 'g_main_loop'

The logic in owl_select_prune_bad_fds still needs to be reimplemented.

Conflicts:
	configure.ac
	owl.c
	select.c
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r351c535 rf97c1a6  
    1616
    1717  g_type_init();
     18  g_thread_init(NULL);
     19
     20  owl_select_init();
    1821
    1922  g->lines=LINES;
     
    9598
    9699  owl_errqueue_init(&(g->errqueue));
    97   g->got_err_signal=0;
    98100
    99101  owl_zbuddylist_create(&(g->zbuddies));
     
    104106  owl_message_init_fmtext_cache();
    105107  owl_list_create(&(g->io_dispatch_list));
    106   owl_list_create(&(g->psa_list));
    107108  g->timerlist = NULL;
    108   g->interrupted = FALSE;
    109109  g->kill_buffer = NULL;
     110
     111  g->interrupt_count = 0;
     112  g->interrupt_lock = g_mutex_new();
    110113}
    111114
     
    344347
    345348void owl_global_set_resize_pending(owl_global *g) {
    346   g->resizepending=1;
     349  g->resizepending = true;
    347350}
    348351
     
    444447  /* resize the screen.  If lines or cols is 0 use the terminal size */
    445448  if (!g->resizepending) return;
    446   g->resizepending = 0;
     449  g->resizepending = false;
    447450
    448451  owl_global_get_terminal_size(&g->lines, &g->cols);
     
    676679}
    677680
    678 int owl_global_is_doaimevents(const owl_global *g)
    679 {
    680   if (g->aim_doprocessing) return(1);
    681   return(0);
     681bool owl_global_is_doaimevents(const owl_global *g)
     682{
     683  return g->aim_event_source != NULL;
    682684}
    683685
    684686void owl_global_set_doaimevents(owl_global *g)
    685687{
    686   g->aim_doprocessing=1;
     688  if (g->aim_event_source)
     689    return;
     690  g->aim_event_source = owl_aim_event_source_new(owl_global_get_aimsess(g));
     691  g_source_attach(g->aim_event_source, NULL);
    687692}
    688693
    689694void owl_global_set_no_doaimevents(owl_global *g)
    690695{
    691   g->aim_doprocessing=0;
     696  if (!g->aim_event_source)
     697    return;
     698  g_source_destroy(g->aim_event_source);
     699  g_source_unref(g->aim_event_source);
     700  g->aim_event_source = NULL;
    692701}
    693702
     
    807816}
    808817
    809 void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
    810 {
    811   g->got_err_signal = signum;
    812   if (siginfo) {
    813     g->err_signal_info = *siginfo;
    814   } else {
    815     siginfo_t si;
    816     memset(&si, 0, sizeof(si));
    817     g->err_signal_info = si;
    818   }
    819 }
    820 
    821 int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
    822 {
    823   int signum;
    824   if (siginfo && g->got_err_signal) {
    825     *siginfo = g->err_signal_info;
    826   }
    827   signum = g->got_err_signal;
    828   g->got_err_signal = 0;
    829   return signum;
    830 }
    831 
    832 
    833818owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
    834819{
     
    861846}
    862847
    863 owl_list *owl_global_get_psa_list(owl_global *g)
    864 {
    865   return &(g->psa_list);
    866 }
    867 
    868848GList **owl_global_get_timerlist(owl_global *g)
    869849{
    870850  return &(g->timerlist);
    871 }
    872 
    873 int owl_global_is_interrupted(const owl_global *g) {
    874   return g->interrupted;
    875 }
    876 
    877 void owl_global_set_interrupted(owl_global *g) {
    878   g->interrupted = 1;
    879 }
    880 
    881 void owl_global_unset_interrupted(owl_global *g) {
    882   g->interrupted = 0;
    883851}
    884852
     
    948916  g->kill_buffer = g_strndup(kill, len);
    949917}
     918
     919void owl_global_add_interrupt(owl_global *g) {
     920  /* TODO: This can almost certainly be done with atomic
     921   * operations. Whatever. */
     922  g_mutex_lock(g->interrupt_lock);
     923  g->interrupt_count++;
     924  g_mutex_unlock(g->interrupt_lock);
     925}
     926
     927bool owl_global_take_interrupt(owl_global *g) {
     928  bool ans = false;
     929  g_mutex_lock(g->interrupt_lock);
     930  if (g->interrupt_count > 0) {
     931    ans = true;
     932    g->interrupt_count--;
     933  }
     934  g_mutex_unlock(g->interrupt_lock);
     935  return ans;
     936}
Note: See TracChangeset for help on using the changeset viewer.