📄 main.c
字号:
tm_globs->unread_even=gtk_style_copy (clist->style);#if 1 tm_globs->unread_odd->font = tm_globs->unread_even->font = gdk_font_load ("-*-helvetica-bold-r-*--*-*-*-*-*-*-*-1"); tm_globs->read_odd->font = tm_globs->read_even->font = gdk_font_load ("-*-helvetica-medium-r-*--*-*-*-*-*-*-*-1");#endif tm_globs->read_even->base[GTK_STATE_NORMAL].red=(0xe0 << 8); tm_globs->read_even->base[GTK_STATE_NORMAL].green=(0xe0 << 8); tm_globs->read_even->base[GTK_STATE_NORMAL].blue=(0xe0 << 8); tm_globs->read_odd->base[GTK_STATE_NORMAL].red=(0xff << 8); tm_globs->read_odd->base[GTK_STATE_NORMAL].green=(0xff << 8); tm_globs->read_odd->base[GTK_STATE_NORMAL].blue=(0xff << 8); tm_globs->unread_even->base[GTK_STATE_NORMAL].red=(0xe0 << 8); tm_globs->unread_even->base[GTK_STATE_NORMAL].green=(0xe0 << 8); tm_globs->unread_even->base[GTK_STATE_NORMAL].blue=(0xe0 << 8); tm_globs->unread_odd->base[GTK_STATE_NORMAL].red=(0xff << 8); tm_globs->unread_odd->base[GTK_STATE_NORMAL].green=(0xff << 8); tm_globs->unread_odd->base[GTK_STATE_NORMAL].blue=(0xff << 8);#if 1 /* trey */ tm_globs->sens_u1 = gtk_style_copy (tm_globs->unread_odd); tm_globs->sens_r1 = gtk_style_copy (tm_globs->read_odd); tm_globs->sens_u1->base[GTK_STATE_NORMAL].red = tm_globs->sens_r1->base[GTK_STATE_NORMAL].red = (0xe0 << 8); tm_globs->sens_u1->base[GTK_STATE_NORMAL].green = tm_globs->sens_r1->base[GTK_STATE_NORMAL].green = (0xa0 << 8); tm_globs->sens_u1->base[GTK_STATE_NORMAL].blue = tm_globs->sens_r1->base[GTK_STATE_NORMAL].blue = (0xa0 << 8); tm_globs->sens_u2 = gtk_style_copy (tm_globs->unread_odd); tm_globs->sens_r2 = gtk_style_copy (tm_globs->read_odd); tm_globs->sens_u2->base[GTK_STATE_NORMAL].red = tm_globs->sens_r2->base[GTK_STATE_NORMAL].red = (0xa0 << 8); tm_globs->sens_u2->base[GTK_STATE_NORMAL].green = tm_globs->sens_r2->base[GTK_STATE_NORMAL].green = (0xa0 << 8); tm_globs->sens_u2->base[GTK_STATE_NORMAL].blue = tm_globs->sens_r2->base[GTK_STATE_NORMAL].blue = (0xe0 << 8); tm_globs->sens_u3 = gtk_style_copy (tm_globs->unread_odd); tm_globs->sens_r3 = gtk_style_copy (tm_globs->read_odd); tm_globs->sens_u3->base[GTK_STATE_NORMAL].red = tm_globs->sens_r3->base[GTK_STATE_NORMAL].red = ((0xa0-40) << 8); tm_globs->sens_u3->base[GTK_STATE_NORMAL].green = tm_globs->sens_r3->base[GTK_STATE_NORMAL].green = ((0xa0-40) << 8); tm_globs->sens_u3->base[GTK_STATE_NORMAL].blue = tm_globs->sens_r3->base[GTK_STATE_NORMAL].blue = (0xe0 << 8); tm_globs->sens_u4 = gtk_style_copy (tm_globs->unread_odd); tm_globs->sens_r4 = gtk_style_copy (tm_globs->read_odd); tm_globs->sens_u4->base[GTK_STATE_NORMAL].red = tm_globs->sens_r4->base[GTK_STATE_NORMAL].red = (0xe0 << 8); tm_globs->sens_u4->base[GTK_STATE_NORMAL].green = tm_globs->sens_r4->base[GTK_STATE_NORMAL].green = ((0xa0-40) << 8); tm_globs->sens_u4->base[GTK_STATE_NORMAL].blue = tm_globs->sens_r4->base[GTK_STATE_NORMAL].blue = ((0xa0-40) << 8); tm_globs->sens_u5 = gtk_style_copy (tm_globs->unread_odd); tm_globs->sens_r5 = gtk_style_copy (tm_globs->read_odd); tm_globs->sens_u5->base[GTK_STATE_NORMAL].red = tm_globs->sens_r5->base[GTK_STATE_NORMAL].red = (0xe0 << 8); tm_globs->sens_u5->base[GTK_STATE_NORMAL].green = tm_globs->sens_r5->base[GTK_STATE_NORMAL].green = (0xa0 << 8); tm_globs->sens_u5->base[GTK_STATE_NORMAL].blue = tm_globs->sens_r5->base[GTK_STATE_NORMAL].blue = (0xa0 << 8);#endif tm_globs->pid=-1; tm_globs->rlist=NULL; tm_globs->rsel=NULL; tm_globs->vsel=NULL; pipe(tm_globs->dpipe); pipe(tm_globs->pspipe); pipe(tm_globs->cspipe); if (fcntl (tm_globs->dpipe[0], F_SETFL, O_NONBLOCK)==-1) {#ifdef DEBUG insert_error ("error while setting non-blocking on pipe\n");#endif } if (fcntl (tm_globs->pspipe[0], F_SETFL, O_NONBLOCK)==-1) {#ifdef DEBUG insert_error ("error while setting non-blocking on pipe\n");#endif } if (fcntl (tm_globs->cspipe[0], F_SETFL, O_NONBLOCK)==-1) {#ifdef DEBUG insert_error ("error while setting non-blocking on pipe\n");#endif } tm_globs->debug.red=0; tm_globs->debug.blue=255; tm_globs->debug.green=0; tm_globs->warning.red=255; tm_globs->warning.blue=0; tm_globs->warning.green=255; tm_globs->error.red=255; tm_globs->error.blue=0; tm_globs->error.green=0; tm_globs->message.red=0; tm_globs->message.blue=0; tm_globs->message.green=255; gtk_timeout_add (60000, (GtkFunction)message_anti_leak, NULL); calendar_load ();}int puma_sigsegv (int blah) { return -1;}int pop_count_accounts () { PopAccount *account=first_popaccount (); int count=0; for (;account;account=account->next) { count++; } return count;}void grey_out_stuff () { GtkWidget *get_message=lookup_widget (tm_globs->main_window, "get_message"); GtkWidget *new_message=lookup_widget (tm_globs->main_window, "new_message"); int pc=pop_count_accounts (); if (pc==0) { gtk_widget_set_sensitive (get_message, FALSE); gtk_widget_set_sensitive (new_message, FALSE); } else { gtk_widget_set_sensitive (get_message, TRUE); gtk_widget_set_sensitive (new_message, TRUE); }}void self_check () { { // storage verification PopAccount *seek=first_popaccount (); while (seek) { if (folder_seek_by_name (seek->folder)==-1) { free (seek->folder); seek->folder=strdup (_("Inbox")); } seek=seek->next; } seek=first_popaccount (); if (seek) { if (tm_globs->default_account) { if (seek_popaccount_by_name (tm_globs->default_account)==-1) { insert_warning (_("Default account self check failed. Resetting to first account\n")); seek=seek_popaccount (0); tm_globs->default_account=strdup (seek->name); } } else { insert_warning (_("Default account self check failed. Resetting to first account\n")); tm_globs->default_account=strdup (seek->name); } } } { // Filter rule verification GList *seek, *d=NULL; for (seek=filter_first ();seek;seek=seek->next) { FilterRule *rule=seek->data; if (rule->folder) { if (folder_seek_by_name (rule->folder)==-1) { d=g_list_append (d, rule); } } } for (seek=d;seek;seek=seek->next) { filter_delete_rule (seek->data); } if (d) g_list_free (d); } {// Folder storeable verification Folder *fl; for (fl=folder_first ();fl;fl=fl->next) { if (strcasecmp (fl->name, "outbox") != 0 && strcasecmp (fl->name, "sent-items") != 0 && strcasecmp (fl->name, "trash") != 0 && (fl->flags & CAN_STORE_NEW_MAIL) == 0) { fl->flags |= CAN_STORE_NEW_MAIL; } } } {// Event verification Llist *seek; GList *destroy=NULL, *gseek; for (seek=event_first();seek;seek=seek->next) { CalendarEvent *event=seek->data; if (!event) { insert_error (_("Calendar Data is apparently corrupt, attempting to continue\n")); } else { if (!event->start) { insert_error (_("Event '%s' is corrupt, deleting\n"), event->subject); destroy=g_list_append (destroy, event); goto done; } if (!event->stop) { insert_error (_("Event '%s' is corrupt, deleting\n"), event->subject); destroy=g_list_append (destroy, event); goto done; } if (event->start->time == event->stop->time) { insert_error (_("Event '%s' is corrupt, deleting\n"), event->subject); destroy=g_list_append (destroy, event); }done: } } for (gseek=destroy;gseek;gseek=gseek->next) { event_destroy (gseek->data); } }}int main (int argc, char **argv) { Folder *fl; PopAccount *acct;#ifdef LANG_DEBUG lang_load_external ("lang.db"); lang_startup ();#else lang_generate_list ();#endif abook_set_question_func ((QuestionFunc)create_yesno); startup (argc, argv); make_default_prefrances (); window_sizes_rehash(); paned_pos_rehash(); clist_pos_rehash(); folders_read (); folders_read_index (); fl=folder_first (); while (fl) {create_new_folder (fl); fl=fl->next;} if (load_preferences ()==-1) { insert_warning (_("Unable to load Preferences. New preferences file has been created.\n")); grey_out_stuff (); } /* go through list of mail accounts and pick out the imap ones */ acct = first_popaccount (); while (acct) { if (acct->type == IMAP) { nf_add_imap_acct (acct); } acct = acct->next; } mime_type_add_defaults (); gtk_widget_show (tm_globs->main_window); if (!tm_globs->printer) tm_globs->printer = strdup("lpr"); abooks_read (); abooks_load_all (); abooks_save_all (); mime_types_rehash_clist (); self_check (); /* I'm pretty sure that the wasted space values don't need to be * updated every second. Once per 10 seconds should be fine! */ prefs_show(0); tm_globs->wsflag = 1; prefs_setup_info() ; gtk_timeout_add( 10000, (GtkFunction)prefs_setup_info, NULL ) ; /* This actually does more that I thought. We need it to check * very often since this is where completion events are checked. In * other words, when we are finished receiving messages, the GUI isn't * notified until this timer fires and has a chance to be updated. As * such, 60-seconds is a VERY bad idea. Now, we check every ~1/2 second. */ tm_globs -> getMsgTimeout = gtk_timeout_add( 950, (GtkFunction)message_event_loop, NULL ) ; /* Add a timer to maintain our event notifications */ calendar_event_loop() ; tm_globs -> eventLoopTimeout = gtk_timeout_add( 60*60*1000, (GtkFunction)calendar_event_loop, NULL ) ; /* Now, set up global configuration for c-client code */#include "linkage.c" #ifdef NEWMAILBACKEND mail_parameters( NULL, SET_RFC822OUTPUT, (void *)post_rfc822_output) ;#endif#ifdef WANTLDAP /* This builds and populates the GAB initially */ gab_update_wrapper( NULL ) ;#endif /* clear the undo list to get ready */ clear_undo_list (); /* Go into the GTK main event loop */ gtk_main() ;#ifdef LANG_DEBUG lang_save_internal ("include/lang-database.h"); lang_save_external ("lang.db");#endif lang_shutdown (); return 0;}#ifdef WANTLDAPintgab_update_search (gpointer data, char *target){ int retval = 0; char *base = NULL; char *filter = NULL; char *name = NULL; char *pass = NULL; if (tm_globs->ldap_port == 0) tm_globs->ldap_port = 389;#ifdef WANTSSL if (tm_globs->ldap_ssl) tm_globs->ldap_ssl = 0;#endif if (tm_globs->ldap_base) base = strdup (tm_globs->ldap_base); else base = strdup (""); if (target) filter = strdup (target); if (tm_globs->ldap_username) { name = malloc ((strlen (tm_globs->ldap_username) + 4) * sizeof (char)); sprintf (name, "cn=%s", tm_globs->ldap_username); } else name = strdup (""); if (tm_globs->ldap_password) pass = strdup (tm_globs->ldap_password); else pass = strdup (""); if (tm_globs->ldap_host) update_gab (tm_globs->ldap_host, tm_globs->ldap_port, base, name, pass, filter); else retval = 1; if (base) free (base); if (name) free (name); if (pass) free (pass); return retval;}void gab_update_wrapper (gpointer data) { char *tmp ; int baseal ; char *base ; char *ptmp ; /* Make sure we have a default port correctly configured. */ if( tm_globs -> ldap_port == 0 ) tm_globs -> ldap_port = 389 ;#ifdef WANTSSL if (!tm_globs->ldap_ssl) tm_globs->ldap_ssl=0;#endif /* Make sure we always have a base dn */ if( !tm_globs -> ldap_base) { base = strdup( "" ) ; baseal = 1 ; } else { base = tm_globs -> ldap_base ; baseal = 0 ; } /* Now, make sure we have a username to auth against */ if( tm_globs -> ldap_username ) { /* We allloc +4 for the "cn=" (3) plus a null. */ tmp = malloc( (strlen(tm_globs -> ldap_username)+4)*sizeof(char) ) ; sprintf( tmp, "cn=%s", tm_globs -> ldap_username ) ; } else { tmp = strdup( "" ) ; } /* See if we are configed to log on */ if( (tm_globs -> ldap_host) && (tm_globs -> ldap_username) && (tm_globs -> ldap_password) ) { update_gab( tm_globs -> ldap_host, tm_globs -> ldap_port, base, tmp, tm_globs -> ldap_password, NULL ) ; } else { /* This is for anonymous access */ if( tm_globs -> ldap_host ) { ptmp = strdup( "" ) ; update_gab( tm_globs -> ldap_host, tm_globs -> ldap_port, base, tmp, ptmp, NULL ) ; free( ptmp ) ; } } if( baseal ) free( base ) ; free( tmp ) ; return ; }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -