}
-void get_mm(void)
-{
- FILE *fp;
-
- fp = fopen(file_citadel_control, "r");
- if (fp == NULL) {
- lprintf(CTDL_CRIT, "Cannot open %s: %s\n",
- file_citadel_control,
- strerror(errno));
- exit(errno);
- }
- fread((char *) &CitControl, sizeof(struct CitControl), 1, fp);
- fclose(fp);
-}
-
-
/*
* Back end for the MSGS command: output message number only.
*/
int num_processed = 0;
long thismsg;
struct MetaData smi;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
int is_seen = 0;
long lastold = 0L;
int printed_lastold = 0;
long *search_msgs = NULL;
/* Learn about the user and room in question */
- get_mm();
getuser(&CC->user, CC->curr_user);
CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
template = (struct CtdlMessage *)
malloc(sizeof(struct CtdlMessage));
memset(template, 0, sizeof(struct CtdlMessage));
+ template->cm_magic = CTDLMESSAGE_MAGIC;
+ template->cm_anon_type = MES_NORMAL;
+
while(client_getln(buf, sizeof buf), strcmp(buf,"000")) {
extract_token(tfield, buf, 0, '|', sizeof tfield);
extract_token(tvalue, buf, 1, '|', sizeof tvalue);
{
int i;
- if (is_valid_message(msg) == 0) return;
+ if (is_valid_message(msg) == 0)
+ {
+ if (msg != NULL) free (msg);
+ return;
+ }
for (i = 0; i < 256; ++i)
if (msg->cm_fields[i] != NULL) {
void cmd_msg3(char *cmdbuf)
{
long msgnum;
- struct CtdlMessage *msg;
+ struct CtdlMessage *msg = NULL;
struct ser_ret smr;
if (CC->internal_pgm == 0) {
lprintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
recipient);
if (getuser(&userbuf, recipient) == 0) {
+ // Add a flag so the Funambol module knows its mail
+ msg->cm_fields['W'] = strdup(recipient);
MailboxName(actual_rm, sizeof actual_rm,
&userbuf, MAILROOM);
CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0, msg);
BumpNewMailCounter(userbuf.usernum);
+ if (strlen(config.c_funambol_host) > 0) {
+ /* Generate a instruction message for the Funambol notification
+ server, in the same style as the SMTP queue */
+ instr = malloc(SIZ * 2);
+ snprintf(instr, SIZ * 2,
+ "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
+ "bounceto|%s@%s\n",
+ SPOOLMIME, newmsgid, (long)time(NULL),
+ msg->cm_fields['A'], msg->cm_fields['N']
+ );
+
+ imsg = malloc(sizeof(struct CtdlMessage));
+ memset(imsg, 0, sizeof(struct CtdlMessage));
+ imsg->cm_magic = CTDLMESSAGE_MAGIC;
+ imsg->cm_anon_type = MES_NORMAL;
+ imsg->cm_format_type = FMT_RFC822;
+ imsg->cm_fields['A'] = strdup("Citadel");
+ imsg->cm_fields['J'] = strdup("do not journal");
+ imsg->cm_fields['M'] = instr;
+ imsg->cm_fields['W'] = strdup(recipient);
+ CtdlSubmitMsg(imsg, NULL, FNBL_QUEUE_ROOM);
+ CtdlFreeMessage(imsg);
+ }
}
else {
lprintf(CTDL_DEBUG, "No user <%s>\n", recipient);
* the current room (returns 1 for yes, 0 for no)
*/
int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void) {
- getuser(&CC->user, CC->curr_user);
- if ((CC->user.axlevel < 6)
- && (CC->user.usernum != CC->room.QRroomaide)
- && ((CC->room.QRflags & QR_MAILBOX) == 0)
- && (!(CC->internal_pgm))) {
- return(0);
- }
- return(1);
+ int ra;
+ CtdlRoomAccess(&CC->room, &CC->user, &ra, NULL);
+ if (ra & UA_DELETEALLOWED) return(1);
+ return(0);
}
+
/*
* Delete message from current room
*/