[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" |
---|
[e20dd769] | 10 | #include "globalnotifier.h" |
---|
[7d4fbcd] | 11 | |
---|
| 12 | #ifndef MAXHOSTNAMELEN |
---|
| 13 | #define MAXHOSTNAMELEN 256 |
---|
| 14 | #endif |
---|
| 15 | |
---|
| 16 | void owl_global_init(owl_global *g) { |
---|
| 17 | struct hostent *hent; |
---|
| 18 | char hostname[MAXHOSTNAMELEN]; |
---|
[ad15610] | 19 | char *cd; |
---|
[e20dd769] | 20 | g->gn = owl_global_notifier_new(g); |
---|
[7d4fbcd] | 21 | |
---|
[8262340] | 22 | g->malloced=0; |
---|
| 23 | g->freed=0; |
---|
| 24 | |
---|
[7d4fbcd] | 25 | gethostname(hostname, MAXHOSTNAMELEN); |
---|
| 26 | hent=gethostbyname(hostname); |
---|
| 27 | if (!hent) { |
---|
[a8938c7] | 28 | g->thishost=owl_strdup("localhost"); |
---|
[7d4fbcd] | 29 | } else { |
---|
[a8938c7] | 30 | g->thishost=owl_strdup(hent->h_name); |
---|
[7d4fbcd] | 31 | } |
---|
| 32 | |
---|
[a999d9e] | 33 | g->context_stack = NULL; |
---|
| 34 | owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL); |
---|
| 35 | |
---|
[7d4fbcd] | 36 | g->curmsg=0; |
---|
| 37 | g->topmsg=0; |
---|
[bd783db] | 38 | g->markedmsgid=-1; |
---|
[7d4fbcd] | 39 | g->needrefresh=1; |
---|
[a8938c7] | 40 | g->startupargs=NULL; |
---|
[7d4fbcd] | 41 | |
---|
| 42 | owl_variable_dict_setup(&(g->vars)); |
---|
| 43 | |
---|
| 44 | g->lines=LINES; |
---|
| 45 | g->cols=COLS; |
---|
| 46 | |
---|
| 47 | g->rightshift=0; |
---|
| 48 | |
---|
[38cc669] | 49 | g->tw = NULL; |
---|
[7d4fbcd] | 50 | |
---|
| 51 | owl_keyhandler_init(&g->kh); |
---|
| 52 | owl_keys_setup_keymaps(&g->kh); |
---|
| 53 | |
---|
[129e609] | 54 | owl_dict_create(&(g->filters)); |
---|
| 55 | g->filterlist = NULL; |
---|
[7d4fbcd] | 56 | owl_list_create(&(g->puntlist)); |
---|
[20aced3] | 57 | g->messagequeue = g_queue_new(); |
---|
[f1e629d] | 58 | owl_dict_create(&(g->styledict)); |
---|
[7d4fbcd] | 59 | g->curmsg_vert_offset=0; |
---|
| 60 | g->resizepending=0; |
---|
[f7cf6c2] | 61 | g->relayoutpending = 0; |
---|
[7d4fbcd] | 62 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
| 63 | g->zaway=0; |
---|
| 64 | if (has_colors()) { |
---|
| 65 | g->hascolors=1; |
---|
| 66 | } |
---|
| 67 | g->colorpairs=COLOR_PAIRS; |
---|
[8fa9562] | 68 | owl_fmtext_init_colorpair_mgr(&(g->cpmgr)); |
---|
[7d4fbcd] | 69 | g->debug=OWL_DEBUG; |
---|
[41c9a96] | 70 | owl_regex_init(&g->search_re); |
---|
[7d4fbcd] | 71 | g->starttime=time(NULL); /* assumes we call init only a start time */ |
---|
[7f792c1] | 72 | g->lastinputtime=g->starttime; |
---|
[700c712] | 73 | g->newmsgproc_pid=0; |
---|
[61e79a9] | 74 | |
---|
[7d4fbcd] | 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); |
---|
[10b866d] | 78 | owl_history_init(&(g->msghist)); |
---|
| 79 | owl_history_init(&(g->cmdhist)); |
---|
[5a9f6fe] | 80 | owl_history_set_norepeats(&(g->cmdhist)); |
---|
[7d4fbcd] | 81 | g->nextmsgid=0; |
---|
| 82 | |
---|
[d2a4534] | 83 | owl_mainpanel_init(&(g->mainpanel)); |
---|
[7d4fbcd] | 84 | _owl_global_setup_windows(g); |
---|
| 85 | |
---|
| 86 | /* Fill in some variables which don't have constant defaults */ |
---|
| 87 | /* TODO: come back later and check passwd file first */ |
---|
[a8938c7] | 88 | g->homedir=owl_strdup(getenv("HOME")); |
---|
[7d4fbcd] | 89 | |
---|
[b363d83] | 90 | g->confdir = NULL; |
---|
| 91 | g->startupfile = NULL; |
---|
[ad15610] | 92 | cd = owl_sprintf("%s/%s", g->homedir, OWL_CONFIG_DIR); |
---|
[b363d83] | 93 | owl_global_set_confdir(g, cd); |
---|
| 94 | owl_free(cd); |
---|
| 95 | |
---|
[7d4fbcd] | 96 | owl_messagelist_create(&(g->msglist)); |
---|
| 97 | owl_mainwin_init(&(g->mw)); |
---|
| 98 | owl_popwin_init(&(g->pw)); |
---|
[d70f45f] | 99 | owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin); |
---|
[385fda9] | 100 | g_signal_connect(g->mainpanel.sepwin, "redraw", G_CALLBACK(sepbar_redraw), NULL); |
---|
[d09e5a1] | 101 | |
---|
| 102 | g->aim_screenname=NULL; |
---|
[81655f8] | 103 | g->aim_screenname_for_filters=NULL; |
---|
[d09e5a1] | 104 | g->aim_loggedin=0; |
---|
[aa5f725] | 105 | owl_buddylist_init(&(g->buddylist)); |
---|
[b7bb454] | 106 | |
---|
[09489b89] | 107 | g->havezephyr=0; |
---|
| 108 | g->haveaim=0; |
---|
[b7bb454] | 109 | g->ignoreaimlogin=0; |
---|
[a352335c] | 110 | owl_global_set_no_doaimevents(g); |
---|
[ec6ff52] | 111 | |
---|
| 112 | owl_errqueue_init(&(g->errqueue)); |
---|
[c9e72d1] | 113 | g->got_err_signal=0; |
---|
[5a95b69] | 114 | |
---|
| 115 | owl_zbuddylist_create(&(g->zbuddies)); |
---|
[8e401cae] | 116 | |
---|
[f25812b] | 117 | g->zaldlist = NULL; |
---|
| 118 | g->pseudologin_notify = 0; |
---|
| 119 | |
---|
[a387d12e] | 120 | owl_message_init_fmtext_cache(); |
---|
[df0138f] | 121 | owl_list_create(&(g->io_dispatch_list)); |
---|
[4f2166b] | 122 | owl_list_create(&(g->psa_list)); |
---|
[58d1f8a] | 123 | g->timerlist = NULL; |
---|
[adee9cc] | 124 | g->interrupted = FALSE; |
---|
[0881cdd] | 125 | |
---|
| 126 | /* set up a pad for input */ |
---|
| 127 | g->input_pad = newpad(1, 1); |
---|
| 128 | nodelay(g->input_pad, 1); |
---|
| 129 | keypad(g->input_pad, 1); |
---|
| 130 | meta(g->input_pad, 1); |
---|
[7d4fbcd] | 131 | } |
---|
| 132 | |
---|
[eb6cedc] | 133 | /* Called once perl has been initialized */ |
---|
| 134 | void owl_global_complete_setup(owl_global *g) |
---|
| 135 | { |
---|
| 136 | owl_cmddict_setup(&(g->cmds)); |
---|
| 137 | } |
---|
| 138 | |
---|
[8ae2de9] | 139 | /* If *pan does not exist, we create a new panel, otherwise we replace the |
---|
| 140 | window in *pan with win. |
---|
| 141 | |
---|
| 142 | libpanel PANEL objects cannot exist without owner a valid window. This |
---|
| 143 | maintains the invariant for _owl_global_setup_windows. */ |
---|
| 144 | void _owl_panel_set_window(PANEL **pan, WINDOW *win) |
---|
| 145 | { |
---|
| 146 | WINDOW *oldwin; |
---|
[b3adfb5] | 147 | |
---|
| 148 | if (win == NULL) { |
---|
[0e3cdf1] | 149 | owl_function_debugmsg("_owl_panel_set_window: passed NULL win (failed to allocate?)"); |
---|
[b3adfb5] | 150 | endwin(); |
---|
| 151 | exit(50); |
---|
| 152 | } |
---|
| 153 | |
---|
[8ae2de9] | 154 | if (*pan) { |
---|
| 155 | oldwin = panel_window(*pan); |
---|
| 156 | replace_panel(*pan, win); |
---|
| 157 | delwin(oldwin); |
---|
| 158 | } else { |
---|
| 159 | *pan = new_panel(win); |
---|
| 160 | } |
---|
| 161 | } |
---|
| 162 | |
---|
[7d4fbcd] | 163 | void _owl_global_setup_windows(owl_global *g) { |
---|
[f6fae8d] | 164 | int cols, recwinlines; |
---|
[7d4fbcd] | 165 | |
---|
| 166 | cols=g->cols; |
---|
| 167 | |
---|
[d2a4534] | 168 | recwinlines = owl_global_get_recwin_lines(g); |
---|
[7d4fbcd] | 169 | |
---|
| 170 | /* create the new windows */ |
---|
[d2a4534] | 171 | _owl_panel_set_window(&g->recpan, newwin(recwinlines, cols, 0, 0)); |
---|
| 172 | _owl_panel_set_window(&g->seppan, newwin(1, cols, recwinlines, 0)); |
---|
[7d4fbcd] | 173 | } |
---|
| 174 | |
---|
| 175 | owl_context *owl_global_get_context(owl_global *g) { |
---|
[a999d9e] | 176 | if (!g->context_stack) |
---|
| 177 | return NULL; |
---|
| 178 | return g->context_stack->data; |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | static void owl_global_lookup_keymap(owl_global *g) { |
---|
| 182 | owl_context *c = owl_global_get_context(g); |
---|
| 183 | if (!c || !c->keymap) |
---|
| 184 | return; |
---|
| 185 | |
---|
| 186 | if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { |
---|
| 187 | owl_function_error("Unable to activate keymap '%s'", c->keymap); |
---|
| 188 | } |
---|
[7d4fbcd] | 189 | } |
---|
[a999d9e] | 190 | |
---|
| 191 | void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) { |
---|
| 192 | owl_context *c; |
---|
| 193 | if (!(mode & OWL_CTX_MODE_BITS)) |
---|
| 194 | mode |= OWL_CTX_INTERACTIVE; |
---|
| 195 | c = owl_malloc(sizeof *c); |
---|
| 196 | c->mode = mode; |
---|
| 197 | c->data = data; |
---|
| 198 | c->keymap = owl_strdup(keymap); |
---|
| 199 | g->context_stack = g_list_prepend(g->context_stack, c); |
---|
| 200 | owl_global_lookup_keymap(g); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | void owl_global_pop_context(owl_global *g) { |
---|
| 204 | owl_context *c; |
---|
| 205 | if (!g->context_stack) |
---|
| 206 | return; |
---|
| 207 | c = owl_global_get_context(g); |
---|
| 208 | g->context_stack = g_list_delete_link(g->context_stack, |
---|
| 209 | g->context_stack); |
---|
| 210 | owl_free(c->keymap); |
---|
| 211 | owl_free(c); |
---|
| 212 | owl_global_lookup_keymap(g); |
---|
| 213 | } |
---|
| 214 | |
---|
[8742840] | 215 | int owl_global_get_lines(const owl_global *g) { |
---|
[7d4fbcd] | 216 | return(g->lines); |
---|
| 217 | } |
---|
| 218 | |
---|
[8742840] | 219 | int owl_global_get_cols(const owl_global *g) { |
---|
[7d4fbcd] | 220 | return(g->cols); |
---|
| 221 | } |
---|
| 222 | |
---|
[8742840] | 223 | int owl_global_get_recwin_lines(const owl_global *g) { |
---|
[d2a4534] | 224 | return g->mainpanel.recwinlines; |
---|
[7d4fbcd] | 225 | } |
---|
| 226 | |
---|
| 227 | /* curmsg */ |
---|
| 228 | |
---|
[8742840] | 229 | int owl_global_get_curmsg(const owl_global *g) { |
---|
[7d4fbcd] | 230 | return(g->curmsg); |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | void owl_global_set_curmsg(owl_global *g, int i) { |
---|
| 234 | g->curmsg=i; |
---|
| 235 | /* we will reset the vertical offset from here */ |
---|
| 236 | /* we might want to move this out to the functions later */ |
---|
| 237 | owl_global_set_curmsg_vert_offset(g, 0); |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | /* topmsg */ |
---|
| 241 | |
---|
[8742840] | 242 | int owl_global_get_topmsg(const owl_global *g) { |
---|
[7d4fbcd] | 243 | return(g->topmsg); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | void owl_global_set_topmsg(owl_global *g, int i) { |
---|
| 247 | g->topmsg=i; |
---|
| 248 | } |
---|
| 249 | |
---|
[70110286] | 250 | /* markedmsgid */ |
---|
| 251 | |
---|
[8742840] | 252 | int owl_global_get_markedmsgid(const owl_global *g) { |
---|
[70110286] | 253 | return(g->markedmsgid); |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | void owl_global_set_markedmsgid(owl_global *g, int i) { |
---|
| 257 | g->markedmsgid=i; |
---|
| 258 | /* i; index of message in the current view. |
---|
[c08c70a] | 259 | const owl_message *m; |
---|
[70110286] | 260 | owl_view *v; |
---|
| 261 | |
---|
| 262 | v = owl_global_get_current_view(&g); |
---|
| 263 | m = owl_view_get_element(v, i); |
---|
| 264 | g->markedmsgid = m ? owl_message_get_id(m) : 0; |
---|
| 265 | */ |
---|
| 266 | } |
---|
| 267 | |
---|
[7d4fbcd] | 268 | /* windows */ |
---|
| 269 | |
---|
| 270 | owl_mainwin *owl_global_get_mainwin(owl_global *g) { |
---|
| 271 | return(&(g->mw)); |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | owl_popwin *owl_global_get_popwin(owl_global *g) { |
---|
| 275 | return(&(g->pw)); |
---|
| 276 | } |
---|
| 277 | |
---|
| 278 | /* msglist */ |
---|
| 279 | |
---|
| 280 | owl_messagelist *owl_global_get_msglist(owl_global *g) { |
---|
| 281 | return(&(g->msglist)); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | /* keyhandler */ |
---|
| 285 | |
---|
| 286 | owl_keyhandler *owl_global_get_keyhandler(owl_global *g) { |
---|
| 287 | return(&(g->kh)); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | /* curses windows */ |
---|
| 291 | |
---|
[8742840] | 292 | WINDOW *owl_global_get_curs_recwin(const owl_global *g) { |
---|
[b3adfb5] | 293 | return panel_window(g->recpan); |
---|
[7d4fbcd] | 294 | } |
---|
| 295 | |
---|
[385fda9] | 296 | owl_window *owl_global_get_curs_sepwin(const owl_global *g) { |
---|
| 297 | return g->mainpanel.sepwin; |
---|
[7d4fbcd] | 298 | } |
---|
| 299 | |
---|
[d70f45f] | 300 | owl_window *owl_global_get_curs_msgwin(const owl_global *g) { |
---|
| 301 | return g->msgwin.window; |
---|
[7d4fbcd] | 302 | } |
---|
| 303 | |
---|
[f6fae8d] | 304 | owl_window *owl_global_get_curs_typwin(const owl_global *g) { |
---|
| 305 | return g->mainpanel.typwin; |
---|
[7d4fbcd] | 306 | } |
---|
| 307 | |
---|
| 308 | /* typwin */ |
---|
| 309 | |
---|
[8742840] | 310 | owl_editwin *owl_global_get_typwin(const owl_global *g) { |
---|
[a556caa] | 311 | return(g->tw); |
---|
[7d4fbcd] | 312 | } |
---|
| 313 | |
---|
| 314 | /* refresh */ |
---|
| 315 | |
---|
[8742840] | 316 | int owl_global_is_needrefresh(const owl_global *g) { |
---|
[7d4fbcd] | 317 | if (g->needrefresh==1) return(1); |
---|
| 318 | return(0); |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | void owl_global_set_needrefresh(owl_global *g) { |
---|
| 322 | g->needrefresh=1; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | void owl_global_set_noneedrefresh(owl_global *g) { |
---|
| 326 | g->needrefresh=0; |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | /* variable dictionary */ |
---|
| 330 | |
---|
| 331 | owl_vardict *owl_global_get_vardict(owl_global *g) { |
---|
| 332 | return &(g->vars); |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | /* command dictionary */ |
---|
| 336 | |
---|
| 337 | owl_cmddict *owl_global_get_cmddict(owl_global *g) { |
---|
| 338 | return &(g->cmds); |
---|
| 339 | } |
---|
| 340 | |
---|
| 341 | /* rightshift */ |
---|
| 342 | |
---|
| 343 | void owl_global_set_rightshift(owl_global *g, int i) { |
---|
[5b80b87] | 344 | g->rightshift = i; |
---|
| 345 | g_object_notify(G_OBJECT(g->gn), "rightshift"); |
---|
[7d4fbcd] | 346 | } |
---|
| 347 | |
---|
[8742840] | 348 | int owl_global_get_rightshift(const owl_global *g) { |
---|
[7d4fbcd] | 349 | return(g->rightshift); |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | /* typwin */ |
---|
| 353 | |
---|
[58d47ca] | 354 | owl_editwin *owl_global_set_typwin_active(owl_global *g, int style, owl_history *hist) { |
---|
[38cc669] | 355 | int d; |
---|
| 356 | d = owl_global_get_typewindelta(g); |
---|
[73eda8c] | 357 | if (d > 0 && style == OWL_EDITWIN_STYLE_MULTILINE) |
---|
[da466e0] | 358 | owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); |
---|
| 359 | |
---|
[f6fae8d] | 360 | if (g->typwin_erase_id) { |
---|
| 361 | g_signal_handler_disconnect(owl_global_get_curs_typwin(g), g->typwin_erase_id); |
---|
| 362 | g->typwin_erase_id = 0; |
---|
| 363 | } |
---|
| 364 | |
---|
[38cc669] | 365 | g->tw = owl_editwin_new(owl_global_get_curs_typwin(g), |
---|
| 366 | owl_global_get_typwin_lines(g), |
---|
| 367 | g->cols, |
---|
| 368 | style, |
---|
| 369 | hist); |
---|
[58d47ca] | 370 | return g->tw; |
---|
[7d4fbcd] | 371 | } |
---|
| 372 | |
---|
| 373 | void owl_global_set_typwin_inactive(owl_global *g) { |
---|
[da466e0] | 374 | int d = owl_global_get_typewindelta(g); |
---|
[73eda8c] | 375 | if (d > 0 && owl_editwin_get_style(g->tw) == OWL_EDITWIN_STYLE_MULTILINE) |
---|
[da466e0] | 376 | owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); |
---|
| 377 | |
---|
[f6fae8d] | 378 | if (!g->typwin_erase_id) { |
---|
| 379 | g->typwin_erase_id = |
---|
| 380 | g_signal_connect(owl_global_get_curs_typwin(g), "redraw", G_CALLBACK(owl_window_erase_cb), NULL); |
---|
| 381 | } |
---|
| 382 | owl_window_dirty(owl_global_get_curs_typwin(g)); |
---|
| 383 | |
---|
[38cc669] | 384 | g->tw = NULL; |
---|
[7d4fbcd] | 385 | } |
---|
| 386 | |
---|
| 387 | /* resize */ |
---|
| 388 | |
---|
| 389 | void owl_global_set_resize_pending(owl_global *g) { |
---|
| 390 | g->resizepending=1; |
---|
| 391 | } |
---|
| 392 | |
---|
[f7cf6c2] | 393 | void owl_global_set_relayout_pending(owl_global *g) { |
---|
| 394 | g->relayoutpending = 1; |
---|
| 395 | } |
---|
| 396 | |
---|
[8742840] | 397 | const char *owl_global_get_homedir(const owl_global *g) { |
---|
[a8938c7] | 398 | if (g->homedir) return(g->homedir); |
---|
| 399 | return("/"); |
---|
[7d4fbcd] | 400 | } |
---|
| 401 | |
---|
[8742840] | 402 | const char *owl_global_get_confdir(const owl_global *g) { |
---|
[b363d83] | 403 | if (g->confdir) return(g->confdir); |
---|
| 404 | return("/"); |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | /* |
---|
| 408 | * Setting this also sets startupfile to confdir/startup |
---|
| 409 | */ |
---|
[e19eb97] | 410 | void owl_global_set_confdir(owl_global *g, const char *cd) { |
---|
[27f6487] | 411 | owl_free(g->confdir); |
---|
[b363d83] | 412 | g->confdir = owl_strdup(cd); |
---|
[27f6487] | 413 | owl_free(g->startupfile); |
---|
[b363d83] | 414 | g->startupfile = owl_sprintf("%s/startup", cd); |
---|
| 415 | } |
---|
| 416 | |
---|
[8742840] | 417 | const char *owl_global_get_startupfile(const owl_global *g) { |
---|
[b363d83] | 418 | if(g->startupfile) return(g->startupfile); |
---|
| 419 | return("/"); |
---|
| 420 | } |
---|
| 421 | |
---|
[8742840] | 422 | int owl_global_get_direction(const owl_global *g) { |
---|
[7d4fbcd] | 423 | return(g->direction); |
---|
| 424 | } |
---|
| 425 | |
---|
| 426 | void owl_global_set_direction_downwards(owl_global *g) { |
---|
| 427 | g->direction=OWL_DIRECTION_DOWNWARDS; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | void owl_global_set_direction_upwards(owl_global *g) { |
---|
| 431 | g->direction=OWL_DIRECTION_UPWARDS; |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | /* perl stuff */ |
---|
| 435 | |
---|
| 436 | void owl_global_set_perlinterp(owl_global *g, void *p) { |
---|
| 437 | g->perl=p; |
---|
| 438 | } |
---|
| 439 | |
---|
[8742840] | 440 | void *owl_global_get_perlinterp(const owl_global *g) { |
---|
[7d4fbcd] | 441 | return(g->perl); |
---|
| 442 | } |
---|
| 443 | |
---|
[8742840] | 444 | int owl_global_is_config_format(const owl_global *g) { |
---|
[7d4fbcd] | 445 | if (g->config_format) return(1); |
---|
| 446 | return(0); |
---|
| 447 | } |
---|
| 448 | |
---|
| 449 | void owl_global_set_config_format(owl_global *g, int state) { |
---|
| 450 | if (state==1) { |
---|
| 451 | g->config_format=1; |
---|
| 452 | } else { |
---|
| 453 | g->config_format=0; |
---|
| 454 | } |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | void owl_global_set_have_config(owl_global *g) { |
---|
| 458 | g->haveconfig=1; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | void owl_global_set_no_have_config(owl_global *g) { |
---|
| 462 | g->haveconfig=0; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | int owl_global_have_config(owl_global *g) { |
---|
| 466 | if (g->haveconfig) return(1); |
---|
| 467 | return(0); |
---|
| 468 | } |
---|
| 469 | |
---|
[285bc9a] | 470 | /* |
---|
| 471 | * Compute the size of the terminal. Try a ioctl, fallback to other stuff on |
---|
| 472 | * fail. |
---|
| 473 | */ |
---|
[d39f68c] | 474 | void owl_global_get_terminal_size(int *lines, int *cols) { |
---|
[285bc9a] | 475 | struct winsize size; |
---|
| 476 | /* get the new size */ |
---|
| 477 | ioctl(STDIN_FILENO, TIOCGWINSZ, &size); |
---|
| 478 | if (size.ws_row) { |
---|
| 479 | *lines = size.ws_row; |
---|
| 480 | } else { |
---|
| 481 | *lines = LINES; |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | if (size.ws_col) { |
---|
| 485 | *cols = size.ws_col; |
---|
| 486 | } else { |
---|
| 487 | *cols = COLS; |
---|
| 488 | } |
---|
| 489 | } |
---|
| 490 | |
---|
[d39f68c] | 491 | void owl_global_resize(owl_global *g, int lines, int cols) { |
---|
[7d4fbcd] | 492 | /* resize the screen. If x or y is 0 use the terminal size */ |
---|
| 493 | if (!g->resizepending) return; |
---|
[8479494] | 494 | g->resizepending = 0; |
---|
[7d4fbcd] | 495 | |
---|
[7a6e6c7] | 496 | owl_global_get_terminal_size(&lines, &cols); |
---|
| 497 | if (lines) g->lines = lines; |
---|
| 498 | if (cols) g->cols = cols; |
---|
| 499 | owl_window_resize(owl_window_get_screen(), g->lines, g->cols); |
---|
[7d4fbcd] | 500 | |
---|
[f9f88f3] | 501 | owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols); |
---|
| 502 | } |
---|
| 503 | |
---|
| 504 | void owl_global_relayout(owl_global *g) { |
---|
[f7cf6c2] | 505 | if (!g->relayoutpending) return; |
---|
| 506 | g->relayoutpending = 0; |
---|
| 507 | |
---|
[f9f88f3] | 508 | owl_function_debugmsg("Relayouting..."); |
---|
| 509 | |
---|
[7d4fbcd] | 510 | /* re-initialize the windows */ |
---|
| 511 | _owl_global_setup_windows(g); |
---|
| 512 | |
---|
[f1e629d] | 513 | /* in case any styles rely on the current width */ |
---|
| 514 | owl_messagelist_invalidate_formats(owl_global_get_msglist(g)); |
---|
| 515 | |
---|
[c0f9e30] | 516 | /* recalculate the topmsg to make sure the current message is on |
---|
| 517 | * screen */ |
---|
| 518 | owl_function_calculate_topmsg(OWL_DIRECTION_NONE); |
---|
| 519 | |
---|
[7d4fbcd] | 520 | /* refresh stuff */ |
---|
| 521 | owl_mainwin_redisplay(&(g->mw)); |
---|
[385fda9] | 522 | sepbar_dirty(); |
---|
[59ab8dd] | 523 | |
---|
[8240bce] | 524 | owl_function_full_redisplay(); |
---|
[7d4fbcd] | 525 | } |
---|
| 526 | |
---|
| 527 | /* debug */ |
---|
| 528 | |
---|
[8742840] | 529 | int owl_global_is_debug_fast(const owl_global *g) { |
---|
[7d4fbcd] | 530 | if (g->debug) return(1); |
---|
| 531 | return(0); |
---|
| 532 | } |
---|
| 533 | |
---|
| 534 | /* starttime */ |
---|
| 535 | |
---|
[8742840] | 536 | time_t owl_global_get_starttime(const owl_global *g) { |
---|
[7d4fbcd] | 537 | return(g->starttime); |
---|
| 538 | } |
---|
| 539 | |
---|
[8742840] | 540 | time_t owl_global_get_runtime(const owl_global *g) { |
---|
[7d4fbcd] | 541 | return(time(NULL)-g->starttime); |
---|
| 542 | } |
---|
| 543 | |
---|
[8742840] | 544 | time_t owl_global_get_lastinputtime(const owl_global *g) { |
---|
[7f792c1] | 545 | return(g->lastinputtime); |
---|
| 546 | } |
---|
| 547 | |
---|
[eebef19] | 548 | void owl_global_set_lastinputtime(owl_global *g, time_t time) { |
---|
| 549 | g->lastinputtime = time; |
---|
[7f792c1] | 550 | } |
---|
| 551 | |
---|
[8742840] | 552 | time_t owl_global_get_idletime(const owl_global *g) { |
---|
[7f792c1] | 553 | return(time(NULL)-g->lastinputtime); |
---|
| 554 | } |
---|
| 555 | |
---|
[8742840] | 556 | const char *owl_global_get_hostname(const owl_global *g) { |
---|
[a8938c7] | 557 | if (g->thishost) return(g->thishost); |
---|
| 558 | return(""); |
---|
[61e79a9] | 559 | } |
---|
| 560 | |
---|
[7d4fbcd] | 561 | /* userclue */ |
---|
| 562 | |
---|
| 563 | void owl_global_set_userclue(owl_global *g, int clue) { |
---|
| 564 | g->userclue=clue; |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | void owl_global_add_userclue(owl_global *g, int clue) { |
---|
| 568 | g->userclue|=clue; |
---|
| 569 | } |
---|
| 570 | |
---|
[8742840] | 571 | int owl_global_get_userclue(const owl_global *g) { |
---|
[7d4fbcd] | 572 | return(g->userclue); |
---|
| 573 | } |
---|
| 574 | |
---|
[8742840] | 575 | int owl_global_is_userclue(const owl_global *g, int clue) { |
---|
[7d4fbcd] | 576 | if (g->userclue & clue) return(1); |
---|
| 577 | return(0); |
---|
| 578 | } |
---|
| 579 | |
---|
| 580 | /* viewwin */ |
---|
| 581 | |
---|
| 582 | owl_viewwin *owl_global_get_viewwin(owl_global *g) { |
---|
| 583 | return(&(g->vw)); |
---|
| 584 | } |
---|
| 585 | |
---|
| 586 | |
---|
| 587 | /* vert offset */ |
---|
| 588 | |
---|
[8742840] | 589 | int owl_global_get_curmsg_vert_offset(const owl_global *g) { |
---|
[7d4fbcd] | 590 | return(g->curmsg_vert_offset); |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | void owl_global_set_curmsg_vert_offset(owl_global *g, int i) { |
---|
[5b80b87] | 594 | g->curmsg_vert_offset = i; |
---|
| 595 | g_object_notify(G_OBJECT(g->gn), "curmsg-vert-offset"); |
---|
[7d4fbcd] | 596 | } |
---|
| 597 | |
---|
| 598 | /* startup args */ |
---|
| 599 | |
---|
[e19eb97] | 600 | void owl_global_set_startupargs(owl_global *g, int argc, const char *const *argv) { |
---|
[a8938c7] | 601 | int i, len; |
---|
| 602 | |
---|
| 603 | if (g->startupargs) owl_free(g->startupargs); |
---|
| 604 | |
---|
| 605 | len=0; |
---|
| 606 | for (i=0; i<argc; i++) { |
---|
[591e6aa7] | 607 | len+=strlen(argv[i])+5; |
---|
[a8938c7] | 608 | } |
---|
[34509d5] | 609 | g->startupargs=owl_malloc(len+5); |
---|
[7d4fbcd] | 610 | |
---|
| 611 | strcpy(g->startupargs, ""); |
---|
| 612 | for (i=0; i<argc; i++) { |
---|
[b9cb41b] | 613 | sprintf(g->startupargs + strlen(g->startupargs), "%s ", argv[i]); |
---|
[7d4fbcd] | 614 | } |
---|
| 615 | g->startupargs[strlen(g->startupargs)-1]='\0'; |
---|
| 616 | } |
---|
| 617 | |
---|
[8742840] | 618 | const char *owl_global_get_startupargs(const owl_global *g) { |
---|
[a8938c7] | 619 | if (g->startupargs) return(g->startupargs); |
---|
| 620 | return(""); |
---|
[7d4fbcd] | 621 | } |
---|
| 622 | |
---|
| 623 | /* history */ |
---|
| 624 | |
---|
[10b866d] | 625 | owl_history *owl_global_get_msg_history(owl_global *g) { |
---|
| 626 | return(&(g->msghist)); |
---|
| 627 | } |
---|
| 628 | |
---|
| 629 | owl_history *owl_global_get_cmd_history(owl_global *g) { |
---|
| 630 | return(&(g->cmdhist)); |
---|
[7d4fbcd] | 631 | } |
---|
| 632 | |
---|
| 633 | /* filterlist */ |
---|
[129e609] | 634 | typedef struct _owl_global_filter_ent { /* noproto */ |
---|
| 635 | owl_global *g; |
---|
| 636 | owl_filter *f; |
---|
| 637 | } owl_global_filter_ent; |
---|
[7d4fbcd] | 638 | |
---|
[8742840] | 639 | owl_filter *owl_global_get_filter(const owl_global *g, const char *name) { |
---|
[129e609] | 640 | owl_global_filter_ent *e = owl_dict_find_element(&(g->filters), name); |
---|
| 641 | if (e) return e->f; |
---|
| 642 | return NULL; |
---|
| 643 | } |
---|
[7d4fbcd] | 644 | |
---|
[5294cbf] | 645 | static void owl_global_delete_filter_ent(void *data) |
---|
| 646 | { |
---|
[129e609] | 647 | owl_global_filter_ent *e = data; |
---|
| 648 | e->g->filterlist = g_list_remove(e->g->filterlist, e->f); |
---|
| 649 | owl_filter_delete(e->f); |
---|
| 650 | owl_free(e); |
---|
[7d4fbcd] | 651 | } |
---|
| 652 | |
---|
| 653 | void owl_global_add_filter(owl_global *g, owl_filter *f) { |
---|
[129e609] | 654 | owl_global_filter_ent *e = owl_malloc(sizeof *e); |
---|
| 655 | e->g = g; |
---|
| 656 | e->f = f; |
---|
| 657 | |
---|
| 658 | owl_dict_insert_element(&(g->filters), owl_filter_get_name(f), |
---|
[5294cbf] | 659 | e, owl_global_delete_filter_ent); |
---|
[129e609] | 660 | g->filterlist = g_list_append(g->filterlist, f); |
---|
[7d4fbcd] | 661 | } |
---|
| 662 | |
---|
[e19eb97] | 663 | void owl_global_remove_filter(owl_global *g, const char *name) { |
---|
[129e609] | 664 | owl_global_filter_ent *e = owl_dict_remove_element(&(g->filters), name); |
---|
| 665 | if (e) |
---|
[5294cbf] | 666 | owl_global_delete_filter_ent(e); |
---|
[7d4fbcd] | 667 | } |
---|
| 668 | |
---|
| 669 | /* nextmsgid */ |
---|
| 670 | |
---|
| 671 | int owl_global_get_nextmsgid(owl_global *g) { |
---|
| 672 | return(g->nextmsgid++); |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | /* current view */ |
---|
| 676 | |
---|
| 677 | owl_view *owl_global_get_current_view(owl_global *g) { |
---|
| 678 | return(&(g->current_view)); |
---|
| 679 | } |
---|
| 680 | |
---|
| 681 | /* has colors */ |
---|
| 682 | |
---|
[8742840] | 683 | int owl_global_get_hascolors(const owl_global *g) { |
---|
[7d4fbcd] | 684 | if (g->hascolors) return(1); |
---|
| 685 | return(0); |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | /* color pairs */ |
---|
| 689 | |
---|
[8742840] | 690 | int owl_global_get_colorpairs(const owl_global *g) { |
---|
[7d4fbcd] | 691 | return(g->colorpairs); |
---|
| 692 | } |
---|
| 693 | |
---|
[8fa9562] | 694 | owl_colorpair_mgr *owl_global_get_colorpair_mgr(owl_global *g) { |
---|
| 695 | return(&(g->cpmgr)); |
---|
| 696 | } |
---|
| 697 | |
---|
[7d4fbcd] | 698 | /* puntlist */ |
---|
| 699 | |
---|
| 700 | owl_list *owl_global_get_puntlist(owl_global *g) { |
---|
| 701 | return(&(g->puntlist)); |
---|
| 702 | } |
---|
| 703 | |
---|
[c08c70a] | 704 | int owl_global_message_is_puntable(owl_global *g, const owl_message *m) { |
---|
[77bced3] | 705 | const owl_list *pl; |
---|
[7d4fbcd] | 706 | int i, j; |
---|
| 707 | |
---|
| 708 | pl=owl_global_get_puntlist(g); |
---|
| 709 | j=owl_list_get_size(pl); |
---|
| 710 | for (i=0; i<j; i++) { |
---|
| 711 | if (owl_filter_message_match(owl_list_get_element(pl, i), m)) return(1); |
---|
| 712 | } |
---|
| 713 | return(0); |
---|
| 714 | } |
---|
| 715 | |
---|
| 716 | int owl_global_should_followlast(owl_global *g) { |
---|
[9e5c9f3] | 717 | const owl_view *v; |
---|
[7d4fbcd] | 718 | |
---|
| 719 | if (!owl_global_is__followlast(g)) return(0); |
---|
| 720 | |
---|
| 721 | v=owl_global_get_current_view(g); |
---|
| 722 | |
---|
| 723 | if (owl_global_get_curmsg(g)==owl_view_get_size(v)-1) return(1); |
---|
| 724 | return(0); |
---|
| 725 | } |
---|
[1fd0b25] | 726 | |
---|
[8742840] | 727 | int owl_global_is_search_active(const owl_global *g) { |
---|
[41c9a96] | 728 | if (owl_regex_is_set(&g->search_re)) return(1); |
---|
[1fd0b25] | 729 | return(0); |
---|
| 730 | } |
---|
| 731 | |
---|
[89b2daf] | 732 | void owl_global_set_search_re(owl_global *g, const owl_regex *re) { |
---|
[41c9a96] | 733 | if (owl_regex_is_set(&g->search_re)) { |
---|
[5cbc929] | 734 | owl_regex_cleanup(&g->search_re); |
---|
[41c9a96] | 735 | owl_regex_init(&g->search_re); |
---|
| 736 | } |
---|
| 737 | if (re != NULL) |
---|
| 738 | owl_regex_copy(re, &g->search_re); |
---|
[1fd0b25] | 739 | } |
---|
| 740 | |
---|
[8742840] | 741 | const owl_regex *owl_global_get_search_re(const owl_global *g) { |
---|
[41c9a96] | 742 | return &g->search_re; |
---|
[1fd0b25] | 743 | } |
---|
[700c712] | 744 | |
---|
[0e5afa2] | 745 | void owl_global_set_newmsgproc_pid(owl_global *g, pid_t i) { |
---|
[700c712] | 746 | g->newmsgproc_pid=i; |
---|
| 747 | } |
---|
| 748 | |
---|
[0e5afa2] | 749 | pid_t owl_global_get_newmsgproc_pid(const owl_global *g) { |
---|
[700c712] | 750 | return(g->newmsgproc_pid); |
---|
| 751 | } |
---|
| 752 | |
---|
[d09e5a1] | 753 | /* AIM stuff */ |
---|
| 754 | |
---|
[8742840] | 755 | int owl_global_is_aimloggedin(const owl_global *g) |
---|
[6a415e9] | 756 | { |
---|
[d09e5a1] | 757 | if (g->aim_loggedin) return(1); |
---|
| 758 | return(0); |
---|
| 759 | } |
---|
| 760 | |
---|
[8742840] | 761 | const char *owl_global_get_aim_screenname(const owl_global *g) |
---|
[6a415e9] | 762 | { |
---|
[a352335c] | 763 | if (owl_global_is_aimloggedin(g)) { |
---|
| 764 | return (g->aim_screenname); |
---|
| 765 | } |
---|
| 766 | return(""); |
---|
[d09e5a1] | 767 | } |
---|
| 768 | |
---|
[8742840] | 769 | const char *owl_global_get_aim_screenname_for_filters(const owl_global *g) |
---|
[81655f8] | 770 | { |
---|
| 771 | if (owl_global_is_aimloggedin(g)) { |
---|
| 772 | return (g->aim_screenname_for_filters); |
---|
| 773 | } |
---|
| 774 | return(""); |
---|
| 775 | } |
---|
| 776 | |
---|
[e19eb97] | 777 | void owl_global_set_aimloggedin(owl_global *g, const char *screenname) |
---|
[6a415e9] | 778 | { |
---|
[65b2173] | 779 | char *sn_escaped; |
---|
[e19eb97] | 780 | const char *quote; |
---|
[d09e5a1] | 781 | g->aim_loggedin=1; |
---|
| 782 | if (g->aim_screenname) owl_free(g->aim_screenname); |
---|
[81655f8] | 783 | if (g->aim_screenname_for_filters) owl_free(g->aim_screenname_for_filters); |
---|
[d09e5a1] | 784 | g->aim_screenname=owl_strdup(screenname); |
---|
[81655f8] | 785 | sn_escaped = owl_text_quote(screenname, OWL_REGEX_QUOTECHARS, OWL_REGEX_QUOTEWITH); |
---|
| 786 | quote = owl_getquoting(sn_escaped); |
---|
[9f4e3f8] | 787 | g->aim_screenname_for_filters=owl_sprintf("%s%s%s", quote, sn_escaped, quote); |
---|
[81655f8] | 788 | owl_free(sn_escaped); |
---|
[d09e5a1] | 789 | } |
---|
| 790 | |
---|
[6a415e9] | 791 | void owl_global_set_aimnologgedin(owl_global *g) |
---|
| 792 | { |
---|
[d09e5a1] | 793 | g->aim_loggedin=0; |
---|
| 794 | } |
---|
| 795 | |
---|
[8742840] | 796 | int owl_global_is_doaimevents(const owl_global *g) |
---|
[a352335c] | 797 | { |
---|
| 798 | if (g->aim_doprocessing) return(1); |
---|
| 799 | return(0); |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | void owl_global_set_doaimevents(owl_global *g) |
---|
| 803 | { |
---|
| 804 | g->aim_doprocessing=1; |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | void owl_global_set_no_doaimevents(owl_global *g) |
---|
| 808 | { |
---|
| 809 | g->aim_doprocessing=0; |
---|
| 810 | } |
---|
| 811 | |
---|
[6a415e9] | 812 | aim_session_t *owl_global_get_aimsess(owl_global *g) |
---|
| 813 | { |
---|
[d09e5a1] | 814 | return(&(g->aimsess)); |
---|
| 815 | } |
---|
| 816 | |
---|
[c15bbfb] | 817 | aim_conn_t *owl_global_get_bosconn(owl_global *g) |
---|
| 818 | { |
---|
| 819 | return(&(g->bosconn)); |
---|
| 820 | } |
---|
| 821 | |
---|
| 822 | void owl_global_set_bossconn(owl_global *g, aim_conn_t *conn) |
---|
[6a415e9] | 823 | { |
---|
[c15bbfb] | 824 | g->bosconn=*conn; |
---|
[d09e5a1] | 825 | } |
---|
| 826 | |
---|
| 827 | /* message queue */ |
---|
| 828 | |
---|
[6a415e9] | 829 | void owl_global_messagequeue_addmsg(owl_global *g, owl_message *m) |
---|
| 830 | { |
---|
[20aced3] | 831 | g_queue_push_tail(g->messagequeue, m); |
---|
[d09e5a1] | 832 | } |
---|
| 833 | |
---|
| 834 | /* pop off the first message and return it. Return NULL if the queue |
---|
| 835 | * is empty. The caller should free the message after using it, if |
---|
| 836 | * necessary. |
---|
| 837 | */ |
---|
[13a3c1db] | 838 | owl_message *owl_global_messagequeue_popmsg(owl_global *g) |
---|
[6a415e9] | 839 | { |
---|
[d09e5a1] | 840 | owl_message *out; |
---|
| 841 | |
---|
[20aced3] | 842 | if (g_queue_is_empty(g->messagequeue)) |
---|
| 843 | return NULL; |
---|
| 844 | out = g_queue_pop_head(g->messagequeue); |
---|
| 845 | return out; |
---|
[d09e5a1] | 846 | } |
---|
| 847 | |
---|
[6a415e9] | 848 | int owl_global_messagequeue_pending(owl_global *g) |
---|
| 849 | { |
---|
[20aced3] | 850 | return !g_queue_is_empty(g->messagequeue); |
---|
[d09e5a1] | 851 | } |
---|
[aa5f725] | 852 | |
---|
[6a415e9] | 853 | owl_buddylist *owl_global_get_buddylist(owl_global *g) |
---|
| 854 | { |
---|
[aa5f725] | 855 | return(&(g->buddylist)); |
---|
| 856 | } |
---|
| 857 | |
---|
[bd3f232] | 858 | /* style */ |
---|
| 859 | |
---|
| 860 | /* Return the style with name 'name'. If it does not exist return |
---|
| 861 | * NULL */ |
---|
[8742840] | 862 | const owl_style *owl_global_get_style_by_name(const owl_global *g, const char *name) |
---|
[bd3f232] | 863 | { |
---|
[f1e629d] | 864 | return owl_dict_find_element(&(g->styledict), name); |
---|
| 865 | } |
---|
| 866 | |
---|
| 867 | /* creates a list and fills it in with keys. duplicates the keys, |
---|
| 868 | * so they will need to be freed by the caller. */ |
---|
[8742840] | 869 | int owl_global_get_style_names(const owl_global *g, owl_list *l) { |
---|
[f1e629d] | 870 | return owl_dict_get_keys(&(g->styledict), l); |
---|
[bd3f232] | 871 | } |
---|
| 872 | |
---|
[cf83b7a] | 873 | void owl_global_add_style(owl_global *g, owl_style *s) |
---|
| 874 | { |
---|
[f1fc47f] | 875 | /* |
---|
| 876 | * If we're redefining the current style, make sure to update |
---|
| 877 | * pointers to it. |
---|
| 878 | */ |
---|
| 879 | if(g->current_view.style |
---|
| 880 | && !strcmp(owl_style_get_name(g->current_view.style), |
---|
| 881 | owl_style_get_name(s))) |
---|
| 882 | g->current_view.style = s; |
---|
| 883 | owl_dict_insert_element(&(g->styledict), owl_style_get_name(s), |
---|
[516c27e] | 884 | s, (void (*)(void *))owl_style_delete); |
---|
[bd3f232] | 885 | } |
---|
[cf83b7a] | 886 | |
---|
[09489b89] | 887 | void owl_global_set_haveaim(owl_global *g) |
---|
| 888 | { |
---|
| 889 | g->haveaim=1; |
---|
| 890 | } |
---|
| 891 | |
---|
[8742840] | 892 | int owl_global_is_haveaim(const owl_global *g) |
---|
[09489b89] | 893 | { |
---|
| 894 | if (g->haveaim) return(1); |
---|
| 895 | return(0); |
---|
| 896 | } |
---|
| 897 | |
---|
[b7bb454] | 898 | void owl_global_set_ignore_aimlogin(owl_global *g) |
---|
| 899 | { |
---|
| 900 | g->ignoreaimlogin = 1; |
---|
| 901 | } |
---|
| 902 | |
---|
| 903 | void owl_global_unset_ignore_aimlogin(owl_global *g) |
---|
| 904 | { |
---|
| 905 | g->ignoreaimlogin = 0; |
---|
| 906 | } |
---|
| 907 | |
---|
[8742840] | 908 | int owl_global_is_ignore_aimlogin(const owl_global *g) |
---|
[b7bb454] | 909 | { |
---|
| 910 | return g->ignoreaimlogin; |
---|
| 911 | } |
---|
| 912 | |
---|
[09489b89] | 913 | void owl_global_set_havezephyr(owl_global *g) |
---|
| 914 | { |
---|
| 915 | g->havezephyr=1; |
---|
| 916 | } |
---|
| 917 | |
---|
[8742840] | 918 | int owl_global_is_havezephyr(const owl_global *g) |
---|
[09489b89] | 919 | { |
---|
| 920 | if (g->havezephyr) return(1); |
---|
| 921 | return(0); |
---|
| 922 | } |
---|
[de03334] | 923 | |
---|
[ec6ff52] | 924 | owl_errqueue *owl_global_get_errqueue(owl_global *g) |
---|
| 925 | { |
---|
| 926 | return(&(g->errqueue)); |
---|
| 927 | } |
---|
[c9e72d1] | 928 | |
---|
| 929 | void owl_global_set_errsignal(owl_global *g, int signum, siginfo_t *siginfo) |
---|
| 930 | { |
---|
| 931 | g->got_err_signal = signum; |
---|
| 932 | if (siginfo) { |
---|
| 933 | g->err_signal_info = *siginfo; |
---|
| 934 | } else { |
---|
[7892963] | 935 | siginfo_t si; |
---|
| 936 | memset(&si, 0, sizeof(si)); |
---|
| 937 | g->err_signal_info = si; |
---|
[c9e72d1] | 938 | } |
---|
| 939 | } |
---|
| 940 | |
---|
| 941 | int owl_global_get_errsignal_and_clear(owl_global *g, siginfo_t *siginfo) |
---|
| 942 | { |
---|
| 943 | int signum; |
---|
| 944 | if (siginfo && g->got_err_signal) { |
---|
| 945 | *siginfo = g->err_signal_info; |
---|
| 946 | } |
---|
| 947 | signum = g->got_err_signal; |
---|
| 948 | g->got_err_signal = 0; |
---|
| 949 | return signum; |
---|
| 950 | } |
---|
| 951 | |
---|
[5a95b69] | 952 | |
---|
| 953 | owl_zbuddylist *owl_global_get_zephyr_buddylist(owl_global *g) |
---|
| 954 | { |
---|
| 955 | return(&(g->zbuddies)); |
---|
| 956 | } |
---|
[8232149] | 957 | |
---|
[f25812b] | 958 | GList **owl_global_get_zaldlist(owl_global *g) |
---|
| 959 | { |
---|
| 960 | return &(g->zaldlist); |
---|
| 961 | } |
---|
| 962 | |
---|
| 963 | int owl_global_get_pseudologin_notify(owl_global *g) |
---|
| 964 | { |
---|
| 965 | return g->pseudologin_notify; |
---|
| 966 | } |
---|
| 967 | |
---|
| 968 | void owl_global_set_pseudologin_notify(owl_global *g, int notify) |
---|
| 969 | { |
---|
| 970 | g->pseudologin_notify = notify; |
---|
| 971 | } |
---|
| 972 | |
---|
[8232149] | 973 | struct termios *owl_global_get_startup_tio(owl_global *g) |
---|
| 974 | { |
---|
| 975 | return(&(g->startup_tio)); |
---|
| 976 | } |
---|
[8e401cae] | 977 | |
---|
[df0138f] | 978 | owl_list *owl_global_get_io_dispatch_list(owl_global *g) |
---|
| 979 | { |
---|
| 980 | return &(g->io_dispatch_list); |
---|
| 981 | } |
---|
| 982 | |
---|
[4f2166b] | 983 | owl_list *owl_global_get_psa_list(owl_global *g) |
---|
| 984 | { |
---|
| 985 | return &(g->psa_list); |
---|
| 986 | } |
---|
| 987 | |
---|
[58d1f8a] | 988 | GList **owl_global_get_timerlist(owl_global *g) |
---|
[b7bb454] | 989 | { |
---|
[58d1f8a] | 990 | return &(g->timerlist); |
---|
[b7bb454] | 991 | } |
---|
[adee9cc] | 992 | |
---|
[8742840] | 993 | int owl_global_is_interrupted(const owl_global *g) { |
---|
[0cb6c26] | 994 | return g->interrupted; |
---|
[adee9cc] | 995 | } |
---|
| 996 | |
---|
| 997 | void owl_global_set_interrupted(owl_global *g) { |
---|
| 998 | g->interrupted = 1; |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | void owl_global_unset_interrupted(owl_global *g) { |
---|
| 1002 | g->interrupted = 0; |
---|
| 1003 | } |
---|