From 47d7a53099be598c26be4de63e9d8fe52c2e0e66 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 13 Sep 2008 01:06:43 +0200 Subject: CoreStatusRequest nach Client/Request/ verschoben --- src/Client/CommandParser.cpp | 4 +- src/Client/Request/CoreStatusRequest.h | 82 ++++++++++++++++++++++++++++++++++ src/Client/Request/Makefile.am | 2 +- src/Client/Request/Makefile.in | 73 ++++++++++++++++++++++++------ 4 files changed, 144 insertions(+), 17 deletions(-) create mode 100644 src/Client/Request/CoreStatusRequest.h (limited to 'src/Client') diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp index 22de6e9..3100466 100644 --- a/src/Client/CommandParser.cpp +++ b/src/Client/CommandParser.cpp @@ -18,7 +18,7 @@ */ #include "CommandParser.h" -#include +#include "Request/CoreStatusRequest.h" #include #include @@ -85,7 +85,7 @@ void CommandParser::helpCommand(const std::vector &args) { void CommandParser::statusCommand(const std::vector&) { activeRequests++; - Common::Request::CoreStatusRequest::send(connection, *requestManager, sigc::mem_fun(this, &CommandParser::coreStatusRequestFinished)); + Request::CoreStatusRequest::send(connection, *requestManager, sigc::mem_fun(this, &CommandParser::coreStatusRequestFinished)); } void CommandParser::exitCommand(const std::vector&) { diff --git a/src/Client/Request/CoreStatusRequest.h b/src/Client/Request/CoreStatusRequest.h new file mode 100644 index 0000000..328c4ff --- /dev/null +++ b/src/Client/Request/CoreStatusRequest.h @@ -0,0 +1,82 @@ +/* + * CoreStatusRequest.h + * + * Copyright (C) 2008 Matthias Schiffer + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MAD_CLIENT_REQUEST_CORESTATUSREQUEST_H_ +#define MAD_CLIENT_REQUEST_CORESTATUSREQUEST_H_ + +#include +#include +#include +#include + +#include + +namespace Mad { +namespace Client { +namespace Request { + +class CoreStatusRequest: public Common::Request::Request { + private: + sigc::signal finished; + + CoreStatusRequest() {} + + public: + static bool send(Net::Connection *connection, Common::RequestManager &requestManager, const sigc::slot &callback) { + CoreStatusRequest *request = new CoreStatusRequest(); + + request->finished.connect(callback); + + if(requestManager.sendRequest(connection, request)) + return true; + + delete request; + return false; + } + + virtual bool sendRequest(Net::Connection *connection, uint16_t requestId) { + if(isSent()) + return false; + + if(!connection->send(Net::Packet(Net::Packet::CORE_STATUS, requestId))) + return false; + + setSent(); + return true; + } + + virtual bool handlePacket(Net::Connection*, const Net::Packet &packet) { + if(isFinished()) + return false; + + if(packet.getType() != Net::Packet::OK) + return false; // TODO Logging + + finished(Net::Packets::HostStatusPacket(packet)); + + setFinished(); + return true; + } +}; + +} +} +} + +#endif /* MAD_CLIENT_REQUEST_CORESTATUSREQUEST_H_ */ diff --git a/src/Client/Request/Makefile.am b/src/Client/Request/Makefile.am index 33bc72a..58db76c 100644 --- a/src/Client/Request/Makefile.am +++ b/src/Client/Request/Makefile.am @@ -1 +1 @@ -noinst_HEADERS = +noinst_HEADERS = CoreStatusRequest.h diff --git a/src/Client/Request/Makefile.in b/src/Client/Request/Makefile.in index 1ac4924..d81a597 100644 --- a/src/Client/Request/Makefile.in +++ b/src/Client/Request/Makefile.in @@ -45,6 +45,8 @@ CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ @@ -162,7 +164,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -noinst_HEADERS = +noinst_HEADERS = CoreStatusRequest.h all: all-am .SUFFIXES: @@ -201,12 +203,53 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique tags: TAGS -TAGS: +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi ctags: CTAGS -CTAGS: - +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -268,7 +311,7 @@ clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile -distclean-am: clean-am distclean-generic +distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am @@ -318,16 +361,18 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: all all-am check check-am clean clean-generic clean-libtool \ - distclean distclean-generic distclean-libtool distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool ctags distclean distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. -- cgit v1.2.3