13 #include <X11/Xutil.h>
14 #include <X11/Xatom.h>
15 #include <X11/Xft/Xft.h>
17 #include "string_utils.h"
18 #include "file_utils.h"
21 #include "md5_utils.h"
23 #include "icons_utils.h"
26 static struct mail_entry mail
;
28 void parse_file(const char *filename
)
32 fh
= fopen(filename
, "r");
36 parse_mail_header(fh
, &mail
.hdr
);
41 static void print_mail(struct mail_entry
*mail
)
46 print_mail_header(&mail
->hdr
);
49 void display_osd(int argc
, char **argv
)
51 struct notify_object no
;
60 /* Open connection with the server */
61 dpy
= XOpenDisplay(NULL
);
63 fprintf(stderr
, "Cannot open display\n");
67 icon
= icon_get_path((char *) mail
.hdr
.addr_md5
);
69 osd_init(dpy
, &no
, mail
.hdr
.from
, mail
.hdr
.subject
, icon
);
71 if (osd_new_frame(argc
, argv
, &no
)) {
76 /* Select kind of events we are interested in */
77 XSelectInput(no
.frame
.display
, no
.frame
.win
,
78 ExposureMask
| KeyPressMask
| ButtonPressMask
);
80 /* Create OSD object */
81 if (osd_new_notify_object(argc
, argv
, &no
)) {
85 /* Map (show) the window */
86 XMapWindow(no
.frame
.display
, no
.frame
.win
);
90 XNextEvent(no
.frame
.display
, &e
);
94 /* Draw or redraw the window */
95 osd_show_notify_object(&no
);
98 /* Exit on key press or mouse button press */
106 osd_delete_notify_object(&no
);
109 icon_free_path(icon
);
111 /* Close connection to server */
112 XCloseDisplay(no
.frame
.display
);
115 int main(int argc
, char **argv
)
120 fprintf(stderr
, "%s <file>\n", argv
[0]);
133 display_osd(argc
, argv
);