예제 #1
0
파일: talk.c 프로젝트: icewwn/fbbs-1
int t_query(const char *uname)
{
	if (streq(currentuser.userid, "guest"))
		return DONOTHING;

	char userid[EXT_IDLEN + 1];
	if (uname) {
		if (*uname == '\0')
			return DONOTHING;
		strlcpy(userid, uname, sizeof(userid));
		strtok(userid, " ");
	} else {
		set_user_status(ST_QUERY);
		screen_flush();
		screen_move(2, 0);
		screen_clrtobot();
		screen_printf("<输入使用者代号, 按空白键可列出符合字串>");
		user_complete(1, "查询谁: ", userid, sizeof(userid));
		if (*userid == '\0')
			return FULLUPDATE;
	}

	if (tui_query_result(userid) != 0) {
		screen_move_clear(2);
		screen_printf("\033[1m不正确的使用者代号\033[m\n");
		pressanykey();
		return FULLUPDATE;
	}

	if (session_status() != ST_LUSERS && session_status() != ST_LAUSERS
			&& session_status() != ST_FRIEND && session_status() != ST_GMENU)
	pressanykey();
	return FULLUPDATE;
}
예제 #2
0
/**
 * Get next byte from stdin in gbk encoding (if conversion is needed).
 */
int terminal_getchar(void)
{
	int ch = do_terminal_getchar();
	while ((RMSG || msg_num) && session_status() != ST_LOCKSCREEN) {
		msg_reply(ch);
		ch = do_terminal_getchar();
	}
	return ch;
}
예제 #3
0
static void cmd_session_status(struct http_channel *c)
{
    struct http_session *s = locate_session(c);
    if (!s)
        return;

    response_open(c, "session-status");
    session_status(c, s);
    response_close(c, "session-status");
    release_session(c, s);
}
예제 #4
0
void cChannelSession::dataRX(const QVector<QByteArray> &data)
{
    if (data.count() < 2)
    {
        qDebug() << "[ERROR]cChannelSession::dataRX-> Pocos campos... :" << data.count();
        return;
    }
    int cmd = data[1].toInt();
    //qDebug() << "[INFO]cChannelSession::dataRX-> Comando:" << cmd;
    if(cmd == CMD_JOIN_SESSION)
    {
        QString id = data[2];
        emit join_session(id);
    }
    else if (cmd == CMD_SESSION_STATUS)
    {
        QString id      = data[2];
        bool status     = data[3].toInt();
        QString reason  = data[4];
        emit session_status(id,status,reason);
    }
    else if (cmd == CMD_GET_SESSION_USERLIST)
    {
        QString id = data[2];
        emit get_session_userlist(id);
    }
    else if (cmd == CMD_SESSION_USERLIST)
    {
        QString id = data[2];
        QByteArray array = data[3];
        cUsersInfoList userslist(array);
        emit session_userlist(id,userslist);
    }
    else if (cmd == CMD_GET_CHATROOM_LIST)
    {
        QString id = data[2];
        emit get_chatroom_list(id);
    }
    else if (cmd == CMD_CHATROOM_LIST)
    {
        QString id = data[2];
        QVector<cChatInfo> chats;
        for ( int i = 3 ; i < data.count() ; i+=3 )
        {
            cChatInfo chatroom(data[i],data[i+1],data[i+2].toInt());
            chats.append(chatroom);
        }
        emit chatroom_list(id,chats);
    }
    else if(cmd == CMD_JOIN_CHATROOM)
    {
        QString id = data[2];
        emit join_chatroom(id);
    }
    else if(cmd == CMD_CHATROOM_STATUS)
    {
        QString id      = data[2];
        bool status     = data[3].toInt();
        QString reason  = data[4];
        emit chatroom_status(id,status,reason);
    }
    else if(cmd == CMD_GET_CHATROOM_USERLIST)
    {
        QString chatroom_id = data[2];
        emit get_chatroom_userlist(chatroom_id);
    }
    else if(cmd == CMD_CHATROOM_USERLIST)
    {
        QString id = data[2];
        QByteArray array = data[3];
        cUsersInfoList userslist(array);
        emit chatroom_userlist(id,userslist);
    }
    else if(cmd == CMD_CREATE_CHATROOM)
    {
        QString name    = data[2];
        bool persistent = data[3].toInt();
        emit create_chatroom(name,persistent);
    }
    else if(cmd == CMD_CHATROOM_MSG)
    {
        QVector<cChatMsg> msgs;
        QString id = data[2];
        for ( int i = 3 ; i < data.count() ; i+=3 )
        {
            QDateTime timestamp;
            timestamp.fromMSecsSinceEpoch(data[i+2].toInt());
            cChatMsg msg(data[i],data[i+1],timestamp);
            msgs.append(msg);
        }
        emit chatroom_msg(id,msgs);
    }
    else if(cmd == CMD_GET_FILELIST)
    {
        QString id = data[2];
        emit get_file_list(id);
    }
    else if(cmd == CMD_FILELIST)
    {
        QString id = data[2];

    }
    else if(cmd == CMD_GET_PAD_LIST)
    {
        QString id = data[2];
        emit get_pad_list(id);
    }
    else if(cmd == CMD_PAD_LIST)
    {
        QString id = data[2];
        QByteArray array(data[3]);
        cPadsInfoList padslist(array);
        emit pad_list(id,padslist);

    }
    else if(cmd == CMD_JOIN_PAD)
    {
        QString id = data[2];
        emit join_pad(id);
    }
    else if(cmd == CMD_PAD_STATUS)
    {
        QString id      = data[2];
        bool status     = data[3].toInt();
        QString reason  = data[4];
        emit pad_status(id,status,reason);
    }
    else if(cmd == CMD_GET_PAD_USERLIST)
    {
        QString id = data[2];
        emit get_pad_userlist(id);
    }
    else if(cmd == CMD_PAD_USERLIST)
    {
        QString id = data[2];
        QByteArray array = data[3];
        cUsersInfoList userslist(array);
        emit pad_userlist(id,userslist);
    }
    else if(cmd == CMD_GET_PAD_DOCUMENT)
    {
        QString id(data[2]);
        emit get_pad_document(id);
    }
    else if(cmd == CMD_PAD_DOCUMENT)
    {
        QString id(data[2]);
        QString padText(data[3]);
        emit pad_document(id,padText);
    }
    else if(cmd == CMD_PAD_CHANGES)
    {
        QString id(data[2]);
        QString sender = data[3];
        int pos(data[4].toInt());
        int del(data[5].toInt());
        int add(data[6].toInt());
        QString text(data[7]);
        emit pad_changes(id,sender,pos,del,add,text);
    }
    else
    {
        qDebug() << "[ERROR]cChannelSession::dataRX-> Comando desconocido:" << cmd;
    }
}