⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main-window-callbacks.c

📁 一个功能全面的电子邮件客户端
💻 C
📖 第 1 页 / 共 5 页
字号:
			gtk_clist_set_row_data (clist2, gtk_clist_append (clist2, cl_data), afs);			free (cl_data[0]);			free (cl_data[1]);			free (cl_data[2]);		}	}	if (hinfo->from) {		rfc822_parse_adrlist(&adrlist,hinfo->from,"");		for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {			snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);			recip -> tree = tree ;			recip -> email = adrbuffer ;			recip -> type = 0 ;			new_message_window_add_recip( NULL, recip ) ;		}		mail_free_address(&adrlist);		adrlist=NIL;	}        if (hinfo->to) {		rfc822_parse_adrlist(&adrlist,hinfo->to,"");                for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {                        snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);			if(!popaccount_is_my_address(adrbuffer))			  {			    recip -> tree = tree ;			    recip -> email = adrbuffer ;			    recip -> type = 0 ;			    new_message_window_add_recip( NULL, recip ) ;			  }		}                mail_free_address(&adrlist);                adrlist=NIL;        }        if (hinfo->cc) {		rfc822_parse_adrlist(&adrlist,hinfo->cc,"");                for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {                        snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);			if(!popaccount_is_my_address(adrbuffer))			  {			    recip -> tree = tree ;			    recip -> email = adrbuffer ;			    recip -> type = 1 ;			    new_message_window_add_recip( NULL, recip ) ;			  }		}                mail_free_address(&adrlist);                adrlist=NIL;        }	subject=lookup_widget (window, "subject_entry");	if(!hinfo->subject) hinfo->subject = strdup("");	tmp=(char *)calloc (strlen(hinfo->subject)+5, sizeof(char));	if (strncasecmp ("re:", hinfo->subject, 3)!=0)		snprintf (tmp, strlen(hinfo->subject)+5, "Re: %s", hinfo->subject);	else		snprintf (tmp, strlen(hinfo->subject)+5, "%s", hinfo->subject);	if (tmp) gtk_entry_set_text (GTK_ENTRY (subject), tmp);	destroy_hinfo (hinfo);	if (g_list_length (tree->children)==0) {	  recip -> tree = tree ;	  recip -> email = NULL ;	  recip -> type = 0 ;	  new_message_window_add_recip( NULL, recip ) ;	}	if( tmp ) free (tmp);}void reply_to_all_clicked (GtkWidget *widget, gpointer data) {	Message *msg=tm_globs->msg_selected;	int hsize;	Header_Info *hinfo;	char *tmp, *message, *head;	GtkWidget *window;	GtkTree *tree;	GtkWidget *body=NULL;	GtkWidget *subject;	GtkWidget *clist=lookup_widget (tm_globs->main_window, "message_clist");	RecipSignalData *recip ;	GtkCList *clist2;	char *cl_data[3];        ADDRESS *adrlist = NIL, *adrseek = NIL;        char adrbuffer[4096];	char *tmpadr;	AFS *afs;	msg=tm_globs->msg_selected;	window=make_new_message_window (NULL, NULL);	tree=GTK_TREE (lw (window, "recip_tree"));	gtk_tree_clear_items (tree, 0, g_list_length (tree->children));	body=lookup_widget (window, "body_textbox"); // fixes your problems	message=message_load (folder_seek (folder_seek_by_name (msg->rfolder)), msg);	hsize=message_hsize (message);	head=(char *)calloc (hsize+2, sizeof(char));	memmove (head, message, hsize);	free (message);	hinfo=parse_header (head);	free (head);	recip = calloc( 1, sizeof(RecipSignalData) ) ;	if (!(tm_globs->flags & REPLY_NONE)) {		if (tm_globs->flags & REPLY_QUOTED) {			message=message_get_reply_quoted (msg);			gtk_text_insert (GTK_TEXT (body), NULL, NULL, NULL, message, -1);			free (message);		} else {			clist2=GTK_CLIST (lw (window, "attachment_clist"));			afs=(AFS *)calloc (1, sizeof (AFS));			afs->data=strdup (message);			afs->type=strdup ("message/rfc822");			cl_data[0]=strdup ("message/rfc822");			cl_data[1]=strdup ("Original Message");			cl_data[2]=(char *)calloc (20, sizeof (char));			snprintf (cl_data[2], 19, "%lu", (unsigned long)strlen (message));			gtk_clist_set_row_data (clist2, gtk_clist_append (clist2, cl_data), afs);			free (cl_data[0]);			free (cl_data[1]);			free (cl_data[2]);		}	}	if ((msg)&&(GTK_CLIST (clist)->selection)) {        if (hinfo->from) {		tmpadr=strdup(hinfo->from);                rfc822_parse_adrlist(&adrlist,tmpadr,"");                for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {                        snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);			recip -> tree = tree ;			recip -> email = adrbuffer ;			recip -> type = 0 ;			new_message_window_add_recip( NULL, recip ) ;                }                mail_free_address(&adrlist);                adrlist=NIL;		free(tmpadr);        }        if (hinfo->to) {		tmpadr=strdup(hinfo->to);                rfc822_parse_adrlist(&adrlist,tmpadr,"");                for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {                        snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);                        if(!popaccount_is_my_address(adrbuffer))			  {			    recip -> tree = tree ;			    recip -> email = adrbuffer ;			    recip -> type = 0 ;			    new_message_window_add_recip( NULL, recip ) ;			  }                }                mail_free_address(&adrlist);                adrlist=NIL;		free(tmpadr);        }        if (hinfo->cc) {		tmpadr=strdup(hinfo->cc);                rfc822_parse_adrlist(&adrlist,tmpadr,"");                for (adrseek=adrlist; adrseek; adrseek=adrseek->next) {                        snprintf(adrbuffer, 4096, "%s@%s", adrseek->mailbox,adrseek->host);                        if(!popaccount_is_my_address(adrbuffer))			  {			    recip -> tree = tree ;			    recip -> email = adrbuffer ;			    recip -> type = 1 ;			    new_message_window_add_recip( NULL, recip ) ;			  }                }                mail_free_address(&adrlist);                adrlist=NIL;		free(tmpadr);        }		destroy_hinfo (hinfo);		subject=lookup_widget (window, "subject_entry");		tmp=(char *)calloc (strlen(msg->subject)+5, sizeof(char));		if (strncasecmp ("re:", msg->subject, 3)!=0)			snprintf (tmp, strlen(msg->subject)+5, "Re: %s", msg->subject);		else			snprintf (tmp, strlen(msg->subject)+5, "%s", msg->subject);		if (tmp) gtk_entry_set_text (GTK_ENTRY (subject), tmp);		free (tmp);	}}void main_window_sender_add (GtkWidget *widget, gpointer data) {	Abook *abook=data;	Message *msg=tm_globs->msg_selected;	if (msg) {		char *email, *first, *last;		if (parse_from_line (msg->from, &email, &first, &last)) {			if (!abook_entry_seek_by_email (abook, email)) {				Abook_entry *entry=abook_entry_new (abook);				abook_entry_set_default (entry, email);				entry->first=first;				entry->last=last;				abook_entry_create (entry, entry);			} else {				insert_warning ("You already have them in that addressbook\n");			}		} else {			insert_error ("Unable to parse from line\n");		}	}}/* * This function has really BAD race conditions in it.  We need to make sure * that accounts are checked serially for now.  Hopefully in the near future, * we'll check all accounts concurrently. */int message_event_loop () {  int cnt ;  int isBusy ;  int busyID ;  PopAccount *pop;  time_t t=time (NULL);#ifdef DMALLOC  dmalloc_verify( NULL ) ;#endif  /*   * Notice, if we are already checking messages, don't do this!   * If this is the case, return and don't poll the accounts.   * The catch is, this only checks against when the use has   * hit the get messages button.  It doesn't guard against this   * function being called multiple times per second!   */#if DEBUG > 4  printf( "message_event_loop() is running on timer.\n" ) ;#endif  cnt = 0 ;  if( tm_globs -> pid == -1 ) {    /*     * Count how many accounts we have and figure out if any are busy.     */    isBusy = 0 ;    busyID = -1 ;        for( pop = first_popaccount() ; pop ; pop = pop -> next ) {#if DEBUG > 4      printf( "#%d has pid of %d && spid of %d.\n", pop -> id, pop -> pid, pop -> spid ) ;#endif      if( (pop -> pid != -1) || (pop -> spid != -1) ) isBusy = 1 ;      if( (busyID == -1 ) && (pop -> busy) ) busyID = cnt ;      cnt++ ;    }#if DEBUG > 4    printf( "There are %d accounts that may need to be serviced.  isBusy = %d\n", cnt, isBusy ) ;#endif    if( (isBusy == 0) && (cnt) ) {      /* Now, figure out which account to check is next */      if( busyID == -1 ) busyID = 0 ;      else {	pop = seek_popaccount( busyID ) ;	if( pop ) {	  pop -> busy = 0 ;	  busyID = (++busyID)%cnt ;	}      }#ifdef DMALLOC	dmalloc_verify( NULL ) ;#endif      /* Now, see if we need to attend to the account */#if DEBUG > 4      printf( "Checking account %d on timer basis.\n", busyID ) ;#endif      pop = seek_popaccount( busyID ) ;      if( pop ) {	pop -> busy = 1 ;	if( (pop->check_at == 0) && (pop->timeout != 0) ) pop -> check_at = t + pop->timeout * 60 ;	if( (pop->check_at <= t) && (pop->timeout != 0) ) {	  insert_message( _("Automatically fetching messages on account '%s'.  'Get Messages' is disabled for the duration.\n"), pop->name);	  pop->check_at= t + pop->timeout * 60;		  	  /*	   * Since we are fetching messages, we need to disable the GUI to keep a conflict	   * of a double fetch from biting us.  Don't worry, when the fetch announces a	   * "DONE", the GUI will be unlocked again.  Ya!  Sweet!	   */	  gtk_widget_set_sensitive( lookup_widget( tm_globs -> main_window, "get_message" ), FALSE ) ;	  gtk_widget_set_sensitive( lookup_widget( tm_globs -> status, "stopthat" ), TRUE ) ;	  gtk_widget_set_sensitive( lookup_widget( tm_globs -> status, "skip"), TRUE ) ;	  if( !(tm_globs->flags & HIDE_STATUS_WINDOW) ) show_status( NULL, NULL ) ;	  	  /* Get the messages *//* no! don't remove the timeout, wtf? 	  gtk_timeout_remove( tm_globs -> getMsgTimeout ) ;*/#if 0          if (pop->type==IMAP) {		nf_imap_check_mail (pop);          } else {		fork_receive_message1 (pop->id, 1);	  }#else		fork_receive_messages (pop->id);#endif	  	  /* Make sure we know when it's done. */	  tm_globs->getMsgTimeout=gtk_timeout_add( 125, (GtkFunction)get_message_timeout, NULL ) ;	}      }    }  }#ifdef DMALLOC  dmalloc_verify( NULL ) ;#endif#if DEBUG > 8  printf( "Counted %d accounts that are ready to fetch from.\n", cnt ) ;#endif  return TRUE ;}/* * This function is the event loop that handles calendar reminders * and application execution.  It should fire once every hour.  In * short, this loop will look for the nearest event to schedule. * When it determines the closest event, it will create another * timer to only handle the single event.  In turn, it will cause * this event to trigger again to automatically cause it to be * rescheduled any other pending (closest) event.  As a reminder, * this function should be called anytime an event is added or deleted. */intcalendar_event_loop(){  Llist *ev ;  time_t ct ;  int waitTime ;  CalendarEvent *cev ;  CalendarEvent *nearEvent ;  /* If there are no pending events, just reschedule us and return. */#ifdef DMALLOC  dmalloc_verify( NULL ) ;#endif  ev = event_first() ;  if( ev )    {      /* Remember, we really only want the events that have reminders */      ct = time( NULL ) ;      nearEvent = (CalendarEvent *)NULL ;      while( ev )	{	  /* Grab the event node from the current linked node */	  cev = (CalendarEvent *)ev -> data ;	  if( cev -> flags & EVENT_REMINDER )	    {	      if( !nearEvent &&		  (cev -> start -> time - ((cev -> reminder)*60)) >= ct )		{		  nearEvent = cev ;		}	      else		{		  /*		   * Don't forget that we need to also include pre-time offset		   * in our calculation.		   */		  if( ((cev -> start -> time - (((cev -> reminder)*60))) >= ct) &&		      ((cev -> start -> time - ((cev -> reminder)*60)) <		       (nearEvent -> start -> time - ((nearEvent -> reminder)*60))) )		    nearEvent = cev ;		}	    }	  /* Go to the next linked node */	  ev = ev -> next ;	}      if( nearEvent )	{	  /*	   * Now we find the soonest that a reminder event will need to fire, so let's	   * calculate the duration needed for the timer.  Remember to take into account	   * the early warning option available (e.g. 5-minutes early).	   */	  waitTime = (nearEvent -> start -> time - ((nearEvent -> reminder)*60) - ct) * 1000 ;	  if( waitTime > 0 )	    {#if DEBUG > 4	      printf( "start time = %d, reminder = %d, ct = %d\n",		      (int)nearEvent -> start -> time, ((nearEvent -> reminder)*60), (int)ct ) ;	      p

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -