?? email_portpass.cxx
字號:
// generated by Fast Light User Interface Designer (fluid) version 1.0010
#include <pthread.h>
#include <assert.h>
#include "Email_portpass.h"
#ifdef COMMU_PPP
#include "commu_db.h"
#endif
char *format(char *p0, char *p1, char *p2);
pthread_mutex_t count_mutex = PTHREAD_MUTEX_INITIALIZER;
void func(int signo)
{
int unreg;
if ((unreg =
unreg_database(setnum_id, newmail_id, oldmail_id,
changelog_id)) == -1) {
printf("unregister database error!\n");
#ifdef COMMU_PPP
ApStopCommuStyle("Email");
#endif
exit(-1);
}
#ifdef COMMU_PPP
ApStopCommuStyle("Email");
#endif
return;
}
void free_mail(Rmail * p)
{
if (p->sender != NULL) {
free(p->sender);
p->sender = NULL;
printf("free p->sender complete\n");
}
if (p->receiver != NULL) {
free(p->receiver);
p->receiver = NULL;
printf("free p->receiver complete\n");
}
if (p->date != NULL) {
free(p->date);
p->date = NULL;
printf("free p->date complete\n");
}
if (p->subject != NULL) {
free(p->subject);
p->subject = NULL;
printf("free p->subject complete\n");
}
if (p->content != NULL) {
free(p->content);
p->content = NULL;
printf("free p->content complete\n");
}
if (p->attach_file != NULL) {
free(p->attach_file);
p->attach_file = NULL;
printf("free p->attachfile complete\n");
}
if (p != NULL) {
free(p);
p = NULL;
printf("free p complete\n");
}
}
void print_all_popmail(struct RmailList *rmail)
{
int i;
int db_num, logdb_num;
Rmail *p = popmail.mail;
Rmail *q = p;
struct new_rvmail *rvmail;
struct loginfo *logbuf;
rvmail = (struct new_rvmail *) malloc(MAXRCVMAIL);
if ((db_num = get_the_datanum(oldmail_id)) == -1) {
printf("get record number error!\n");
}
printf("there are %d new mails.\n", popmail.total);
for (i = 0; i < popmail.total; i++) {
rvmail->mail_line = i + db_num;
snprintf(rvmail->user, 20, "%s", USERNAME);
rvmail->mailid = total_mailid++;
if (p->sender != NULL)
snprintf(rvmail->sender, 64, "%s", p->sender);
if (p->receiver != NULL)
snprintf(rvmail->receiver, 64, "%s", p->receiver);
if (p->date != NULL)
snprintf(rvmail->date, 40, "%s", p->date);
if (p->subject != NULL)
snprintf(rvmail->subject, 64, "%s", p->subject);
if (p->messageid != NULL)
snprintf(rvmail->messageid, 128, "%s", p->messageid);
if (p->content != NULL)
snprintf(rvmail->content, 1024, "%s\n", p->content);
if (add_oldmail2db(rvmail, oldmail_id) == -1) {
printf("add record(oldmail) error!\n");
}
logdb_num = db_get_record_number(changelog_id);
logbuf = (struct loginfo *) malloc(MAXCHLOG);
logbuf->order = logdb_num;
logbuf->mailid = rvmail->mailid;
logbuf->opid = 0;
strncpy(logbuf->user, USERNAME, 20);
add_changelog2db(logbuf, changelog_id);
free(logbuf);
Rm_browser->insert(++user_oldmail,
format(p->sender, p->date, p->subject));
p = p->next;
q = p;
}
if (!numset.ifrempass) {
Mportpass_set_wnidow->hide();
Emain_window->redraw();
Emain_window->show();
}
Mreiv_gp->show();
Msend_gp->hide();
Mreiv_gp->redraw();
return;
}
int send_the_mail(char *buf)
{
int securstyle = 1;
Mlist *mimefiles = NULL;
if (eml_prepare_mail
(numset.smtp, atoi(numset.smtpport), ((NEW *) buf)->from,
((NEW *) buf)->to, ((NEW *) buf)->cc, ((NEW *) buf)->subject,
((NEW *) buf)->textbody, mimefiles) != SUCCESS) {
printf("%s\n ", smtpArror());
return -1;
}
if (securstyle)
if (eml_send_mail_needAuth
(&smtpserver, &mymail, numset.mnum, numset.passwd) != SUCCESS)
{
printf("%s\n ", smtpArror());
return -1;
}
if (!securstyle)
if (eml_send_mail_noNeedAuth(&smtpserver, &mymail) != SUCCESS) {
printf("%s\n ", smtpArror());
return -1;
}
return 0;
}
void *send_all_mail(void *)
{
char *buf = NULL;
int sum = user_newmail;
int i = 0;
if ((buf = (char *) malloc(MAXNEWMAIL)) == NULL) {
printf("can not send .malloc failed.\n");
return NULL;
}
printf("THERE ARE %d mailS IN SEND_BOX\n", user_newmail);
for (i = 1; i <= user_newmail; i++) {
printf("\nNow, deal with NO.%d mail:\n", i);
buf = read_fromdatabase(buf, i, SEND, newmail_id, oldmail_id);
if (send_the_mail(buf) == -1) {
printf("send No:%d mail error!\n", i);
return NULL;
}
}
for (i = 1; i <= sum; i++) {
delete_mail(newmail_id, oldmail_id, 1, NEW_MAIL_READ);
}
return NULL;
}
int recorsend_email(Login login)
{
#ifdef M_THREAD
pthread_t pt;
#endif
char host[30];
Server popserver;
char smtphost[30];
char username[30];
char password[30];
signal(SIGSEGV, func);
// add by posaidong
strcpy(host, numset.pop3);
strcpy(username, numset.mnum);
strcpy(smtphost, numset.smtp);
if (numset.ifrempass == 1)
strcpy(password, numset.passwd);
else
strcpy(password, login.userpasswd);
snprintf(popserver.hostname, 32, host);
popserver.port = 110;
prepare_popmail(&popmail);
if (eml_pop3_mails
(&popserver, username, password,
numset.ifemptyserver) != SUCCESS) {
printf("PASSWD WRONG%s\n", pop3error());
fl_alert("無法接收郵件!密碼錯誤或網絡未連接!\n");
return -1;
}
print_all_popmail(&popmail);
return 0;
}
static void cb_Mport_fir_chkbut(Fl_Check_Button *, void *)
{
if (Mport_fir_chkbut->value() == 1) {
Mport_pop_in->value("110");
Mport_pop_in->deactivate();
Mport_smtp_in->value("25");
Mport_smtp_in->deactivate();
} else {
Mport_pop_in->activate();
Mport_smtp_in->activate();
}
}
static void cb_Mport_con_but(Fl_Button *, void *)
{
strcpy(numset.pop3port, Mport_pop_in->value());
strcpy(numset.smtpport, Mport_smtp_in->value());
Mportpass_set_wnidow->hide();
Mnb_chr_window->show();
}
static void cb_Mport_canc_but(Fl_Button *, void *)
{
Mportpass_set_wnidow->hide();
Mnb_chr_window->show();
}
int get_login(Login * login)
{
int null_flag = NON_EMPTY;
if (strlen(Mlogin_ser_in->value()) == 0)
null_flag = EMPTY_ERROR;
else
login->servname = strdup(Mlogin_ser_in->value());
if (strlen(Mlogin_user_in->value()) == 0)
null_flag = EMPTY_ERROR;
else
login->username = strdup(Mlogin_user_in->value());
if (strlen(Mlogin_pass_in->value()) == 0)
null_flag = EMPTY_ERROR;
else
login->userpasswd = strdup(Mlogin_pass_in->value());
if (null_flag == EMPTY_ERROR) {
fl_alert("請輸入帳號密碼!\n");
return -1;
}
return 0;
}
static void cb_Mlogin_con_but(Fl_Button *, void *)
{
Login login;
if (get_login(&login) < 0)
return;
if (mail_cmd == NEW_MAIL) {
Mportpass_set_wnidow->hide();
Mold_read_window->show();
} else
recorsend_email(login);
Mportpass_set_wnidow->hide();
Emain_window->show();
}
static void cb_Mlogin_canc_but(Fl_Button *, void *)
{
Mportpass_set_wnidow->hide();
Emain_window->show();
}
int Email_passport_window(int COMMAND)
{
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);
mail_cmd = COMMAND;
Fl_Window *w;
{
Fl_Window *o = Mportpass_set_wnidow =
new Fl_Window(0, 40, PPW_W, PPW_H);
w = o;
o->color(c1);
{
Fl_Group *o = Mport_set_gp = new Fl_Group(0, 0, PPW_W, PPW_H);
o->color(c1);
{
Fl_Input *o = Mport_pop_in =
new Fl_Input(2 * PPW_W / 3, PPW_H / 10, PPW_W / 6,
PPW_H / 8,
"pop3\267\376\316\361\306\367\266\313\277\332\272\305\243\272");
o->color(255);
o->box(FL_BORDER_BOX);
if (strlen(numset.pop3port) == 0)
o->value("110");
else
o->value(numset.pop3port);
o->redraw();
}
{
Fl_Input *o = Mport_smtp_in =
new Fl_Input(2 * PPW_W / 3, PPW_H * 11 / 40, PPW_W / 6,
PPW_H / 8,
"smtp\267\376\316\361\306\367\266\313\277\332\272\305\243\272");
o->color(255);
o->box(FL_BORDER_BOX);
if (strlen(numset.smtpport) == 0)
o->value("25");
else
o->value(numset.smtpport);
o->redraw();
}
{
Fl_Check_Button *o = Mport_fir_chkbut =
new Fl_Check_Button(PPW_W / 3, PPW_H / 2, PPW_H / 8,
PPW_H / 8,
"\312\271\323\303\304\254\310\317\326\265");
o->color(c1);
o->down_box(FL_DIAMOND_DOWN_BOX);
o->callback((Fl_Callback *) cb_Mport_fir_chkbut);
}
{
Fl_Button *o = Mport_con_but =
new Fl_Button(PPW_W * 7 / 30, PPW_H * 4 / 5, PPW_W / 5,
PPW_H / 8,
"\310\267\310\317");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->callback((Fl_Callback *) cb_Mport_con_but);
}
{
Fl_Button *o = Mport_canc_but =
new Fl_Button(PPW_W * 17 / 30, PPW_H * 4 / 5,
PPW_W / 5, PPW_H / 8,
"\310\241\317\373");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->callback((Fl_Callback *) cb_Mport_canc_but);
}
if (COMMAND != PORT_SET)
o->hide();
o->end();
}
{
Fl_Group *o = Mlogin_gp = new Fl_Group(0, 0, PPW_W, PPW_H);
o->color(c1);
{
Fl_Box *o = Mlogin_box =
new Fl_Box(0, PPW_H / 20, PPW_W, PPW_H / 10,
"\307\353\312\344\310\353\304\372\324\332\317\302\301\320\267\376\316\361\306\367\311\317\265\304\323\303\273\247\303\373\274\260\303\334\302\353\243\272");
o->color(c1);
o->box(FL_FLAT_BOX);
o->labelsize(10);
o->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
}
{
Fl_Input *o = Mlogin_ser_in =
new Fl_Input(PPW_W / 3, PPW_H * 3 / 20,
PPW_W * 2 / 3 - PPW_W / 10,
PPW_H / 8,
"\267\376\316\361\306\367\243\272");
o->color(255);
o->box(FL_BORDER_BOX);
o->value(numset.pop3);
o->deactivate();
}
{
Fl_Input *o = Mlogin_user_in =
new Fl_Input(PPW_W / 3, PPW_H * 13 / 40,
PPW_W * 2 / 3 - PPW_W / 10, PPW_H / 8,
"\323\303\273\247\303\373\243\272");
o->color(255);
o->box(FL_BORDER_BOX);
o->value(numset.mnum);
o->deactivate();
}
{
Fl_Input *o = Mlogin_pass_in =
new Fl_Secret_Input(PPW_W / 3, PPW_H / 2,
PPW_W * 2 / 3 - PPW_W / 10,
PPW_H / 8,
"\303\334\302\353\243\272");
o->color(255);
o->box(FL_BORDER_BOX);
}
{
Fl_Button *o = Mlogin_con_but =
new Fl_Button(PPW_W * 7 / 30, PPW_H * 4 / 5, PPW_W / 5,
PPW_H / 8,
"\310\267\310\317");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->callback((Fl_Callback *) cb_Mlogin_con_but);
}
{
Fl_Button *o = Mlogin_canc_but =
new Fl_Button(PPW_W * 17 / 30, PPW_H * 4 / 5,
PPW_W / 5, PPW_H / 8,
"\310\241\317\373");
o->color(c2);
o->selection_color(c2);
o->box(FL_THIN_UP_BOX);
o->callback((Fl_Callback *) cb_Mlogin_canc_but);
}
if (COMMAND != LOGIN_SET && COMMAND != NEW_MAIL)
o->hide();
o->end();
}
o->end();
}
w->show();
while (w->visible())
Fl::wait();
return 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -