Commit Diff


commit - 7575a9e1bb90c1876999881509797900787bb6b0
commit + 2eef1fa31676e58b0038f1c02dcc8df5e23149e6
blob - b52dcbbb56458c63591c2aa9ede3920dc3477134
blob + 3fa133a5301d994759b9fa0939e716c9b2ec0bfb
--- src/cmd/faces/facedb.c
+++ src/cmd/faces/facedb.c
@@ -17,7 +17,6 @@ static int		nsaved;
 static char	*facedom;
 static char	*libface;
 static char	*homeface;
-static char	*machinelist;
 
 /*
  * Loading the files is slow enough on a dial-up line to be worth this trouble
@@ -258,7 +257,7 @@ estrstrdup(char *a, char *b)
 static char*
 tryfindfiledir(char *dom, char *user, char *dir)
 {
-	char *dict, *ndir, *x;
+	char *dict, *ndir, *x, *odom;
 	int fd;
 	int i, n;
 	Dir *d;
@@ -269,7 +268,6 @@ tryfindfiledir(char *dom, char *user, char *dir)
 	x = estrstrdup(dir, "/.machinelist");
 	dom = estrdup(translatedomain(dom, x));
 	free(x);
-
 	/*
 	 * If this directory has a .dict, use it.
 	 */
@@ -354,12 +352,9 @@ findfile(Face *f, char *dom, char *user)
 	}
 	if(libface == nil)
 		libface = unsharp("#9/face");
-	if(machinelist == nil)
-		machinelist = estrstrdup(libface, "/.machinelist");
 	if(homeface == nil)
 		homeface = smprint("%s/lib/face", getenv("HOME"));
 
-	dom = translatedomain(dom, machinelist);
 	if(dom == nil)
 		dom = facedom;
 
blob - 4d246b5c20f3c9ed2198f0588ff4dd8b169df7f0
blob + 6d82c779f866639c06d7df1a403232dcf4ae796b
--- src/cmd/faces/plumb.c
+++ src/cmd/faces/plumb.c
@@ -81,7 +81,17 @@ setname(Face *f, char *sender)
 {
 	char *at, *bang;
 	char *p;
+	char *fld[3];
+	int nf;
 
+	p = estrdup(sender);
+	nf = tokenize(p, fld, 3);
+	if(nf <= 1)
+		sender = estrdup(fld[0]);
+	else
+		sender = estrdup(fld[1]);
+	free(p);
+
 	/* works with UTF-8, although it's written as ASCII */
 	for(p=sender; *p!='\0'; p++)
 		*p = tolower(*p);
@@ -189,7 +199,7 @@ nextface(void)
 	int i;
 	Face *f;
 	Plumbmsg *m;
-	char *t, *senderp, *showmailp, *digestp;
+	char *t, *data, *showmailp, *digestp;
 	ulong xtime;
 
 	f = emalloc(sizeof(Face));
@@ -197,13 +207,18 @@ nextface(void)
 		m = plumbrecvfid(seefd);
 		if(m == nil)
 			killall("error on seemail plumb port");
+		if(strncmp(m->data, "Mail/", 5) != 0){
+			plumbfree(m);
+			continue;
+		}
+		data = m->data+5;
 		t = value(m->attr, "mailtype", "");
 		if(strcmp(t, "delete") == 0)
-			delete(m->data, value(m->attr, "digest", nil));
+			delete(data, value(m->attr, "digest", nil));
 		else if(strcmp(t, "new") != 0)
 			fprint(2, "faces: unknown plumb message type %s\n", t);
 		else for(i=0; i<nmaildirs; i++)
-			if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0)
+			if(strncmp(data, maildirs[i], strlen(maildirs[i])) == 0)
 				goto Found;
 		plumbfree(m);
 		continue;
@@ -216,11 +231,16 @@ nextface(void)
 			plumbfree(m);
 			continue;
 		}
-		senderp = estrdup(value(m->attr, "sender", "???"));
-		showmailp = estrdup(m->data);
+		showmailp = estrdup(data);
 		if(digestp)
 			digestp = estrdup(digestp);
+		setname(f, value(m->attr, "sender", "???"));
 		plumbfree(m);
+		f->time = xtime;
+		f->tm = *localtime(xtime);
+		f->str[Sshow] = showmailp;
+		f->str[Sdigest] = digestp;
+		return f;
 	}
 	return nil;
 }
@@ -244,7 +264,7 @@ Face*
 dirface(char *dir, char *num)
 {
 	Face *f;
-	char buf[1024],  *fld[3], *info, *p, *t, *s;
+	char buf[1024],  *info, *p, *t, *s;
 	int n;
 	ulong len;
 	CFid *fid;
@@ -274,8 +294,8 @@ dirface(char *dir, char *num)
 			f->time = atoi(t);
 			f->tm = *localtime(f->time);
 		}
-		else if(strcmp(s, "from") == 0 && tokenize(t, fld, 3) >= 2)
-			setname(f, estrdup(fld[1]));
+		else if(strcmp(s, "from") == 0)
+			setname(f, t);
 		else if(strcmp(s, "digest") == 0)
 			f->str[Sdigest] = estrdup(t);
 	}