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