Ejemplo n.º 1
0
static void login_client_failed(const struct master_login_client *client,
				const char *errormsg)
{
	struct client_input input;
	const char *msg;

	client_parse_input(client->data, client->auth_req.data_size, &input);
	msg = t_strdup_printf("%s NO ["IMAP_RESP_CODE_UNAVAILABLE"] %s\r\n",
			      input.tag, errormsg);
	if (write(client->fd, msg, strlen(msg)) < 0) {
		/* ignored */
	}
}
Ejemplo n.º 2
0
static void client_add_input(struct client *client, const buffer_t *buf)
{
	struct ostream *output;
	struct client_input input;

	if (buf != NULL && buf->used > 0) {
		client_parse_input(buf->data, buf->used, &input);
		if (input.input_size > 0 &&
		    !i_stream_add_data(client->input, input.input,
				       input.input_size))
			i_panic("Couldn't add client input to stream");
	} else {
		/* IMAPLOGINTAG environment is compatible with mailfront */
		memset(&input, 0, sizeof(input));
		input.tag = getenv("IMAPLOGINTAG");
	}

	output = client->output;
	o_stream_ref(output);
	o_stream_cork(output);
	if (input.tag == NULL) {
		client_send_line(client, t_strconcat(
			"* PREAUTH [CAPABILITY ",
			str_c(client->capability_string), "] "
			"Logged in as ", client->user->username, NULL));
	} else if (input.send_untagged_capability) {
		/* client doesn't seem to understand tagged capabilities. send
		   untagged instead and hope that it works. */
		client_send_line(client, t_strconcat("* CAPABILITY ",
			str_c(client->capability_string), NULL));
		client_send_line(client,
				 t_strconcat(input.tag, " OK Logged in", NULL));
	} else {
		client_send_line(client, t_strconcat(
			input.tag, " OK [CAPABILITY ",
			str_c(client->capability_string), "] Logged in", NULL));
	}
	(void)client_handle_input(client);
	o_stream_uncork(output);
	o_stream_unref(&output);
}
Ejemplo n.º 3
0
void send_button_clicked(GtkWidget * widget, gpointer data)
{
	char *text;
    int num = (int) data;
	GtkTextIter start, end;

	gtk_text_buffer_get_bounds(GTK_TEXT_BUFFER(allmsg[num].buffer_down), &start, &end);	/*获得缓冲区开始和结束位置的Iter */
	const GtkTextIter s = start, e = end;
	text = (char *)gtk_text_buffer_get_text(GTK_TEXT_BUFFER(allmsg[num].buffer_down), &s, &e, FALSE);	/*获得文本框缓冲区文本 */
    char send_text[MAXLEN];
    sprintf(send_text, "to %s : ", allmsg[num].to_name);
    strcat(send_text, text);    
    printf("%s\n",send_text);

    client_parse_input(cli, send_text);    //发送信息
    
    sprintf(send_text, "%s : ", cli->name);
    strcat(send_text, text);   
    combochange_log(num, send_text);         //在聊天窗口显示
    
    gtk_text_buffer_set_text(GTK_TEXT_BUFFER(allmsg[num].buffer_down), "", -1);  //清空缓冲区
}