source: global.c @ fe8cad8

barnowl_perlaimdebianrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since fe8cad8 was c0f9e30, checked in by Alejandro R. Sedeño <asedeno@mit.edu>, 17 years ago
Fixing a personal pet peeve: resizing should not leave the current message off screen.
  • Property mode set to 100644
File size: 19.4 KB
Line 
1#include <stdio.h>
2#include <unistd.h>
3#include <stdlib.h>
4#include <string.h>
5#include <netdb.h>
6#include <termios.h>
7#include <sys/ioctl.h>
8#include <time.h>
9#include "owl.h"
10
11static const char fileIdent[] = "$Id$";
12
13#ifndef MAXHOSTNAMELEN
14#define MAXHOSTNAMELEN 256
15#endif
16
17void owl_global_init(owl_global *g) {
18  struct hostent *hent;
19  char hostname[MAXHOSTNAMELEN];
20  char *cd;
21
22  g->malloced=0;
23  g->freed=0;
24
25  gethostname(hostname, MAXHOSTNAMELEN);
26  hent=gethostbyname(hostname);
27  if (!hent) {
28    g->thishost=owl_strdup("localhost");
29  } else {
30    g->thishost=owl_strdup(hent->h_name);
31  }
32
33  owl_context_init(&g->ctx);
34  owl_context_set_startup(&g->ctx);
35  g->curmsg=0;
36  g->topmsg=0;
37  g->needrefresh=1;
38  g->startupargs=NULL;
39
40  owl_variable_dict_setup(&(g->vars));
41  owl_cmddict_setup(&(g->cmds));
42
43  g->lines=LINES;
44  g->cols=COLS;
45
46  g->rightshift=0;
47
48  owl_editwin_init(&(g->tw), NULL, owl_global_get_typwin_lines(g), g->cols, OWL_EDITWIN_STYLE_ONELINE, NULL);
49
50  owl_keyhandler_init(&g->kh);
51  owl_keys_setup_keymaps(&g->kh);
52
53  owl_list_create(&(g->muxevents));
54  owl_list_create(&(g->filterlist));
55  owl_list_create(&(g->puntlist));
56  owl_list_create(&(g->messagequeue));
57  owl_dict_create(&(g->styledict));
58  g->curmsg_vert_offset=0;
59  g->resizepending=0;
60  g->typwinactive=0;
61  g->direction=OWL_DIRECTION_DOWNWARDS;
62  g->zaway=0;
63  if (has_colors()) {
64    g->hascolors=1;
65  }
66  g->colorpairs=COLOR_PAIRS;
67  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
68  g->debug=OWL_DEBUG;
69  g->searchactive=0;
70  g->searchstring=NULL;
71  g->starttime=time(NULL); /* assumes we call init only a start time */
72  g->lastinputtime=g->starttime;
73  g->newmsgproc_pid=0;
74 
75  owl_global_set_config_format(g, 0);
76  owl_global_set_userclue(g, OWL_USERCLUE_NONE);
77  owl_global_set_no_have_config(g);
78  owl_history_init(&(g->msghist));
79  owl_history_init(&(g->cmdhist));
80  owl_history_set_norepeats(&(g->cmdhist));
81  g->nextmsgid=0;
82
83  _owl_global_setup_windows(g);
84
85  /* Fill in some variables which don't have constant defaults */
86  /* TODO: come back later and check passwd file first */
87  g->homedir=owl_strdup(getenv("HOME"));
88
89  g->confdir = NULL;
90  g->startupfile = NULL;
91  cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR);
92  owl_global_set_confdir(g, cd);
93  owl_free(cd);
94
95  owl_messagelist_create(&(g->msglist));
96  owl_mainwin_init(&(g->mw));
97  owl_popwin_init(&(g->pw));
98
99  g->aim_screenname=NULL;
100  g->aim_loggedin=0;
101  owl_timer_create_countdown(&(g->aim_noop_timer), 30);
102  owl_timer_create_countdown(&(g->aim_ignorelogin_timer), 0);
103  owl_timer_create_countdown(&(g->aim_buddyinfo_timer), 60);
104  owl_buddylist_init(&(g->buddylist));
105   
106  g->havezephyr=0;
107  g->haveaim=0;
108  owl_global_set_no_doaimevents(g);
109
110  owl_errqueue_init(&(g->errqueue));
111  g->got_err_signal=0;
112
113  owl_zbuddylist_create(&(g->zbuddies));
114  owl_timer_create_countdown(&(g->zephyr_buddycheck_timer), 60*3);
115
116  owl_obarray_init(&(g->obarray));
117
118  owl_message_init_fmtext_cache();
119}
120
121void _owl_global_setup_windows(owl_global *g) {
122  int cols, typwin_lines;
123
124  cols=g->cols;
125  typwin_lines=owl_global_get_typwin_lines(g);
126
127  /* set the new window sizes */
128  g->recwinlines=g->lines-(typwin_lines+2);
129  if (g->recwinlines<0) {
130    /* gotta deal with this */
131    g->recwinlines=0;
132  }
133
134  owl_function_debugmsg("_owl_global_setup_windows: about to call newwin(%i, %i, 0, 0)\n", g->recwinlines, cols);
135
136  /* create the new windows */
137  g->recwin=newwin(g->recwinlines, cols, 0, 0);
138  if (g->recwin==NULL) {
139    owl_function_debugmsg("_owl_global_setup_windows: newwin returned NULL\n", g->recwinlines, cols);
140    endwin();
141    exit(50);
142  }
143     
144  g->sepwin=newwin(1, cols, g->recwinlines, 0);
145  g->msgwin=newwin(1, cols, g->recwinlines+1, 0);
146  g->typwin=newwin(typwin_lines, cols, g->recwinlines+2, 0);
147
148  owl_editwin_set_curswin(&(g->tw), g->typwin, typwin_lines, g->cols);
149
150  idlok(g->typwin, FALSE);
151  idlok(g->recwin, FALSE);
152  idlok(g->sepwin, FALSE);
153  idlok(g->msgwin, FALSE);
154
155  nodelay(g->typwin, 1);
156  keypad(g->typwin, TRUE);
157  wmove(g->typwin, 0, 0);
158
159  meta(g->typwin, TRUE);
160}
161
162owl_context *owl_global_get_context(owl_global *g) {
163  return(&g->ctx);
164}
165                         
166int owl_global_get_lines(owl_global *g) {
167  return(g->lines);
168}
169
170int owl_global_get_cols(owl_global *g) {
171  return(g->cols);
172}
173
174int owl_global_get_recwin_lines(owl_global *g) {
175  return(g->recwinlines);
176}
177
178/* curmsg */
179
180int owl_global_get_curmsg(owl_global *g) {
181  return(g->curmsg);
182}
183
184void owl_global_set_curmsg(owl_global *g, int i) {
185  g->curmsg=i;
186  /* we will reset the vertical offset from here */
187  /* we might want to move this out to the functions later */
188  owl_global_set_curmsg_vert_offset(g, 0);
189}
190
191/* topmsg */
192
193int owl_global_get_topmsg(owl_global *g) {
194  return(g->topmsg);
195}
196
197void owl_global_set_topmsg(owl_global *g, int i) {
198  g->topmsg=i;
199}
200
201/* windows */
202
203owl_mainwin *owl_global_get_mainwin(owl_global *g) {
204  return(&(g->mw));
205}
206
207owl_popwin *owl_global_get_popwin(owl_global *g) {
208  return(&(g->pw));
209}
210
211/* msglist */
212
213owl_messagelist *owl_global_get_msglist(owl_global *g) {
214  return(&(g->msglist));
215}
216
217/* keyhandler */
218
219owl_keyhandler *owl_global_get_keyhandler(owl_global *g) {
220  return(&(g->kh));
221}
222
223/* curses windows */
224
225WINDOW *owl_global_get_curs_recwin(owl_global *g) {
226  return(g->recwin);
227}
228
229WINDOW *owl_global_get_curs_sepwin(owl_global *g) {
230  return(g->sepwin);
231}
232
233WINDOW *owl_global_get_curs_msgwin(owl_global *g) {
234  return(g->msgwin);
235}
236
237WINDOW *owl_global_get_curs_typwin(owl_global *g) {
238  return(g->typwin);
239}
240
241/* typwin */
242
243owl_editwin *owl_global_get_typwin(owl_global *g) {
244  return(&(g->tw));
245}
246
247/* buffercommand */
248
249void owl_global_set_buffercommand(owl_global *g, char *command) {
250  owl_editwin_set_command(owl_global_get_typwin(g), command);
251}
252
253char *owl_global_get_buffercommand(owl_global *g) {
254  return owl_editwin_get_command(owl_global_get_typwin(g));
255}
256
257void owl_global_set_buffercallback(owl_global *g, void (*cb)(owl_editwin*)) {
258  owl_editwin_set_callback(owl_global_get_typwin(g), cb);
259}
260
261void (*owl_global_get_buffercallback(owl_global *g))(owl_editwin*) {
262  return owl_editwin_get_callback(owl_global_get_typwin(g));
263}
264
265/* refresh */
266
267int owl_global_is_needrefresh(owl_global *g) {
268  if (g->needrefresh==1) return(1);
269  return(0);
270}
271
272void owl_global_set_needrefresh(owl_global *g) {
273  g->needrefresh=1;
274}
275
276void owl_global_set_noneedrefresh(owl_global *g) {
277  g->needrefresh=0;
278}
279
280/* variable dictionary */
281
282owl_vardict *owl_global_get_vardict(owl_global *g) {
283  return &(g->vars);
284}
285
286/* command dictionary */
287
288owl_cmddict *owl_global_get_cmddict(owl_global *g) {
289  return &(g->cmds);
290}
291
292/* rightshift */
293
294void owl_global_set_rightshift(owl_global *g, int i) {
295  g->rightshift=i;
296}
297
298int owl_global_get_rightshift(owl_global *g) {
299  return(g->rightshift);
300}
301
302/* typwin */
303
304int owl_global_is_typwin_active(owl_global *g) {
305  if (g->typwinactive==1) return(1);
306  return(0);
307}
308
309void owl_global_set_typwin_active(owl_global *g) {
310  g->typwinactive=1;
311}
312
313void owl_global_set_typwin_inactive(owl_global *g) {
314  g->typwinactive=0;
315}
316
317/* resize */
318
319void owl_global_set_resize_pending(owl_global *g) {
320  g->resizepending=1;
321}
322
323char *owl_global_get_homedir(owl_global *g) {
324  if (g->homedir) return(g->homedir);
325  return("/");
326}
327
328char *owl_global_get_confdir(owl_global *g) {
329  if (g->confdir) return(g->confdir);
330  return("/");
331}
332
333/*
334 * Setting this also sets startupfile to confdir/startup
335 */
336void owl_global_set_confdir(owl_global *g, char *cd) {
337  free(g->confdir);
338  g->confdir = owl_strdup(cd);
339  free(g->startupfile);
340  g->startupfile = owl_sprintf("%s/startup", cd);
341}
342
343char *owl_global_get_startupfile(owl_global *g) {
344  if(g->startupfile) return(g->startupfile);
345  return("/");
346}
347
348int owl_global_get_direction(owl_global *g) {
349  return(g->direction);
350}
351
352void owl_global_set_direction_downwards(owl_global *g) {
353  g->direction=OWL_DIRECTION_DOWNWARDS;
354}
355
356void owl_global_set_direction_upwards(owl_global *g) {
357  g->direction=OWL_DIRECTION_UPWARDS;
358}
359
360/* perl stuff */
361
362void owl_global_set_perlinterp(owl_global *g, void *p) {
363  g->perl=p;
364}
365
366void *owl_global_get_perlinterp(owl_global *g) {
367  return(g->perl);
368}
369
370int owl_global_is_config_format(owl_global *g) {
371  if (g->config_format) return(1);
372  return(0);
373}
374
375void owl_global_set_config_format(owl_global *g, int state) {
376  if (state==1) {
377    g->config_format=1;
378  } else {
379    g->config_format=0;
380  }
381}
382
383void owl_global_set_have_config(owl_global *g) {
384  g->haveconfig=1;
385}
386
387void owl_global_set_no_have_config(owl_global *g) {
388  g->haveconfig=0;
389}
390
391int owl_global_have_config(owl_global *g) {
392  if (g->haveconfig) return(1);
393  return(0);
394}
395
396void owl_global_resize(owl_global *g, int x, int y) {
397  /* resize the screen.  If x or y is 0 use the terminal size */
398  struct winsize size;
399   
400  if (!g->resizepending) return;
401
402  /* delete the current windows */
403  delwin(g->recwin);
404  delwin(g->sepwin);
405  delwin(g->msgwin);
406  delwin(g->typwin);
407  if (!isendwin()) {
408    endwin();
409  }
410
411  refresh();
412
413  /* get the new size */
414  ioctl(STDIN_FILENO, TIOCGWINSZ, &size);
415  if (x==0) {
416    g->lines=size.ws_row;
417  } else {
418    g->lines=x;
419  }
420
421  if (y==0) {
422    g->cols=size.ws_col;
423  } else {
424    g->cols=y;
425  }
426
427#ifdef HAVE_RESIZETERM
428  resizeterm(size.ws_row, size.ws_col);
429#endif
430
431  /* re-initialize the windows */
432  _owl_global_setup_windows(g);
433
434  /* in case any styles rely on the current width */
435  owl_messagelist_invalidate_formats(owl_global_get_msglist(g));
436
437  /* recalculate the topmsg to make sure the current message is on
438   * screen */
439  owl_function_calculate_topmsg(OWL_DIRECTION_NONE);
440
441  /* refresh stuff */
442  g->needrefresh=1;
443  owl_mainwin_redisplay(&(g->mw));
444  sepbar(NULL);
445
446  if (owl_global_is_typwin_active(g)) {
447    owl_editwin_redisplay(&(g->tw), 0);
448  }     
449  /* TODO: this should handle other forms of popwins */
450  if (owl_popwin_is_active(owl_global_get_popwin(g)) 
451      && owl_global_get_viewwin(g)) {
452    owl_popwin_refresh(owl_global_get_popwin(g));
453    owl_viewwin_redisplay(owl_global_get_viewwin(g), 0);
454  }
455
456  owl_function_debugmsg("New size is %i lines, %i cols.", size.ws_row, size.ws_col);
457  owl_function_makemsg("");
458  g->resizepending=0;
459}
460
461/* debug */
462
463int owl_global_is_debug_fast(owl_global *g) {
464  if (g->debug) return(1);
465  return(0);
466}
467
468/* starttime */
469
470time_t owl_global_get_starttime(owl_global *g) {
471  return(g->starttime);
472}
473
474time_t owl_global_get_runtime(owl_global *g) {
475  return(time(NULL)-g->starttime);
476}
477
478time_t owl_global_get_lastinputtime(owl_global *g) {
479  return(g->lastinputtime);
480}
481
482void owl_global_update_lastinputtime(owl_global *g) {
483  g->lastinputtime = time(NULL);
484}
485
486time_t owl_global_get_idletime(owl_global *g) {
487  return(time(NULL)-g->lastinputtime);
488}
489
490void owl_global_get_runtime_string(owl_global *g, char *buff) {
491  time_t diff;
492
493  diff=time(NULL)-owl_global_get_starttime(g);
494
495  /* print something nicer later */   
496  sprintf(buff, "%i seconds", (int) diff);
497}
498
499char *owl_global_get_hostname(owl_global *g) {
500  if (g->thishost) return(g->thishost);
501  return("");
502}
503
504/* userclue */
505
506void owl_global_set_userclue(owl_global *g, int clue) {
507  g->userclue=clue;
508}
509
510void owl_global_add_userclue(owl_global *g, int clue) {
511  g->userclue|=clue;
512}
513
514int owl_global_get_userclue(owl_global *g) {
515  return(g->userclue);
516}
517
518int owl_global_is_userclue(owl_global *g, int clue) {
519  if (g->userclue & clue) return(1);
520  return(0);
521}
522
523/* viewwin */
524
525owl_viewwin *owl_global_get_viewwin(owl_global *g) {
526  return(&(g->vw));
527}
528
529
530/* vert offset */
531
532int owl_global_get_curmsg_vert_offset(owl_global *g) {
533  return(g->curmsg_vert_offset);
534}
535
536void owl_global_set_curmsg_vert_offset(owl_global *g, int i) {
537  g->curmsg_vert_offset=i;
538}
539
540/* startup args */
541
542void owl_global_set_startupargs(owl_global *g, int argc, char **argv) {
543  int i, len;
544
545  if (g->startupargs) owl_free(g->startupargs);
546 
547  len=0;
548  for (i=0; i<argc; i++) {
549    len+=strlen(argv[i])+5;
550  }
551  g->startupargs=malloc(len+5);
552
553  strcpy(g->startupargs, "");
554  for (i=0; i<argc; i++) {
555    sprintf(g->startupargs, "%s%s ", g->startupargs, argv[i]);
556  }
557  g->startupargs[strlen(g->startupargs)-1]='\0';
558}
559
560char *owl_global_get_startupargs(owl_global *g) {
561  if (g->startupargs) return(g->startupargs);
562  return("");
563}
564
565/* history */
566
567owl_history *owl_global_get_msg_history(owl_global *g) {
568  return(&(g->msghist));
569}
570
571owl_history *owl_global_get_cmd_history(owl_global *g) {
572  return(&(g->cmdhist));
573}
574
575/* muxevents */
576
577owl_muxevents *owl_global_get_muxevents(owl_global *g) {
578  return(&(g->muxevents));
579}
580
581/* filterlist */
582
583owl_list *owl_global_get_filterlist(owl_global *g) {
584  return(&(g->filterlist));
585}
586
587owl_filter *owl_global_get_filter(owl_global *g, char *name) {
588  int i, j;
589  owl_filter *f;
590
591  j=owl_list_get_size(&(g->filterlist));
592  for (i=0; i<j; i++) {
593    f=owl_list_get_element(&(g->filterlist), i);
594    if (!strcmp(name, owl_filter_get_name(f))) {
595      return(f);
596    }
597  }
598  return(NULL);
599}
600
601void owl_global_add_filter(owl_global *g, owl_filter *f) {
602  owl_list_append_element(&(g->filterlist), f);
603}
604
605void owl_global_remove_filter(owl_global *g, char *name) {
606  int i, j;
607  owl_filter *f;
608
609  j=owl_list_get_size(&(g->filterlist));
610  for (i=0; i<j; i++) {
611    f=owl_list_get_element(&(g->filterlist), i);
612    if (!strcmp(name, owl_filter_get_name(f))) {
613      owl_filter_free(f);
614      owl_list_remove_element(&(g->filterlist), i);
615      break;
616    }
617  }
618}
619
620/* nextmsgid */
621
622int owl_global_get_nextmsgid(owl_global *g) {
623  return(g->nextmsgid++);
624}
625
626/* current view */
627
628owl_view *owl_global_get_current_view(owl_global *g) {
629  return(&(g->current_view));
630}
631
632/* has colors */
633
634int owl_global_get_hascolors(owl_global *g) {
635  if (g->hascolors) return(1);
636  return(0);
637}
638
639/* color pairs */
640
641int owl_global_get_colorpairs(owl_global *g) {
642  return(g->colorpairs);
643}
644
645owl_colorpair_mgr *owl_global_get_colorpair_mgr(owl_global *g) {
646  return(&(g->cpmgr));
647}
648
649/* puntlist */
650
651owl_list *owl_global_get_puntlist(owl_global *g) {
652  return(&(g->puntlist));
653}
654
655int owl_global_message_is_puntable(owl_global *g, owl_message *m) {
656  owl_list *pl;
657  int i, j;
658
659  pl=owl_global_get_puntlist(g);
660  j=owl_list_get_size(pl);
661  for (i=0; i<j; i++) {
662    if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1);
663  }
664  return(0);
665}
666
667int owl_global_should_followlast(owl_global *g) {
668  owl_view *v;
669 
670  if (!owl_global_is__followlast(g)) return(0);
671 
672  v=owl_global_get_current_view(g);
673 
674  if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1);
675  return(0);
676}
677
678int owl_global_is_search_active(owl_global *g) {
679  if (g->searchactive) return(1);
680  return(0);
681}
682
683void owl_global_set_search_active(owl_global *g, char *string) {
684  g->searchactive=1;
685  if (g->searchstring != NULL) owl_free(g->searchstring);
686  g->searchstring=owl_strdup(string);
687}
688
689void owl_global_set_search_inactive(owl_global *g) {
690  g->searchactive=0;
691}
692
693char *owl_global_get_search_string(owl_global *g) {
694  if (g->searchstring==NULL) return("");
695  return(g->searchstring);
696}
697
698void owl_global_set_newmsgproc_pid(owl_global *g, int i) {
699  g->newmsgproc_pid=i;
700}
701
702int owl_global_get_newmsgproc_pid(owl_global *g) {
703  return(g->newmsgproc_pid);
704}
705
706void owl_global_add_to_malloced(owl_global *g, int i) {
707  g->malloced+=i;
708}
709
710void owl_global_add_to_freed(owl_global *g, int i) {
711  g->freed+=1;
712}
713
714int owl_global_get_malloced(owl_global *g) {
715  return(g->malloced);
716}
717
718int owl_global_get_freed(owl_global *g) {
719  return(g->freed);
720}
721
722int owl_global_get_meminuse(owl_global *g) {
723  return(g->malloced-g->freed);
724}
725
726/* AIM stuff */
727
728int owl_global_is_aimloggedin(owl_global *g)
729{
730  if (g->aim_loggedin) return(1);
731  return(0);
732}
733
734char *owl_global_get_aim_screenname(owl_global *g)
735{
736  if (owl_global_is_aimloggedin(g)) {
737    return (g->aim_screenname);
738  }
739  return("");
740}
741
742void owl_global_set_aimloggedin(owl_global *g, char *screenname)
743{
744  g->aim_loggedin=1;
745  if (g->aim_screenname) owl_free(g->aim_screenname);
746  g->aim_screenname=owl_strdup(screenname);
747}
748
749void owl_global_set_aimnologgedin(owl_global *g)
750{
751  g->aim_loggedin=0;
752}
753
754int owl_global_is_doaimevents(owl_global *g)
755{
756  if (g->aim_doprocessing) return(1);
757  return(0);
758}
759
760void owl_global_set_doaimevents(owl_global *g)
761{
762  g->aim_doprocessing=1;
763}
764
765void owl_global_set_no_doaimevents(owl_global *g)
766{
767  g->aim_doprocessing=0;
768}
769
770aim_session_t *owl_global_get_aimsess(owl_global *g)
771{
772  return(&(g->aimsess));
773}
774
775aim_conn_t *owl_global_get_bosconn(owl_global *g)
776{
777  return(&(g->bosconn));
778}
779
780void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn)
781{
782  g->bosconn=*conn;
783}
784
785int owl_global_is_aimnop_time(owl_global *g)
786{
787  if (owl_timer_is_expired(&(g->aim_noop_timer))) return(1);
788  return(0);
789}
790
791void owl_global_aimnop_sent(owl_global *g)
792{
793  owl_timer_reset(&(g->aim_noop_timer));
794}
795
796owl_timer *owl_global_get_aim_login_timer(owl_global *g)
797{
798  return(&(g->aim_ignorelogin_timer));
799}
800
801/* message queue */
802
803void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m)
804{
805  owl_list_append_element(&(g->messagequeue), m);
806}
807
808/* pop off the first message and return it.  Return NULL if the queue
809 * is empty.  The caller should free the message after using it, if
810 * necessary.
811 */
812owl_message *owl_global_messagequeue_popmsg(owl_global *g)
813{
814  owl_message *out;
815
816  if (owl_list_get_size(&(g->messagequeue))==0) return(NULL);
817  out=owl_list_get_element(&(g->messagequeue), 0);
818  owl_list_remove_element(&(g->messagequeue), 0);
819  return(out);
820}
821
822int owl_global_messagequeue_pending(owl_global *g)
823{
824  if (owl_list_get_size(&(g->messagequeue))==0) return(0);
825  return(1);
826}
827
828owl_buddylist *owl_global_get_buddylist(owl_global *g)
829{
830  return(&(g->buddylist));
831}
832 
833/* style */
834
835/* Return the style with name 'name'.  If it does not exist return
836 * NULL */
837owl_style *owl_global_get_style_by_name(owl_global *g, char *name)
838{
839  return owl_dict_find_element(&(g->styledict), name);
840}
841
842/* creates a list and fills it in with keys.  duplicates the keys,
843 * so they will need to be freed by the caller. */
844int owl_global_get_style_names(owl_global *g, owl_list *l) {
845  return owl_dict_get_keys(&(g->styledict), l);
846}
847
848void owl_global_add_style(owl_global *g, owl_style *s)
849{
850  /*
851   * If we're redefining the current style, make sure to update
852   * pointers to it.
853   */
854  if(g->current_view.style
855     && !strcmp(owl_style_get_name(g->current_view.style),
856                owl_style_get_name(s)))
857    g->current_view.style = s;
858  owl_dict_insert_element(&(g->styledict), owl_style_get_name(s),
859                          s, (void(*)(void*))owl_style_free);
860}
861
862void owl_global_set_haveaim(owl_global *g)
863{
864  g->haveaim=1;
865}
866
867int owl_global_is_haveaim(owl_global *g)
868{
869  if (g->haveaim) return(1);
870  return(0);
871}
872
873void owl_global_set_havezephyr(owl_global *g)
874{
875  g->havezephyr=1;
876}
877
878int owl_global_is_havezephyr(owl_global *g)
879{
880  if (g->havezephyr) return(1);
881  return(0);
882}
883
884owl_timer *owl_global_get_aim_buddyinfo_timer(owl_global *g)
885{
886  return(&(g->aim_buddyinfo_timer));
887}
888
889owl_errqueue *owl_global_get_errqueue(owl_global *g)
890{
891  return(&(g->errqueue));
892}
893
894void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo)
895{
896  g->got_err_signal = signum;
897  if (siginfo) {
898    g->err_signal_info = *siginfo;
899  } else {
900    memset(&(g->err_signal_info), 0, sizeof(siginfo_t));
901  }
902}
903
904int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo)
905{
906  int signum;
907  if (siginfo && g->got_err_signal) {
908    *siginfo = g->err_signal_info;
909  } 
910  signum = g->got_err_signal;
911  g->got_err_signal = 0;
912  return signum;
913}
914
915owl_timer *owl_global_get_zephyr_buddycheck_timer(owl_global *g)
916{
917  return(&(g->zephyr_buddycheck_timer));
918}
919
920owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g)
921{
922  return(&(g->zbuddies));
923}
924
925struct termios *owl_global_get_startup_tio(owl_global *g)
926{
927  return(&(g->startup_tio));
928}
929
930char * owl_global_intern(owl_global *g, char * string)
931{
932  return owl_obarray_insert(&(g->obarray), string);
933}
Note: See TracBrowser for help on using the repository browser.