static logs_log_t *logs_log_find(const char *session, const char *uid, int create) { list_t l; logs_log_t *temp = NULL; if (log_curlog && !xstrcmp(log_curlog->session, session) && !xstrcmp(log_curlog->uid, uid)) { if (log_curlog->lw) logs_window_check(log_curlog, time(NULL)); /* tutaj ? */ return log_curlog->lw ? log_curlog : logs_log_new(log_curlog, session, uid); } for (l=log_logs; l; l = l->next) { logs_log_t *ll = l->data; if ( (!ll->session || !xstrcmp(ll->session, session)) && !xstrcmp(ll->uid, uid)) { log_window_t *lw = ll->lw; if (lw || !create) { if (lw) logs_window_check(ll, time(NULL)); /* tutaj ? */ return ll; } else { temp = ll; break; } } } logs_window_close(log_curlog, 1); if (!create) return NULL; return (log_curlog = logs_log_new(temp, session, uid)); }
static void logs_window_new(window_t *w) { const char *uid; if (!w->target || !w->session || w->id == WINDOW_CONTACTS_ID) /* XXX w->id in WINDOW_RESERVED_ID ??? */ return; uid = get_uid_any(w->session, w->target); /* XXX, do we really want/need to create log struct with invalid uid? XXX */ logs_log_new(NULL, session_uid_get(w->session), uid ? uid : w->target); }
static void logs_window_new(window_t *w) { const char *uid; if (!w->target || !w->session || w->id == 1000) return; uid = get_uid_any(w->session, w->target); /* XXX, do we really want/need to create log struct with invalid uid? XXX */ logs_log_new(NULL, session_uid_get(w->session), uid ? uid : w->target); }
static void logs_log_reopen(logs_log_t *ll) { char *session = g_strdup(ll->session); char *uid = g_strdup(ll->uid); char *oldfn = g_strdup(ll->fname); g_ptr_array_remove(logs_logs, ll); ll = logs_log_new(session, uid, FALSE); debug_function("logs_log_reopen() %s => %s\n", oldfn, ll?ll->fname:""); g_free(session); g_free(uid); g_free(oldfn); }
static logs_log_t *logs_log_open(const char *session, const char *uid, gboolean raw) { logs_log_t *ll; if (!(ll = logs_log_new(session, uid, raw))) return NULL; logs_open_file(ll); if (ll->file) return ll; debug_error("logs_log_open(%s, %u, %d) - Can't open %s ff=%d\n", session, uid, raw, ll->fname, ll->format); g_ptr_array_remove(logs_logs, ll); return NULL; }