#include #include #include #include #include #include #include "framework.h" #include "tlmpmail.h" #include "tlmpmail.m" #include "keys.h" #include static const char K_FOLDER[]="folder"; static const char K_CURRENT[]="current"; static HELP_FILE help_editflags ("tlmpmail","editflags"); extern int uithread_id; static void mail_editflags (MAIL_MESSAGE &msg) { DIALOG dia; dia.settype (DIATYPE_POPUP); char deleted = msg.deleted ? 1 : 0; char viewed = msg.viewed ? 1 : 0; char replied = msg.replied ? 1 : 0; dia.gui_form(); dia.gui_label(""); dia.gui_label(MSG_U(I_DELETED,"deleted")); dia.gui_label(MSG_U(I_VIEWED,"viewed")); dia.gui_label(MSG_U(I_REPLIED,"replied")); dia.gui_label(MSG_R(T_CLASS)); dia.newline(); dia.newf_chk (MSG_U(F_MESSAGEHASBEEN,"Message has been"),deleted,""); dia.gui_dispolast (GUI_H_CENTER,1,GUI_V_CENTER,1); dia.newf_chk (NULL,viewed,""); dia.gui_dispolast (GUI_H_CENTER,1,GUI_V_CENTER,1); dia.newf_chk (NULL,replied,""); dia.gui_dispolast (GUI_H_CENTER,1,GUI_V_CENTER,1); SSTRING classstr; for (int i=0; i 0) classstr.append("/"); static const char *tbclass[]={ K_CLASS1,K_CLASS2,K_CLASS3,K_CLASS4,K_CLASS5 }; classstr.append (msg.getflag(tbclass[i])); } dia.newf_info (NULL,classstr.get()); dia.gui_end(); dia.gui_dispolast (GUI_H_LEFT,10,GUI_V_CENTER,1); dia.newline(); SSTRING type (msg.flags.get_str (K_MSGTYPE)); folder_view_fieldtype (dia,type); dia.gui_dispolast (GUI_H_LEFT,10,GUI_V_CENTER,1); dia.newline(); SSTRING project (msg.flags.get_str (K_PROJECT)); folder_view_fieldproject (dia,project); dia.gui_dispolast (GUI_H_LEFT,10,GUI_V_CENTER,1); dia.newline(); SSTRING remind (msg.flags.get_str(K_REMIND)); int remind_field = dia.getnb(); dia.newf_str (MSG_U(F_REMIND,"Remind date"),remind,15); PRIVATE_MESSAGE today,add_day,add_week,add_month,b_clear; dia.new_button (MSG_U(B_TODAY,"Today"),"",today); dia.new_button (MSG_U(B_ADDONEDAY,"+ day"),"",add_day); dia.new_button (MSG_U(B_ADDONEWEEK,"+ week"),"",add_week); dia.new_button (MSG_U(B_ADDONEMONTH,"+ month"),"",add_month); dia.new_button (MSG_R(B_CLEAR),"",b_clear); dia.newline(); dia.newf_textarea (MSG_R(F_COMMENT),msg.comment,60,10); dia.gui_dispolast (GUI_H_LEFT,10,GUI_V_CENTER,1); dia.newline(); int nof = 0; while (1){ MENU_STATUS code = dia.edit (MSG_U(T_EDITFLAGS,"Message status") ,MSG_U(I_EDITFLAGS ,"You have control over the state of the message") ,help_editflags ,nof); if (code == MENU_CANCEL || code == MENU_ESCAPE){ break; }else if (code == MENU_MESSAGE){ dia.save(); if (dialog_testmessage (b_clear)){ remind.setempty(); dia.reload (remind_field); }else{ time_t date = time(NULL); if (remind.is_filled()){ date = miscmail_date2sec (remind.get()); } if (dialog_testmessage (today)){ date = time(NULL); }else if (dialog_testmessage (add_day)){ date += (24*60*60)*1; }else if (dialog_testmessage (add_week)){ date += (24*60*60)*7; }else if (dialog_testmessage (add_month)){ date += (24*60*60)*28; } struct tm *tt = localtime (&date); remind.setfromf ("%04d/%02d/%02d",tt->tm_year+1900 ,tt->tm_mon+1,tt->tm_mday); dia.reload (remind_field); } }else{ msg.set_deleted(deleted); msg.set_viewed(viewed); msg.set_replied(replied); msg.folder_wakeup(); msg.flags.set_str (K_MSGTYPE,type.get()); msg.flags.set_str (K_PROJECT,project.get()); msg.flags.set_str (K_REMIND,remind.get()); msg.setmodified(); folder_view_updatetype (type.get()); folder_view_updateproject (project.get()); break; } } } class CODIALOG_COMPOSE{ public: PRIVATE_MESSAGE details; char msgtype; CODIALOG_COMPOSE(){ msgtype = 0; } }; class CODIALOG_VIEW{ public: PRIVATE_MESSAGE flags,save,print; CODIALOG_VIEW(){ } }; // Various strings to compose popup menus static const char *delmsg; static const char *movemsg; static const char *copymsg; static const char *tag; static const char *shownew; static const char *showdeleted; static const char *showreplied; static const char *showtagged; static const char *showtoday; static const char *showthisweek; static const char *showthismonth; static const char *showtoday_notqual; // Not qualified messages static const char *showthisweek_notqual; static const char *showthismonth_notqual; static const char *showcommented; static const char *showtyped; static const char *showassigned; static const char *cplxfilter; static const char *contin ; static const char *reply ; static const char *reply_pick ; static const char *forward ; static const char *view ; static const char *filter_from ; static const char *filter_to ; static const char *filter_subject ; static const char *filter_thread ; static const char *filter_fromto ; static const char *edit_flags ; static const char *add_addrbook; static const char *mark_friend; static const char *mark_rejected; static const char *delete_all ; static const char *undelete_all ; static const char *tag_all ; static const char *untag_all ; static FOLDER_FILTER *mailmain_notqual( FOLDER_VIEW *folder, FILTER_ON cmd) { FOLDER_FILTER *filter = new FOLDER_FILTER( folder ,cmd ,""); folders_register(filter); filter = new FOLDER_FILTER( filter ,FILTER_ON_MSGTYPE ,FILTER_SCOPE_PARTIAL ,""); filter->setmode (true); return filter; } /* Process the selection of the popup menus. Given that the "s" menu string are uniq, the same function may be used to process the various popups, which are redundant (matter of user taste). For now, we have a big popup doing every things and smaller doing subset of the large popup. */ static void mailmain_dopopup ( FOLDER_VIEW *folder, const char *s, _F_FRAMEWORK *c) { if (s == tag_all){ folder->set_tagged(true); }else if (s == untag_all){ folder->set_tagged(false); }else if (s == delete_all){ folder->set_deleted(true); }else if (s == undelete_all){ folder->set_deleted(false); }else{ FOLDER_VIEW *newfolder = NULL; if (s == shownew){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_VIEWED ,"0"); }else if (s == showdeleted){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_DELETED ,"1"); }else if (s == showreplied){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_REPLIED ,"1"); }else if (s == showtagged){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_TAGGED ,"1"); }else if (s == showtoday){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_TODAY ,""); }else if (s == showthisweek){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_THISWEEK ,""); }else if (s == showthismonth){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_THISMONTH ,""); }else if (s == showtoday_notqual){ newfolder = mailmain_notqual (folder,FILTER_ON_TODAY); }else if (s == showthisweek_notqual){ newfolder = mailmain_notqual (folder,FILTER_ON_THISWEEK); }else if (s == showthismonth_notqual){ newfolder = mailmain_notqual (folder,FILTER_ON_THISMONTH); }else if (s == showtyped){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_MSGTYPE ,FILTER_SCOPE_PARTIAL ,""); }else if (s == showassigned){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_PROJECT ,FILTER_SCOPE_PARTIAL ,""); }else if (s == showcommented){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_COMMENT ,FILTER_SCOPE_PARTIAL ,""); } if (newfolder != NULL){ folders_register(newfolder); c->newdocument(newfolder); } } } /* Purge deleted messages from the postponed folder */ static void mailmain_updatepost() { folders_update (K_POSTPONED,true); } /* Setup a view on all messages sharing the same subject */ static FOLDER_FILTER *mailmain_filtersubject( FOLDER_VIEW *folder, MAIL_MESSAGE &msg) { const char *subject = msg.getsubject(); int len = strlen(MSG_R(I_REPLYPREFIX)); if (strncasecmp(subject,MSG_R(I_REPLYPREFIX),len)==0){ subject = str_skip(subject+len); } return new FOLDER_FILTER(folder,FILTER_ON_SUBJECT,FILTER_SCOPE_PARTIAL ,subject); } static int mail_main (int argc, char *argv[]) { SSTRINGS startfolders; uithread_init(30); static const char *tbdic[]={"tlmpwork","tlmpsql","bolixo",NULL}; int ret = (argc, argv,tbdic); fprintf (stderr,"tlmpmail %s\n",tlmpmail_version); fprintf (stderr,MSG_U(I_OPTIONS ,"--debug\n" "--folder foldername or path\n" )); xconf_error ("%s",msg); int ret = -1; if (strcmp(opt,"--folder")==0){ glocal.startfolders.add (new SSTRING(val)); ret = 1; }else if (strcmp(opt,"--debug")==0){ debug = true; ret = 0; } return ret; usage(); return -1; glocal MAIL_COMPOSE *compo; glocal MAIL_VIEW *view; glocal SSTRING msgstatus1; glocal SSTRING msgstatus2; glocal PRIVATE_MESSAGE updstatus; glocal SSTRINGS folders; // Folder still active to save state glocal int msgstatus_delay = 5; glocal PRIVATE_MESSAGE maintimer; // Initialise the strings for the popup { delmsg = MSG_U(M_DELMSG,"(un)Delete"); movemsg = MSG_U(M_MOVEMSG,"Move to another folder"); copymsg = MSG_U(M_COPYMSG,"Copy to another folder"); tag = MSG_U(M_TAGMSG,"(un)Tag"); shownew = MSG_U(M_SHOWNEW,"New messages"); showdeleted = MSG_U(M_SHOWDELETED,"Deleted messages"); showreplied = MSG_U(M_SHOWREPLIED,"Replied messages"); showtagged = MSG_U(M_SHOWTAGGED,"Tagged messages"); showtoday = MSG_U(M_SHOWTODAY,"Messages received today"); showthisweek = MSG_U(M_SHOWTHISWEEK,"Messages received this week"); showthismonth = MSG_U(M_SHOWTHISMONTH,"Messages received this month"); showtoday_notqual = MSG_U(M_SHOWTODAYNOTQUAL,"Messages received today (not qualified)"); showthisweek_notqual = MSG_U(M_SHOWTHISWEEKNOTQUAL,"Messages received this week (not qualified)"); showthismonth_notqual = MSG_U(M_SHOWTHISMONTHNOTQUAL,"Messages received this month (not qualified)"); showcommented = MSG_U(M_SHOWCOMMENTED,"Commented messages"); showassigned = MSG_U(M_SHOWASSIGNED,"Messages assigned to a project"); showtyped = MSG_U(M_SHOWTYPED,"Qualified messages"); cplxfilter = MSG_U(M_COMPLEXFILTER,"Complex filter"); contin = MSG_R(B_CONTINUE); reply = MSG_U(M_REPLY,"Reply"); reply_pick = MSG_R(B_REPLY_PICK); forward = MSG_U(M_FORWARD,"Forward"); view = MSG_U(M_VIEW,"View"); filter_from = MSG_U(M_FILTERONFROM,"Filter on \"from\""); filter_to = MSG_U(M_FILTERONTO,"Filter on \"to\""); filter_subject = MSG_U(M_FILTERONSUBJECT,"Filter on subject"); filter_thread = MSG_U(M_SHOWTHREAD,"show thread"); filter_fromto = MSG_U(M_SHOWFROMTO,"show author history"); edit_flags = MSG_U(M_EDITFLAGS,"edit flags"); add_addrbook = MSG_U(M_ADDADDRBOOK,"Add to address book"); mark_friend = MSG_U(M_MARKFRIEND,"Add to friend list"); mark_rejected = MSG_U(M_MARKREJECTED,"Add to bugger list"); delete_all = MSG_U(M_DELETEALL,"Delete all"); undelete_all = MSG_U(M_UNDELETEALL,"Undelete all"); tag_all = MSG_U(M_TAGALL,"Tag all"); untag_all = MSG_U(M_UNTAGALL,"Untag all"); } if (linuxconf_getvalnum(K_NOTICE,K_EXPERIMENTAL,0)==0){ xconf_notice ( "This is an experimental mail program\n" "It may not be reliable. You may want to use it\n" "in a demo account.\n" "It uses the same folders and address book as pine."); linuxconf_replace (K_NOTICE,K_EXPERIMENTAL,1); linuxconf_save(); } glocal.view = NULL; glocal.compo = NULL; (); mailmain_updatepost(); compose_quotereply (msg,txt,"> "); initnewmsg (txt); return attachs.edit(); glocal int ret = -1; glocal MAIL_MESSAGE_FULL msg = msg; glocal const ATTACHEMENTS *attachs = &attachs; (); glocal.ret = (glocal.msg,*glocal.attachs); mailformat (msg,attachs,ss); return 0; // Ok the message was delivered. // First we update our correspondant white list classify_addtmpfriends (addrs); classify_addsubject (msg.subject.get()); // Then we save the message in the sent-mail folder // or the per-recipient sentmail glocal MAIL_MESSAGE_FULL *msg = &msg; SSTRING path(msg.fcc); if (path.is_empty()){ if (addrbook_getfcc(addrs.getitem(0)->get(),path)==-1){ path.setfrom (prefs_getfcc()); } } if (path.is_filled()){ folder_2abs (path.get(),path); (path.get()); (path,true); SSTREAM_FILE ss(fout); ss.puts ("\n"); ATTACHEMENTS noatt; // We are not archiving attachements mailformat(*glocal.msg,noatt,ss); return 0; } folders_checkupdate(); const char *first_addr = msg.getemail_to(); if (msg.getnb_to()==1 && first_addr[0] == '#'){ glocal OBJECTSUB *osub = &osub; glocal int nbsent = 0; (first_addr+1,true); if (line[0] != '\0' && line[0] != '#'){ SSTRING word; const char *pt = str_copyword(word,line); pt = str_skip(pt); glocal.msg.to.remove_all(); glocal.msg.to.set (pt,word.get()); glocal.osub->exec(); if (glocal.ret == -1){ tlmp_error (MSG_U(E_CANTSEND ,"Can't send message to %s, aborting"),line); }else{ glocal.nbsent++; } } return glocal.ret; if (glocal.ret==-1){ glocal.msgstatus1.setfromf (MSG_U(I_LISTNOTALLSENT,"%d messages sent, some errors") ,glocal.nbsent); }else{ glocal.msgstatus1.setfromf (MSG_U(I_LISTSENT,"%d messages sent") ,glocal.nbsent); } }else{ osub.exec(); if (glocal.ret==-1){ glocal.msgstatus1.setfrom (MSG_U(I_MAILNOTSENT,"Message not sent")); }else{ glocal.msgstatus1.setfrom (MSG_U(I_MAILSENT,"Message sent")); mailmain_updatepost(); } } dialog_sendmessage (glocal.updstatus); return glocal.ret; glocal MAIL_MESSAGE_FULL *msg = &msg; glocal const ATTACHEMENTS *attachs = &attachs; mailmain_updatepost(); SSTRING path; folder_2abs (K_POSTPONED,path); (path.get()); (path,true); SSTREAM_FILE ss(fout); glocal.msg->date = time(NULL); mailformat(*glocal.msg,*glocal.attachs,ss); return 0; addrbook_pick(emails); return addrbook_complete(nick,emails); SSTRING f; if (folder_pick(f)!=-1) folder.setfrom(f); CODIALOG_COMPOSE *co = new CODIALOG_COMPOSE; dia.newf_chk ("urgent",co->msgtype,"ok"); dia.new_button (MSG_U(B_EXTRAINFO,"Details"),"",co->details); dia.newline(); dia.setbutinfo (MENU_USR6,MSG_U(B_SPELL,"Spell"),MSG_R(B_SPELL)); butmask = MENUBUT_USR6; return co; CODIALOG_COMPOSE *co = (CODIALOG_COMPOSE*)data; delete co; CODIALOG_COMPOSE *co = (CODIALOG_COMPOSE*)data; if (dialog_testmessage(co->details)){ xconf_notice ("Add some details"); } glocal.compo = &compo; (); EMAILADDRS empty; glocal.compo->reply(msg,to,empty,empty); EMAILADDRS to,cc,bcc; if (miscmail_pickaddrs(msg,to,cc,bcc)!=-1){ glocal.compo->reply(msg,to,cc,bcc); } glocal.compo->compose (to); glocal.compo->forward(msg); CODIALOG_VIEW *co = new CODIALOG_VIEW; dia.new_button (MSG_R(M_EDITFLAGS),"",co->flags); dia.new_button (MSG_U(B_SAVEMSG,"Save"),"",co->save); dia.new_button (MSG_U(B_PRINTMSG,"Print"),"",co->print); dia.newline(); return co; CODIALOG_VIEW *co = (CODIALOG_VIEW*)data; delete co; CODIALOG_VIEW *co = (CODIALOG_VIEW*)data; if (dialog_testmessage(co->flags)){ mail_editflags (msg); }else if (dialog_testmessage(co->save)){ miscmail_save (full); }else if (dialog_testmessage(co->print)){ if (miscmail_print (full) != -1){ glocal.msgstatus1.setfrom (MSG_U(I_PRINTED,"Message printed")); dialog_sendmessage (glocal.updstatus); } } glocal.view = &view; ("tlmpmail"); ("tlmpmail",tlmpmail_version); printf ("Jacques Gélinas jack@solucorp.qc.ca\n"); setgpl(); printf ( "This is an experimental mail program\n" "It may not be reliable. You may want to use it\n" "in a demo account. It uses the same folder as pine."); printf (MSG_U(I_INTRO ,"Part of the TLMPWORK package\n" "available from http://www.solucorp.qc.ca/tlmp") ); topmenu (MSG_U(M_FILE,"File")); menuentry (3,MSG_U(M_CLOSE,"Close folder")); menuentry (2,MSG_U(M_EXPUNGE,"Purge deleted messages")); menuentry (4,MSG_U(M_CLOSEEXPUNGE,"Close and purge")); menuentry (5,MSG_U(M_CLASSIFY,"Classify")); menuentry (99,MSG_U(M_QUIT,"Quit")); endmenu(); topmenu (MSG_U(M_FOLDERS,"Folders")); menuentry (101,MSG_U(M_OPENSTD,"Open")); menuentry (102,MSG_U(M_OPENVIRT,"Open virtual")); menuentry (104,MSG_U(M_APPLYFILTER,"Apply filter")); topmenu (MSG_U(M_OPTIONS,"Options")); menuentry (901,MSG_U(M_PREFER,"Preferences")); menuentry (902,MSG_U(M_SIGNATURE,"Edit signature")); menuentry (903,MSG_U(M_EDITFILTERS,"Edit filters")); menuentry (905,MSG_U(M_EDITVIRTUALS,"Edit virtual folders")); menuentry (906,MSG_U(M_FRIENDS,"Edit friend list")); menuentry (907,MSG_U(M_REJECTED,"Edit black list")); menuentry (908,MSG_U(M_MLIST,"Edit mailing lists list")); menuentry (909,MSG_U(M_MKEYWORD,"Edit subject keyword list")); menuentry (904,MSG_U(M_DEBUG,"Turn Debuging on/off")); endmenu(); helpmenu(); endmenu(); if (id == 99){ end(); }else if (id == 101){ SSTRING f; if (folder_pick (f)!=-1){ newdocument(folders_alloc (f.get())); } }else if (id == 102){ FOLDER_VIEWS views; virtual_pick(views); for (int i=0; i newbutton (100,"",MSG_U(B_COMPOSE,"Compose"),""); newbutton (101,"",MSG_U(B_CONTINUE,"Continue"),""); newbutton (102,"",MSG_U(B_ADDRBOOK,"Address book"),""); newbutton (103,"",MSG_U(B_FILTER,"Filter"),""); newbutton (106,"",MSG_U(B_QFILTER,"Quick filter"),""); newbutton (104,"",MSG_U(B_THREAD,"Thread"),""); newbutton (105,"",MSG_U(B_SENTMAIL,"Sent mail"),""); if (id == 100){ glocal.compo->compose(); }else if (id == 101){ /* #Specification: postponed-msgs / strategy Postponed messages are stored in a folder called postponed-msgs. This folder is presented through a filter ignoring message marked deleted. When we resume editing of a message, we set it to deleted. This way, the message is kept in the folder for a longer time in case of a crash. When we send a message we do a purge on the postponed folder. */ FOLDER_VIEW *post = folders_alloc (K_POSTPONED); FOLDER_FILTER *f = new FOLDER_FILTER(post ,FILTER_ON_DELETED ,"0"); folders_register (f); f->settitle (MSG_U(I_POSTPONED,"Postponed messages")); newdocument(f); }else if (id == 102){ EMAILADDRS addrs; if (addrbook_pick (addrs)!=-1){ glocal.compo->compose(addrs); } }else if (id == 105){ FOLDER_VIEW *f = folders_alloc (prefs_getfcc()); newdocument(f); }else{ //xconf_notice ("taskdo %d",id); } // We do nothing, letting end == false // One day we may present a logo // fprintf (stderr,"Message %d\n",dialog_testmessage(glocal.maintimer)); folders_checkupdate(); glocal _F_FRAMEWORK *c = this; glocal FRAMEWORK_INFO *info = &info; glocal MAIL_FILTERS filters; FOLDER_VIEW *folder = (FOLDER_VIEW*)info.data; folder->incrusage(); { // We remember which folder are active SSTRING id; if (folder->getid(id)!=-1){ glocal.folders.add (new SSTRING(id)); } } const char *title = folder->gettitle(); (folder,title,info,this ,strstr(title,prefs_getfcc())!=NULL); glocal.filters.setup(); folder->loadindex (tb,revision); glocal.filters.present (msg,dcs); if (folder->is_postponed()){ msg.set_deleted(true); glocal.compo->resume(msg); }else{ msg.set_viewed(true); glocal.view->view (folder,msg,true); } DIALOG_MENUPOPUP dia; dia.new_menuitem ("",MSG_R(M_CLOSE)); dia.new_menuitem ("",MSG_R(M_EXPUNGE)); dia.new_menuitem ("",MSG_R(M_CLOSEEXPUNGE)); int sel = 0; if (dia.editmenu (NULL,sel)==MENU_OK){ if (sel == 0){ end = true; }else if (sel == 1){ folder->update (true); }else if (sel == 2){ folder->update (true); end = true; } } if (uistate.shiftkey){ // Quick view on all messages with same subject FOLDER_VIEW *newfolder = mailmain_filtersubject (folder,msg); folders_register(newfolder); glocal.c->newdocument(newfolder); }else{ bool post = folder->is_postponed(); DIALOG_MENUPOPUP dia; if (post){ dia.new_menuitem ("",contin); dia.new_menuitem ("",delmsg); dia.new_menuitem ("-",MSG_U(M_FILTERS,"Filters")); }else{ dia.new_menuitem ("",reply); dia.new_menuitem ("",reply_pick); dia.new_menuitem ("",delmsg); dia.new_menuitem ("",forward); dia.new_menuitem ("",movemsg); dia.new_menuitem ("",copymsg); dia.new_menuitem ("",view); dia.new_menuitem ("",tag); dia.new_menuitem ("",edit_flags); dia.new_menuitem ("",add_addrbook); dia.new_menuitem ("",mark_friend); dia.new_menuitem ("",mark_rejected); // A sub menu dia.new_menuitem ("-",MSG_U(M_SHOWONLY,"Show only")); dia.new_menuitem ("",shownew); dia.new_menuitem ("",showreplied); dia.new_menuitem ("",showtagged); dia.new_menuitem ("",showdeleted); dia.new_menuitem ("","-"); dia.new_menuitem ("",showtoday); dia.new_menuitem ("",showthisweek); dia.new_menuitem ("",showthismonth); dia.new_menuitem ("","-"); dia.new_menuitem ("",showcommented); dia.new_menuitem ("",showassigned); dia.new_menuitem ("",showtyped); dia.new_menuitem ("-",MSG_R(M_FILTERS)); dia.new_menuitem ("",cplxfilter); } dia.new_menuitem ("",filter_from); dia.new_menuitem ("",filter_to); dia.new_menuitem ("",filter_subject); dia.new_menuitem ("",filter_thread); dia.new_menuitem ("",filter_fromto); if (!post){ dia.new_menuitem ("-",MSG_U(M_ONMESSAGES,"On messages")); dia.new_menuitem ("",delete_all); dia.new_menuitem ("",undelete_all); dia.new_menuitem ("",tag_all); dia.new_menuitem ("",untag_all); } int sel = 0; if (dia.editmenu (NULL,sel)==MENU_OK){ const char *s = dia.getmenustr(sel); FOLDER_VIEW *newfolder = NULL; if (s == delmsg){ msg_delete (no); }else if (s == movemsg || s == copymsg){ if (mail_copy (msg)!=-1){ if (s == movemsg) msg.set_deleted(true); glocal.msgstatus2.setfrom (MSG_U(I_MSGMOVED,"Message copied")); dialog_sendmessage (glocal.updstatus); } }else if (s == contin){ glocal.compo->resume(msg); }else if (s == reply){ glocal.compo->reply(msg); }else if (s == reply_pick){ EMAILADDRS to,cc,bcc; if (miscmail_pickaddrs (msg,to,cc,bcc)!=-1){ glocal.compo->reply(msg,to,cc,bcc); } }else if (s == forward){ glocal.compo->forward(msg); }else if (s == view){ msg.set_viewed(true); glocal.view->view (folder,msg,false); }else if (s == tag){ msg.set_tagged(!msg.tagged); }else if (s == edit_flags){ mail_editflags(msg); }else if (s == add_addrbook){ addrbook_add (msg); }else if (s == mark_friend){ msg.set_friends(); }else if (s == mark_rejected){ msg.set_rejected(); }else if (s == cplxfilter){ FOLDER_FILTER *fold = new FOLDER_FILTER(folder); fold->setfrom (msg.getemail_from(),FILTER_SCOPE_FULL); fold->setto (msg.getemail_to(),FILTER_SCOPE_FULL); fold->setsubject (msg.getsubject(),FILTER_SCOPE_FULL); if (fold->editfilter()==-1){ delete fold; }else{ newfolder = fold; } }else if (s == filter_from){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_FROM ,msg.getemail_from()); }else if (s == filter_to){ newfolder = new FOLDER_FILTER( folder ,FILTER_ON_TO ,msg.getemail_to()); }else if (s == filter_subject){ newfolder = mailmain_filtersubject (folder,msg); }else if (s == filter_thread){ newfolder = new FOLDER_THREAD (msg); }else if (s == filter_fromto){ FOLDER_MULTI *m; const char *email; glocal.m = new FOLDER_MULTI; glocal.email = msg.getemail_from(); FOLDER_FILTER *f = new FOLDER_FILTER( folder ,FILTER_ON_FROM ,glocal.email); glocal.m->add (f); SSTRING mail; folder_getmaildir (mail); (mail.get()); if (strncmp(basename,"sent-mail",9)==0){ FOLDER_VIEW *sent = folders_alloc (basename); FOLDER_FILTER *f = new FOLDER_FILTER( sent ,FILTER_ON_TO ,glocal.email); glocal.m->add (f); } newfolder = glocal.m; }else{ mailmain_dopopup (folder,s,glocal.c); } if (newfolder != NULL){ folders_register(newfolder); glocal.c->newdocument(newfolder); } } } if (glocal.info->has_focus){ glocal.msgstatus2.setfromf (MSG_U(I_FOLDERINFO,"Message %d of %d (%d new, %d deleted, %d tagged)") ,curmsg+1,nbmsg,nbnew,nbdeleted,nbtagged); dialog_sendmessage (glocal.updstatus); } glocal.msgstatus1.setfrom (text); dialog_sendmessage (glocal.updstatus); glocal.msgstatus_delay = 2; uithread_yield(); if (dialog_testmessage(glocal.info->docmsgs.menubar)){ if (glocal.info->menuid == 3 || glocal.info->menuid == 4){ if (glocal.info->menuid == 4){ notice (MSG_U(N_SYNCING,"Syncing folders")); folder->update(true); notice (MSG_U(N_SYNCINGDONE,"Syncing done")); } end = true; }else if (glocal.info->menuid == 2){ notice (MSG_R(N_SYNCING)); folder->update(true); notice (MSG_R(N_SYNCINGDONE)); }else if (glocal.info->menuid == 5){ folder->classify(); }else if (glocal.info->menuid == 104){ SSTRING filtername; if (filters_pick(filtername)!=-1){ FOLDER_FILTER *fold = new FOLDER_FILTER(folder); fold->loaddef (filtername.get()); folders_register(fold); glocal.c->newdocument(fold); } } }else if (dialog_testmessage(glocal.info->docmsgs.taskbar)){ if (glocal.info->taskid == 103){ FOLDER_FILTER *fold = new FOLDER_FILTER(folder); if (fold->editfilter()!=-1){ folders_register(fold); glocal.c->newdocument(fold); }else{ delete fold; } }else if (glocal.info->taskid == 106){ FOLDER_FILTER *fold = new FOLDER_FILTER(folder); if (fold->editqfilter()!=-1){ folders_register(fold); glocal.c->newdocument(fold); }else{ delete fold; } }else if (glocal.info->taskid == 104){ FOLDER_THREAD *t = new FOLDER_THREAD (msg); folders_register (t); glocal.c->newdocument (t); } } // Contextual menu when we click in column title DIALOG_MENUPOPUP dia; if (column == 1){ dia.new_menuitem ("",shownew); dia.new_menuitem ("",showreplied); dia.new_menuitem ("",showtagged); dia.new_menuitem ("",showdeleted); dia.new_menuitem ("","-"); dia.new_menuitem ("",showcommented); dia.new_menuitem ("",showassigned); dia.new_menuitem ("",showtyped); dia.new_menuitem ("","-"); dia.new_menuitem ("",delete_all); dia.new_menuitem ("",undelete_all); dia.new_menuitem ("",tag_all); dia.new_menuitem ("",untag_all); }else if (column == 4 || column == 0){ dia.new_menuitem ("",showtoday); dia.new_menuitem ("",showthisweek); dia.new_menuitem ("",showthismonth); dia.new_menuitem ("",showtoday_notqual); dia.new_menuitem ("",showthisweek_notqual); dia.new_menuitem ("",showthismonth_notqual); } int sel = 0; if (dia.getnb()>0 && dia.editmenu (NULL,sel)==MENU_OK){ const char *s = dia.getmenustr(sel); mailmain_dopopup (folder,s,glocal.c); } { SSTRING id; if (folder->getid(id)!=-1){ int lk = glocal.folders.lookup(id.get()); glocal.folders.remove_del(lk); } } folder->decrusage(); folders_free (); (ending); dia.newf_str (NULL,glocal.msgstatus1,40); dia.set_lastreadonly(); dia.newf_str (NULL,glocal.msgstatus2,40); dia.set_lastreadonly(); dia.waitfor (glocal.updstatus); settimer (glocal.msgstatus_delay); glocal.msgstatus_delay = 5; glocal.msgstatus1.setempty(); linuxconf_removeall (K_FOLDER,K_CURRENT); for (int i=0; iget(); linuxconf_add (K_FOLDER,K_CURRENT,s); } linuxconf_save(); SSTRINGS tb; linuxconf_getall (K_FOLDER,K_CURRENT,tb,false); FOLDER_VIEWS views; // Process folders used in previous session for (int i=0; iget(),views); } // Process the ones from the command line for (int i=0; iget(),views); } for (int i=0; i return ret; } int main (int argc, char *argv[]) { const char *pt = strrchr(argv[0],'/'); if (pt == NULL){ pt = argv[0]; }else{ pt++; } int ret = -1; if (strcmp(pt,"foldercopy")==0){ ret = foldercopy (argc,argv); }else if (strcmp(pt,"folderwalk")==0){ ret = folderwalk (argc,argv); }else if (strcmp(pt,"base64")==0){ ret = base64 (argc,argv); }else{ ret = mail_main (argc,argv); } return ret; }