?? email_main.cxx
字號:
// generated by Fast Light User Interface Designer (fluid) version 1.0010
#ifdef M_PTHREAD
#include <pthread.h>
#endif
#include "Email_main.h"
#include <assert.h>
extern Number numset;
#ifdef M_THREAD
int RS_but_value;
#endif
Fl_Window *win;
void youdo(void)
{
struct new_email *buf1;
struct new_rvmail *buf2;
struct numberset *buf3;
struct loginfo *buf4;
int i, db_num, current;
win->show();
strncpy(USERNAME, xz_del_s, 20);
printf("current user is %s\n", USERNAME);
buf1 = (struct new_email *) malloc(MAXNEWMAIL);
db_num = db_get_record_number(newmail_id);
for (i = 0, current = 0; i < db_num; i++) {
db_search_key(newmail_id, &i, buf1, sizeof(int));
if (!strcmp(USERNAME, buf1->user))
current++;
}
user_newmail = current;
free(buf1);
buf2 = (struct new_rvmail *) malloc(MAXRCVMAIL);
db_num = db_get_record_number(oldmail_id);
for (i = 0, current = 0; i < db_num; i++) {
db_search_key(oldmail_id, &i, buf2, sizeof(int));
if (!strcmp(USERNAME, buf2->user))
current++;
}
user_oldmail = current;
free(buf2);
buf3 = (struct numberset *) malloc(MAXCHRNUM);
db_num = db_get_record_number(setnum_id);
for (i = 0, current = 0; i < db_num; i++) {
db_search_key(setnum_id, &i, buf3, sizeof(int));
if (!strcmp(USERNAME, buf3->user))
current++;
}
user_account = current;
free(buf3);
printf("current user:\n\taccount: %d\n\tnewmail: %d\n\toldmail: %d\n",
user_account, user_newmail, user_oldmail);
buf4 = (struct loginfo *) malloc(MAXCHLOG);
db_num = db_get_record_number(changelog_id);
if (db_num == 0)
total_mailid = 0;
else {
sort_changelog_database(changelog_id);
db_change_current_pos(changelog_id, db_num - 1);
db_get_current_pos(changelog_id, buf4);
total_mailid = buf4->mailid;
db_delete_current_record(changelog_id);
}
free(buf4);
printf("total_mailid = %d\n", total_mailid);
if (get_mail_fdb(SENDMAIL, newmail_id) == -1) {
printf("newmail in database show error!\n");
return;
}
printf("show newmail over\n");
if (get_mail_fdb(RECVMAIL, oldmail_id) == -1) {
printf("oldmail in database show error!\n");
return;
}
printf("show oldmail over\n");
return;
}
static void cb_Numset_but(Fl_Button *, void *)
{
Email_numset();
Emain_window->hide();
}
static void cb_RS_but(Fl_Button *, void *)
{
int i;
if (user_account == 0) {
fl_alert("無帳號可用,請先設定郵件帳號!");
return;
}
for (i = 1; i <= user_account; i++) {
if (number_manage(i, 0, setnum_id) == -1) {
printf("Operation error!\n");
return;
}
if (numset.ifrempass == 1) {
recorsend_email(login); //delete by ydong
} else {
Emain_window->hide();
Email_passport_window(LOGIN_SET);
}
}
send_all_mail(NULL);
}
static void cb_Rmbox_but(Fl_Button *, void *)
{
Mreiv_gp->show();
Msend_gp->hide();
rcvsend = RMBOX;
}
static void cb_Smbox_but(Fl_Button *, void *)
{
Msend_gp->show();
Mreiv_gp->hide();
rcvsend = SMBOX;
}
static void cb_Nmail_but(Fl_Button *, void *)
{
if (user_account == 0) {
fl_alert("無帳號可用,請先設定郵件帳號!");
return;
}
if (number_manage(1, 0, setnum_id) == -1) {
printf("Read from setnum db error!");
return;
}
Emain_window->hide();
if (rcvsend == SMBOX)
Msend_gp->hide();
else
Mreiv_gp->hide();
Email_rw_window(MAIL_WRITE);
}
static void cb_Exit_but(Fl_Button *, void *)
{
int unreg;
if (!fl_ask("真的退出HUC Email?"))
return;
if ((unreg =
unreg_database(setnum_id, newmail_id, oldmail_id,
changelog_id)) == -1) {
printf("unregister database error!\n");
return;
}
#ifdef COMMU_PPP
ApStopCommuStyle("Email");
#endif
win->hide();
exit(0);
}
static void cb_Sm_browser(Fl_Widget *, void *)
{
char *buf, *temp;
buf = (char *) malloc(MAXNEWMAIL);
assert(buf);
if (Sm_browser->text(Sm_browser->value()) != 0) {
if ((temp =
read_fromdatabase(buf, Sm_browser->value(), SEND, newmail_id,
oldmail_id)) == NULL) {
printf("can not read the data from database !\n");
free(buf);
return;
}
Emain_window->hide();
Msend_gp->hide();
Email_rw_window(MAIL_READ);
show_email_content(buf);
free(buf);
} else {
free(buf);
}
return;
}
static void cb_Rm_browser(Fl_Widget *, void *)
{
char *buf = NULL, *temp;
buf = (char *) malloc(MAXRCVMAIL);
assert(buf);
if (Rm_browser->text(Rm_browser->value()) != 0) {
if ((temp =
read_fromdatabase(buf, Rm_browser->value(), RECEIVE,
newmail_id, oldmail_id)) == 0) {
printf("can not read the data from database !\n");
free(buf);
return;
}
Emain_window->hide();
Mreiv_gp->hide();
sum_email = get_the_datanum(oldmail_id);
Email_rw_window(OLD_MAIL_READ);
Email_reic_show(buf);
printf("mail line = %d\n", ((RCV *) buf)->mail_line);
free(buf);
} else {
free(buf);
}
return;
}
#ifdef M_THREAD
void loop_handle(void *)
{
if (RS_but_value == 1) {
RS_but_value = 0;
RS_but->value(0);
RS_but->activate();
RS_but->redraw();
}
Fl::add_timeout(1.0, loop_handle);
return;
}
#endif
int create_main_window()
{
Fl_Color c1 = (Fl_Color) atoi("100");
Fl_Color c2 = (Fl_Color) atoi("200");
Fl::set_color(c1, 204, 255, 204);
Fl::set_color(c2, 153, 255, 153);
{
Fl_Window *o = Emain_window = new Fl_Window(0, 40, WIN_W, WIN_H);
o->color(c1);
win = o;
{
Fl_Button *o = Numset_but =
new Fl_Button(WIN_W / 10, 4 * WIN_H / 5 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "帳號設定");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_Numset_but);
}
{
Fl_Button *o = RS_but =
new Fl_Button(2 * WIN_W / 5, 4 * WIN_H / 5 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "收發郵件");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_RS_but);
}
{
Fl_Button *o = Rmbox_but =
new Fl_Button(7 * WIN_W / 10, 4 * WIN_H / 5 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "收件箱");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_Rmbox_but);
}
{
Fl_Button *o = Smbox_but =
new Fl_Button(WIN_W / 10, 9 * WIN_H / 10 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "發件箱");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_Smbox_but);
}
{
Fl_Button *o = Nmail_but =
new Fl_Button(2 * WIN_W / 5, 9 * WIN_H / 10 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "新郵件");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_Nmail_but);
}
{
Fl_Button *o = Exit_but =
new Fl_Button(7 * WIN_W / 10, 9 * WIN_H / 10 + WIN_H / 50,
WIN_H / 5, 4 * WIN_H / 50, "退出");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->labelsize(8);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
o->callback((Fl_Callback *) cb_Exit_but);
}
{
Fl_Group *o = Msend_gp =
new Fl_Group(0, 0, WIN_W, 4 * WIN_H / 5);
o->color(c1);
{
Fl_Box *o = Smp_box =
new Fl_Box(0, 0, WIN_W / 3, WIN_H / 10, "發件人");
o->color(c1);
o->box(FL_UP_BOX);
}
{
Fl_Box *o = Smt_box =
new Fl_Box(WIN_W / 3, 0, WIN_W / 3, WIN_H / 10,
"收件人");
o->color(c1);
o->box(FL_UP_BOX);
}
{
Fl_Box *o = Smtm_box =
new Fl_Box(2 * WIN_W / 3, 0, WIN_W / 3, WIN_H / 10,
"\261\352\314\342");
o->color(c1);
o->box(FL_UP_BOX);
}
Sm_browser =
new Fl_Select_Browser(0, WIN_H / 10, WIN_W,
7 * WIN_H / 10);
Sm_browser->column_widths(tabs_main);
Sm_browser->color(255);
Sm_browser->callback(cb_Sm_browser, 0);
o->hide();
o->end();
}
{
Fl_Group *o = Mreiv_gp =
new Fl_Group(0, 0, WIN_W, 4 * WIN_H / 5);
o->color(c1);
{
Fl_Box *o = Rmp_box =
new Fl_Box(0, 0, WIN_W / 3, WIN_H / 10,
"\267\242\274\376\310\313");
o->color(c1);
o->box(FL_UP_BOX);
}
{
Fl_Box *o = Rmt_box =
new Fl_Box(WIN_W / 3, 0, WIN_W / 3, WIN_H / 10,
"\312\261\274\344");
o->color(c1);
o->box(FL_UP_BOX);
}
{
Fl_Box *o = Rmtm_box =
new Fl_Box(2 * WIN_W / 3, 0, WIN_W / 3, WIN_H / 10,
"\261\352\314\342");
o->color(c1);
o->box(FL_UP_BOX);
}
Rm_browser =
new Fl_Select_Browser(0, WIN_H / 10, WIN_W,
7 * WIN_H / 10);
Rm_browser->column_widths(tabs_main);
Rm_browser->color(255);
Rm_browser->callback(cb_Rm_browser, 0);
o->end();
}
o->end();
}
#ifdef M_THREAD
RS_but_value = 0;
#endif
number_manage(1, 0, setnum_id);
#ifdef M_THREAD
Fl::add_timeout(1.0, loop_handle);
while (Fl::wait());
return 0;
#else
return Fl::run();
#endif
}
void function(int signo)
{
int unreg;
if ((unreg =
unreg_database(setnum_id, newmail_id, oldmail_id,
changelog_id)) == -1) {
printf("unregister database error!\n");
return;
}
#ifdef COMMU_PPP
ApStopCommuStyle("Email");
#endif
win->hide();
exit(0);
}
int main(int argc, char **argv)
{
signal(SIGINT, function);
#ifdef M_WIN
#ifdef COMMU_PPP
int n;
n = ApStartCommuStyle("Email");
if (n == 0) {
printf("Sorry ! PPP can not start.........\n");
ApStopCommuStyle("Email");
return -1;
}
#endif
main_init(argc, argv);
#endif
choose_user(9, 1);
if ((changelog_id = changelog_data_create()) == -1) {
printf("create/register setnum data error!\n");
return -1;
}
if ((setnum_id = setnum_data_create()) == -1) {
printf("create/register setnum data error!\n");
return -1;
}
if ((oldmail_id = oldmail_data_create()) == -1) {
printf("create/register oldmail data error!\n");
return -1;
}
if ((newmail_id = newmail_data_create()) == -1) {
printf("create/register newmail data error!\n");
return -1;
}
create_main_window();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -