wmbiff: Raise sleep interval to 20 secs
[dockapps.git] / wmbiff-0.4.27 / wmbiff / LicqClient.c
blob2b22af10e3bc3308f06627da39da82048886e02a
1 /* $Id: LicqClient.c,v 1.11 2002/06/21 04:31:31 bluehal Exp $ */
2 /* Author : Yong-iL Joh ( tolkien@mizi.com )
3 Modified: Jorge GarcĂ­a ( Jorge.Garcia@uv.es )
4 *
5 * LICQ checker.
7 * Last Updated : $Date: 2002/06/21 04:31:31 $
9 */
11 #ifdef HAVE_CONFIG_H
12 #include <config.h>
13 #endif
15 #include "Client.h"
16 #include <sys/stat.h>
17 #include <utime.h>
18 #include <errno.h>
19 #ifdef USE_DMALLOC
20 #include <dmalloc.h>
21 #endif
23 #define PCM (pc->u).mbox
25 int licqCheckHistory( /*@notnull@ */ Pop3 pc)
27 struct utimbuf ut;
29 DM(pc, DEBUG_INFO, ">Mailbox: '%s'\n", pc->path);
31 if (fileHasChanged(pc->path, &ut.actime, &PCM.mtime, &PCM.size) != 0
32 || pc->OldMsgs < 0) {
33 FILE *F;
34 char buf[1024];
35 int count_status = 0;
37 F = openMailbox(pc, pc->path);
38 if (F == NULL)
39 return -1;
40 /* count message */
41 while (fgets(buf, BUF_SIZE, F)) {
42 if ((buf[0] == '[') || (buf[0] == '-')) { /* new, or old licq */
43 count_status++;
46 (void) fclose(F);
48 pc->TotalMsgs = count_status * 2;
49 pc->UnreadMsgs = pc->TotalMsgs - count_status;
50 DM(pc, DEBUG_INFO, "from: %d status: %d\n", pc->TotalMsgs,
51 pc->UnreadMsgs);
53 /* Not clear that resetting the mtime is useful, as
54 mutt is not involved. Unfortunately, I
55 (nspring/blueHal) can't tell whether this
56 cut-and-pasted code is needed */
57 ut.modtime = PCM.mtime;
58 utime(pc->path, &ut);
61 return 0;
64 int licqCreate( /*@notnull@ */ Pop3 pc, const char *str)
66 /* LICQ format: licq:fullpathname */
68 pc->TotalMsgs = 0;
69 pc->UnreadMsgs = 0;
70 pc->OldMsgs = -1;
71 pc->OldUnreadMsgs = -1;
72 pc->checkMail = licqCheckHistory;
74 strcpy(pc->path, str + 5); /* cut off ``licq:'' */
76 DM(pc, DEBUG_INFO, "licq: str = '%s'\n", str);
77 DM(pc, DEBUG_INFO, "licq: path= '%s'\n", pc->path);
79 return 0;
82 /* vim:set ts=4: */
84 * Local Variables:
85 * tab-width: 4
86 * c-indent-level: 4
87 * c-basic-offset: 4
88 * End: