comparison mcabber/src/histolog.c @ 1598:a087125d8fc8

Replace libjabber with loudmouth
author franky
date Sun, 11 Oct 2009 15:38:32 +0200
parents ec55cdf44335
children dcd5d4c75199
comparison
equal deleted inserted replaced
1597:4f59a414217e 1598:a087125d8fc8
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA 19 * USA
20 */ 20 */
21 21
22 #include <ctype.h>
23 #include <errno.h>
24 #include <fcntl.h>
25 #include <stdlib.h>
22 #include <string.h> 26 #include <string.h>
23 #include <stdlib.h>
24 #include <time.h>
25 #include <ctype.h>
26 #include <sys/types.h> 27 #include <sys/types.h>
27 #include <sys/stat.h> 28 #include <sys/stat.h>
28 #include <fcntl.h> 29 #include <time.h>
29 #include <unistd.h> 30 #include <unistd.h>
30 31
31 #include "histolog.h" 32 #include "histolog.h"
32 #include "hbuf.h" 33 #include "hbuf.h"
33 #include "jabglue.h"
34 #include "utils.h" 34 #include "utils.h"
35 #include "screen.h" 35 #include "screen.h"
36 #include "settings.h" 36 #include "settings.h"
37 #include "utils.h" 37 #include "utils.h"
38 #include "roster.h" 38 #include "roster.h"
39 #include "xmpp.h"
39 40
40 static guint UseFileLogging; 41 static guint UseFileLogging;
41 static guint FileLoadLogs; 42 static guint FileLoadLogs;
42 static char *RootDir; 43 static char *RootDir;
43 44
74 if (lstat(path, &bufstat) != 0) 75 if (lstat(path, &bufstat) != 0)
75 break; 76 break;
76 if (S_ISLNK(bufstat.st_mode)) { 77 if (S_ISLNK(bufstat.st_mode)) {
77 g_free(log_jid); 78 g_free(log_jid);
78 log_jid = g_new0(char, bufstat.st_size+1); 79 log_jid = g_new0(char, bufstat.st_size+1);
79 readlink(path, log_jid, bufstat.st_size); 80 if (readlink(path, log_jid, bufstat.st_size) < 0) return NULL;
80 g_free(path); 81 g_free(path);
81 path = user_histo_file(log_jid); 82 path = user_histo_file(log_jid);
82 } else 83 } else
83 break; 84 break;
84 } 85 }
442 scr_LogPrint(LPRINT_NORMAL, "Cannot open state file [%s]", 443 scr_LogPrint(LPRINT_NORMAL, "Cannot open state file [%s]",
443 strerror(errno)); 444 strerror(errno));
444 goto hlog_save_state_return; 445 goto hlog_save_state_return;
445 } 446 }
446 447
447 if (!jb_getonline()) { 448 if (!lm_connection_is_authenticated(lconnection)) {
448 // We're not connected. Let's use the unread_jids hash. 449 // We're not connected. Let's use the unread_jids hash.
449 GList *unread_jid = unread_jid_get_list(); 450 GList *unread_jid = unread_jid_get_list();
450 unread_ptr = unread_jid; 451 unread_ptr = unread_jid;
451 for ( ; unread_jid ; unread_jid = g_list_next(unread_jid)) 452 for ( ; unread_jid ; unread_jid = g_list_next(unread_jid))
452 fprintf(fp, "%s\n", (char*)unread_jid->data); 453 fprintf(fp, "%s\n", (char*)unread_jid->data);