annotate src/control.c @ 480:5d32ceec7f25 noffle

[svn] * docs/FAQ: Improve X-NOFFLE-Status entry.
author bears
date Wed, 13 Oct 2004 22:49:53 +0100
parents 21300895412f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
2 control.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
4 $Id: control.c 517 2003-04-03 17:21:24Z bears $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
5 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
6
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
7 #if HAVE_CONFIG_H
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
8 #include <config.h>
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
9 #endif
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
10
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
11 #include <stdio.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
12 #include "common.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
13 #include "content.h"
197
24d4cd032da5 [svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents: 185
diff changeset
14 #include "control.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
15 #include "database.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
16 #include "group.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
17 #include "itemlist.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
18 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
19 #include "outgoing.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
20 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
21
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
22 int
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 Ctrl_cancel( const char *msgId )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
24 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 ItemList *refs;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 const char *ref;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 Str server;
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
28 Bool inOutgoing = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 int res = CANCEL_OK;
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
30 Bool removeFromDb = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 /* See if in outgoing and zap if so. */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 if ( Out_find( msgId, server ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
35 Out_remove( server, msgId );
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
36 Log_dbg( LOG_DBG_CONTROL,
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
37 "'%s' cancelled from outgoing queue for '%s'.\n",
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
38 msgId, server );
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
39 inOutgoing = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 if ( ! Db_contains( msgId ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
43 {
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
44 Log_dbg( LOG_DBG_CONTROL, "Cancel: '%s' not in database.", msgId );
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
45 return inOutgoing ? CANCEL_OK : CANCEL_NO_SUCH_MSG;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
47
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 Retrieve the Xrefs, remove from each group and then
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50 remove from the database.
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 refs = new_Itl( Db_xref( msgId ), " " );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
53 for( ref = Itl_first( refs ); ref != NULL; ref = Itl_next( refs ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
54 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
55 Str grp;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56 int no;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
58 if ( sscanf( ref, "%"MAXCHAR_STR"[^:]:%d", grp, &no ) != 2 )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61 if ( Grp_exists( grp ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
63 Cont_read( grp );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 Cont_delete( no );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
65 /*
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
66 * If we don't manage to remove the overview, leave the message
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
67 * in the main database to avoid confusion. Yes, the message
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
68 * will not be cancelled properly for this group but we don't
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
69 * signal this to the calling routine.
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
70 */
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
71 if ( Cont_write() )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
72 Log_dbg( LOG_DBG_CONTROL,
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
73 "Removed '%s' from group '%s'.",
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
74 msgId, grp );
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
75 else
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
76 removeFromDb = FALSE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
78 if ( ! Grp_local( grp ) && ! inOutgoing )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 res = CANCEL_NEEDS_MSG;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
80 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
82 {
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
83 Log_dbg( LOG_DBG_CONTROL,
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
84 "Group '%s' in Xref for '%s' not found.", grp, msgId );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 del_Itl( refs );
223
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
88 if ( removeFromDb )
ffb1848a39db [svn] * src/util.c: Improve (correct) error detection when updating
bears
parents: 197
diff changeset
89 Db_delete( msgId );
377
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
90 Log_dbg( LOG_DBG_CONTROL, "Message '%s' cancelled%s.", msgId,
21300895412f [svn] * src/common.h,src/control.c,src/noffle.c,src/post.c: Find actual bug
bears
parents: 287
diff changeset
91 (res == CANCEL_NEEDS_MSG) ? ", needs cancelling upstream" : "" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 return res;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
93 }