#include #include #include #include #include #include "tlmpmail.h" #include "keys.h" #include "tlmpmail.m" /* Return the default file carbon copy */ const char *prefs_getfcc() { return linuxconf_getval (K_PREF,K_FCC); } static SSTRING charset; /* Return the default charset */ const char *prefs_getcharset() { if (charset.is_empty()){ charset = linuxconf_getval (K_PREF,K_CHARSET,"us-ascii"); } return charset.get(); } /* Return the default inbox */ const char *prefs_getinbox() { static SSTRING def; struct passwd *p = getpwuid (getuid()); if (p != NULL){ def.setfromf ("/var/spool/mail/%s",p->pw_name); }else{ def.setfrom ("/var/spool/mail/unknown-user"); } return linuxconf_getval (K_PREF,K_INBOX,def.get()); } void prefs_getuserinfo(SSTRING &myname, SSTRING &myaddr) { myname.setfrom (linuxconf_getval (K_PREF,K_MYNAME)); myaddr.setfrom (linuxconf_getval (K_PREF,K_MYADDR)); const char *id = "unknown"; const char *gecos = "unknown user"; struct passwd *p = getpwuid (getuid()); if (p != NULL){ id = p->pw_name; gecos = p->pw_gecos; } if (myname.is_empty()){ myname.setfrom (gecos); } if (myaddr.is_empty()){ char tmpaddr[1000]; if (gethostname(tmpaddr,sizeof(tmpaddr))==-1){ strcpy (tmpaddr,"Unknown.host.domain"); } myaddr.setfromf ("%s@%s",id,tmpaddr); } } /* Get the email address of the user */ void prefs_getmyemail(SSTRING &s) { SSTRING tmp; prefs_getuserinfo (tmp,s); } /* Get the name of the user */ void prefs_getmyname(SSTRING &s) { SSTRING tmp; prefs_getuserinfo (s,tmp); } /* Get all the email addresses associated with me. This includes my address and all the aliases */ void prefs_getmyaddrs (SSTRINGS &addrs) { addrs.remove_all(); SSTRING *s = new SSTRING; prefs_getmyemail(*s); addrs.add (s); linuxconf_getall (K_PREF,K_MYALIASES,addrs,true); } void prefs_edit() { DIALOG dia; dia.setcontext (NULL); dia.newf_title (MSG_U(T_IDS,"Ids"),1,"",MSG_R(T_IDS)); SSTRING myname (linuxconf_getval(K_PREF,K_MYNAME)); SSTRING myaddr (linuxconf_getval(K_PREF,K_MYADDR)); SSTRINGS myaliases; linuxconf_getall(K_PREF,K_MYALIASES,myaliases,true); myaliases.add (new SSTRING); // One extra field dia.newf_str (MSG_U(F_MYNAME,"My name"),myname); dia.newf_str (MSG_U(F_MYADDR,"My email address"),myaddr); int field_aliases = dia.getnb(); for (int i=0; i