source: global.c @ 74037d9

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