示例#1
0
文件: http.c 项目: ezotrank/monit-src
int check_http(Socket_T socket) {
        Port_T P;
        char host[STRLEN];
        char auth[STRLEN]= {0};
        const char *request = NULL;
        const char *hostheader = NULL;

        ASSERT(socket);

        P = socket_get_Port(socket);

        ASSERT(P);

        request = P->request ? P->request : "/";

        Util_getHTTPHostHeader(socket, host, STRLEN);
        hostheader = P->request_hostheader ? P->request_hostheader : host;

        if (socket_print(socket,
                         "GET %s HTTP/1.1\r\n"
                         "Host: %s\r\n"
                         "Accept: */*\r\n"
                         "User-Agent: %s/%s\r\n"
                         "%s\r\n",
                         request, hostheader, prog, VERSION,
                         get_auth_header(P, auth, STRLEN)) < 0) {
                socket_setError(socket, "HTTP: error sending data -- %s\n", STRERROR);
                return FALSE;
        }

        return check_request(socket, P);
}
示例#2
0
//屏蔽好友
void LayerUserInfo::handle_block_user(cmd_data_pointer data)
{
    ClearError();
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->response_down(rec);
    switch (processor.status()) {
        case msg::Status::SUCCESS: {
            // 获取约友圈
//            if(GameDataManager::TYPE_SQUARE == GDM->circletype){
//                GDM->send_get_moment(0, 0, msg::MomentDisplayType::SQUARE);
//            }
//            else if(GameDataManager::TYPE_RECOMMEND == GDM->circletype){
//                GDM->send_get_moment(0, 0, msg::MomentDisplayType::RECOMMEND);
//            }
//            else if(GameDataManager::TYPE_FRIEND == GDM->circletype){
//                GDM->send_get_moment(0, 0, msg::MomentDisplayType::FRIEND);
//            }
            isBlockMoment = !isBlockMoment;
            mCheckboxHiteMoments->setSelected(isBlockMoment);
            setCheckBoxTextures(mCheckboxHiteMoments);
            break;
        }
        case msg::Status::FAILED:
            ShowError(tools::local_string("operate_failed","操作失败"));
            break;
        default:
            break;
    }

}
示例#3
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Get file details for a specified NFS File */
void
nfsfs_stat(pid_t pid, VNode self, const char *path, stat_t *buf) {
	dprintf(1, "*** nfsfs_stat: %p, %s, %p\n", self, path, buf);

	Process *p = process_lookup(pid);

	if (self != NULL) {
		NFS_File *nf = (NFS_File *) self->extra;
		if (nf == NULL) {
			dprintf(0, "!!! nfsfs_stat: Broken NFS file! No nfs struct! (file %s)\n",
					path);
			syscall_reply(process_get_tid(p), SOS_VFS_ERROR);
			return;
		}

		memcpy((void *) buf, (void *) &(self->vstat), sizeof(stat_t));
		syscall_reply(process_get_tid(p), SOS_VFS_OK);
	}
	
	// stat non open file
	else {
		dprintf(1, "*** nfsfs_stat: trying to stat non open file! (file %s)\n", path);

		NFS_StatRequest *rq = (NFS_StatRequest *) create_request(RT_STAT, self, pid);
		rq->stat = buf;
		rq->path = path;
		check_request((NFS_BaseRequest *) rq);
	}
}
示例#4
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Open a specified file using NFS */
void
nfsfs_open(pid_t pid, VNode self, const char *path, fmode_t mode,
		void (*open_done)(pid_t pid, VNode self, fmode_t mode, int status)) {
	dprintf(1, "*** nfsfs_open: %p, %s, %d, %p\n", self, path, mode, open_done);

	memcpy( (void *) self->path, (void *) path, MAX_FILE_NAME);
	self->readers = 0;
	self->writers = 0;
	self->vstat.st_type = ST_FILE;
	self->next = NULL;
	self->previous = NULL;

	if (new_nfsfile(self) == NULL) {
		dprintf(0, "!!! nfsfs_open: malloc failed!\n");
		open_done(pid, self, mode, SOS_VFS_NOMEM);
		return;
	}

	self->open = nfsfs_open;
	self->close = nfsfs_close;
	self->read = nfsfs_read;
	self->write = nfsfs_write;
	self->flush = nfsfs_flush;
	self->getdirent = nfsfs_getdirent;
	self->stat = nfsfs_stat;
	self->remove = nfsfs_remove;

	NFS_LookupRequest *rq = (NFS_LookupRequest *) create_request(RT_LOOKUP, self, pid);
	rq->mode = mode;
	rq->open_done = open_done;
	
	check_request((NFS_BaseRequest *) rq);
}
示例#5
0
文件: cancel.c 项目: andreiw/polaris
int
cancel (RSTATUS *prs, int spool)
{
	if (prs->request->outcome & RS_DONE)
		return (0);

	prs->request->outcome |= RS_CANCELLED;

	if (spool || (prs->request->actions & ACT_NOTIFY))
		prs->request->outcome |= RS_NOTIFY;

	if (prs->request->outcome & RS_PRINTING) {
		terminate(prs->printer->exec);
	}
	else if (prs->request->outcome & RS_FILTERING) {
		terminate (prs->exec);
	}
	else if (prs->request->outcome | RS_NOTIFY) {
		/* start fix for bugid 1100252	*/
		if (prs->printer->status & PS_REMOTE) {
			snprintf(cerrbuf, sizeof (cerrbuf),
				"Remote status=%d, canceled by remote system\n",
				prs->reason);
		}
		notify (prs, cerrbuf, 0, 0, 0);
		cerrbuf[0] = (char) NULL;
		/* end fix for bugid 1100252	*/
	}
	check_request (prs);

	return (1);
}
示例#6
0
// 添加好友
void LayerUserInfo::handle_add_friend(cmd_data_pointer data)
{
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->response_down(rec);
    TipView::showAlertView(processor.message());
    
}
示例#7
0
int main(void) {
	chdir("/");
        for(;;) {
		if(check_request() > 0) {
			if(file_exists(TASKQ_EXE)) {
				system(TASKQ_EXE);
			}
		}
		sleep(1);
	}
}
示例#8
0
void render_text(xcb_connection_t *dpy, xcb_window_t win, int16_t x, int16_t y)
{
	char id[10];
	xcb_void_cookie_t ck;
	snprintf(id, sizeof(id), "0x%X", win);
	xcb_gcontext_t gc = get_font_gc(dpy, win, "-*-fixed-medium-*-*-*-18-*-*-*-*-*-*-*");
	/* Doesn't work without _checked */
	ck = xcb_image_text_8_checked(dpy, strlen(id), win, gc, x, y, id);
	check_request(dpy, ck, "Can't draw text");
	xcb_free_gc(dpy, gc);
}
示例#9
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Get directory entries of the NFS filesystem */
void
nfsfs_getdirent(pid_t pid, VNode self, int pos, char *name, size_t nbyte) {
	dprintf(1, "*** nfsfs_getdirent: %p, %d, %p, %d\n", self, pos, name, nbyte);

	NFS_DirRequest *rq = (NFS_DirRequest *) create_request(RT_DIR, self, pid);
	rq->pos = pos;
	rq->buf = name;
	rq->nbyte = nbyte;
	rq->cpos = 0;

	check_request((NFS_BaseRequest *) rq);
}
示例#10
0
xcb_gc_t get_font_gc(xcb_connection_t *dpy, xcb_window_t win, const char *font_name)
{
	xcb_void_cookie_t ck;
	xcb_font_t font = xcb_generate_id(dpy);
	ck = xcb_open_font_checked(dpy, font, strlen(font_name), font_name);
	check_request(dpy, ck, "Can't open font");
	xcb_gcontext_t gc = xcb_generate_id(dpy);
	uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
	uint32_t values[] = {0xffcccccc, 0xff111111, font};
	xcb_create_gc(dpy, gc, win, mask, values);
	xcb_close_font(dpy, font);
	return gc;
}
示例#11
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Remove a file */
void
nfsfs_remove(pid_t pid, VNode self, const char *path) {
	dprintf(1, "*** nfsfs_remove: %d %s ***\n", pid, path);

	if (self != NULL) {
		// cant remove open files
		syscall_reply(process_get_tid(process_lookup(pid)), SOS_VFS_OPEN);
	} else {
		// remove file
		NFS_RemoveRequest *rq = (NFS_RemoveRequest *)
			create_request(RT_REMOVE, self, pid);
		rq->path = path;
		check_request((NFS_BaseRequest *) rq);
	}
}
示例#12
0
void LayerUserInfo::receiverDiamond(cmd_data_pointer data)
{
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->response_down(rec);
    switch (processor.status()) {
        case msg::Status::SUCCESS: {
            Toast::ToastShow(tools::local_string("give_successfully","赠送成功"));
            break;
        }
        case msg::Status::FAILED:
            Toast::ToastShow(processor.message());
            break;
        default:
            break;
    }
}
示例#13
0
文件: http.c 项目: Happy-Ferret/Monit
int check_http(Socket_T socket) {
        Port_T P;
        char host[STRLEN];
        char auth[STRLEN] = {};
        const char *request = NULL;
        const char *hostheader = NULL;

        ASSERT(socket);

        P = socket_get_Port(socket);

        ASSERT(P);

        request = P->request ? P->request : "/";

        hostheader = _findHostHeaderIn(P->http_headers);
        hostheader = hostheader ? hostheader : P->request_hostheader
                                ? P->request_hostheader : Util_getHTTPHostHeader(socket, host, STRLEN); // Otherwise use deprecated request_hostheader or default host
        StringBuffer_T sb = StringBuffer_create(168);
        StringBuffer_append(sb,
                            "GET %s HTTP/1.1\r\n"
                            "Host: %s\r\n"
                            "Accept: */*\r\n"
                            "User-Agent: Monit/%s\r\n"
                            "%s",
                            request, hostheader, VERSION,
                            get_auth_header(P, auth, STRLEN));
        // Add headers if we have them
        if (P->http_headers) {
                for (list_t p = P->http_headers->head; p; p = p->next) {
                        if (Str_startsWith(p->e, "Host")) // Already set contrived above
                                continue;
                        StringBuffer_append(sb, "%s\r\n", p->e);
                }
        }
        StringBuffer_append(sb, "\r\n");
        int send_status = socket_write(socket, (void*)StringBuffer_toString(sb), StringBuffer_length(sb));
        StringBuffer_free(&sb);
        if (send_status < 0) {
                socket_setError(socket, "HTTP: error sending data -- %s", STRERROR);
                return FALSE;
        }

        return check_request(socket, P);
}
示例#14
0
//删除好友
void LayerUserInfo::handle_delete_friend(cmd_data_pointer data) 
{
    ClearError();
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->response_down(rec);
    switch (processor.status()) {
        case msg::Status::SUCCESS: {
            Toast::ToastShow(tools::local_string("delete_friend_successed","删除好友成功"));
            InitNormal();
            break;
        }
        case msg::Status::FAILED:
            Toast::ToastShow(processor.message());
            break;
        default:
            break;
    }
}
示例#15
0
//接收已屏蔽的朋友圈列表
void LayerUserInfo::handle_all_block_user_list(cmd_data_pointer data)
{
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->GetMomentBlockUsers_down(rec);
    
    isBlockMoment = true;
    for (auto userInfo: processor.users())
    {
        if(userInfo.userid() == mInfo.userid())
        {
            isBlockMoment = false;
            break;
        }
    }
    
    mCheckboxHiteMoments->setSelected(isBlockMoment);
    setCheckBoxTextures(mCheckboxHiteMoments);
    
}
示例#16
0
文件: rarpd.c 项目: afett/rarpd
void handle_request(int fd, struct link *link, bool check_bootable)
{
	memset(link->buf, 0, sizeof(link->buf));
	memset(&link->src, 0, sizeof(link->src));

	ssize_t size = read_request(fd,
		&link->src, link->buf, sizeof(link->buf));

	if (size <= 0) {
		return;
	}

	if (!check_frame(&link->src, link)) {
		return;
	}

	if ((size_t) size < sizeof(struct ether_arp)) {
		XLOG_WARNING("request to short");
		return;
	}

	struct ether_arp *arp_req = (struct ether_arp *)link->buf;
	if (!check_request(arp_req, &link->src)) {
		return;
	}

	struct in_addr ip;
	memset(&ip, 0, sizeof(in_addr_t));
	int ret = resolve((struct ether_addr*)&arp_req->arp_tha, &ip);
	if (ret != 0) {
		return;
	}

	XLOG_DEBUG("found address: %s", inet_ntoa(ip));
	if (check_bootable == true && !is_bootable(ip)) {
		return;
	}

	create_reply(arp_req, &ip, link);
	dispatcher_flags(&link->handler, POLLOUT);
}
示例#17
0
Bool deferred_alloc_add(deferred_alloc_t *dalloc, memory_request_t *requests)
{
  memory_request_t *request, *last = NULL;

  HQASSERT(dalloc != NULL, "No alloc to add to");
  HQASSERT(requests != NULL, "No requests to add");
#ifdef ASSERT_BUILD
  for ( request = requests ; request != NULL ; request = request->next )
    check_request(request, FALSE);
#endif

  for ( request = requests ; request != NULL ; request = request->next ) {
    HQASSERT(request->min_count == request->max_count, "Flexible requests NYI.");
    if ( !request->pool->mps_debug )
      request->size = ADJUST_FOR_FENCEPOSTS(request->size);
    last = request; /* remember this for later */
  }
  /* Link the whole chain in front of the current requests. */
  last->next = dalloc->requests; dalloc->requests = requests;
  return TRUE;
}
示例#18
0
void LayerUserInfo::handle_deal_request(cmd_data_pointer data)
{
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->DealRequest_down(rec);
    
    switch (processor.response().status()) {
        case msg::Status::SUCCESS:
            Toast::ToastShow(tools::local_string("request_has_aready_send","已发送请求"));
            IM->deal_request(processor.requestid(), processor.accepted());
            break;
        case msg::Status::FAILED:
            Toast::ToastShow(tools::local_string("request_failed","请求失败"));
            break;
            
        default:
            break;
    }
    
    InitNormal();
}
示例#19
0
void http1_1_handler(int clientDescriptor) {

    std::vector<std::string> lines = get_request_lines(clientDescriptor);

    std::vector<std::string> startString = split(lines[0], ' ');
    if (!check_request(clientDescriptor, lines, startString)) {
        return;
    }
    std::string requestPath = startString[1];

    if (requestPath[0] == '/') {
        requestPath = requestPath.substr(1, requestPath.length() - 1);
    }
    for (size_t i = 1; i < requestPath.length(); ++i) {
        if (requestPath[i] == '.' && requestPath[i - 1] == '.') {
            process_error(clientDescriptor, FORBIDDEN);
            return;
        }
    }
    if (requestPath == "") {
        requestPath += homePageFile;
    }
    std::string mime = define_MIME(requestPath);
    if (mime == "none") {
        requestPath += ".html";
        mime = "text/html";
    }

    std::string fileBuf;

    FILE *file = popen(("python3 " + CGIPath + "cgi.py " + sitePath + requestPath + " " + CGIPath).c_str(), "r");
    while (!feof(file)) {
        fileBuf += fgetc(file);
    }
    fileBuf.pop_back();

    http_reply(clientDescriptor, OK, mime, fileBuf);
    wr_close(clientDescriptor);
}
示例#20
0
void server::HttpServer::worker(server::TcpServerConnection* connection)
{
  server::HttpServerSession session;
  session.connection = connection;

  try
  {
    process_request(&session);
    check_request(&session);
    prepare_session(&session);
    request_handler(session);
    check_session_response(&session);
    send_response(&session);
  }
  catch(Exception& e)
  {
    bad_request(&session, e);
  }
  catch(std::bad_alloc& e)
  {
  }
}
示例#21
0
void http1_1_handler(int clientDescriptor) {

    std::vector<std::string> lines = get_request_lines(clientDescriptor);

    std::vector<std::string> startString = split(lines[0], ' ');
    if (!check_request(clientDescriptor, lines, startString)) {
        return;
    }
    std::string requestPath = startString[1];

    if (requestPath[0] == '/') {
        requestPath = requestPath.substr(1, requestPath.length() - 1);
    }
    for (size_t i = 1; i < requestPath.length(); ++i) {
        if (requestPath[i] == '.' && requestPath[i - 1] == '.') {
            process_error(clientDescriptor, FORBIDDEN);
            return;
        }
    }
    if (requestPath == "") {
        requestPath += homePageFile;
    }
    std::string mime = define_MIME(requestPath);
    if (mime == "none") {
        requestPath += ".html";
        mime = "text/html";
    }

    std::string fileBuf;

    if (get_file(sitePath + requestPath, fileBuf) == -1) {
        process_error(clientDescriptor, NOT_FOUND);
        return;
    }

    http_reply(clientDescriptor, OK, mime, fileBuf);
    wr_close(clientDescriptor);
}
示例#22
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Read a specified number of bytes into a buffer from the given NFS file */
void
nfsfs_read(pid_t pid, VNode self, fildes_t file, L4_Word_t pos,
		char *buf, size_t nbyte, void (*read_done)(pid_t pid,
			VNode self, fildes_t file, L4_Word_t pos, char *buf, size_t nbyte, int status)) {
	dprintf(1, "*** nfsfs_read: %p, %d, %d, %p, %d\n", self, file, pos, buf, nbyte);

	NFS_File *nf = (NFS_File *) self->extra;	
	if (self == NULL || nf == NULL) {
		dprintf(0, "!!! nfsfs_read: Invalid NFS file (p %d, f %d), no nfs struct!\n",
				pid, file);
		read_done(pid, self, file, pos, buf, 0, SOS_VFS_NOFILE);
		return;
	}

	NFS_ReadRequest *rq = (NFS_ReadRequest *) create_request(RT_READ, self, pid);
	rq->file = file;
	rq->buf = buf;
	rq->pos = pos;
	rq->nbyte = nbyte;
	rq->read_done = read_done;

	check_request((NFS_BaseRequest *) rq);
}
示例#23
0
文件: nfsfs.c 项目: dafyddcrosby/L4OS
/* Write the specified number of bytes from the buffer buf to a given NFS file */
void
nfsfs_write(pid_t pid, VNode self, fildes_t file, L4_Word_t offset,
		const char *buf, size_t nbyte, void (*write_done)(pid_t pid, VNode self,
			fildes_t file, L4_Word_t offset, const char *buf, size_t nbyte, int status)) {
	dprintf(1, "*** nfsfs_write: %p, %d, %d, %p, %d\n", self, file, offset, buf, nbyte);

	NFS_File *nf = (NFS_File *) self->extra;	
	if (nf == NULL) {
		dprintf(0, "!!! nfsfs_write: Invalid NFS file (p %d, f %d), no nfs struct!\n",
				pid, file);
		write_done(pid, self, file, offset, buf, 0, SOS_VFS_NOFILE);
		return;
	}

	NFS_WriteRequest *rq = (NFS_WriteRequest *) create_request(RT_WRITE, self, pid);
	rq->file = file;
	rq->buf = (char *) buf;
	rq->offset = offset;
	rq->nbyte = nbyte;
	rq->write_done = write_done;

	check_request((NFS_BaseRequest *) rq);
}
示例#24
0
//获得好友列表
void LayerUserInfo::handle_get_friends_list(cmd_data_pointer data)
{
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    auto processor = PM->getFriendList_down(rec);
    switch (processor.response().status()) {
        case msg::Status::SUCCESS: {
            
            bool isFriend = false;
            auto friendVec = processor.friendinfo();
            for(auto tFriend : friendVec)
            {
                if(tFriend.userdetailinfo().userid() == mInfo.userid())
                {
                    isFriend = true;
                    break;
                }
            }
            mIsFriend = isFriend;
            mBtnSendMsg->setVisible(true);
            if(mIsFriend)
            {
                mBtnDeleteFriend->setVisible(true);
            }
            else
            {
                mBtnSendMsg->setTitleText(tools::local_string("add_friend","添加好友"));
            }
            break;
        }
        case msg::Status::FAILED:
            break;
        default:
            break;
    }
}
示例#25
0
int	main(void)
{
	char **postvars	= NULL;	/* POST	request	data repository	*/
	char **getvars = NULL; /* GET request data repository */
	int	form_method; /*	POST = 1, GET =	0 */
	int	i;


	form_method	= getRequestMethod();


	if(form_method == POST)	{
		getvars	= getGETvars();
		postvars = getPOSTvars();
	} else if(form_method == GET) {
		getvars	= getGETvars();
	}

/* Parse Request */

	if(form_method == POST)	{

/*Preset checkbox settings*/

for	(i=0; postvars[i]; i+= 2) {

	if(strncmp(postvars[i],	"CH1",2) ==	0){	cgiinfo.choice	=	 atoi(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"TR",2) ==	0){	cgiinfo.time2run	=atoi(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"UF",2) ==	0){	cgiinfo.unitfreq	=atoi(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"UA",2) ==	0){	cgiinfo.unitamp		=atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"UD",2) ==	0){	cgiinfo.unitdco		=atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"O1", 2) ==	0){	cgiinfo.DCoffset	= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"A1", 2) ==	0){	cgiinfo.amplitude	= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"F1", 2) ==	0){	cgiinfo.frequency	= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"S1", 2) ==	0){	cgiinfo.symmetry	= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"P1", 2) ==	0){	cgiinfo.phase		= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"D1", 2) ==	0){	cgiinfo.dutycycle	= atof(postvars[i +	1]); } else
	if(strncmp(postvars[i],	"B2", 2) ==	0){	cgiinfo.cmd	= RUN; } else
	if(strncmp(postvars[i],	"B1", 2) ==	0){	cgiinfo.cmd	= CALC;	} else
	if(strncmp(postvars[i],	"B3", 2) ==	0){	cgiinfo.cmd	= STOP; } else
	if(strncmp(postvars[i],	"FB", 2) ==	0){	cgiinfo.framebuffer = atof(postvars[i + 1]); }

	}
}

	cgiinfo.DCoffset	*= cgiinfo.unitdco;
    cgiinfo.amplitude	*= cgiinfo.unitamp;
	cgiinfo.frequency	*= cgiinfo.unitfreq;

	switch(cgiinfo.cmd)
	{
		case CALC:
		calc_frequency(form_method, getvars, postvars, cgiinfo.frequency);
  		check_request (form_method, getvars, postvars);
		make_file_init(form_method, getvars, postvars);
		system ("/bin/gnuplot /home/httpd/cgi-bin/gnuplot.plt");
		capture(form_method, getvars, postvars);
		break;

		case RUN:
		calc_frequency(form_method, getvars, postvars, cgiinfo.frequency);
		sample(form_method, getvars, postvars);
		display(form_method, getvars, postvars);
		break;

		case STOP:

		break;

		default:
		break;
	}

  exit(0);

};
示例#26
0
void LayerGroupList::handle_search_group(cmd_data_pointer data)
{
    ClearError();
    std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
    if (!check_request(rec)) return;
    
    auto processor = PM->SearchGroup_Down(rec);
    auto response = processor.response();
    auto status = response.status();
    switch (status) {
        case msg::Status::SUCCESS: {
            countGroupList = groups_.size();
            groups_.clear();
            for (auto iterGroup : processor.groupinfo())
            {
                if (!(group_layer_type_ == GROUPLAYERTYPE::GAMESELECTGROUP && !iterGroup.allowcreateroom()))
                {
                    groups_.push_back(iterGroup);
                }
            }
            
            //聊天时间排序
            auto sortFunc = [&](const msg::GroupInfo &data1, const msg::GroupInfo data2)
            {
                auto lastmessage1 = CM->get_last_message(data1.groupid(), ChatMessageManager::MESSAGETYPE::GROUPCHAT);
                if(!lastmessage1)
                {
                    return false;
                }
                auto lastmessage2 = CM->get_last_message(data2.groupid(), ChatMessageManager::MESSAGETYPE::GROUPCHAT);
                if(!lastmessage2)
                {
                    return true;
                }
                
                const std::string submit_time1 = lastmessage1->subtime();
                if(submit_time1.empty())
                {
                    return false;
                }
                const std::string submit_time2 = lastmessage2->subtime();
                if(submit_time2.empty())
                {
                    return true;
                }
                
                return tools::stod(submit_time1) >  tools::stod(submit_time2);
            };
            
            std::sort(groups_.begin(), groups_.end(), sortFunc);
            tableview_->reloadData();
            if(countGroupList == groups_.size() && !sizeOffset.equals(Size::ZERO))
            {
                tableview_->setContentOffset(sizeOffset);
            }
            break;
        }
        case msg::Status::FAILED:
            ShowError(response.message());
            break;
        default:
            break;
    }
   
    
}
示例#27
0
void BuyChipLayer::handle_get_permission(cmd_data_pointer data)
{
    if (GetRoom()->get_group_id() == 0)
    {
        need_credit_ = false;
    }else
    {
        std::shared_ptr<net_data_recv_package> rec = dynamic_pointer_cast<net_data_recv_package>(data);
        if (!check_request(rec)) return;
        auto processor = PM->GetUserPermission_down(rec);
        need_credit_ = true;
        if (processor.has_permission())
        {
            permission_.CopyFrom(processor.permission());
        }else{
            need_credit_ = false;
        }
    }

    auto user = static_pointer_cast<user_texas>(GetRoom()->get_user( GDM->get_user_id()));
    if(user) {
        int buyin_min = GetRoom()->get_buyin_min();
        int buyin_max = GetRoom()->get_buyin_max();
        
        ;//permission_.needcredit();
        if (need_credit_)
        {
            uint32_t credit = permission_.credit();
            
            if (credit < buyin_max)
            {
                buyin_max = credit;
            }
        }
        
        int min_chip = buyin_min - user->get_properties()->chips();
        int max_chip = buyin_max - user->get_properties()->chips();
        
        if (need_credit_ && permission_.credit() < min_chip)
        {
            TipView::showAlertView(tools::local_string("no_credit","信用值不足"));
            this->removeFromParent();
            return;
        }
        
        if (max_chip <= 0)
        {
            TipView::showAlertView(tools::local_string("max_chip", "您的计分牌已经达到极限,不能添加"));
            this->removeFromParent();
            return;
        }
        
        min_chip = std::max(0, min_chip);
        
        text_min_number_->setString(tools::to_string(min_chip));
        text_max_number_->setString(tools::to_string(max_chip));
        text_buy_number_->setString(tools::to_string(min_chip));
    }
    slider_slider_chip(slider_chip_, Slider::EventType::ON_PERCENTAGE_CHANGED);
    this->setVisible(true);
}