Removed old telldus-core, it has been rewritten

This commit is contained in:
Micke Prag 2011-05-18 09:40:56 +00:00
parent 875bb235ca
commit 5887a4d2fd
179 changed files with 0 additions and 21827 deletions

View file

@ -1,254 +0,0 @@
INSTALLATION INSTRUCTIONS
These instructions refer to the package you are installing as
some-package.tar.gz or some-package.zip. The .zip file is intended for use
on Windows.
The directory you choose for the installation will be referred to as
your-install-dir.
Note to Qt Visual Studio Integration users: In the instructions below,
instead of building from command line with nmake, you can use the menu
command 'Qt->Open Solution from .pro file' on the .pro files in the
example and plugin directories, and then build from within Visual
Studio.
Unpacking and installation
--------------------------
1. Unpacking the archive (if you have not done so already).
On Unix and Mac OS X (in a terminal window):
cd your-install-dir
gunzip some-package.tar.gz
tar xvf some-package.tar
This creates the subdirectory some-package containing the files.
On Windows:
Unpack the .zip archive by right-clicking it in explorer and
choosing "Extract All...". If your version of Windows does not
have zip support, you can use the infozip tools available
from www.info-zip.org.
If you are using the infozip tools (in a command prompt window):
cd your-install-dir
unzip some-package.zip
2. Configuring the package.
The configure script is called "configure" on unix/mac and
"configure.bat" on Windows. It should be run from a command line
after cd'ing to the package directory.
You can choose whether you want to use the component by including
its source code directly into your project, or build the component
as a dynamic shared library (DLL) that is loaded into the
application at run-time. The latter may be preferable for
technical or licensing (LGPL) reasons. If you want to build a DLL,
run the configure script with the argument "-library". Also see
the note about usage below.
(Components that are Qt plugins, e.g. styles and image formats,
are by default built as a plugin DLL.)
The configure script will prompt you in some cases for further
information. Answer these questions and carefully read the license text
before accepting the license conditions. The package cannot be used if
you do not accept the license conditions.
3. Building the component and examples (when required).
If a DLL is to be built, or if you would like to build the
examples, next give the commands
qmake
make [or nmake if your are using Microsoft Visual C++]
The example program(s) can be found in the directory called
"examples" or "example".
Components that are Qt plugins, e.g. styles and image formats, are
ready to be used as soon as they are built, so the rest of this
installation instruction can be skipped.
4. Building the Qt Designer plugin (optional).
Some of the widget components are provided with plugins for Qt
Designer. To build and install the plugin, cd into the
some-package/plugin directory and give the commands
qmake
make [or nmake if your are using Microsoft Visual C++]
Restart Qt Designer to make it load the new widget plugin.
Note: If you are using the built-in Qt Designer from the Qt Visual
Studio Integration, you will need to manually copy the plugin DLL
file, i.e. copy
%QTDIR%\plugins\designer\some-component.dll
to the Qt Visual Studio Integration plugin path, typically:
C:\Program Files\Trolltech\Qt VS Integration\plugins
Note: If you for some reason are using a Qt Designer that is built
in debug mode, you will need to build the plugin in debug mode
also. Edit the file plugin.pro in the plugin directory, changing
'release' to 'debug' in the CONFIG line, before running qmake.
Solutions components are intended to be used directly from the package
directory during development, so there is no 'make install' procedure.
Using a component in your project
---------------------------------
To use this component in your project, add the following line to the
project's .pro file (or do the equivalent in your IDE):
include(your-install-dir/some-package/src/some-package.pri)
This adds the package's sources and headers to the SOURCES and HEADERS
project variables respectively (or, if the component has been
configured as a DLL, it adds that library to the LIBS variable), and
updates INCLUDEPATH to contain the package's src
directory. Additionally, the .pri file may include some dependencies
needed by the package.
To include a header file from the package in your sources, you can now
simply use:
#include <SomeClass>
or alternatively, in pre-Qt 4 style:
#include <some-class.h>
Refer to the documentation to see the classes and headers this
components provides.
Install documentation (optional)
--------------------------------
The HTML documentation for the package's classes is located in the
your-install-dir/some-package/doc/html/index.html. You can open this
file and read the documentation with any web browser.
To install the documentation into Qt Assistant (for Qt version 4.4 and
later):
1. In Assistant, open the Edit->Preferences dialog and choose the
Documentation tab. Click the Add... button and select the file
your-install-dir/some-package/doc/html/some-package.qch
For Qt versions prior to 4.4, do instead the following:
1. The directory your-install-dir/some-package/doc/html contains a
file called some-package.dcf. Execute the following commands in a
shell, command prompt or terminal window:
cd your-install-dir/some-package/doc/html/
assistant -addContentFile some-package.dcf
The next time you start Qt Assistant, you can access the package's
documentation.
Removing the documentation from assistant
-----------------------------------------
If you have installed the documentation into Qt Assistant, and want to uninstall it, do as follows, for Qt version 4.4 and later:
1. In Assistant, open the Edit->Preferences dialog and choose the
Documentation tab. In the list of Registered Documentation, select
the item com.trolltech.qtsolutions.some-package_version, and click
the Remove button.
For Qt versions prior to 4.4, do instead the following:
1. The directory your-install-dir/some-package/doc/html contains a
file called some-package.dcf. Execute the following commands in a
shell, command prompt or terminal window:
cd your-install-dir/some-package/doc/html/
assistant -removeContentFile some-package.dcf
Using the component as a DLL
----------------------------
1. Normal components
The shared library (DLL) is built and placed in the
some-package/lib directory. It is intended to be used directly
from there during development. When appropriate, both debug and
release versions are built, since the run-time linker will in some
cases refuse to load a debug-built DLL into a release-built
application or vice versa.
The following steps are taken by default to help the dynamic
linker to locate the DLL at run-time (during development):
Unix: The some-package.pri file will add linker instructions to
add the some-package/lib directory to the rpath of the
executable. (When distributing, or if your system does not support
rpath, you can copy the shared library to another place that is
searched by the dynamic linker, e.g. the "lib" directory of your
Qt installation.)
Mac: The full path to the library is hardcoded into the library
itself, from where it is copied into the executable at link time,
and ready by the dynamic linker at run-time. (When distributing,
you will want to edit these hardcoded paths in the same way as for
the Qt DLLs. Refer to the document "Deploying an Application on
Mac OS X" in the Qt Reference Documentation.)
Windows: the .dll file(s) are copied into the "bin" directory of
your Qt installation. The Qt installation will already have set up
that directory to be searched by the dynamic linker.
2. Plugins
For Qt Solutions plugins (e.g. image formats), both debug and
release versions of the plugin are built by default when
appropriate, since in some cases the release Qt library will not
load a debug plugin, and vice versa. The plugins are automatically
copied into the plugins directory of your Qt installation when
built, so no further setup is required.
Plugins may also be built statically, i.e. as a library that will be
linked into your application executable, and so will not need to
be redistributed as a separate plugin DLL to end users. Static
building is required if Qt itself is built statically. To do it,
just add "static" to the CONFIG variable in the plugin/plugin.pro
file before building. Refer to the "Static Plugins" section in the
chapter "How to Create Qt Plugins" for explanation of how to use a
static plugin in your application. The source code of the example
program(s) will also typically contain the relevant instructions
as comments.
Uninstalling
------------
The following command will remove any fils that have been
automatically placed outside the package directory itself during
installation and building
make distclean [or nmake if your are using Microsoft Visual C++]
If Qt Assistant documentation or Qt Designer plugins have been
installed, they can be uninstalled manually, ref. above.
Enjoy! :)
- The Qt Solutions Team.

View file

@ -1,10 +0,0 @@
Nokia Qt LGPL Exception version 1.0
As a special exception to the GNU Lesser General Public License
version 2.1, the object code form of a "work that uses the Library"
may incorporate material from a header file that is part of the
Library. You may distribute such object code under terms of your
choice, provided that the incorporated material (i) does not exceed
more than 5% of the total size of the Library; and (ii) is limited to
numerical parameters, data structure layouts, accessors, macros,
inline functions and templates.

View file

@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View file

@ -1,504 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View file

@ -1,7 +0,0 @@
Service v2.6
The QtService component is useful for developing Windows services
and Unix daemons.

View file

@ -1,13 +0,0 @@
TEMPLATE=lib
CONFIG += qt dll qtservice-buildlib
mac:CONFIG += absolute_library_soname
win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release build_all
include(../src/qtservice.pri)
TARGET = $$QTSERVICE_LIBNAME
DESTDIR = $$QTSERVICE_LIBDIR
win32 {
DLLDESTDIR = $$[QT_INSTALL_BINS]
QMAKE_DISTCLEAN += $$[QT_INSTALL_BINS]\\$${QTSERVICE_LIBNAME}.dll
}
target.path = $$DESTDIR
INSTALLS += target

View file

@ -1,6 +0,0 @@
infile(config.pri, SOLUTIONS_LIBRARY, yes): CONFIG += qtservice-uselib
TEMPLATE += fakelib
QTSERVICE_LIBNAME = $$qtLibraryTarget(QtSolutions_Service-2.6)
TEMPLATE -= fakelib
QTSERVICE_LIBDIR = $$PWD/lib
unix:qtservice-uselib:!qtservice-buildlib:QMAKE_RPATHDIR += $$QTSERVICE_LIBDIR

View file

@ -1,112 +0,0 @@
#!/bin/sh
if [ "x$1" != "x" -a "x$1" != "x-library" ]; then
echo "Usage: $0 [-library]"
echo
echo "-library: Build the component as a dynamic library (DLL). Default is to"
echo " include the component source code directly in the application."
echo " A DLL may be preferable for technical or licensing (LGPL) reasons."
echo
exit 0
fi
# only ask to accept the license text once
if [ ! -f .licenseAccepted ]; then
# determine if opensource or commercial package
if [ -f LICENSE.LGPL ]; then
# opensource edition
while true; do
echo
echo "You are licensed to use this software under the terms of"
echo "the GNU General Public License (GPL) version 3, or"
echo "the GNU Lesser General Public License (LGPL) version 2.1"
echo "with certain additional extra rights as specified in the"
echo "Nokia Qt LGPL Exception version 1.0."
echo
echo "Type 'G' to view the GNU General Public License (GPL) version 3."
echo "Type 'L' to view the GNU Lesser General Public License (LGPL) version 2.1."
echo "Type 'E' to view the Nokia Qt LGPL Exception version 1.0."
echo "Type 'yes' to accept this license offer."
echo "Type 'no' to decline this license offer."
echo
echo "Do you accept the terms of this license? "
read answer
echo
if [ "x$answer" = "xno" ]; then
echo "You are not licensed to use this software."
echo
exit 1
elif [ "x$answer" = "xyes" ]; then
echo license accepted > .licenseAccepted
break
elif [ "x$answer" = "xe" -o "x$answer" = "xE" ]; then
more LGPL_EXCEPTION.txt
elif [ "x$answer" = "xl" -o "x$answer" = "xL" ]; then
more LICENSE.LGPL
elif [ "x$answer" = "xg" -o "x$answer" = "xG" ]; then
more LICENSE.GPL3
fi
done
else
while true; do
echo
echo "Please choose your region."
echo
echo "Type 1 for North or South America."
echo "Type 2 for anywhere outside North and South America."
echo
echo "Select: "
read region
if [ "x$region" = "x1" ]; then
licenseFile=LICENSE.US
break;
elif [ "x$region" = "x2" ]; then
licenseFile=LICENSE.NO
break;
fi
done
while true; do
echo
echo "License Agreement"
echo
echo "Type '?' to view the Qt Solutions Commercial License."
echo "Type 'yes' to accept this license offer."
echo "Type 'no' to decline this license offer."
echo
echo "Do you accept the terms of this license? "
read answer
echo
if [ "x$answer" = "xno" ]; then
echo "You are not licensed to use this software."
echo
exit 1
elif [ "x$answer" = "xyes" ]; then
echo license accepted > .licenseAccepted
cp "$licenseFile" LICENSE
rm LICENSE.US
rm LICENSE.NO
break
elif [ "x$answer" = "x?" ]; then
more "$licenseFile"
fi
done
fi
fi
rm -f config.pri
if [ "x$1" = "x-library" ]; then
echo "Configuring to build this component as a dynamic library."
echo "SOLUTIONS_LIBRARY = yes" > config.pri
fi
echo
echo "This component is now configured."
echo
echo "To build the component library (if requested) and example(s),"
echo "run qmake and your make command."
echo
echo "To remove or reconfigure, run make distclean."
echo

View file

@ -1,131 +0,0 @@
h3.fn,span.fn
{
margin-left: 1cm;
text-indent: -1cm;
}
a:link
{
color: #004faf;
text-decoration: none
}
a:visited
{
color: #672967;
text-decoration: none
}
a.obsolete
{
color: #661100;
text-decoration: none
}
a.compat
{
color: #661100;
text-decoration: none
}
a.obsolete:visited
{
color: #995500;
text-decoration: none
}
a.compat:visited
{
color: #995500;
text-decoration: none
}
td.postheader
{
font-family: sans-serif
}
tr.address
{
font-family: sans-serif
}
body
{
background: #ffffff;
color: black
}
table tr.odd {
background: #f0f0f0;
color: black;
}
table tr.even {
background: #e4e4e4;
color: black;
}
table.annotated th {
padding: 3px;
text-align: left
}
table.annotated td {
padding: 3px;
}
table tr pre
{
padding-top: none;
padding-bottom: none;
padding-left: none;
padding-right: none;
border: none;
background: none
}
tr.qt-style
{
background: #a2c511;
color: black
}
body pre
{
padding: 0.2em;
border: #e7e7e7 1px solid;
background: #f1f1f1;
color: black
}
span.preprocessor, span.preprocessor a
{
color: darkblue;
}
span.comment
{
color: darkred;
font-style: italic
}
span.string,span.char
{
color: darkgreen;
}
.title
{
text-align: center
}
.subtitle
{
font-size: 0.8em
}
.small-subtitle
{
font-size: 0.65em
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

View file

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/doc/index.qdoc -->
<head>
<title>Service</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">Service<br /><span class="subtitle"></span>
</h1>
<a name="description"></a>
<h2>Description</h2>
<p>The <a href="qtservice.html">QtService</a> component is useful for developing Windows services and Unix daemons.</p>
<p>The project provides a <a href="qtservice.html">QtService</a> template class that can be used to implement service applications, and a <a href="qtservicecontroller.html">QtServiceController</a> class to control a service.</p>
<p>On Windows systems the implementation uses the Service Control Manager.</p>
<p>On Unix systems services are implemented as daemons.</p>
<a name="classes"></a>
<h2>Classes</h2>
<ul>
<li><a href="qtservicecontroller.html">QtServiceController</a></li>
<li><a href="qtservicebase.html">QtServiceBase</a></li>
<li><a href="qtservice.html">QtService</a></li>
</ul>
<a name="examples"></a>
<h2>Examples</h2>
<ul>
<li><a href="qtservice-example-interactive.html">An Interactive Service</a></li>
<li><a href="qtservice-example-server.html">A simple HTTP Server</a></li>
<li><a href="qtservice-example-controller.html">A simple Service Controller</a></li>
</ul>
<a name="tested-platforms"></a>
<h2>Tested platforms</h2>
<ul>
<li>Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005</li>
<li>Qt 4.4, 4.5 / Linux / gcc</li>
<li>Qt 4.4, 4.5 / MacOS X 10.5 / gcc</li>
</ul>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,195 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/examples/controller/controller.qdoc -->
<head>
<title>A simple Service Controller</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">A simple Service Controller<br /><span class="subtitle"></span>
</h1>
<p>It is a very simple implementation of universal command-line controller. This controller can install and control any service written using <a href="qtservice.html">QtService</a> component. It demonstrates how to use <a href="qtservicecontroller.html">QtServiceController</a> class. On Windows, this is an alternative to using the &quot;Services&quot; Administrative Tool or the built-in <tt>sc.exe</tt> command-line tool to control services.</p>
<p>A note about services on Windows Vista: Installing/uninstalling and starting/stopping services requires security privileges. The simplest way to achieve this is to set the &quot;Run as Administrator&quot; property on the executable (right-click the executable file, select Properties, and choose the Compatibilty tab in the Properties dialog). This applies even if you are logged in as Administrator. Also, the command-line shell should be started with &quot;Run as Administrator&quot;. Note that the service itself does not need special privileges to run. Only if you want the service to be able to install itself (the -i option) or similar, then the service will need to be run as Administrator. Otherwise, the recommended procedure is to use a controller such as this example and/or the &quot;Services&quot; Administrative Tool to manage the service.</p>
<p>A usability hint: in some circumstances, e.g&#x2e; when running this example on Windows Vista with the &quot;Run as Administrator&quot; property set, output will be sent to a shell window which will close immediately upon termination, not leaving the user enough time to read the output. In such cases, append the -w(ait) argument, which will make the controller wait for a keypress before terminating.</p>
<p>Here is the complete source code:</p>
<pre><span class="comment"> /****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/</span>
#include &lt;QtCore/QStringList&gt;
#include &lt;QtCore/QDir&gt;
#include &lt;QtCore/QSettings&gt;
#include &quot;qtservice.h&quot;
int processArgs(int argc, char **argv)
{
if (argc &gt; 2) {
QString arg1(argv[1]);
if (arg1 == QLatin1String(&quot;-i&quot;) ||
arg1 == QLatin1String(&quot;-install&quot;)) {
if (argc &gt; 2) {
QString account;
QString password;
QString path(argv[2]);
if (argc &gt; 3)
account = argv[3];
if (argc &gt; 4)
password = argv[4];
printf(&quot;The service %s installed.\n&quot;,
(QtServiceController::install(path, account, password) ? &quot;was&quot; : &quot;was not&quot;));
return 0;
}
} else {
QString serviceName(argv[1]);
QtServiceController controller(serviceName);
QString option(argv[2]);
if (option == QLatin1String(&quot;-u&quot;) ||
option == QLatin1String(&quot;-uninstall&quot;)) {
printf(&quot;The service \&quot;%s\&quot; %s uninstalled.\n&quot;,
controller.serviceName().toLatin1().constData(),
(controller.uninstall() ? &quot;was&quot; : &quot;was not&quot;));
return 0;
} else if (option == QLatin1String(&quot;-s&quot;) ||
option == QLatin1String(&quot;-start&quot;)) {
QStringList args;
for (int i = 3; i &lt; argc; ++i)
args.append(QString::fromLocal8Bit(argv[i]));
printf(&quot;The service \&quot;%s\&quot; %s started.\n&quot;,
controller.serviceName().toLatin1().constData(),
(controller.start(args) ? &quot;was&quot; : &quot;was not&quot;));
return 0;
} else if (option == QLatin1String(&quot;-t&quot;) ||
option == QLatin1String(&quot;-terminate&quot;)) {
printf(&quot;The service \&quot;%s\&quot; %s stopped.\n&quot;,
controller.serviceName().toLatin1().constData(),
(controller.stop() ? &quot;was&quot; : &quot;was not&quot;));
return 0;
} else if (option == QLatin1String(&quot;-p&quot;) ||
option == QLatin1String(&quot;-pause&quot;)) {
printf(&quot;The service \&quot;%s\&quot; %s paused.\n&quot;,
controller.serviceName().toLatin1().constData(),
(controller.pause() ? &quot;was&quot; : &quot;was not&quot;));
return 0;
} else if (option == QLatin1String(&quot;-r&quot;) ||
option == QLatin1String(&quot;-resume&quot;)) {
printf(&quot;The service \&quot;%s\&quot; %s resumed.\n&quot;,
controller.serviceName().toLatin1().constData(),
(controller.resume() ? &quot;was&quot; : &quot;was not&quot;));
return 0;
} else if (option == QLatin1String(&quot;-c&quot;) ||
option == QLatin1String(&quot;-command&quot;)) {
if (argc &gt; 3) {
QString codestr(argv[3]);
int code = codestr.toInt();
printf(&quot;The command %s sent to the service \&quot;%s\&quot;.\n&quot;,
(controller.sendCommand(code) ? &quot;was&quot; : &quot;was not&quot;),
controller.serviceName().toLatin1().constData());
return 0;
}
} else if (option == QLatin1String(&quot;-v&quot;) ||
option == QLatin1String(&quot;-version&quot;)) {
bool installed = controller.isInstalled();
printf(&quot;The service\n&quot;
&quot;\t\&quot;%s\&quot;\n\n&quot;, controller.serviceName().toLatin1().constData());
printf(&quot;is %s&quot;, (installed ? &quot;installed&quot; : &quot;not installed&quot;));
printf(&quot; and %s\n\n&quot;, (controller.isRunning() ? &quot;running&quot; : &quot;not running&quot;));
if (installed) {
printf(&quot;path: %s\n&quot;, controller.serviceFilePath().toLatin1().data());
printf(&quot;description: %s\n&quot;, controller.serviceDescription().toLatin1().data());
printf(&quot;startup: %s\n&quot;, controller.startupType() == QtServiceController::AutoStartup ? &quot;Auto&quot; : &quot;Manual&quot;);
}
return 0;
}
}
}
printf(&quot;controller [-i PATH | SERVICE_NAME [-v | -u | -s | -t | -p | -r | -c CODE] | -h] [-w]\n\n&quot;
&quot;\t-i(nstall) PATH\t: Install the service\n&quot;
&quot;\t-v(ersion)\t: Print status of the service\n&quot;
&quot;\t-u(ninstall)\t: Uninstall the service\n&quot;
&quot;\t-s(tart)\t: Start the service\n&quot;
&quot;\t-t(erminate)\t: Stop the service\n&quot;
&quot;\t-p(ause)\t: Pause the service\n&quot;
&quot;\t-r(esume)\t: Resume the service\n&quot;
&quot;\t-c(ommand) CODE\t: Send a command to the service\n&quot;
&quot;\t-h(elp)\t\t: Print this help info\n&quot;
&quot;\t-w(ait)\t\t: Wait for keypress when done\n&quot;);
return 0;
}
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
<span class="comment">// QtService stores service settings in SystemScope, which normally require root privileges.</span>
<span class="comment">// To allow testing this example as non-root, we change the directory of the SystemScope settings file.</span>
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning(&quot;(Example uses dummy settings file: %s/QtSoftware.conf)&quot;, QDir::tempPath().toLatin1().constData());
#endif
int result = processArgs(argc, argv);
if (QString::fromLocal8Bit(argv[argc-1]) == QLatin1String(&quot;-w&quot;) ||
QString::fromLocal8Bit(argv[argc-1]) == QLatin1String(&quot;-wait&quot;)) {
printf(&quot;\nPress Enter to continue...&quot;);
QFile input;
input.open(stdin, QIODevice::ReadOnly);
input.readLine();
printf(&quot;\n&quot;);
}
return result;
}</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,161 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/examples/interactive/interactive.qdoc -->
<head>
<title>An Interactive Service</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">An Interactive Service<br /><span class="subtitle"></span>
</h1>
<p>This example implements a service with a simple user interface.</p>
<p>Services are usually non-interactive console applications. User interaction, if required, is usually implemented in a separate, normal GUI application that communicates with the service through an IPC channel. For simple communication, <a href="qtservicecontroller.html#sendCommand">QtServiceController::sendCommand</a>() and <a href="qtservicebase.html#processCommand">QtService::processCommand</a>() may be used, possibly in combination with a shared settings file. For more complex, interactive communication, a custom IPC channel should be used, e.g&#x2e; based on Qt's networking classes.</p>
<p>However, although not recommended in the general case, in certain circumstances a service may provide a GUI itself. This is typically only possible if the service process is run as the same user as the one that is logged in, so that it will have access to the screen. Note however that on Windows Vista, service GUIs are not allowed at all, since services run in a diferent session than all user sessions, for security reasons.</p>
<p>This example demonstrates how to subclass the <a href="qtservice.html">QtService</a> class, the use of start(), stop(), pause(), resume(), and how to use processCommand() to receive control commands while running.</p>
<p>Here is the complete source code:</p>
<pre><span class="comment"> /****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/</span>
#include &lt;QtGui/QApplication&gt;
#include &lt;QtGui/QDesktopWidget&gt;
#include &lt;QtGui/QLabel&gt;
#include &lt;QtCore/QDir&gt;
#include &lt;QtCore/QSettings&gt;
#include &quot;qtservice.h&quot;
class InteractiveService : public QtService&lt;QApplication&gt;
{
public:
InteractiveService(int argc, char **argv);
~InteractiveService();
protected:
void start();
void stop();
void pause();
void resume();
void processCommand(int code);
private:
QLabel *gui;
};
InteractiveService::InteractiveService(int argc, char **argv)
: QtService&lt;QApplication&gt;(argc, argv, &quot;Qt Interactive Service&quot;), gui(0)
{
setServiceDescription(&quot;A Qt service with user interface.&quot;);
setServiceFlags(QtServiceBase::CanBeSuspended);
}
InteractiveService::~InteractiveService()
{
}
void InteractiveService::start()
{
#if defined(Q_OS_WIN)
if ((QSysInfo::WindowsVersion &amp; QSysInfo::WV_NT_based) &amp;&amp;
(QSysInfo::WindowsVersion &gt;= QSysInfo::WV_VISTA)) {
logMessage( &quot;Service GUI not allowed on Windows Vista. See the documentation for this example for more information.&quot;, QtServiceBase::Error );
return;
}
#endif
qApp-&gt;setQuitOnLastWindowClosed(false);
gui = new QLabel(&quot;Service&quot;, 0, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
gui-&gt;move(QApplication::desktop()-&gt;availableGeometry().topLeft());
gui-&gt;show();
}
void InteractiveService::stop()
{
delete gui;
}
void InteractiveService::pause()
{
if (gui)
gui-&gt;hide();
}
void InteractiveService::resume()
{
if (gui)
gui-&gt;show();
}
void InteractiveService::processCommand(int code)
{
gui-&gt;setText(&quot;Command code &quot; + QString::number(code));
gui-&gt;adjustSize();
}
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
<span class="comment">// QtService stores service settings in SystemScope, which normally require root privileges.</span>
<span class="comment">// To allow testing this example as non-root, we change the directory of the SystemScope settings file.</span>
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning(&quot;(Example uses dummy settings file: %s/QtSoftware.conf)&quot;, QDir::tempPath().toLatin1().constData());
#endif
InteractiveService service(argc, argv);
return service.exec();
}</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,159 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/examples/server/server.qdoc -->
<head>
<title>A simple HTTP Server</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">A simple HTTP Server<br /><span class="subtitle"></span>
</h1>
<p>It is a very simple implementation of a HTTP daemon that listens on chosen port (defaultly 8080) and sends back a simple HTML page back for every GET request it gets. After sending the page, it closes the connection.</p>
<pre><span class="comment"> // HttpDaemon is the the class that implements the simple HTTP server.</span>
class HttpDaemon : public QTcpServer
{
Q_OBJECT
public:
HttpDaemon(quint16 port, QObject* parent = 0)
: QTcpServer(parent), disabled(false)
{
listen(QHostAddress::Any, port);
}
void incomingConnection(int socket)
{
if (disabled)
return;
<span class="comment">// When a new client connects, the server constructs a QTcpSocket and all</span>
<span class="comment">// communication with the client is done over this QTcpSocket. QTcpSocket</span>
<span class="comment">// works asynchronously, this means that all the communication is done</span>
<span class="comment">// in the two slots readClient() and discardClient().</span>
QTcpSocket* s = new QTcpSocket(this);
connect(s, SIGNAL(readyRead()), this, SLOT(readClient()));
connect(s, SIGNAL(disconnected()), this, SLOT(discardClient()));
s-&gt;setSocketDescriptor(socket);
QtServiceBase::instance()-&gt;logMessage(&quot;New Connection&quot;);
}
void pause()
{
disabled = true;
}
void resume()
{
disabled = false;
}
private slots:
void readClient()
{
if (disabled)
return;
<span class="comment">// This slot is called when the client sent data to the server. The</span>
<span class="comment">// server looks if it was a get request and sends a very simple HTML</span>
<span class="comment">// document back.</span>
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket-&gt;canReadLine()) {
QStringList tokens = QString(socket-&gt;readLine()).split(QRegExp(&quot;[ \r\n][ \r\n]*&quot;));
if (tokens[0] == &quot;GET&quot;) {
QTextStream os(socket);
os.setAutoDetectUnicode(true);
os &lt;&lt; &quot;HTTP/1.0 200 Ok\r\n&quot;
&quot;Content-Type: text/html; charset=\&quot;utf-8\&quot;\r\n&quot;
&quot;\r\n&quot;
&quot;&lt;h1&gt;Nothing to see here&lt;/h1&gt;\n&quot;
&lt;&lt; QDateTime::currentDateTime().toString() &lt;&lt; &quot;\n&quot;;
socket-&gt;close();
QtServiceBase::instance()-&gt;logMessage(&quot;Wrote to client&quot;);
if (socket-&gt;state() == QTcpSocket::UnconnectedState) {
delete socket;
QtServiceBase::instance()-&gt;logMessage(&quot;Connection closed&quot;);
}
}
}
}
void discardClient()
{
QTcpSocket* socket = (QTcpSocket*)sender();
socket-&gt;deleteLater();
QtServiceBase::instance()-&gt;logMessage(&quot;Connection closed&quot;);
}
private:
bool disabled;
};</pre>
<p>The server implementation uses the <a href="qtservicebase.html#logMessage">QtService::logMessage</a>() function to send messages and status reports to the system event log. The server also supports a paused state in which case incoming requests are ignored.</p>
<p>The <tt>HttpService</tt> class subclasses <a href="qtservice.html">QtService</a> to implement the service functionality.</p>
<pre> class HttpService : public QtService&lt;QCoreApplication&gt;
{
public:
HttpService(int argc, char **argv)
: QtService&lt;QCoreApplication&gt;(argc, argv, &quot;Qt HTTP Daemon&quot;)
{
setServiceDescription(&quot;A dummy HTTP service implemented with Qt&quot;);
setServiceFlags(QtServiceBase::CanBeSuspended);
}</pre>
<p>The constructor calls the <a href="qtservice.html">QtService</a> constructor instantiated with <a href="http://doc.trolltech.com/4.4/qcoreapplication.html">QCoreApplication</a> since our service will not use GUI. The first two parameters of our constructor are passed to <a href="qtservice.html">QtService</a>. The last parameter, &quot;Qt HTTP Daemon&quot;, is the name of the service.</p>
<pre> protected:
void start()
{
QCoreApplication *app = application();
quint16 port = (app-&gt;argc() &gt; 1) ?
QString::fromLocal8Bit(app-&gt;argv()[1]).toUShort() : 8080;
daemon = new HttpDaemon(port, app);
if (!daemon-&gt;isListening()) {
logMessage(QString(&quot;Failed to bind to port %1&quot;).arg(daemon-&gt;serverPort()), QtServiceBase::Error);
app-&gt;quit();
}
}</pre>
<p>The implementation of <tt>start()</tt> first checks if the user passed a port number. If yes that port is used by server to listen on. Otherwise default 8080 port is used. Then creates an instance of the HTTP server using operator new, passing the application object as the parent to ensure that the object gets destroyed.</p>
<pre> void pause()
{
daemon-&gt;pause();
}
void resume()
{
daemon-&gt;resume();
}
private:
HttpDaemon *daemon;
};</pre>
<p>The implementations of pause() and resume() forward the request to the server object.</p>
<pre> #include &quot;main.moc&quot;
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
<span class="comment">// QtService stores service settings in SystemScope, which normally require root privileges.</span>
<span class="comment">// To allow testing this example as non-root, we change the directory of the SystemScope settings file.</span>
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning(&quot;(Example uses dummy settings file: %s/QtSoftware.conf)&quot;, QDir::tempPath().toLatin1().constData());
#endif
HttpService service(argc, argv);
return service.exec();
}</pre>
<p>The main entry point function creates the service object and uses the <tt>exec()</tt> function to execute the service.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,52 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>List of All Members for QtService</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">List of All Members for QtService</h1>
<p>This is the complete list of members for <a href="qtservice.html">QtService</a>, including inherited members.</p>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/>enum <a href="qtservicebase.html#MessageType-enum">MessageType</a></li>
<li><div class="fn"/>enum <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlag</a></li>
<li><div class="fn"/>flags <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a></li>
<li><div class="fn"/><a href="qtservice.html#QtService">QtService</a> ( int, char **, const QString &amp; )</li>
<li><div class="fn"/><a href="qtservice.html#dtor.QtService">~QtService</a> ()</li>
<li><div class="fn"/><a href="qtservice.html#application">application</a> () const : Application *</li>
<li><div class="fn"/><a href="qtservicebase.html#createApplication">createApplication</a> ( int &amp;, char ** )</li>
<li><div class="fn"/><a href="qtservicebase.html#exec">exec</a> () : int</li>
<li><div class="fn"/><a href="qtservicebase.html#executeApplication">executeApplication</a> () : int</li>
<li><div class="fn"/><a href="qtservicebase.html#instance">instance</a> () : QtServiceBase *</li>
<li><div class="fn"/><a href="qtservicebase.html#logMessage">logMessage</a> ( const QString &amp;, MessageType, int, uint, const QByteArray &amp; )</li>
<li><div class="fn"/><a href="qtservicebase.html#pause">pause</a> ()</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><a href="qtservicebase.html#processCommand">processCommand</a> ( int )</li>
<li><div class="fn"/><a href="qtservicebase.html#resume">resume</a> ()</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceDescription">serviceDescription</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceFlags">serviceFlags</a> () const : ServiceFlags</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceName">serviceName</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicebase.html#setServiceDescription">setServiceDescription</a> ( const QString &amp; )</li>
<li><div class="fn"/><a href="qtservicebase.html#setServiceFlags">setServiceFlags</a> ( ServiceFlags )</li>
<li><div class="fn"/><a href="qtservicebase.html#setStartupType">setStartupType</a> ( QtServiceController::StartupType )</li>
<li><div class="fn"/><a href="qtservicebase.html#start">start</a> ()</li>
<li><div class="fn"/><a href="qtservicebase.html#startupType">startupType</a> () const : QtServiceController::StartupType</li>
<li><div class="fn"/><a href="qtservicebase.html#stop">stop</a> ()</li>
</ul>
</td></tr>
</table></p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,76 +0,0 @@
<!DOCTYPE DCF>
<DCF ref="index.html" icon="qtservice.png" imagedir="../../gif" title="Qt Solutions: Service Documentation">
<section ref="classes.html" title="Classes">
<section ref="qtservice.html" title="QtService Class Reference">
<keyword ref="qtservice.html">QtService</keyword>
<keyword ref="qtservice.html#application">application</keyword>
<section ref="qtservice-members.html" title="List of all members"/>
</section>
<section ref="qtservicebase.html" title="QtServiceBase Class Reference">
<keyword ref="qtservicebase.html">QtServiceBase</keyword>
<keyword ref="qtservicebase.html#MessageType-enum">MessageType</keyword>
<keyword ref="qtservicebase.html#MessageType-enum">QtServiceBase::Warning</keyword>
<keyword ref="qtservicebase.html#MessageType-enum">QtServiceBase::Error</keyword>
<keyword ref="qtservicebase.html#MessageType-enum">QtServiceBase::Success</keyword>
<keyword ref="qtservicebase.html#MessageType-enum">QtServiceBase::Information</keyword>
<keyword ref="qtservicebase.html#ServiceFlag-enum">ServiceFlag</keyword>
<keyword ref="qtservicebase.html#ServiceFlag-enum">ServiceFlags</keyword>
<keyword ref="qtservicebase.html#ServiceFlag-enum">QtServiceBase::Default</keyword>
<keyword ref="qtservicebase.html#ServiceFlag-enum">QtServiceBase::CannotBeStopped</keyword>
<keyword ref="qtservicebase.html#ServiceFlag-enum">QtServiceBase::CanBeSuspended</keyword>
<keyword ref="qtservicebase.html#createApplication">createApplication</keyword>
<keyword ref="qtservicebase.html#exec">exec</keyword>
<keyword ref="qtservicebase.html#executeApplication">executeApplication</keyword>
<keyword ref="qtservicebase.html#instance">instance</keyword>
<keyword ref="qtservicebase.html#logMessage">logMessage</keyword>
<keyword ref="qtservicebase.html#pause">pause</keyword>
<keyword ref="qtservicebase.html#processCommand">processCommand</keyword>
<keyword ref="qtservicebase.html#resume">resume</keyword>
<keyword ref="qtservicebase.html#serviceDescription">serviceDescription</keyword>
<keyword ref="qtservicebase.html#serviceFlags">serviceFlags</keyword>
<keyword ref="qtservicebase.html#serviceName">serviceName</keyword>
<keyword ref="qtservicebase.html#setServiceDescription">setServiceDescription</keyword>
<keyword ref="qtservicebase.html#setServiceFlags">setServiceFlags</keyword>
<keyword ref="qtservicebase.html#setStartupType">setStartupType</keyword>
<keyword ref="qtservicebase.html#start">start</keyword>
<keyword ref="qtservicebase.html#startupType">startupType</keyword>
<keyword ref="qtservicebase.html#stop">stop</keyword>
<section ref="qtservicebase-members.html" title="List of all members"/>
</section>
<section ref="qtservicecontroller.html" title="QtServiceController Class Reference">
<keyword ref="qtservicecontroller.html">QtServiceController</keyword>
<keyword ref="qtservicecontroller.html#StartupType-enum">StartupType</keyword>
<keyword ref="qtservicecontroller.html#StartupType-enum">QtServiceController::AutoStartup</keyword>
<keyword ref="qtservicecontroller.html#StartupType-enum">QtServiceController::ManualStartup</keyword>
<keyword ref="qtservicecontroller.html#install">install</keyword>
<keyword ref="qtservicecontroller.html#isInstalled">isInstalled</keyword>
<keyword ref="qtservicecontroller.html#isRunning">isRunning</keyword>
<keyword ref="qtservicecontroller.html#pause">pause</keyword>
<keyword ref="qtservicecontroller.html#resume">resume</keyword>
<keyword ref="qtservicecontroller.html#sendCommand">sendCommand</keyword>
<keyword ref="qtservicecontroller.html#serviceDescription">serviceDescription</keyword>
<keyword ref="qtservicecontroller.html#serviceFilePath">serviceFilePath</keyword>
<keyword ref="qtservicecontroller.html#serviceName">serviceName</keyword>
<keyword ref="qtservicecontroller.html#start">start</keyword>
<keyword ref="qtservicecontroller.html#startupType">startupType</keyword>
<keyword ref="qtservicecontroller.html#stop">stop</keyword>
<keyword ref="qtservicecontroller.html#uninstall">uninstall</keyword>
<section ref="qtservicecontroller-members.html" title="List of all members"/>
</section>
</section>
<section ref="overviews.html" title="Overviews">
<section ref="qtservice-example-server.html" title="A simple HTTP Server">
<keyword ref="qtservice-example-server.html">A simple HTTP Server</keyword>
</section>
<section ref="qtservice-example-controller.html" title="A simple Service Controller">
<keyword ref="qtservice-example-controller.html">A simple Service Controller</keyword>
</section>
<section ref="qtservice-example-interactive.html" title="An Interactive Service">
<keyword ref="qtservice-example-interactive.html">An Interactive Service</keyword>
</section>
<section ref="index.html" title="Service">
<keyword ref="index.html">Service</keyword>
</section>
</section>
<section ref="examples.html" title="Tutorial &amp; Examples"/>
</DCF>

View file

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>QtService Class Reference</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">QtService Class Reference</h1>
<p>The QtService is a convenient template class that allows you to create a service for a particular application type. <a href="#details">More...</a></p>
<pre> #include &lt;QtService&gt;</pre><p>Inherits <a href="qtservicebase.html">QtServiceBase</a>.</p>
<ul>
<li><a href="qtservice-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qtservice.html#QtService">QtService</a></b> ( int <i>argc</i>, char ** <i>argv</i>, const QString &amp; <i>name</i> )</li>
<li><div class="fn"/><b><a href="qtservice.html#dtor.QtService">~QtService</a></b> ()</li>
</ul>
<ul>
<li><div class="fn"/>9 public functions inherited from <a href="qtservicebase.html#public-functions">QtServiceBase</a></li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/>Application * <b><a href="qtservice.html#application">application</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>7 protected functions inherited from <a href="qtservicebase.html#protected-functions">QtServiceBase</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 static public member inherited from <a href="qtservicebase.html#static-public-members">QtServiceBase</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QtService is a convenient template class that allows you to create a service for a particular application type.</p>
<p>A Windows service or Unix daemon (a &quot;service&quot;), is a program that runs &quot;in the background&quot; independently of whether a user is logged in or not. A service is often set up to start when the machine boots up, and will typically run continuously as long as the machine is on.</p>
<p>Services are usually non-interactive console applications. User interaction, if required, is usually implemented in a separate, normal GUI application that communicates with the service through an IPC channel. For simple communication, <a href="qtservicecontroller.html#sendCommand">QtServiceController::sendCommand</a>() and <a href="qtservicebase.html#processCommand">QtService::processCommand</a>() may be used, possibly in combination with a shared settings file. For more complex, interactive communication, a custom IPC channel should be used, e.g&#x2e; based on Qt's networking classes. (In certain circumstances, a service may provide a GUI itself, ref. the &quot;interactive&quot; example documentation).</p>
<p><b>Note:</b> On Unix systems, this class relies on facilities provided by the <a href="http://doc.trolltech.com/4.4/qtnetwork.html">QtNetwork</a> module, provided as part of the <a href="http://doc.trolltech.com/4.4/opensourceedition.html">Qt Open Source Edition</a> and certain <a href="http://doc.trolltech.com/4.4/commercialeditions.html">Qt Commercial Editions</a>.</p>
<p>The QtService class functionality is inherited from <a href="qtservicebase.html">QtServiceBase</a>, but in addition the QtService class binds an instance of <a href="qtservicebase.html">QtServiceBase</a> with an application type.</p>
<p>Typically, you will create a service by subclassing the QtService template class. For example:</p>
<pre> class MyService : public QtService&lt;QApplication&gt;
{
public:
MyService(int argc, char **argv);
~MyService();
protected:
void start();
void stop();
void pause();
void resume();
void processCommand(int code);
};</pre>
<p>The application type can be <a href="http://doc.trolltech.com/4.4/qcoreapplication.html">QCoreApplication</a> for services without GUI, <a href="http://doc.trolltech.com/4.4/qapplication.html">QApplication</a> for services with GUI or you can use your own custom application type.</p>
<p>You must reimplement the <a href="qtservicebase.html#start">QtServiceBase::start</a>() function to perform the service's work. Usually you create some main object on the heap which is the heart of your service.</p>
<p>In addition, you might want to reimplement the <a href="qtservicebase.html#pause">QtServiceBase::pause</a>(), <a href="qtservicebase.html#processCommand">QtServiceBase::processCommand</a>(), <a href="qtservicebase.html#resume">QtServiceBase::resume</a>() and <a href="qtservicebase.html#stop">QtServiceBase::stop</a>() to intervene the service's process on controller requests. You can control any given service using an instance of the <a href="qtservicecontroller.html">QtServiceController</a> class which also allows you to control services from separate applications. The mentioned functions are all virtual and won't do anything unless they are reimplemented.</p>
<p>Your custom service is typically instantiated in the application's main function. Then the main function will call your service's <a href="qtservicebase.html#exec">exec</a>() function, and return the result of that call. For example:</p>
<pre> int main(int argc, char **argv)
{
MyService service(argc, argv);
return service.exec();
}</pre>
<p>When the <a href="qtservicebase.html#exec">exec</a>() function is called, it will parse the <a href="qtservicebase.html#servicespecificarguments">service specific arguments</a> passed in <tt>argv</tt>, perform the required actions, and exit.</p>
<p>If none of the arguments is recognized as service specific, <a href="qtservicebase.html#exec">exec</a>() will first call the <a href="qtservicebase.html#createApplication">createApplication</a>() function, then <a href="qtservicebase.html#executeApplication">executeApplication</a>() and finally the <a href="qtservicebase.html#start">start</a>() function. In the end, <a href="qtservicebase.html#exec">exec</a>() returns while the service continues in its own process waiting for commands from the service controller.</p>
<p>See also <a href="qtservicebase.html">QtServiceBase</a> and <a href="qtservicecontroller.html">QtServiceController</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QtService"></a>QtService::QtService ( int <i>argc</i>, char ** <i>argv</i>, const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Constructs a <a href="qtservice.html">QtService</a> object called <i>name</i>. The <i>argc</i> and <i>argv</i> parameters are parsed after the <a href="qtservicebase.html#exec">exec</a>() function has been called. Then they are passed to the application's constructor.</p>
<p>There can only be one <a href="qtservice.html">QtService</a> object in a process.</p>
<p>See also <a href="qtservicebase.html#QtServiceBase">QtServiceBase</a>().</p>
<h3 class="fn"><a name="dtor.QtService"></a>QtService::~QtService ()</h3>
<p>Destroys the service object.</p>
<h3 class="fn"><a name="application"></a>Application * QtService::application () const&nbsp;&nbsp;<tt> [protected]</tt></h3>
<p>Returns a pointer to the application object.</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,111 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QDOCINDEX>
<INDEX url="" title="Qt Solutions: Service Documentation" version="">
<namespace access="public" threadsafety="unspecified" status="commendable" name="" href="" location="" module="">
<class access="public" threadsafety="unspecified" status="commendable" name="QtServiceController" href="qtservicecontroller.html" location="qtservice.h" bases="" module="">
<enum access="public" threadsafety="unspecified" status="commendable" name="StartupType" fullname="QtServiceController::StartupType" href="qtservicecontroller.html#StartupType-enum" location="qtservice.h">
<value name="AutoStartup" value="0"></value>
<value name="ManualStartup" value="1"></value>
</enum>
<function access="public" threadsafety="unspecified" status="commendable" name="QtServiceController" fullname="QtServiceController::QtServiceController" href="qtservicecontroller.html#QtServiceController" location="qtservice.h" virtual="non" meta="constructor" const="false" static="false" overload="false" type="" signature="QtServiceController(const QString &amp; name)">
<parameter left="const QString &amp;" right="" name="name" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="~QtServiceController" fullname="QtServiceController::~QtServiceController" href="qtservicecontroller.html#dtor.QtServiceController" location="qtservice.h" virtual="impure" meta="destructor" const="false" static="false" overload="false" type="" signature="~QtServiceController()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="isInstalled" fullname="QtServiceController::isInstalled" href="qtservicecontroller.html#isInstalled" location="qtservice_win.cpp" virtual="non" meta="plain" const="true" static="false" overload="false" type="bool" signature="isInstalled() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="isRunning" fullname="QtServiceController::isRunning" href="qtservicecontroller.html#isRunning" location="qtservice_win.cpp" virtual="non" meta="plain" const="true" static="false" overload="false" type="bool" signature="isRunning() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceName" fullname="QtServiceController::serviceName" href="qtservicecontroller.html#serviceName" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="QString" signature="serviceName() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceDescription" fullname="QtServiceController::serviceDescription" href="qtservicecontroller.html#serviceDescription" location="qtservice_win.cpp" virtual="non" meta="plain" const="true" static="false" overload="false" type="QString" signature="serviceDescription() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="startupType" fullname="QtServiceController::startupType" href="qtservicecontroller.html#startupType" location="qtservice_win.cpp" virtual="non" meta="plain" const="true" static="false" overload="false" type="StartupType" signature="startupType() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceFilePath" fullname="QtServiceController::serviceFilePath" href="qtservicecontroller.html#serviceFilePath" location="qtservice_win.cpp" virtual="non" meta="plain" const="true" static="false" overload="false" type="QString" signature="serviceFilePath() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="install" fullname="QtServiceController::install" href="qtservicecontroller.html#install" location="qtservice.h" virtual="non" meta="plain" const="false" static="true" overload="false" type="bool" signature="install(const QString &amp; serviceFilePath, const QString &amp; account, const QString &amp; password)">
<parameter left="const QString &amp;" right="" name="serviceFilePath" default=""></parameter>
<parameter left="const QString &amp;" right="" name="account" default="QString()"></parameter>
<parameter left="const QString &amp;" right="" name="password" default="QString()"></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="uninstall" fullname="QtServiceController::uninstall" href="qtservicecontroller.html#uninstall" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="uninstall()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="start" fullname="QtServiceController::start" href="qtservicecontroller.html#start" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="start(const QStringList &amp; arguments)">
<parameter left="const QStringList &amp;" right="" name="arguments" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="start" fullname="QtServiceController::start" href="qtservicecontroller.html#start-2" location="qtservice.h" virtual="non" meta="plain" const="false" static="false" overload="true" overload-number="2" type="bool" signature="start()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="stop" fullname="QtServiceController::stop" href="qtservicecontroller.html#stop" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="stop()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="pause" fullname="QtServiceController::pause" href="qtservicecontroller.html#pause" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="pause()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="resume" fullname="QtServiceController::resume" href="qtservicecontroller.html#resume" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="resume()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="sendCommand" fullname="QtServiceController::sendCommand" href="qtservicecontroller.html#sendCommand" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="bool" signature="sendCommand(int code)">
<parameter left="int" right="" name="code" default=""></parameter>
</function>
</class>
<class access="public" threadsafety="unspecified" status="commendable" name="QtServiceBase" href="qtservicebase.html" location="qtservice.h" bases="" module="">
<target name="servicespecificarguments"></target>
<enum access="public" threadsafety="unspecified" status="commendable" name="MessageType" fullname="QtServiceBase::MessageType" href="qtservicebase.html#MessageType-enum" location="qtservice.h">
<value name="Success" value="0"></value>
<value name="Error" value="1"></value>
<value name="Warning" value="2"></value>
<value name="Information" value="3"></value>
</enum>
<enum access="public" threadsafety="unspecified" status="commendable" name="ServiceFlag" fullname="QtServiceBase::ServiceFlag" href="qtservicebase.html#ServiceFlag-enum" location="qtservice.h" typedef="QtServiceBase::ServiceFlags">
<value name="Default" value="0x00"></value>
<value name="CanBeSuspended" value="0x01"></value>
<value name="CannotBeStopped" value="0x02"></value>
</enum>
<typedef access="public" threadsafety="unspecified" status="commendable" name="ServiceFlags" fullname="QtServiceBase::ServiceFlags" href="qtservicebase.html#ServiceFlags-typedef" location="qtservice.h" enum="QtServiceBase::ServiceFlag"></typedef>
<function access="public" threadsafety="unspecified" status="commendable" name="QtServiceBase" fullname="QtServiceBase::QtServiceBase" href="qtservicebase.html#QtServiceBase" location="qtservice.h" virtual="non" meta="constructor" const="false" static="false" overload="false" type="" signature="QtServiceBase(int argc, char ** argv, const QString &amp; name)">
<parameter left="int" right="" name="argc" default=""></parameter>
<parameter left="char **" right="" name="argv" default=""></parameter>
<parameter left="const QString &amp;" right="" name="name" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="~QtServiceBase" fullname="QtServiceBase::~QtServiceBase" href="qtservicebase.html#dtor.QtServiceBase" location="qtservice.h" virtual="impure" meta="destructor" const="false" static="false" overload="false" type="" signature="~QtServiceBase()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceName" fullname="QtServiceBase::serviceName" href="qtservicebase.html#serviceName" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="QString" signature="serviceName() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceDescription" fullname="QtServiceBase::serviceDescription" href="qtservicebase.html#serviceDescription" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="QString" signature="serviceDescription() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="setServiceDescription" fullname="QtServiceBase::setServiceDescription" href="qtservicebase.html#setServiceDescription" location="qtservice.h" virtual="non" meta="plain" const="false" static="false" overload="false" type="void" signature="setServiceDescription(const QString &amp; description)">
<parameter left="const QString &amp;" right="" name="description" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="startupType" fullname="QtServiceBase::startupType" href="qtservicebase.html#startupType" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="QtServiceController::StartupType" signature="startupType() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="setStartupType" fullname="QtServiceBase::setStartupType" href="qtservicebase.html#setStartupType" location="qtservice.h" virtual="non" meta="plain" const="false" static="false" overload="false" type="void" signature="setStartupType(QtServiceController::StartupType type)">
<parameter left="QtServiceController::StartupType" right="" name="type" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="serviceFlags" fullname="QtServiceBase::serviceFlags" href="qtservicebase.html#serviceFlags" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="ServiceFlags" signature="serviceFlags() const"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="setServiceFlags" fullname="QtServiceBase::setServiceFlags" href="qtservicebase.html#setServiceFlags" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="void" signature="setServiceFlags(QFlags&lt;QtServiceBase::ServiceFlag&gt; flags)">
<parameter left="QFlags&lt;QtServiceBase::ServiceFlag&gt;" right="" name="flags" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="exec" fullname="QtServiceBase::exec" href="qtservicebase.html#exec" location="qtservice.h" virtual="non" meta="plain" const="false" static="false" overload="false" type="int" signature="exec()"></function>
<function access="public" threadsafety="unspecified" status="commendable" name="logMessage" fullname="QtServiceBase::logMessage" href="qtservicebase.html#logMessage" location="qtservice_win.cpp" virtual="non" meta="plain" const="false" static="false" overload="false" type="void" signature="logMessage(const QString &amp; message, MessageType type, int id, uint category, const QByteArray &amp; data)">
<parameter left="const QString &amp;" right="" name="message" default=""></parameter>
<parameter left="MessageType" right="" name="type" default="Success"></parameter>
<parameter left="int" right="" name="id" default="0"></parameter>
<parameter left="uint" right="" name="category" default="0"></parameter>
<parameter left="const QByteArray &amp;" right="" name="data" default="QByteArray()"></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="instance" fullname="QtServiceBase::instance" href="qtservicebase.html#instance" location="qtservice.h" virtual="non" meta="plain" const="false" static="true" overload="false" type="QtServiceBase *" signature="instance()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="start" fullname="QtServiceBase::start" href="qtservicebase.html#start" location="qtservice.h" virtual="pure" meta="plain" const="false" static="false" overload="false" type="void" signature="start()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="stop" fullname="QtServiceBase::stop" href="qtservicebase.html#stop" location="qtservice.h" virtual="impure" meta="plain" const="false" static="false" overload="false" type="void" signature="stop()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="pause" fullname="QtServiceBase::pause" href="qtservicebase.html#pause" location="qtservice.h" virtual="impure" meta="plain" const="false" static="false" overload="false" type="void" signature="pause()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="resume" fullname="QtServiceBase::resume" href="qtservicebase.html#resume" location="qtservice.h" virtual="impure" meta="plain" const="false" static="false" overload="false" type="void" signature="resume()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="processCommand" fullname="QtServiceBase::processCommand" href="qtservicebase.html#processCommand" location="qtservice.h" virtual="impure" meta="plain" const="false" static="false" overload="false" type="void" signature="processCommand(int code)">
<parameter left="int" right="" name="code" default=""></parameter>
</function>
<function access="protected" threadsafety="unspecified" status="commendable" name="createApplication" fullname="QtServiceBase::createApplication" href="qtservicebase.html#createApplication" location="qtservice.h" virtual="pure" meta="plain" const="false" static="false" overload="false" type="void" signature="createApplication(int &amp; argc, char ** argv)">
<parameter left="int &amp;" right="" name="argc" default=""></parameter>
<parameter left="char **" right="" name="argv" default=""></parameter>
</function>
<function access="protected" threadsafety="unspecified" status="commendable" name="executeApplication" fullname="QtServiceBase::executeApplication" href="qtservicebase.html#executeApplication" location="qtservice.h" virtual="pure" meta="plain" const="false" static="false" overload="false" type="int" signature="executeApplication()"></function>
</class>
<class access="public" threadsafety="unspecified" status="commendable" name="QtService" href="qtservice.html" location="qtservice.h" bases="QtServiceBase" module="">
<function access="public" threadsafety="unspecified" status="commendable" name="QtService" fullname="QtService::QtService" href="qtservice.html#QtService" location="qtservice.h" virtual="non" meta="constructor" const="false" static="false" overload="false" type="" signature="QtService(int argc, char ** argv, const QString &amp; name)">
<parameter left="int" right="" name="argc" default=""></parameter>
<parameter left="char **" right="" name="argv" default=""></parameter>
<parameter left="const QString &amp;" right="" name="name" default=""></parameter>
</function>
<function access="public" threadsafety="unspecified" status="commendable" name="~QtService" fullname="QtService::~QtService" href="qtservice.html#dtor.QtService" location="qtservice.h" virtual="non" meta="destructor" const="false" static="false" overload="false" type="" signature="~QtService()"></function>
<function access="protected" threadsafety="unspecified" status="commendable" name="application" fullname="QtService::application" href="qtservice.html#application" location="qtservice.h" virtual="non" meta="plain" const="true" static="false" overload="false" type="Application *" signature="application() const"></function>
</class>
<page access="public" status="commendable" name="index.html" href="index.html" subtype="page" title="Service" fulltitle="Service" subtitle="" location="index.qdoc">
<contents name="description" title="Description" level="1"></contents>
<contents name="classes" title="Classes" level="1"></contents>
<contents name="examples" title="Examples" level="1"></contents>
<contents name="tested-platforms" title="Tested platforms" level="1"></contents>
</page>
<page access="public" status="commendable" name="qtservice-example-interactive.html" href="qtservice-example-interactive.html" subtype="page" title="An Interactive Service" fulltitle="An Interactive Service" subtitle="" location="interactive.qdoc"></page>
<page access="public" status="commendable" name="qtservice-example-server.html" href="qtservice-example-server.html" subtype="page" title="A simple HTTP Server" fulltitle="A simple HTTP Server" subtitle="" location="server.qdoc"></page>
<page access="public" status="commendable" name="qtservice-example-controller.html" href="qtservice-example-controller.html" subtype="page" title="A simple Service Controller" fulltitle="A simple Service Controller" subtitle="" location="controller.qdoc"></page>
</namespace>
</INDEX>

View file

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<QtHelpProject version="1.0">
<namespace>com.trolltech.qtsolutions.qtservice_2.6</namespace>
<virtualFolder>qdoc</virtualFolder>
<customFilter name="Qt Solutions: Service">
<filterAttribute>qt</filterAttribute>
<filterAttribute>qtservice</filterAttribute>
<filterAttribute>solutions</filterAttribute>
</customFilter>
<filterSection>
<filterAttribute>qt</filterAttribute>
<filterAttribute>qtservice</filterAttribute>
<filterAttribute>solutions</filterAttribute>
<toc>
<section ref="index.html" title="Qt Solutions: Service Documentation">
<section ref="qtservice-example-server.html" title="A simple HTTP Server"></section>
<section ref="qtservice-example-controller.html" title="A simple Service Controller"></section>
<section ref="qtservice-example-interactive.html" title="An Interactive Service"></section>
<section ref="index.html" title="Service"></section>
</section>
</toc>
<keywords>
<keyword name="A simple HTTP Server" id="A simple HTTP Server" ref="qtservice-example-server.html"></keyword>
<keyword name="A simple Service Controller" id="A simple Service Controller" ref="qtservice-example-controller.html"></keyword>
<keyword name="An Interactive Service" id="An Interactive Service" ref="qtservice-example-interactive.html"></keyword>
<keyword name="QtService" id="QtService" ref="qtservice.html"></keyword>
<keyword name="application" id="QtService::application" ref="qtservice.html#application"></keyword>
<keyword name="~QtService" id="QtService::~QtService" ref="qtservice.html#dtor.QtService"></keyword>
<keyword name="QtServiceBase" id="QtServiceBase" ref="qtservicebase.html"></keyword>
<keyword name="QtServiceBase::MessageType" id="QtServiceBase::MessageType" ref="qtservicebase.html#MessageType-enum"></keyword>
<keyword name="QtServiceBase::Success" id="QtServiceBase::Success" ref="qtservicebase.html#MessageType-enum"></keyword>
<keyword name="QtServiceBase::Error" id="QtServiceBase::Error" ref="qtservicebase.html#MessageType-enum"></keyword>
<keyword name="QtServiceBase::Warning" id="QtServiceBase::Warning" ref="qtservicebase.html#MessageType-enum"></keyword>
<keyword name="QtServiceBase::Information" id="QtServiceBase::Information" ref="qtservicebase.html#MessageType-enum"></keyword>
<keyword name="QtServiceBase::ServiceFlag" id="QtServiceBase::ServiceFlag" ref="qtservicebase.html#ServiceFlag-enum"></keyword>
<keyword name="QtServiceBase::Default" id="QtServiceBase::Default" ref="qtservicebase.html#ServiceFlag-enum"></keyword>
<keyword name="QtServiceBase::CanBeSuspended" id="QtServiceBase::CanBeSuspended" ref="qtservicebase.html#ServiceFlag-enum"></keyword>
<keyword name="QtServiceBase::CannotBeStopped" id="QtServiceBase::CannotBeStopped" ref="qtservicebase.html#ServiceFlag-enum"></keyword>
<keyword name="QtServiceBase::ServiceFlags" id="QtServiceBase::ServiceFlags" ref="qtservicebase.html#ServiceFlag-enum"></keyword>
<keyword name="createApplication" id="QtServiceBase::createApplication" ref="qtservicebase.html#createApplication"></keyword>
<keyword name="exec" id="QtServiceBase::exec" ref="qtservicebase.html#exec"></keyword>
<keyword name="executeApplication" id="QtServiceBase::executeApplication" ref="qtservicebase.html#executeApplication"></keyword>
<keyword name="instance" id="QtServiceBase::instance" ref="qtservicebase.html#instance"></keyword>
<keyword name="logMessage" id="QtServiceBase::logMessage" ref="qtservicebase.html#logMessage"></keyword>
<keyword name="pause" id="QtServiceBase::pause" ref="qtservicebase.html#pause"></keyword>
<keyword name="processCommand" id="QtServiceBase::processCommand" ref="qtservicebase.html#processCommand"></keyword>
<keyword name="resume" id="QtServiceBase::resume" ref="qtservicebase.html#resume"></keyword>
<keyword name="serviceDescription" id="QtServiceBase::serviceDescription" ref="qtservicebase.html#serviceDescription"></keyword>
<keyword name="serviceFlags" id="QtServiceBase::serviceFlags" ref="qtservicebase.html#serviceFlags"></keyword>
<keyword name="serviceName" id="QtServiceBase::serviceName" ref="qtservicebase.html#serviceName"></keyword>
<keyword name="setServiceDescription" id="QtServiceBase::setServiceDescription" ref="qtservicebase.html#setServiceDescription"></keyword>
<keyword name="setServiceFlags" id="QtServiceBase::setServiceFlags" ref="qtservicebase.html#setServiceFlags"></keyword>
<keyword name="setStartupType" id="QtServiceBase::setStartupType" ref="qtservicebase.html#setStartupType"></keyword>
<keyword name="start" id="QtServiceBase::start" ref="qtservicebase.html#start"></keyword>
<keyword name="startupType" id="QtServiceBase::startupType" ref="qtservicebase.html#startupType"></keyword>
<keyword name="stop" id="QtServiceBase::stop" ref="qtservicebase.html#stop"></keyword>
<keyword name="~QtServiceBase" id="QtServiceBase::~QtServiceBase" ref="qtservicebase.html#dtor.QtServiceBase"></keyword>
<keyword name="QtServiceController" id="QtServiceController" ref="qtservicecontroller.html"></keyword>
<keyword name="QtServiceController::StartupType" id="QtServiceController::StartupType" ref="qtservicecontroller.html#StartupType-enum"></keyword>
<keyword name="QtServiceController::AutoStartup" id="QtServiceController::AutoStartup" ref="qtservicecontroller.html#StartupType-enum"></keyword>
<keyword name="QtServiceController::ManualStartup" id="QtServiceController::ManualStartup" ref="qtservicecontroller.html#StartupType-enum"></keyword>
<keyword name="install" id="QtServiceController::install" ref="qtservicecontroller.html#install"></keyword>
<keyword name="isInstalled" id="QtServiceController::isInstalled" ref="qtservicecontroller.html#isInstalled"></keyword>
<keyword name="isRunning" id="QtServiceController::isRunning" ref="qtservicecontroller.html#isRunning"></keyword>
<keyword name="pause" id="QtServiceController::pause" ref="qtservicecontroller.html#pause"></keyword>
<keyword name="resume" id="QtServiceController::resume" ref="qtservicecontroller.html#resume"></keyword>
<keyword name="sendCommand" id="QtServiceController::sendCommand" ref="qtservicecontroller.html#sendCommand"></keyword>
<keyword name="serviceDescription" id="QtServiceController::serviceDescription" ref="qtservicecontroller.html#serviceDescription"></keyword>
<keyword name="serviceFilePath" id="QtServiceController::serviceFilePath" ref="qtservicecontroller.html#serviceFilePath"></keyword>
<keyword name="serviceName" id="QtServiceController::serviceName" ref="qtservicecontroller.html#serviceName"></keyword>
<keyword name="start" id="QtServiceController::start" ref="qtservicecontroller.html#start"></keyword>
<keyword name="startupType" id="QtServiceController::startupType" ref="qtservicecontroller.html#startupType"></keyword>
<keyword name="stop" id="QtServiceController::stop" ref="qtservicecontroller.html#stop"></keyword>
<keyword name="uninstall" id="QtServiceController::uninstall" ref="qtservicecontroller.html#uninstall"></keyword>
<keyword name="~QtServiceController" id="QtServiceController::~QtServiceController" ref="qtservicecontroller.html#dtor.QtServiceController"></keyword>
<keyword name="Service" id="Service" ref="index.html"></keyword>
</keywords>
<files>
<file>qtservice-example-controller.html</file>
<file>index.html</file>
<file>qtservice-example-server.html</file>
<file>qtservice-example-interactive.html</file>
<file>qtservicebase.html</file>
<file>qtservice.html</file>
<file>qtservicecontroller.html</file>
<file>classic.css</file>
<file>images/qt-logo.png</file>
</files>
</filterSection>
</QtHelpProject>

View file

@ -1,51 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>List of All Members for QtServiceBase</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">List of All Members for QtServiceBase</h1>
<p>This is the complete list of members for <a href="qtservicebase.html">QtServiceBase</a>, including inherited members.</p>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/>enum <a href="qtservicebase.html#MessageType-enum">MessageType</a></li>
<li><div class="fn"/>enum <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlag</a></li>
<li><div class="fn"/>flags <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a></li>
<li><div class="fn"/><a href="qtservicebase.html#QtServiceBase">QtServiceBase</a> ( int, char **, const QString &amp; )</li>
<li><div class="fn"/><a href="qtservicebase.html#dtor.QtServiceBase">~QtServiceBase</a> ()</li>
<li><div class="fn"/><a href="qtservicebase.html#createApplication">createApplication</a> ( int &amp;, char ** )</li>
<li><div class="fn"/><a href="qtservicebase.html#exec">exec</a> () : int</li>
<li><div class="fn"/><a href="qtservicebase.html#executeApplication">executeApplication</a> () : int</li>
<li><div class="fn"/><a href="qtservicebase.html#instance">instance</a> () : QtServiceBase *</li>
<li><div class="fn"/><a href="qtservicebase.html#logMessage">logMessage</a> ( const QString &amp;, MessageType, int, uint, const QByteArray &amp; )</li>
<li><div class="fn"/><a href="qtservicebase.html#pause">pause</a> ()</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><a href="qtservicebase.html#processCommand">processCommand</a> ( int )</li>
<li><div class="fn"/><a href="qtservicebase.html#resume">resume</a> ()</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceDescription">serviceDescription</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceFlags">serviceFlags</a> () const : ServiceFlags</li>
<li><div class="fn"/><a href="qtservicebase.html#serviceName">serviceName</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicebase.html#setServiceDescription">setServiceDescription</a> ( const QString &amp; )</li>
<li><div class="fn"/><a href="qtservicebase.html#setServiceFlags">setServiceFlags</a> ( ServiceFlags )</li>
<li><div class="fn"/><a href="qtservicebase.html#setStartupType">setStartupType</a> ( QtServiceController::StartupType )</li>
<li><div class="fn"/><a href="qtservicebase.html#start">start</a> ()</li>
<li><div class="fn"/><a href="qtservicebase.html#startupType">startupType</a> () const : QtServiceController::StartupType</li>
<li><div class="fn"/><a href="qtservicebase.html#stop">stop</a> ()</li>
</ul>
</td></tr>
</table></p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,199 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>QtServiceBase Class Reference</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">QtServiceBase Class Reference</h1>
<p>The QtServiceBase class provides an API for implementing Windows services and Unix daemons. <a href="#details">More...</a></p>
<pre> #include &lt;QtServiceBase&gt;</pre><p>Inherited by <a href="qtservice.html">QtService</a>.</p>
<ul>
<li><a href="qtservicebase-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>enum <b><a href="qtservicebase.html#MessageType-enum">MessageType</a></b> { Success, Error, Warning, Information }</li>
<li><div class="fn"/>enum <b><a href="qtservicebase.html#ServiceFlag-enum">ServiceFlag</a></b> { Default, CanBeSuspended, CannotBeStopped }</li>
<li><div class="fn"/>flags <b><a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a></b></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qtservicebase.html#QtServiceBase">QtServiceBase</a></b> ( int <i>argc</i>, char ** <i>argv</i>, const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>virtual <b><a href="qtservicebase.html#dtor.QtServiceBase">~QtServiceBase</a></b> ()</li>
<li><div class="fn"/>int <b><a href="qtservicebase.html#exec">exec</a></b> ()</li>
<li><div class="fn"/>void <b><a href="qtservicebase.html#logMessage">logMessage</a></b> ( const QString &amp; <i>message</i>, MessageType <i>type</i> = Success, int <i>id</i> = 0, uint <i>category</i> = 0, const QByteArray &amp; <i>data</i> = QByteArray() )</li>
<li><div class="fn"/>QString <b><a href="qtservicebase.html#serviceDescription">serviceDescription</a></b> () const</li>
<li><div class="fn"/>ServiceFlags <b><a href="qtservicebase.html#serviceFlags">serviceFlags</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qtservicebase.html#serviceName">serviceName</a></b> () const</li>
<li><div class="fn"/>void <b><a href="qtservicebase.html#setServiceDescription">setServiceDescription</a></b> ( const QString &amp; <i>description</i> )</li>
<li><div class="fn"/>void <b><a href="qtservicebase.html#setServiceFlags">setServiceFlags</a></b> ( ServiceFlags <i>flags</i> )</li>
<li><div class="fn"/>void <b><a href="qtservicebase.html#setStartupType">setStartupType</a></b> ( QtServiceController::StartupType <i>type</i> )</li>
<li><div class="fn"/>QtServiceController::StartupType <b><a href="qtservicebase.html#startupType">startupType</a></b> () const</li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>QtServiceBase * <b><a href="qtservicebase.html#instance">instance</a></b> ()</li>
</ul>
<a name="protected-functions"></a>
<h3>Protected Functions</h3>
<ul>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#createApplication">createApplication</a></b> ( int &amp; <i>argc</i>, char ** <i>argv</i> ) = 0</li>
<li><div class="fn"/>virtual int <b><a href="qtservicebase.html#executeApplication">executeApplication</a></b> () = 0</li>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#pause">pause</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#processCommand">processCommand</a></b> ( int <i>code</i> )</li>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#resume">resume</a></b> ()</li>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#start">start</a></b> () = 0</li>
<li><div class="fn"/>virtual void <b><a href="qtservicebase.html#stop">stop</a></b> ()</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QtServiceBase class provides an API for implementing Windows services and Unix daemons.</p>
<p>A Windows service or Unix daemon (a &quot;service&quot;), is a program that runs &quot;in the background&quot; independently of whether a user is logged in or not. A service is often set up to start when the machine boots up, and will typically run continuously as long as the machine is on.</p>
<p>Services are usually non-interactive console applications. User interaction, if required, is usually implemented in a separate, normal GUI application that communicates with the service through an IPC channel. For simple communication, <a href="qtservicecontroller.html#sendCommand">QtServiceController::sendCommand</a>() and <a href="qtservicebase.html#processCommand">QtService::processCommand</a>() may be used, possibly in combination with a shared settings file. For more complex, interactive communication, a custom IPC channel should be used, e.g&#x2e; based on Qt's networking classes. (In certain circumstances, a service may provide a GUI itself, ref. the &quot;interactive&quot; example documentation).</p>
<p>Typically, you will create a service by subclassing the <a href="qtservice.html">QtService</a> template class which inherits QtServiceBase and allows you to create a service for a particular application type.</p>
<p>The Windows implementation uses the NT Service Control Manager, and the application can be controlled through the system administration tools. Services are usually launched using the system account, which requires that all DLLs that the service executable depends on (i.e&#x2e; Qt), are located in the same directory as the service, or in a system path.</p>
<p>On Unix a service is implemented as a daemon.</p>
<p>You can retrieve the service's description, state, and startup type using the <a href="qtservicebase.html#serviceDescription">serviceDescription</a>(), <a href="qtservicebase.html#serviceFlags">serviceFlags</a>() and <a href="qtservicebase.html#startupType">startupType</a>() functions respectively. The service's state is decribed by the <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlag</a> enum. The mentioned properites can also be set using the corresponding set functions. In addition you can retrieve the service's name using the <a href="qtservicebase.html#serviceName">serviceName</a>() function.</p>
<p>Several of QtServiceBase's protected functions are called on requests from the <a href="qtservicecontroller.html">QtServiceController</a> class:</p>
<ul>
<li><a href="qtservicebase.html#start">start</a>()</li>
<li><a href="qtservicebase.html#pause">pause</a>()</li>
<li><a href="qtservicebase.html#processCommand">processCommand</a>()</li>
<li><a href="qtservicebase.html#resume">resume</a>()</li>
<li><a href="qtservicebase.html#stop">stop</a>()</li>
</ul>
<p>You can control any given service using an instance of the <a href="qtservicecontroller.html">QtServiceController</a> class which also allows you to control services from separate applications. The mentioned functions are all virtual and won't do anything unless they are reimplemented. You can reimplement these functions to pause and resume the service's execution, as well as process user commands and perform additional clean-ups before shutting down.</p>
<p>QtServiceBase also provides the static <a href="qtservicebase.html#instance">instance</a>() function which returns a pointer to an application's QtServiceBase instance. In addition, a service can report events to the system's event log using the <a href="qtservicebase.html#logMessage">logMessage</a>() function. The <a href="qtservicebase.html#MessageType-enum">MessageType</a> enum describes the different types of messages a service reports.</p>
<p>The implementation of a service application's main function typically creates an service object derived by subclassing the <a href="qtservice.html">QtService</a> template class. Then the main function will call this service's <a href="qtservicebase.html#exec">exec</a>() function, and return the result of that call. For example:</p>
<pre> int main(int argc, char **argv)
{
MyService service(argc, argv);
return service.exec();
}</pre>
<p>When the <a href="qtservicebase.html#exec">exec</a>() function is called, it will parse the service specific arguments passed in <tt>argv</tt>, perform the required actions, and return.</p>
<a name="servicespecificarguments"></a><p>The following arguments are recognized as service specific:</p>
<p><table align="center" cellpadding="2" cellspacing="1" border="0">
<thead><tr valign="top" class="qt-style"><th>Short</th><th>Long</th><th>Explanation</th></tr></thead>
<tr valign="top" class="odd"><td>-i</td><td>-install</td><td>Install the service.</td></tr>
<tr valign="top" class="even"><td>-u</td><td>-uninstall</td><td>Uninstall the service.</td></tr>
<tr valign="top" class="odd"><td>-e</td><td>-exec</td><td>Execute the service as a standalone application (useful for debug purposes). This is a blocking call, the service will be executed like a normal application. In this mode you will not be able to communicate with the service from the contoller.</td></tr>
<tr valign="top" class="even"><td>-t</td><td>-terminate</td><td>Stop the service.</td></tr>
<tr valign="top" class="odd"><td>-p</td><td>-pause</td><td>Pause the service.</td></tr>
<tr valign="top" class="even"><td>-r</td><td>-resume</td><td>Resume a paused service.</td></tr>
<tr valign="top" class="odd"><td>-c <i>cmd</i></td><td>-command <i>cmd</i></td><td>Send the user defined command code <i>cmd</i> to the service application.</td></tr>
<tr valign="top" class="even"><td>-v</td><td>-version</td><td>Display version and status information.</td></tr>
</table></p>
<p>If <i>none</i> of the arguments is recognized as service specific, <a href="qtservicebase.html#exec">exec</a>() will first call the <a href="qtservicebase.html#createApplication">createApplication</a>() function, then <a href="qtservicebase.html#executeApplication">executeApplication</a>() and finally the <a href="qtservicebase.html#start">start</a>() function. In the end, <a href="qtservicebase.html#exec">exec</a>() returns while the service continues in its own process waiting for commands from the service controller.</p>
<p>See also <a href="qtservice.html">QtService</a> and <a href="qtservicecontroller.html">QtServiceController</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="MessageType-enum"></a>enum QtServiceBase::MessageType</h3>
<p>This enum describes the different types of messages a service reports to the system log.</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QtServiceBase::Success</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">An operation has succeeded, e.g&#x2e; the service is started.</td></tr>
<tr><td valign="top"><tt>QtServiceBase::Error</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">An operation failed, e.g&#x2e; the service failed to start.</td></tr>
<tr><td valign="top"><tt>QtServiceBase::Warning</tt></td><td align="center" valign="top"><tt>2</tt></td><td valign="top">An operation caused a warning that might require user interaction.</td></tr>
<tr><td valign="top"><tt>QtServiceBase::Information</tt></td><td align="center" valign="top"><tt>3</tt></td><td valign="top">Any type of usually non-critical information.</td></tr>
</table></p>
<h3 class="flags"><a name="ServiceFlag-enum"></a>enum QtServiceBase::ServiceFlag<br />flags QtServiceBase::ServiceFlags</h3>
<p>This enum describes the different states of a service.</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QtServiceBase::Default</tt></td><td align="center" valign="top"><tt>0x00</tt></td><td valign="top">The service can be stopped, but not suspended.</td></tr>
<tr><td valign="top"><tt>QtServiceBase::CanBeSuspended</tt></td><td align="center" valign="top"><tt>0x01</tt></td><td valign="top">The service can be suspended.</td></tr>
<tr><td valign="top"><tt>QtServiceBase::CannotBeStopped</tt></td><td align="center" valign="top"><tt>0x02</tt></td><td valign="top">The service cannot be stopped.</td></tr>
</table></p>
<p>The ServiceFlags type is a typedef for <a href="qflags.html">QFlags</a>&lt;ServiceFlag&gt;. It stores an OR combination of ServiceFlag values.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QtServiceBase"></a>QtServiceBase::QtServiceBase ( int <i>argc</i>, char ** <i>argv</i>, const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Creates a service instance called <i>name</i>. The <i>argc</i> and <i>argv</i> parameters are parsed after the <a href="qtservicebase.html#exec">exec</a>() function has been called. Then they are passed to the application's constructor. The application type is determined by the <a href="qtservice.html">QtService</a> subclass.</p>
<p>The service is neither installed nor started. The name must not contain any backslashes or be longer than 255 characters. In addition, the name must be unique in the system's service database.</p>
<p>See also <a href="qtservicebase.html#exec">exec</a>(), <a href="qtservicebase.html#start">start</a>(), and <a href="qtservicecontroller.html#install">QtServiceController::install</a>().</p>
<h3 class="fn"><a name="dtor.QtServiceBase"></a>QtServiceBase::~QtServiceBase ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Destroys the service object. This neither stops nor uninstalls the service.</p>
<p>To stop a service the <a href="qtservicebase.html#stop">stop</a>() function must be called explicitly. To uninstall a service, you can use the <a href="qtservicecontroller.html#uninstall">QtServiceController::uninstall</a>() function.</p>
<p>See also <a href="qtservicebase.html#stop">stop</a>() and <a href="qtservicecontroller.html#uninstall">QtServiceController::uninstall</a>().</p>
<h3 class="fn"><a name="createApplication"></a>void QtServiceBase::createApplication ( int &amp; <i>argc</i>, char ** <i>argv</i> )&nbsp;&nbsp;<tt> [pure virtual protected]</tt></h3>
<p>Creates the application object using the <i>argc</i> and <i>argv</i> parameters.</p>
<p>This function is only called when no <a href="qtservicebase.html#servicespecificarguments">service specific arguments</a> were passed to the service constructor, and is called by <a href="qtservicebase.html#exec">exec</a>() before it calls the <a href="qtservicebase.html#executeApplication">executeApplication</a>() and <a href="qtservicebase.html#start">start</a>() functions.</p>
<p>The createApplication() function is implemented in <a href="qtservice.html">QtService</a>, but you might want to reimplement it, for example, if the chosen application type's constructor needs additional arguments.</p>
<p>See also <a href="qtservicebase.html#exec">exec</a>() and <a href="qtservice.html">QtService</a>.</p>
<h3 class="fn"><a name="exec"></a>int QtServiceBase::exec ()</h3>
<p>Executes the service.</p>
<p>When the exec() function is called, it will parse the <a href="qtservicebase.html#servicespecificarguments">service specific arguments</a> passed in <tt>argv</tt>, perform the required actions, and exit.</p>
<p>If none of the arguments is recognized as service specific, exec() will first call the <a href="qtservicebase.html#createApplication">createApplication</a>() function, then <a href="qtservicebase.html#executeApplication">executeApplication</a>() and finally the <a href="qtservicebase.html#start">start</a>() function. In the end, exec() returns while the service continues in its own process waiting for commands from the service controller.</p>
<p>See also <a href="qtservicecontroller.html">QtServiceController</a>.</p>
<h3 class="fn"><a name="executeApplication"></a>int QtServiceBase::executeApplication ()&nbsp;&nbsp;<tt> [pure virtual protected]</tt></h3>
<p>Executes the application previously created with the <a href="qtservicebase.html#createApplication">createApplication</a>() function.</p>
<p>This function is only called when no <a href="qtservicebase.html#servicespecificarguments">service specific arguments</a> were passed to the service constructor, and is called by <a href="qtservicebase.html#exec">exec</a>() after it has called the <a href="qtservicebase.html#createApplication">createApplication</a>() function and before <a href="qtservicebase.html#start">start</a>() function.</p>
<p>This function is implemented in <a href="qtservice.html">QtService</a>.</p>
<p>See also <a href="qtservicebase.html#exec">exec</a>() and <a href="qtservicebase.html#createApplication">createApplication</a>().</p>
<h3 class="fn"><a name="instance"></a>QtServiceBase * QtServiceBase::instance ()&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Returns a pointer to the current application's <a href="qtservicebase.html">QtServiceBase</a> instance.</p>
<h3 class="fn"><a name="logMessage"></a>void QtServiceBase::logMessage ( const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>message</i>, <a href="qtservicebase.html#MessageType-enum">MessageType</a> <i>type</i> = Success, int <i>id</i> = 0, <a href="http://doc.trolltech.com/4.4/qtglobal.html#uint-typedef">uint</a> <i>category</i> = 0, const <a href="http://doc.trolltech.com/4.4/qbytearray.html">QByteArray</a> &amp; <i>data</i> = QByteArray() )</h3>
<p>Reports a message of the given <i>type</i> with the given <i>message</i> to the local system event log. The message identifier <i>id</i> and the message <i>category</i> are user defined values. The <i>data</i> parameter can contain arbitrary binary data.</p>
<p>Message strings for <i>id</i> and <i>category</i> must be provided by a message file, which must be registered in the system registry. Refer to the MSDN for more information about how to do this on Windows.</p>
<p>See also <a href="qtservicebase.html#MessageType-enum">MessageType</a>.</p>
<h3 class="fn"><a name="pause"></a>void QtServiceBase::pause ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplement this function to pause the service's execution (for example to stop a polling timer, or to ignore socket notifiers).</p>
<p>This function is called in reply to controller requests. The default implementation does nothing.</p>
<p>See also <a href="qtservicebase.html#resume">resume</a>() and <a href="qtservicecontroller.html#pause">QtServiceController::pause</a>().</p>
<h3 class="fn"><a name="processCommand"></a>void QtServiceBase::processCommand ( int <i>code</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplement this function to process the user command <i>code</i>.</p>
<p>This function is called in reply to controller requests. The default implementation does nothing.</p>
<p>See also <a href="qtservicecontroller.html#sendCommand">QtServiceController::sendCommand</a>().</p>
<h3 class="fn"><a name="resume"></a>void QtServiceBase::resume ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplement this function to continue the service after a call to <a href="qtservicebase.html#pause">pause</a>().</p>
<p>This function is called in reply to controller requests. The default implementation does nothing.</p>
<p>See also <a href="qtservicebase.html#pause">pause</a>() and <a href="qtservicecontroller.html#resume">QtServiceController::resume</a>().</p>
<h3 class="fn"><a name="serviceDescription"></a><a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> QtServiceBase::serviceDescription () const</h3>
<p>Returns the description of the service.</p>
<p>See also <a href="qtservicebase.html#setServiceDescription">setServiceDescription</a>() and <a href="qtservicebase.html#serviceName">serviceName</a>().</p>
<h3 class="fn"><a name="serviceFlags"></a><a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a> QtServiceBase::serviceFlags () const</h3>
<p>Returns the service's state which is decribed using the <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlag</a> enum.</p>
<p>See also <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a> and <a href="qtservicebase.html#setServiceFlags">setServiceFlags</a>().</p>
<h3 class="fn"><a name="serviceName"></a><a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> QtServiceBase::serviceName () const</h3>
<p>Returns the name of the service.</p>
<p>See also <a href="qtservicebase.html#QtServiceBase">QtServiceBase</a>() and <a href="qtservicebase.html#serviceDescription">serviceDescription</a>().</p>
<h3 class="fn"><a name="setServiceDescription"></a>void QtServiceBase::setServiceDescription ( const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>description</i> )</h3>
<p>Sets the description of the service to the given <i>description</i>.</p>
<p>See also <a href="qtservicebase.html#serviceDescription">serviceDescription</a>().</p>
<h3 class="fn"><a name="setServiceFlags"></a>void QtServiceBase::setServiceFlags ( <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a> <i>flags</i> )</h3>
<p>Sets the service's state to the state described by the given <i>flags</i>.</p>
<p>See also <a href="qtservicebase.html#ServiceFlag-enum">ServiceFlags</a> and <a href="qtservicebase.html#serviceFlags">serviceFlags</a>().</p>
<h3 class="fn"><a name="setStartupType"></a>void QtServiceBase::setStartupType ( <a href="qtservicecontroller.html#StartupType-enum">QtServiceController::StartupType</a> <i>type</i> )</h3>
<p>Sets the service's startup type to the given <i>type</i>.</p>
<p>See also <a href="qtservicecontroller.html#StartupType-enum">QtServiceController::StartupType</a> and <a href="qtservicebase.html#startupType">startupType</a>().</p>
<h3 class="fn"><a name="start"></a>void QtServiceBase::start ()&nbsp;&nbsp;<tt> [pure virtual protected]</tt></h3>
<p>This function must be implemented in <a href="qtservicebase.html">QtServiceBase</a> subclasses in order to perform the service's work. Usually you create some main object on the heap which is the heart of your service.</p>
<p>The function is only called when no service specific arguments were passed to the service constructor, and is called by <a href="qtservicebase.html#exec">exec</a>() after it has called the <a href="qtservicebase.html#executeApplication">executeApplication</a>() function.</p>
<p>Note that you <i>don't</i> need to create an application object or call its <a href="qtservicebase.html#exec">exec</a>() function explicitly.</p>
<p>See also <a href="qtservicebase.html#exec">exec</a>(), <a href="qtservicebase.html#stop">stop</a>(), and <a href="qtservicecontroller.html#start">QtServiceController::start</a>().</p>
<h3 class="fn"><a name="startupType"></a><a href="qtservicecontroller.html#StartupType-enum">QtServiceController::StartupType</a> QtServiceBase::startupType () const</h3>
<p>Returns the service's startup type.</p>
<p>See also <a href="qtservicecontroller.html#StartupType-enum">QtServiceController::StartupType</a> and <a href="qtservicebase.html#setStartupType">setStartupType</a>().</p>
<h3 class="fn"><a name="stop"></a>void QtServiceBase::stop ()&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reimplement this function to perform additional cleanups before shutting down (for example deleting a main object if it was created in the <a href="qtservicebase.html#start">start</a>() function).</p>
<p>This function is called in reply to controller requests. The default implementation does nothing.</p>
<p>See also <a href="qtservicebase.html#start">start</a>() and <a href="qtservicecontroller.html#stop">QtServiceController::stop</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,46 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>List of All Members for QtServiceController</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">List of All Members for QtServiceController</h1>
<p>This is the complete list of members for <a href="qtservicecontroller.html">QtServiceController</a>, including inherited members.</p>
<p><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="45%" valign="top"><ul>
<li><div class="fn"/>enum <a href="qtservicecontroller.html#StartupType-enum">StartupType</a></li>
<li><div class="fn"/><a href="qtservicecontroller.html#QtServiceController">QtServiceController</a> ( const QString &amp; )</li>
<li><div class="fn"/><a href="qtservicecontroller.html#dtor.QtServiceController">~QtServiceController</a> ()</li>
<li><div class="fn"/><a href="qtservicecontroller.html#install">install</a> ( const QString &amp;, const QString &amp;, const QString &amp; ) : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#isInstalled">isInstalled</a> () const : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#isRunning">isRunning</a> () const : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#pause">pause</a> () : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#resume">resume</a> () : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#sendCommand">sendCommand</a> ( int ) : bool</li>
</ul></td><td valign="top"><ul>
<li><div class="fn"/><a href="qtservicecontroller.html#serviceDescription">serviceDescription</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicecontroller.html#serviceFilePath">serviceFilePath</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicecontroller.html#serviceName">serviceName</a> () const : QString</li>
<li><div class="fn"/><a href="qtservicecontroller.html#start">start</a> ( const QStringList &amp; ) : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#start-2">start</a> () : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#startupType">startupType</a> () const : StartupType</li>
<li><div class="fn"/><a href="qtservicecontroller.html#stop">stop</a> () : bool</li>
<li><div class="fn"/><a href="qtservicecontroller.html#uninstall">uninstall</a> () : bool</li>
</ul>
</td></tr>
</table></p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

View file

@ -1,155 +0,0 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- qtservice-2.6-opensource/src/qtservice.cpp -->
<head>
<title>QtServiceController Class Reference</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="57" height="67" border="0" /></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a></td>
</tr></table><h1 class="title">QtServiceController Class Reference</h1>
<p>The QtServiceController class allows you to control services from separate applications. <a href="#details">More...</a></p>
<pre> #include &lt;QtServiceController&gt;</pre><ul>
<li><a href="qtservicecontroller-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h3>Public Types</h3>
<ul>
<li><div class="fn"/>enum <b><a href="qtservicecontroller.html#StartupType-enum">StartupType</a></b> { AutoStartup, ManualStartup }</li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qtservicecontroller.html#QtServiceController">QtServiceController</a></b> ( const QString &amp; <i>name</i> )</li>
<li><div class="fn"/>virtual <b><a href="qtservicecontroller.html#dtor.QtServiceController">~QtServiceController</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#isInstalled">isInstalled</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#isRunning">isRunning</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#pause">pause</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#resume">resume</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#sendCommand">sendCommand</a></b> ( int <i>code</i> )</li>
<li><div class="fn"/>QString <b><a href="qtservicecontroller.html#serviceDescription">serviceDescription</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qtservicecontroller.html#serviceFilePath">serviceFilePath</a></b> () const</li>
<li><div class="fn"/>QString <b><a href="qtservicecontroller.html#serviceName">serviceName</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#start">start</a></b> ( const QStringList &amp; <i>arguments</i> )</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#start-2">start</a></b> ()</li>
<li><div class="fn"/>StartupType <b><a href="qtservicecontroller.html#startupType">startupType</a></b> () const</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#stop">stop</a></b> ()</li>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#uninstall">uninstall</a></b> ()</li>
</ul>
<a name="static-public-members"></a>
<h3>Static Public Members</h3>
<ul>
<li><div class="fn"/>bool <b><a href="qtservicecontroller.html#install">install</a></b> ( const QString &amp; <i>serviceFilePath</i>, const QString &amp; <i>account</i> = QString(), const QString &amp; <i>password</i> = QString() )</li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QtServiceController class allows you to control services from separate applications.</p>
<p>QtServiceController provides a collection of functions that lets you install and run a service controlling its execution, as well as query its status.</p>
<p>In order to run a service, the service must be installed in the system's service database using the <a href="qtservicecontroller.html#install">install</a>() function. The system will start the service depending on the specified <a href="qtservicecontroller.html#StartupType-enum">StartupType</a>; it can either be started during system startup, or when a process starts it manually.</p>
<p>Once a service is installed, the service can be run and controlled manually using the <a href="qtservicecontroller.html#start">start</a>(), <a href="qtservicecontroller.html#stop">stop</a>(), <a href="qtservicecontroller.html#pause">pause</a>(), <a href="qtservicecontroller.html#resume">resume</a>() or <a href="qtservicecontroller.html#sendCommand">sendCommand</a>() functions. You can at any time query for the service's status using the <a href="qtservicecontroller.html#isInstalled">isInstalled</a>() and <a href="qtservicecontroller.html#isRunning">isRunning</a>() functions, or you can query its properties using the <a href="qtservicecontroller.html#serviceDescription">serviceDescription</a>(), <a href="qtservicecontroller.html#serviceFilePath">serviceFilePath</a>(), <a href="qtservicecontroller.html#serviceName">serviceName</a>() and <a href="qtservicecontroller.html#startupType">startupType</a>() functions. For example:</p>
<pre> MyService service; \\ which inherits QtService
QString serviceFilePath;
QtServiceController controller(service.serviceName());
if (controller.install(serviceFilePath))
controller.start()
if (controller.isRunning())
QMessageBox::information(this, tr(&quot;Service Status&quot;),
tr(&quot;The %1 service is started&quot;).arg(controller.serviceName()));
...
controller.stop();
controller.uninstall();
}</pre>
<p>An instance of the service controller can only control one single service. To control several services within one application, you must create en equal number of service controllers.</p>
<p>The QtServiceController destructor neither stops nor uninstalls the associated service. To stop a service the <a href="qtservicecontroller.html#stop">stop</a>() function must be called explicitly. To uninstall a service, you can use the <a href="qtservicecontroller.html#uninstall">uninstall</a>() function.</p>
<p>See also <a href="qtservicebase.html">QtServiceBase</a> and <a href="qtservice.html">QtService</a>.</p>
<hr />
<h2>Member Type Documentation</h2>
<h3 class="fn"><a name="StartupType-enum"></a>enum QtServiceController::StartupType</h3>
<p>This enum describes when a service should be started.</p>
<p><table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
<tr><td valign="top"><tt>QtServiceController::AutoStartup</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The service is started during system startup.</td></tr>
<tr><td valign="top"><tt>QtServiceController::ManualStartup</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The service must be started manually by a process.</td></tr>
</table></p>
<p><b>Warning:</b> The <i>StartupType</i> enum is ignored under UNIX-like systems. A service, or daemon, can only be started manually on such systems with current implementation.</p>
<p>See also <a href="qtservicecontroller.html#startupType">startupType</a>().</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QtServiceController"></a>QtServiceController::QtServiceController ( const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>name</i> )</h3>
<p>Creates a controller object for the service with the given <i>name</i>.</p>
<h3 class="fn"><a name="dtor.QtServiceController"></a>QtServiceController::~QtServiceController ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Destroys the service controller. This neither stops nor uninstalls the controlled service.</p>
<p>To stop a service the <a href="qtservicecontroller.html#stop">stop</a>() function must be called explicitly. To uninstall a service, you can use the <a href="qtservicecontroller.html#uninstall">uninstall</a>() function.</p>
<p>See also <a href="qtservicecontroller.html#stop">stop</a>() and <a href="qtservicecontroller.html#uninstall">QtServiceController::uninstall</a>().</p>
<h3 class="fn"><a name="install"></a>bool QtServiceController::install ( const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>serviceFilePath</i>, const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>account</i> = QString(), const <a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> &amp; <i>password</i> = QString() )&nbsp;&nbsp;<tt> [static]</tt></h3>
<p>Installs the service with the given <i>serviceFilePath</i> and returns true if the service is installed successfully; otherwise returns false.</p>
<p>On Windows service is installed in the system's service control manager with the given <i>account</i> and <i>password</i>.</p>
<p>On Unix service configuration is written to <a href="http://doc.trolltech.com/4.4/qsettings.html#Scope-enum">QSettings::SystemScope</a> using &quot;QtSoftware&quot; as organization name. <i>account</i> and <i>password</i> arguments are ignored.</p>
<p><b>Warning:</b> Due to the different implementations of how services (daemons) are installed on various UNIX-like systems, this method doesn't integrate the service into the system's startup scripts.</p>
<p>See also <a href="qtservicecontroller.html#uninstall">uninstall</a>() and <a href="qtservicecontroller.html#start">start</a>().</p>
<h3 class="fn"><a name="isInstalled"></a>bool QtServiceController::isInstalled () const</h3>
<p>Returns true if the service is installed; otherwise returns false.</p>
<p>On Windows it uses the system's service control manager.</p>
<p>On Unix it checks configuration written to <a href="http://doc.trolltech.com/4.4/qsettings.html#Scope-enum">QSettings::SystemScope</a> using &quot;QtSoftware&quot; as organization name.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>().</p>
<h3 class="fn"><a name="isRunning"></a>bool QtServiceController::isRunning () const</h3>
<p>Returns true if the service is running; otherwise returns false. A service must be installed before it can be run using a controller.</p>
<p>See also <a href="qtservicecontroller.html#start">start</a>() and <a href="qtservicecontroller.html#isInstalled">isInstalled</a>().</p>
<h3 class="fn"><a name="pause"></a>bool QtServiceController::pause ()</h3>
<p>Requests the running service to pause. If the service's state is <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::CanBeSuspended</a>, the service will call the <a href="qtservicebase.html#pause">QtServiceBase::pause</a>() implementation. The function does nothing if the service is not running.</p>
<p>Returns true if a running service was successfully paused; otherwise returns false.</p>
<p>See also <a href="qtservicecontroller.html#resume">resume</a>(), <a href="qtservicebase.html#pause">QtServiceBase::pause</a>(), and <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::ServiceFlags</a>.</p>
<h3 class="fn"><a name="resume"></a>bool QtServiceController::resume ()</h3>
<p>Requests the running service to continue. If the service's state is <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::CanBeSuspended</a>, the service will call the <a href="qtservicebase.html#resume">QtServiceBase::resume</a>() implementation. This function does nothing if the service is not running.</p>
<p>Returns true if a running service was successfully resumed; otherwise returns false.</p>
<p>See also <a href="qtservicecontroller.html#pause">pause</a>(), <a href="qtservicebase.html#resume">QtServiceBase::resume</a>(), and <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::ServiceFlags</a>.</p>
<h3 class="fn"><a name="sendCommand"></a>bool QtServiceController::sendCommand ( int <i>code</i> )</h3>
<p>Sends the user command <i>code</i> to the service. The service will call the <a href="qtservicebase.html#processCommand">QtServiceBase::processCommand</a>() implementation. This function does nothing if the service is not running.</p>
<p>Returns true if the request was sent to a running service; otherwise returns false.</p>
<p>See also <a href="qtservicebase.html#processCommand">QtServiceBase::processCommand</a>().</p>
<h3 class="fn"><a name="serviceDescription"></a><a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> QtServiceController::serviceDescription () const</h3>
<p>Returns the description of the controlled service.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>() and <a href="qtservicecontroller.html#serviceName">serviceName</a>().</p>
<h3 class="fn"><a name="serviceFilePath"></a><a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> QtServiceController::serviceFilePath () const</h3>
<p>Returns the file path to the controlled service.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>() and <a href="qtservicecontroller.html#serviceName">serviceName</a>().</p>
<h3 class="fn"><a name="serviceName"></a><a href="http://doc.trolltech.com/4.4/qstring.html">QString</a> QtServiceController::serviceName () const</h3>
<p>Returns the name of the controlled service.</p>
<p>See also <a href="qtservicecontroller.html#QtServiceController">QtServiceController</a>() and <a href="qtservicecontroller.html#serviceDescription">serviceDescription</a>().</p>
<h3 class="fn"><a name="start"></a>bool QtServiceController::start ( const <a href="http://doc.trolltech.com/4.4/qstringlist.html">QStringList</a> &amp; <i>arguments</i> )</h3>
<p>Starts the installed service passing the given <i>arguments</i> to the service. A service must be installed before a controller can run it.</p>
<p>Returns true if the service could be started; otherwise returns false.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>() and <a href="qtservicecontroller.html#stop">stop</a>().</p>
<h3 class="fn"><a name="start-2"></a>bool QtServiceController::start ()</h3>
<p>This is an overloaded member function, provided for convenience.</p>
<p>Starts the installed service without passing any arguments to the service.</p>
<h3 class="fn"><a name="startupType"></a><a href="qtservicecontroller.html#StartupType-enum">StartupType</a> QtServiceController::startupType () const</h3>
<p>Returns the startup type of the controlled service.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>() and <a href="qtservicecontroller.html#serviceName">serviceName</a>().</p>
<h3 class="fn"><a name="stop"></a>bool QtServiceController::stop ()</h3>
<p>Requests the running service to stop. The service will call the <a href="qtservicebase.html#stop">QtServiceBase::stop</a>() implementation unless the service's state is <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::CannotBeStopped</a>. This function does nothing if the service is not running.</p>
<p>Returns true if a running service was successfully stopped; otherwise false.</p>
<p>See also <a href="qtservicecontroller.html#start">start</a>(), <a href="qtservicebase.html#stop">QtServiceBase::stop</a>(), and <a href="qtservicebase.html#ServiceFlag-enum">QtServiceBase::ServiceFlags</a>.</p>
<h3 class="fn"><a name="uninstall"></a>bool QtServiceController::uninstall ()</h3>
<p>Uninstalls the service and returns true if successful; otherwise returns false.</p>
<p>On Windows service is uninstalled using the system's service control manager.</p>
<p>On Unix service configuration is cleared using <a href="http://doc.trolltech.com/4.4/qsettings.html#Scope-enum">QSettings::SystemScope</a> with &quot;QtSoftware&quot; as organization name.</p>
<p>See also <a href="qtservicecontroller.html#install">install</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%" align="left">Copyright &copy; 2009 Nokia</td>
<td width="40%" align="center"><a href="http://doc.trolltech.com/trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt Solutions</div></td>
</tr></table></div></address></body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4 KiB

View file

@ -1,46 +0,0 @@
/*!
\page index.html
\title Service
\section1 Description
The QtService component is useful for developing Windows
services and Unix daemons.
The project provides a QtService template class that can be used to
implement service applications, and a QtServiceController class
to control a service.
On Windows systems the implementation uses the Service Control
Manager.
On Unix systems services are implemented as daemons.
\section1 Classes
\list
\i QtServiceController \i QtServiceBase \i QtService\endlist
\section1 Examples
\list
\i \link qtservice-example-interactive.html An Interactive Service \endlink \i \link qtservice-example-server.html A simple HTTP Server \endlink \i \link qtservice-example-controller.html A simple Service Controller \endlink \endlist
\section1 Tested platforms
\list
\i Qt 4.4, 4.5 / Windows XP / MSVC.NET 2005
\i Qt 4.4, 4.5 / Linux / gcc
\i Qt 4.4, 4.5 / MacOS X 10.5 / gcc
\endlist
*/

View file

@ -1,7 +0,0 @@
TEMPLATE = app
CONFIG += console qt
QT = core
SOURCES = main.cpp
include(../../src/qtservice.pri)

View file

@ -1,81 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
/*! \page qtservice-example-controller.html
\title A simple Service Controller
It is a very simple implementation of universal command-line
controller. This controller can install and control any service
written using QtService component. It demonstrates how to use
QtServiceController class. On Windows, this is an alternative to
using the "Services" Administrative Tool or the built-in \c sc.exe
command-line tool to control services.
A note about services on Windows Vista: Installing/uninstalling
and starting/stopping services requires security privileges. The
simplest way to achieve this is to set the "Run as Administrator"
property on the executable (right-click the executable file,
select Properties, and choose the Compatibilty tab in the
Properties dialog). This applies even if you are logged in as
Administrator. Also, the command-line shell should be started with
"Run as Administrator". Note that the service itself does not need
special privileges to run. Only if you want the service to be able
to install itself (the -i option) or similar, then the service
will need to be run as Administrator. Otherwise, the recommended
procedure is to use a controller such as this example and/or the
"Services" Administrative Tool to manage the service.
A usability hint: in some circumstances, e.g. when running this
example on Windows Vista with the "Run as Administrator" property
set, output will be sent to a shell window which will close
immediately upon termination, not leaving the user enough time to
read the output. In such cases, append the -w(ait) argument, which
will make the controller wait for a keypress before terminating.
Here is the complete source code:
\quotefile controller/main.cpp
*/

View file

@ -1,169 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include <QtCore/QStringList>
#include <QtCore/QDir>
#include <QtCore/QSettings>
#include "qtservice.h"
int processArgs(int argc, char **argv)
{
if (argc > 2) {
QString arg1(argv[1]);
if (arg1 == QLatin1String("-i") ||
arg1 == QLatin1String("-install")) {
if (argc > 2) {
QString account;
QString password;
QString path(argv[2]);
if (argc > 3)
account = argv[3];
if (argc > 4)
password = argv[4];
printf("The service %s installed.\n",
(QtServiceController::install(path, account, password) ? "was" : "was not"));
return 0;
}
} else {
QString serviceName(argv[1]);
QtServiceController controller(serviceName);
QString option(argv[2]);
if (option == QLatin1String("-u") ||
option == QLatin1String("-uninstall")) {
printf("The service \"%s\" %s uninstalled.\n",
controller.serviceName().toLatin1().constData(),
(controller.uninstall() ? "was" : "was not"));
return 0;
} else if (option == QLatin1String("-s") ||
option == QLatin1String("-start")) {
QStringList args;
for (int i = 3; i < argc; ++i)
args.append(QString::fromLocal8Bit(argv[i]));
printf("The service \"%s\" %s started.\n",
controller.serviceName().toLatin1().constData(),
(controller.start(args) ? "was" : "was not"));
return 0;
} else if (option == QLatin1String("-t") ||
option == QLatin1String("-terminate")) {
printf("The service \"%s\" %s stopped.\n",
controller.serviceName().toLatin1().constData(),
(controller.stop() ? "was" : "was not"));
return 0;
} else if (option == QLatin1String("-p") ||
option == QLatin1String("-pause")) {
printf("The service \"%s\" %s paused.\n",
controller.serviceName().toLatin1().constData(),
(controller.pause() ? "was" : "was not"));
return 0;
} else if (option == QLatin1String("-r") ||
option == QLatin1String("-resume")) {
printf("The service \"%s\" %s resumed.\n",
controller.serviceName().toLatin1().constData(),
(controller.resume() ? "was" : "was not"));
return 0;
} else if (option == QLatin1String("-c") ||
option == QLatin1String("-command")) {
if (argc > 3) {
QString codestr(argv[3]);
int code = codestr.toInt();
printf("The command %s sent to the service \"%s\".\n",
(controller.sendCommand(code) ? "was" : "was not"),
controller.serviceName().toLatin1().constData());
return 0;
}
} else if (option == QLatin1String("-v") ||
option == QLatin1String("-version")) {
bool installed = controller.isInstalled();
printf("The service\n"
"\t\"%s\"\n\n", controller.serviceName().toLatin1().constData());
printf("is %s", (installed ? "installed" : "not installed"));
printf(" and %s\n\n", (controller.isRunning() ? "running" : "not running"));
if (installed) {
printf("path: %s\n", controller.serviceFilePath().toLatin1().data());
printf("description: %s\n", controller.serviceDescription().toLatin1().data());
printf("startup: %s\n", controller.startupType() == QtServiceController::AutoStartup ? "Auto" : "Manual");
}
return 0;
}
}
}
printf("controller [-i PATH | SERVICE_NAME [-v | -u | -s | -t | -p | -r | -c CODE] | -h] [-w]\n\n"
"\t-i(nstall) PATH\t: Install the service\n"
"\t-v(ersion)\t: Print status of the service\n"
"\t-u(ninstall)\t: Uninstall the service\n"
"\t-s(tart)\t: Start the service\n"
"\t-t(erminate)\t: Stop the service\n"
"\t-p(ause)\t: Pause the service\n"
"\t-r(esume)\t: Resume the service\n"
"\t-c(ommand) CODE\t: Send a command to the service\n"
"\t-h(elp)\t\t: Print this help info\n"
"\t-w(ait)\t\t: Wait for keypress when done\n");
return 0;
}
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
// QtService stores service settings in SystemScope, which normally require root privileges.
// To allow testing this example as non-root, we change the directory of the SystemScope settings file.
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData());
#endif
int result = processArgs(argc, argv);
if (QString::fromLocal8Bit(argv[argc-1]) == QLatin1String("-w") ||
QString::fromLocal8Bit(argv[argc-1]) == QLatin1String("-wait")) {
printf("\nPress Enter to continue...");
QFile input;
input.open(stdin, QIODevice::ReadOnly);
input.readLine();
printf("\n");
}
return result;
}

View file

@ -1,4 +0,0 @@
TEMPLATE = subdirs
SUBDIRS = interactive \
server \
controller

View file

@ -1,6 +0,0 @@
TEMPLATE = app
CONFIG += console qt
SOURCES = main.cpp
include(../../src/qtservice.pri)

View file

@ -1,76 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
/*! \page qtservice-example-interactive.html
\title An Interactive Service
This example implements a service with a simple user interface.
Services are usually non-interactive console applications. User
interaction, if required, is usually implemented in a separate,
normal GUI application that communicates with the service through
an IPC channel. For simple communication,
QtServiceController::sendCommand() and QtService::processCommand()
may be used, possibly in combination with a shared settings
file. For more complex, interactive communication, a custom IPC
channel should be used, e.g. based on Qt's networking classes.
However, although not recommended in the general case, in certain
circumstances a service may provide a GUI
itself. This is typically only possible if the service process is run as
the same user as the one that is logged in, so that it will have
access to the screen. Note however that on Windows Vista, service
GUIs are not allowed at all, since services run in a
diferent session than all user sessions, for security reasons.
This example demonstrates how to subclass the QtService class, the use of
start(), stop(), pause(), resume(), and how to use
processCommand() to receive control commands while running.
Here is the complete source code:
\quotefile interactive/main.cpp
*/

View file

@ -1,133 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include <QtGui/QApplication>
#include <QtGui/QDesktopWidget>
#include <QtGui/QLabel>
#include <QtCore/QDir>
#include <QtCore/QSettings>
#include "qtservice.h"
class InteractiveService : public QtService<QApplication>
{
public:
InteractiveService(int argc, char **argv);
~InteractiveService();
protected:
void start();
void stop();
void pause();
void resume();
void processCommand(int code);
private:
QLabel *gui;
};
InteractiveService::InteractiveService(int argc, char **argv)
: QtService<QApplication>(argc, argv, "Qt Interactive Service"), gui(0)
{
setServiceDescription("A Qt service with user interface.");
setServiceFlags(QtServiceBase::CanBeSuspended);
}
InteractiveService::~InteractiveService()
{
}
void InteractiveService::start()
{
#if defined(Q_OS_WIN)
if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) &&
(QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)) {
logMessage( "Service GUI not allowed on Windows Vista. See the documentation for this example for more information.", QtServiceBase::Error );
return;
}
#endif
qApp->setQuitOnLastWindowClosed(false);
gui = new QLabel("Service", 0, Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
gui->move(QApplication::desktop()->availableGeometry().topLeft());
gui->show();
}
void InteractiveService::stop()
{
delete gui;
}
void InteractiveService::pause()
{
if (gui)
gui->hide();
}
void InteractiveService::resume()
{
if (gui)
gui->show();
}
void InteractiveService::processCommand(int code)
{
gui->setText("Command code " + QString::number(code));
gui->adjustSize();
}
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
// QtService stores service settings in SystemScope, which normally require root privileges.
// To allow testing this example as non-root, we change the directory of the SystemScope settings file.
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData());
#endif
InteractiveService service(argc, argv);
return service.exec();
}

View file

@ -1,190 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include <QtCore/QCoreApplication>
#include <QtNetwork/QTcpServer>
#include <QtNetwork/QTcpSocket>
#include <QtCore/QTextStream>
#include <QtCore/QDateTime>
#include <QtCore/QStringList>
#include <QtCore/QDir>
#include <QtCore/QSettings>
#include "qtservice.h"
// HttpDaemon is the the class that implements the simple HTTP server.
class HttpDaemon : public QTcpServer
{
Q_OBJECT
public:
HttpDaemon(quint16 port, QObject* parent = 0)
: QTcpServer(parent), disabled(false)
{
listen(QHostAddress::Any, port);
}
void incomingConnection(int socket)
{
if (disabled)
return;
// When a new client connects, the server constructs a QTcpSocket and all
// communication with the client is done over this QTcpSocket. QTcpSocket
// works asynchronously, this means that all the communication is done
// in the two slots readClient() and discardClient().
QTcpSocket* s = new QTcpSocket(this);
connect(s, SIGNAL(readyRead()), this, SLOT(readClient()));
connect(s, SIGNAL(disconnected()), this, SLOT(discardClient()));
s->setSocketDescriptor(socket);
QtServiceBase::instance()->logMessage("New Connection");
}
void pause()
{
disabled = true;
}
void resume()
{
disabled = false;
}
private slots:
void readClient()
{
if (disabled)
return;
// This slot is called when the client sent data to the server. The
// server looks if it was a get request and sends a very simple HTML
// document back.
QTcpSocket* socket = (QTcpSocket*)sender();
if (socket->canReadLine()) {
QStringList tokens = QString(socket->readLine()).split(QRegExp("[ \r\n][ \r\n]*"));
if (tokens[0] == "GET") {
QTextStream os(socket);
os.setAutoDetectUnicode(true);
os << "HTTP/1.0 200 Ok\r\n"
"Content-Type: text/html; charset=\"utf-8\"\r\n"
"\r\n"
"<h1>Nothing to see here</h1>\n"
<< QDateTime::currentDateTime().toString() << "\n";
socket->close();
QtServiceBase::instance()->logMessage("Wrote to client");
if (socket->state() == QTcpSocket::UnconnectedState) {
delete socket;
QtServiceBase::instance()->logMessage("Connection closed");
}
}
}
}
void discardClient()
{
QTcpSocket* socket = (QTcpSocket*)sender();
socket->deleteLater();
QtServiceBase::instance()->logMessage("Connection closed");
}
private:
bool disabled;
};
class HttpService : public QtService<QCoreApplication>
{
public:
HttpService(int argc, char **argv)
: QtService<QCoreApplication>(argc, argv, "Qt HTTP Daemon")
{
setServiceDescription("A dummy HTTP service implemented with Qt");
setServiceFlags(QtServiceBase::CanBeSuspended);
}
protected:
void start()
{
QCoreApplication *app = application();
quint16 port = (app->argc() > 1) ?
QString::fromLocal8Bit(app->argv()[1]).toUShort() : 8080;
daemon = new HttpDaemon(port, app);
if (!daemon->isListening()) {
logMessage(QString("Failed to bind to port %1").arg(daemon->serverPort()), QtServiceBase::Error);
app->quit();
}
}
void pause()
{
daemon->pause();
}
void resume()
{
daemon->resume();
}
private:
HttpDaemon *daemon;
};
#include "main.moc"
int main(int argc, char **argv)
{
#if !defined(Q_WS_WIN)
// QtService stores service settings in SystemScope, which normally require root privileges.
// To allow testing this example as non-root, we change the directory of the SystemScope settings file.
QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath());
qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData());
#endif
HttpService service(argc, argv);
return service.exec();
}

View file

@ -1,8 +0,0 @@
TARGET = httpservice
TEMPLATE = app
CONFIG += console qt
QT = core network
SOURCES = main.cpp
include(../../src/qtservice.pri)

View file

@ -1,87 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
/*! \page qtservice-example-server.html
\title A simple HTTP Server
It is a very simple implementation of a HTTP daemon that listens on
chosen port (defaultly 8080) and sends back a simple HTML page back for every GET
request it gets. After sending the page, it closes the connection.
\quotefromfile server/main.cpp
\skipto HttpDaemon
\printuntil };
The server implementation uses
the QtService::logMessage() function to send messages and status
reports to the system event log. The server also supports
a paused state in which case incoming requests are ignored.
The \c HttpService class subclasses QtService to implement the
service functionality.
\printto protected:
The constructor calls the QtService constructor instantiated with QCoreApplication
since our service will not use GUI.
The first two parameters of our constructor are passed to QtService.
The last parameter, "Qt HTTP Daemon", is the name of the service.
\printto pause()
The implementation of \c start() first checks if the user passed a port number.
If yes that port is used by server to listen on. Otherwise default 8080 port is used.
Then creates an instance of the HTTP server using operator
new, passing the application object as the parent to ensure that the object
gets destroyed.
\printto private:
\printuntil };
The implementations of pause() and resume() forward the request to the
server object.
\printuntil }
The main entry point function creates the service object and uses
the \c exec() function to execute the service.
*/

View file

@ -1,5 +0,0 @@
TEMPLATE=subdirs
CONFIG += ordered
include(common.pri)
qtservice-uselib:SUBDIRS=buildlib
SUBDIRS+=examples

View file

@ -1 +0,0 @@
#include "qtservice.h"

View file

@ -1 +0,0 @@
#include "qtservice.h"

File diff suppressed because it is too large Load diff

View file

@ -1,197 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QTSERVICE_H
#define QTSERVICE_H
#include <QtCore/QCoreApplication>
#if defined(Q_WS_WIN)
# if !defined(QT_QTSERVICE_EXPORT) && !defined(QT_QTSERVICE_IMPORT)
# define QT_QTSERVICE_EXPORT
# elif defined(QT_QTSERVICE_IMPORT)
# if defined(QT_QTSERVICE_EXPORT)
# undef QT_QTSERVICE_EXPORT
# endif
# define QT_QTSERVICE_EXPORT __declspec(dllimport)
# elif defined(QT_QTSERVICE_EXPORT)
# undef QT_QTSERVICE_EXPORT
# define QT_QTSERVICE_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTSERVICE_EXPORT
#endif
class QStringList;
class QtServiceControllerPrivate;
class QT_QTSERVICE_EXPORT QtServiceController
{
Q_DECLARE_PRIVATE(QtServiceController)
public:
enum StartupType
{
AutoStartup = 0, ManualStartup
};
QtServiceController(const QString &name);
virtual ~QtServiceController();
bool isInstalled() const;
bool isRunning() const;
QString serviceName() const;
QString serviceDescription() const;
StartupType startupType() const;
QString serviceFilePath() const;
static bool install(const QString &serviceFilePath, const QString &account = QString(),
const QString &password = QString());
bool uninstall();
bool start(const QStringList &arguments);
bool start();
bool stop();
bool pause();
bool resume();
bool sendCommand(int code);
private:
QtServiceControllerPrivate *d_ptr;
};
class QtServiceBasePrivate;
class QT_QTSERVICE_EXPORT QtServiceBase
{
Q_DECLARE_PRIVATE(QtServiceBase)
public:
enum MessageType
{
Success = 0, Error, Warning, Information
};
enum ServiceFlag
{
Default = 0x00,
CanBeSuspended = 0x01,
CannotBeStopped = 0x02
};
Q_DECLARE_FLAGS(ServiceFlags, ServiceFlag)
QtServiceBase(int argc, char **argv, const QString &name);
virtual ~QtServiceBase();
QString serviceName() const;
QString serviceDescription() const;
void setServiceDescription(const QString &description);
QtServiceController::StartupType startupType() const;
void setStartupType(QtServiceController::StartupType startupType);
ServiceFlags serviceFlags() const;
void setServiceFlags(ServiceFlags flags);
int exec();
void logMessage(const QString &message, MessageType type = Success,
int id = 0, uint category = 0, const QByteArray &data = QByteArray());
static QtServiceBase *instance();
protected:
virtual void start() = 0;
virtual void stop();
virtual void pause();
virtual void resume();
virtual void processCommand(int code);
virtual void createApplication(int &argc, char **argv) = 0;
virtual int executeApplication() = 0;
private:
friend class QtServiceSysPrivate;
QtServiceBasePrivate *d_ptr;
};
template <typename Application>
class QtService : public QtServiceBase
{
public:
QtService(int argc, char **argv, const QString &name)
: QtServiceBase(argc, argv, name), app(0)
{ }
~QtService()
{
}
protected:
Application *application() const
{ return app; }
virtual void createApplication(int &argc, char **argv)
{
app = new Application(argc, argv);
QCoreApplication *a = app;
Q_UNUSED(a);
}
virtual int executeApplication()
{ return Application::exec(); }
private:
Application *app;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QtServiceBase::ServiceFlags)
#endif // QTSERVICE_H

View file

@ -1,21 +0,0 @@
include(../common.pri)
INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
!win32:QT += network
win32:LIBS += -luser32
qtservice-uselib:!qtservice-buildlib {
LIBS += -L$$QTSERVICE_LIBDIR -l$$QTSERVICE_LIBNAME
} else {
HEADERS += $$PWD/qtservice.h \
$$PWD/qtservice_p.h
SOURCES += $$PWD/qtservice.cpp
win32:SOURCES += $$PWD/qtservice_win.cpp
unix:HEADERS += $$PWD/qtunixsocket.h $$PWD/qtunixserversocket.h
unix:SOURCES += $$PWD/qtservice_unix.cpp $$PWD/qtunixsocket.cpp $$PWD/qtunixserversocket.cpp
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSERVICE_EXPORT
else:qtservice-uselib:DEFINES += QT_QTSERVICE_IMPORT
}

View file

@ -1,93 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QTSERVICE_P_H
#define QTSERVICE_P_H
#include <QtCore/QStringList>
#include "qtservice.h"
class QtServiceControllerPrivate
{
Q_DECLARE_PUBLIC(QtServiceController)
public:
QString serviceName;
QtServiceController *q_ptr;
};
class QtServiceBasePrivate
{
Q_DECLARE_PUBLIC(QtServiceBase)
public:
QtServiceBasePrivate(const QString &name);
~QtServiceBasePrivate();
QtServiceBase *q_ptr;
QString serviceDescription;
QtServiceController::StartupType startupType;
QtServiceBase::ServiceFlags serviceFlags;
QStringList args;
static class QtServiceBase *instance;
QtServiceController controller;
void startService();
int run(bool asService, const QStringList &argList);
bool install(const QString &account, const QString &password);
bool start();
QString filePath() const;
bool sysInit();
void sysSetPath();
void sysCleanup();
class QtServiceSysPrivate *sysd;
};
#endif

View file

@ -1,480 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include "qtservice.h"
#include "qtservice_p.h"
#include "qtunixsocket.h"
#include "qtunixserversocket.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/QFile>
#include <QtCore/QTimer>
#include <QtCore/QDir>
#include <pwd.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <signal.h>
#include <sys/stat.h>
#include <QtCore/QMap>
#include <QtCore/QSettings>
#include <QtCore/QProcess>
static QString encodeName(const QString &name, bool allowUpper = false)
{
QString n = name.toLower();
QString legal = QLatin1String("abcdefghijklmnopqrstuvwxyz1234567890");
if (allowUpper)
legal += QLatin1String("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
int pos = 0;
while (pos < n.size()) {
if (legal.indexOf(n[pos]) == -1)
n.remove(pos, 1);
else
++pos;
}
return n;
}
static QString login()
{
QString l;
uid_t uid = getuid();
passwd *pw = getpwuid(uid);
if (pw)
l = QString(pw->pw_name);
return l;
}
static QString socketPath(const QString &serviceName)
{
QString sn = encodeName(serviceName);
return QString(QLatin1String("/var/tmp/") + sn + QLatin1String(".") + login());
}
static bool sendCmd(const QString &serviceName, const QString &cmd)
{
bool retValue = false;
QtUnixSocket sock;
if (sock.connectTo(socketPath(serviceName))) {
sock.write(QString(cmd+"\r\n").toLatin1().constData());
sock.flush();
sock.waitForReadyRead(-1);
QString reply = sock.readAll();
if (reply == QLatin1String("true"))
retValue = true;
sock.close();
}
return retValue;
}
static QString absPath(const QString &path)
{
QString ret;
if (path[0] != QChar('/')) { // Not an absolute path
int slashpos;
if ((slashpos = path.lastIndexOf('/')) != -1) { // Relative path
QDir dir = QDir::current();
dir.cd(path.left(slashpos));
ret = dir.absolutePath();
} else { // Need to search $PATH
char *envPath = ::getenv("PATH");
if (envPath) {
QStringList envPaths = QString::fromLocal8Bit(envPath).split(':');
for (int i = 0; i < envPaths.size(); ++i) {
if (QFile::exists(envPaths.at(i) + QLatin1String("/") + QString(path))) {
QDir dir(envPaths.at(i));
ret = dir.absolutePath();
break;
}
}
}
}
} else {
QFileInfo fi(path);
ret = fi.absolutePath();
}
return ret;
}
QString QtServiceBasePrivate::filePath() const
{
QString ret;
if (args.isEmpty())
return ret;
QFileInfo fi(args[0]);
QDir dir(absPath(args[0]));
return dir.absoluteFilePath(fi.fileName());
}
QString QtServiceController::serviceDescription() const
{
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
settings.beginGroup(serviceName());
QString desc = settings.value("description").toString();
settings.endGroup();
settings.endGroup();
return desc;
}
QtServiceController::StartupType QtServiceController::startupType() const
{
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
settings.beginGroup(serviceName());
StartupType startupType = (StartupType)settings.value("startupType").toInt();
settings.endGroup();
settings.endGroup();
return startupType;
}
QString QtServiceController::serviceFilePath() const
{
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
settings.beginGroup(serviceName());
QString path = settings.value("path").toString();
settings.endGroup();
settings.endGroup();
return path;
}
bool QtServiceController::uninstall()
{
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
settings.remove(serviceName());
settings.endGroup();
settings.sync();
QSettings::Status ret = settings.status();
if (ret == QSettings::AccessError) {
fprintf(stderr, "Cannot uninstall \"%s\". Cannot write to: %s. Check permissions.\n",
serviceName().toLatin1().constData(),
settings.fileName().toLatin1().constData());
}
return (ret == QSettings::NoError);
}
bool QtServiceController::start(const QStringList &arguments)
{
if (!isInstalled())
return false;
if (isRunning())
return false;
return QProcess::startDetached(serviceFilePath(), arguments);
}
bool QtServiceController::stop()
{
return sendCmd(serviceName(), QLatin1String("terminate"));
}
bool QtServiceController::pause()
{
return sendCmd(serviceName(), QLatin1String("pause"));
}
bool QtServiceController::resume()
{
return sendCmd(serviceName(), QLatin1String("resume"));
}
bool QtServiceController::sendCommand(int code)
{
return sendCmd(serviceName(), QString(QLatin1String("num:") + QString::number(code)));
}
bool QtServiceController::isInstalled() const
{
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
QStringList list = settings.childGroups();
settings.endGroup();
QStringListIterator it(list);
while (it.hasNext()) {
if (it.next() == serviceName())
return true;
}
return false;
}
bool QtServiceController::isRunning() const
{
QtUnixSocket sock;
if (sock.connectTo(socketPath(serviceName())))
return true;
return false;
}
///////////////////////////////////
class QtServiceSysPrivate : public QtUnixServerSocket
{
Q_OBJECT
public:
QtServiceSysPrivate();
~QtServiceSysPrivate();
char *ident;
QtServiceBase::ServiceFlags serviceFlags;
protected:
void incomingConnection(int socketDescriptor);
private slots:
void slotReady();
void slotClosed();
private:
QString getCommand(const QTcpSocket *socket);
QMap<const QTcpSocket *, QString> cache;
};
QtServiceSysPrivate::QtServiceSysPrivate()
: QtUnixServerSocket(), ident(0), serviceFlags(0)
{
}
QtServiceSysPrivate::~QtServiceSysPrivate()
{
if (ident)
delete[] ident;
}
void QtServiceSysPrivate::incomingConnection(int socketDescriptor)
{
QTcpSocket *s = new QTcpSocket(this);
s->setSocketDescriptor(socketDescriptor);
connect(s, SIGNAL(readyRead()), this, SLOT(slotReady()));
connect(s, SIGNAL(disconnected()), this, SLOT(slotClosed()));
}
void QtServiceSysPrivate::slotReady()
{
QTcpSocket *s = (QTcpSocket *)sender();
cache[s] += QString(s->readAll());
QString cmd = getCommand(s);
while (!cmd.isEmpty()) {
bool retValue = false;
if (cmd == QLatin1String("terminate")) {
if (!(serviceFlags & QtServiceBase::CannotBeStopped)) {
QtServiceBase::instance()->stop();
QCoreApplication::instance()->quit();
retValue = true;
}
} else if (cmd == QLatin1String("pause")) {
if (serviceFlags & QtServiceBase::CanBeSuspended) {
QtServiceBase::instance()->pause();
retValue = true;
}
} else if (cmd == QLatin1String("resume")) {
if (serviceFlags & QtServiceBase::CanBeSuspended) {
QtServiceBase::instance()->resume();
retValue = true;
}
} else if (cmd == QLatin1String("alive")) {
retValue = true;
} else if (cmd.length() > 4 && cmd.left(4) == QLatin1String("num:")) {
cmd = cmd.mid(4);
QtServiceBase::instance()->processCommand(cmd.toInt());
retValue = true;
}
QString retString;
if (retValue)
retString = QLatin1String("true");
else
retString = QLatin1String("false");
s->write(retString.toLatin1().constData());
s->flush();
cmd = getCommand(s);
}
}
void QtServiceSysPrivate::slotClosed()
{
QTcpSocket *s = (QTcpSocket *)sender();
s->deleteLater();
}
QString QtServiceSysPrivate::getCommand(const QTcpSocket *socket)
{
int pos = cache[socket].indexOf("\r\n");
if (pos >= 0) {
QString ret = cache[socket].left(pos);
cache[socket].remove(0, pos+2);
return ret;
}
return "";
}
#include "qtservice_unix.moc"
bool QtServiceBasePrivate::sysInit()
{
sysd = new QtServiceSysPrivate;
sysd->serviceFlags = serviceFlags;
// Restrict permissions on files that are created by the service
::umask(027);
return true;
}
void QtServiceBasePrivate::sysSetPath()
{
if (sysd)
sysd->setPath(socketPath(controller.serviceName()));
}
void QtServiceBasePrivate::sysCleanup()
{
if (sysd) {
sysd->close();
delete sysd;
sysd = 0;
}
}
bool QtServiceBasePrivate::start()
{
if (sendCmd(controller.serviceName(), "alive")) {
// Already running
return false;
}
// Could just call controller.start() here, but that would fail if
// we're not installed. We do not want to strictly require installation.
::setenv("QTSERVICE_RUN", "1", 1); // Tell the detached process it's it
return QProcess::startDetached(filePath(), args.mid(1), "/");
}
bool QtServiceBasePrivate::install(const QString &account, const QString &password)
{
Q_UNUSED(account)
Q_UNUSED(password)
QSettings settings(QSettings::SystemScope, "QtSoftware");
settings.beginGroup("services");
settings.beginGroup(controller.serviceName());
settings.setValue("path", filePath());
settings.setValue("description", serviceDescription);
settings.setValue("automaticStartup", startupType);
settings.endGroup();
settings.endGroup();
settings.sync();
QSettings::Status ret = settings.status();
if (ret == QSettings::AccessError) {
fprintf(stderr, "Cannot install \"%s\". Cannot write to: %s. Check permissions.\n",
controller.serviceName().toLatin1().constData(),
settings.fileName().toLatin1().constData());
}
return (ret == QSettings::NoError);
}
void QtServiceBase::logMessage(const QString &message, QtServiceBase::MessageType type,
int, uint, const QByteArray &)
{
if (!d_ptr->sysd)
return;
int st;
switch(type) {
case QtServiceBase::Error:
st = LOG_ERR;
break;
case QtServiceBase::Warning:
st = LOG_WARNING;
break;
default:
st = LOG_INFO;
}
if (!d_ptr->sysd->ident) {
QString tmp = encodeName(serviceName(), TRUE);
int len = tmp.toLocal8Bit().size();
d_ptr->sysd->ident = new char[len+1];
d_ptr->sysd->ident[len] = '\0';
::memcpy(d_ptr->sysd->ident, tmp.toLocal8Bit().constData(), len);
}
openlog(d_ptr->sysd->ident, LOG_PID, LOG_DAEMON);
foreach(QString line, message.split('\n'))
syslog(st, "%s", line.toLocal8Bit().constData());
closelog();
}
void QtServiceBase::setServiceFlags(QtServiceBase::ServiceFlags flags)
{
if (d_ptr->serviceFlags == flags)
return;
d_ptr->serviceFlags = flags;
if (d_ptr->sysd)
d_ptr->sysd->serviceFlags = flags;
}

View file

@ -1,903 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include "qtservice.h"
#include "qtservice_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QFile>
#include <QtCore/QLibrary>
#include <QtCore/QMutex>
#include <QtCore/QSemaphore>
#include <QtCore/QProcess>
#include <QtCore/QSettings>
#include <QtCore/QTextStream>
#include <qt_windows.h>
#include <QtCore/QWaitCondition>
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QVector>
#include <QtCore/QThread>
#include <stdio.h>
#if defined(QTSERVICE_DEBUG)
#include <QtCore/QDebug>
#endif
typedef SERVICE_STATUS_HANDLE(WINAPI*PRegisterServiceCtrlHandler)(const wchar_t*,LPHANDLER_FUNCTION);
static PRegisterServiceCtrlHandler pRegisterServiceCtrlHandler = 0;
typedef BOOL(WINAPI*PSetServiceStatus)(SERVICE_STATUS_HANDLE,LPSERVICE_STATUS);
static PSetServiceStatus pSetServiceStatus = 0;
typedef BOOL(WINAPI*PChangeServiceConfig2)(SC_HANDLE,DWORD,LPVOID);
static PChangeServiceConfig2 pChangeServiceConfig2 = 0;
typedef BOOL(WINAPI*PCloseServiceHandle)(SC_HANDLE);
static PCloseServiceHandle pCloseServiceHandle = 0;
typedef SC_HANDLE(WINAPI*PCreateService)(SC_HANDLE,LPCTSTR,LPCTSTR,DWORD,DWORD,DWORD,DWORD,LPCTSTR,LPCTSTR,LPDWORD,LPCTSTR,LPCTSTR,LPCTSTR);
static PCreateService pCreateService = 0;
typedef SC_HANDLE(WINAPI*POpenSCManager)(LPCTSTR,LPCTSTR,DWORD);
static POpenSCManager pOpenSCManager = 0;
typedef BOOL(WINAPI*PDeleteService)(SC_HANDLE);
static PDeleteService pDeleteService = 0;
typedef SC_HANDLE(WINAPI*POpenService)(SC_HANDLE,LPCTSTR,DWORD);
static POpenService pOpenService = 0;
typedef BOOL(WINAPI*PQueryServiceStatus)(SC_HANDLE,LPSERVICE_STATUS);
static PQueryServiceStatus pQueryServiceStatus = 0;
typedef BOOL(WINAPI*PStartServiceCtrlDispatcher)(CONST SERVICE_TABLE_ENTRY*);
static PStartServiceCtrlDispatcher pStartServiceCtrlDispatcher = 0;
typedef BOOL(WINAPI*PStartService)(SC_HANDLE,DWORD,const wchar_t**);
static PStartService pStartService = 0;
typedef BOOL(WINAPI*PControlService)(SC_HANDLE,DWORD,LPSERVICE_STATUS);
static PControlService pControlService = 0;
typedef HANDLE(WINAPI*PDeregisterEventSource)(HANDLE);
static PDeregisterEventSource pDeregisterEventSource = 0;
typedef BOOL(WINAPI*PReportEvent)(HANDLE,WORD,WORD,DWORD,PSID,WORD,DWORD,LPCTSTR*,LPVOID);
static PReportEvent pReportEvent = 0;
typedef HANDLE(WINAPI*PRegisterEventSource)(LPCTSTR,LPCTSTR);
static PRegisterEventSource pRegisterEventSource = 0;
typedef DWORD(WINAPI*PRegisterServiceProcess)(DWORD,DWORD);
static PRegisterServiceProcess pRegisterServiceProcess = 0;
typedef BOOL(WINAPI*PQueryServiceConfig)(SC_HANDLE,LPQUERY_SERVICE_CONFIG,DWORD,LPDWORD);
static PQueryServiceConfig pQueryServiceConfig = 0;
typedef BOOL(WINAPI*PQueryServiceConfig2)(SC_HANDLE,DWORD,LPBYTE,DWORD,LPDWORD);
static PQueryServiceConfig2 pQueryServiceConfig2 = 0;
#define RESOLVE(name) p##name = (P##name)lib.resolve(#name);
#define RESOLVEA(name) p##name = (P##name)lib.resolve(#name"A");
#define RESOLVEW(name) p##name = (P##name)lib.resolve(#name"W");
static bool winServiceInit()
{
if (!pOpenSCManager) {
QLibrary lib("advapi32");
// only resolve unicode versions
RESOLVEW(RegisterServiceCtrlHandler);
RESOLVE(SetServiceStatus);
RESOLVEW(ChangeServiceConfig2);
RESOLVE(CloseServiceHandle);
RESOLVEW(CreateService);
RESOLVEW(OpenSCManager);
RESOLVE(DeleteService);
RESOLVEW(OpenService);
RESOLVE(QueryServiceStatus);
RESOLVEW(StartServiceCtrlDispatcher);
RESOLVEW(StartService); // need only Ansi version
RESOLVE(ControlService);
RESOLVE(DeregisterEventSource);
RESOLVEW(ReportEvent);
RESOLVEW(RegisterEventSource);
RESOLVEW(QueryServiceConfig);
RESOLVEW(QueryServiceConfig2);
}
return pOpenSCManager != 0;
}
bool QtServiceController::isInstalled() const
{
Q_D(const QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, 0);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t*)d->serviceName.utf16(),
SERVICE_QUERY_CONFIG);
if (hService) {
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::isRunning() const
{
Q_D(const QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, 0);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_QUERY_STATUS);
if (hService) {
SERVICE_STATUS info;
int res = pQueryServiceStatus(hService, &info);
if (res)
result = info.dwCurrentState != SERVICE_STOPPED;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
QString QtServiceController::serviceFilePath() const
{
Q_D(const QtServiceController);
QString result;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, 0);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_QUERY_CONFIG);
if (hService) {
DWORD sizeNeeded = 0;
char data[8 * 1024];
if (pQueryServiceConfig(hService, (LPQUERY_SERVICE_CONFIG)data, 8 * 1024, &sizeNeeded)) {
LPQUERY_SERVICE_CONFIG config = (LPQUERY_SERVICE_CONFIG)data;
result = QString::fromUtf16((const ushort*)config->lpBinaryPathName);
}
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
QString QtServiceController::serviceDescription() const
{
Q_D(const QtServiceController);
QString result;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, 0);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_QUERY_CONFIG);
if (hService) {
DWORD dwBytesNeeded;
char data[8 * 1024];
if (pQueryServiceConfig2(
hService,
SERVICE_CONFIG_DESCRIPTION,
(unsigned char *)data,
8096,
&dwBytesNeeded)) {
LPSERVICE_DESCRIPTION desc = (LPSERVICE_DESCRIPTION)data;
if (desc->lpDescription)
result = QString::fromUtf16((const ushort*)desc->lpDescription);
}
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
QtServiceController::StartupType QtServiceController::startupType() const
{
Q_D(const QtServiceController);
StartupType result = ManualStartup;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, 0);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_QUERY_CONFIG);
if (hService) {
DWORD sizeNeeded = 0;
char data[8 * 1024];
if (pQueryServiceConfig(hService, (QUERY_SERVICE_CONFIG *)data, 8 * 1024, &sizeNeeded)) {
QUERY_SERVICE_CONFIG *config = (QUERY_SERVICE_CONFIG *)data;
result = config->dwStartType == SERVICE_DEMAND_START ? ManualStartup : AutoStartup;
}
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::uninstall()
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(), DELETE);
if (hService) {
if (pDeleteService(hService))
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::start(const QStringList &args)
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (hSCM) {
// Try to open the service
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(), SERVICE_START);
if (hService) {
QVector<const wchar_t *> argv(args.size());
for (int i = 0; i < args.size(); ++i)
argv[i] = (const wchar_t*)args.at(i).utf16();
if (pStartService(hService, args.size(), argv.data()))
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::stop()
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (hSCM) {
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(), SERVICE_STOP|SERVICE_QUERY_STATUS);
if (hService) {
SERVICE_STATUS status;
if (pControlService(hService, SERVICE_CONTROL_STOP, &status)) {
bool stopped = status.dwCurrentState == SERVICE_STOPPED;
int i = 0;
while(!stopped && i < 10) {
Sleep(200);
if (!pQueryServiceStatus(hService, &status))
break;
stopped = status.dwCurrentState == SERVICE_STOPPED;
++i;
}
result = stopped;
} else {
qErrnoWarning(GetLastError(), "stopping");
}
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::pause()
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (hSCM) {
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_PAUSE_CONTINUE);
if (hService) {
SERVICE_STATUS status;
if (pControlService(hService, SERVICE_CONTROL_PAUSE, &status))
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::resume()
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (hSCM) {
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_PAUSE_CONTINUE);
if (hService) {
SERVICE_STATUS status;
if (pControlService(hService, SERVICE_CONTROL_CONTINUE, &status))
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
bool QtServiceController::sendCommand(int code)
{
Q_D(QtServiceController);
bool result = false;
if (!winServiceInit())
return result;
if (code < 0 || code > 127 || !isRunning())
return result;
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_CONNECT);
if (hSCM) {
SC_HANDLE hService = pOpenService(hSCM, (wchar_t *)d->serviceName.utf16(),
SERVICE_USER_DEFINED_CONTROL);
if (hService) {
SERVICE_STATUS status;
if (pControlService(hService, 128 + code, &status))
result = true;
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
#if defined(QTSERVICE_DEBUG)
extern void qtServiceLogDebug(QtMsgType type, const char* msg);
#endif
void QtServiceBase::logMessage(const QString &message, MessageType type,
int id, uint category, const QByteArray &data)
{
#if defined(QTSERVICE_DEBUG)
QByteArray dbgMsg("[LOGGED ");
switch (type) {
case Error: dbgMsg += "Error] " ; break;
case Warning: dbgMsg += "Warning] "; break;
case Success: dbgMsg += "Success] "; break;
case Information: //fall through
default: dbgMsg += "Information] "; break;
}
dbgMsg += message.toAscii();
qtServiceLogDebug((QtMsgType)-1, dbgMsg.constData());
#endif
Q_D(QtServiceBase);
if (!winServiceInit())
return;
WORD wType;
switch (type) {
case Error: wType = EVENTLOG_ERROR_TYPE; break;
case Warning: wType = EVENTLOG_WARNING_TYPE; break;
case Information: wType = EVENTLOG_INFORMATION_TYPE; break;
default: wType = EVENTLOG_SUCCESS; break;
}
HANDLE h = pRegisterEventSource(0, (wchar_t *)d->controller.serviceName().utf16());
if (h) {
const wchar_t *msg = (wchar_t*)message.utf16();
const char *bindata = data.size() ? data.constData() : 0;
pReportEvent(h, wType, category, id, 0, 1, data.size(),(const wchar_t **)&msg,
const_cast<char *>(bindata));
pDeregisterEventSource(h);
}
}
class QtServiceControllerHandler : public QObject
{
Q_OBJECT
public:
QtServiceControllerHandler(QtServiceSysPrivate *sys);
protected:
void customEvent(QEvent *e);
private:
QtServiceSysPrivate *d_sys;
};
class QtServiceSysPrivate
{
public:
enum {
QTSERVICE_STARTUP = 256
};
QtServiceSysPrivate();
void setStatus( DWORD dwState );
void setServiceFlags(QtServiceBase::ServiceFlags flags);
DWORD serviceFlags(QtServiceBase::ServiceFlags flags) const;
inline bool available() const;
static void WINAPI serviceMain( DWORD dwArgc, wchar_t** lpszArgv );
static void WINAPI handler( DWORD dwOpcode );
SERVICE_STATUS status;
SERVICE_STATUS_HANDLE serviceStatus;
QStringList serviceArgs;
static QtServiceSysPrivate *instance;
static QCoreApplication::EventFilter nextFilter;
QWaitCondition condition;
QMutex mutex;
QSemaphore startSemaphore;
QSemaphore startSemaphore2;
QtServiceControllerHandler *controllerHandler;
void handleCustomEvent(QEvent *e);
};
QtServiceControllerHandler::QtServiceControllerHandler(QtServiceSysPrivate *sys)
: QObject(), d_sys(sys)
{
}
void QtServiceControllerHandler::customEvent(QEvent *e)
{
d_sys->handleCustomEvent(e);
}
QtServiceSysPrivate *QtServiceSysPrivate::instance = 0;
QCoreApplication::EventFilter QtServiceSysPrivate::nextFilter = 0;
QtServiceSysPrivate::QtServiceSysPrivate()
{
instance = this;
}
inline bool QtServiceSysPrivate::available() const
{
return 0 != pOpenSCManager;
}
void WINAPI QtServiceSysPrivate::serviceMain(DWORD dwArgc, wchar_t** lpszArgv)
{
if (!instance || !QtServiceBase::instance())
return;
// Windows spins off a random thread to call this function on
// startup, so here we just signal to the QApplication event loop
// in the main thread to go ahead with start()'ing the service.
for (DWORD i = 0; i < dwArgc; i++)
instance->serviceArgs.append(QString::fromUtf16((unsigned short*)lpszArgv[i]));
instance->startSemaphore.release(); // let the qapp creation start
instance->startSemaphore2.acquire(); // wait until its done
// Register the control request handler
instance->serviceStatus = pRegisterServiceCtrlHandler((TCHAR*)QtServiceBase::instance()->serviceName().utf16(), handler);
if (!instance->serviceStatus) // cannot happen - something is utterly wrong
return;
handler(QTSERVICE_STARTUP); // Signal startup to the application -
// causes QtServiceBase::start() to be called in the main thread
// The MSDN doc says that this thread should just exit - the service is
// running in the main thread (here, via callbacks in the handler thread).
}
// The handler() is called from the thread that called
// StartServiceCtrlDispatcher, i.e. our HandlerThread, and
// not from the main thread that runs the event loop, so we
// have to post an event to ourselves, and use a QWaitCondition
// and a QMutex to synchronize.
void QtServiceSysPrivate::handleCustomEvent(QEvent *e)
{
int code = e->type() - QEvent::User;
switch(code) {
case QTSERVICE_STARTUP: // Startup
QtServiceBase::instance()->start();
break;
case SERVICE_CONTROL_STOP:
QtServiceBase::instance()->stop();
QCoreApplication::instance()->quit();
break;
case SERVICE_CONTROL_PAUSE:
QtServiceBase::instance()->pause();
break;
case SERVICE_CONTROL_CONTINUE:
QtServiceBase::instance()->resume();
break;
default:
if (code >= 128 && code <= 255)
QtServiceBase::instance()->processCommand(code - 128);
break;
}
mutex.lock();
condition.wakeAll();
mutex.unlock();
}
void WINAPI QtServiceSysPrivate::handler( DWORD code )
{
if (!instance)
return;
instance->mutex.lock();
switch (code) {
case QTSERVICE_STARTUP: // QtService startup (called from WinMain when started)
instance->setStatus(SERVICE_START_PENDING);
QCoreApplication::postEvent(instance->controllerHandler, new QEvent(QEvent::Type(QEvent::User + code)));
instance->condition.wait(&instance->mutex);
instance->setStatus(SERVICE_RUNNING);
break;
case SERVICE_CONTROL_STOP: // 1
instance->setStatus(SERVICE_STOP_PENDING);
QCoreApplication::postEvent(instance->controllerHandler, new QEvent(QEvent::Type(QEvent::User + code)));
instance->condition.wait(&instance->mutex);
// status will be reported as stopped in start() when qapp::exec returns
break;
case SERVICE_CONTROL_PAUSE: // 2
instance->setStatus(SERVICE_PAUSE_PENDING);
QCoreApplication::postEvent(instance->controllerHandler, new QEvent(QEvent::Type(QEvent::User + code)));
instance->condition.wait(&instance->mutex);
instance->setStatus(SERVICE_PAUSED);
break;
case SERVICE_CONTROL_CONTINUE: // 3
instance->setStatus(SERVICE_CONTINUE_PENDING);
QCoreApplication::postEvent(instance->controllerHandler, new QEvent(QEvent::Type(QEvent::User + code)));
instance->condition.wait(&instance->mutex);
instance->setStatus(SERVICE_RUNNING);
break;
case SERVICE_CONTROL_INTERROGATE: // 4
break;
default:
if ( code >= 128 && code <= 255 ) {
QCoreApplication::postEvent(instance->controllerHandler, new QEvent(QEvent::Type(QEvent::User + code)));
instance->condition.wait(&instance->mutex);
}
break;
}
instance->mutex.unlock();
// Report current status
if (instance->available() && instance->status.dwCurrentState != SERVICE_STOPPED)
pSetServiceStatus(instance->serviceStatus, &instance->status);
}
void QtServiceSysPrivate::setStatus(DWORD state)
{
if (!available())
return;
status.dwCurrentState = state;
pSetServiceStatus(serviceStatus, &status);
}
void QtServiceSysPrivate::setServiceFlags(QtServiceBase::ServiceFlags flags)
{
if (!available())
return;
status.dwControlsAccepted = serviceFlags(flags);
pSetServiceStatus(serviceStatus, &status);
}
DWORD QtServiceSysPrivate::serviceFlags(QtServiceBase::ServiceFlags flags) const
{
DWORD control = 0;
if (flags & QtServiceBase::CanBeSuspended)
control |= SERVICE_ACCEPT_PAUSE_CONTINUE;
if (!(flags & QtServiceBase::CannotBeStopped))
control |= SERVICE_ACCEPT_STOP;
return control;
}
#include "qtservice_win.moc"
class HandlerThread : public QThread
{
public:
HandlerThread()
: success(true), console(false), QThread()
{}
bool calledOk() { return success; }
bool runningAsConsole() { return console; }
protected:
bool success, console;
void run()
{
SERVICE_TABLE_ENTRYW st [2];
st[0].lpServiceName = (wchar_t*)QtServiceBase::instance()->serviceName().utf16();
st[0].lpServiceProc = QtServiceSysPrivate::serviceMain;
st[1].lpServiceName = 0;
st[1].lpServiceProc = 0;
success = (pStartServiceCtrlDispatcher(st) != 0); // should block
if (!success) {
if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
// Means we're started from console, not from service mgr
// start() will ask the mgr to start another instance of us as a service instead
console = true;
}
else {
QtServiceBase::instance()->logMessage(QString("The Service failed to start [%1]").arg(qt_error_string(GetLastError())), QtServiceBase::Error);
}
QtServiceSysPrivate::instance->startSemaphore.release(); // let start() continue, since serviceMain won't be doing it
}
}
};
/*
Ignore WM_ENDSESSION system events, since they make the Qt kernel quit
*/
bool myEventFilter(void* message, long* result)
{
MSG* msg = reinterpret_cast<MSG*>(message);
if (!msg || (msg->message != WM_ENDSESSION) || !(msg->lParam & ENDSESSION_LOGOFF))
return QtServiceSysPrivate::nextFilter ? QtServiceSysPrivate::nextFilter(message, result) : false;
if (QtServiceSysPrivate::nextFilter)
QtServiceSysPrivate::nextFilter(message, result);
if (result)
*result = TRUE;
return true;
}
/* There are three ways we can be started:
- By a service controller (e.g. the Services control panel), with
no (service-specific) arguments. ServiceBase::exec() will then call
start() below, and the service will start.
- From the console, but with no (service-specific) arguments. This
means we should ask a controller to start the service (i.e. another
instance of this executable), and then just terminate. We discover
this case (as different from the above) by the fact that
StartServiceCtrlDispatcher will return an error, instead of blocking.
- From the console, with -e(xec) argument. ServiceBase::exec() will
then call ServiceBasePrivate::exec(), which calls
ServiceBasePrivate::run(), which runs the application as a normal
program.
*/
bool QtServiceBasePrivate::start()
{
sysInit();
if (!winServiceInit())
return false;
// Since StartServiceCtrlDispatcher() blocks waiting for service
// control events, we need to call it in another thread, so that
// the main thread can run the QApplication event loop.
HandlerThread* ht = new HandlerThread();
ht->start();
QtServiceSysPrivate* sys = QtServiceSysPrivate::instance;
// Wait until service args have been received by serviceMain.
// If Windows doesn't call serviceMain (or
// StartServiceControlDispatcher doesn't return an error) within
// a timeout of 20 secs, something is very wrong; give up
if (!sys->startSemaphore.tryAcquire(1, 20000))
return false;
if (!ht->calledOk()) {
if (ht->runningAsConsole())
return controller.start(args.mid(1));
else
return false;
}
int argc = sys->serviceArgs.size();
QVector<char *> argv(argc);
QList<QByteArray> argvData;
for (int i = 0; i < argc; ++i)
argvData.append(sys->serviceArgs.at(i).toLocal8Bit());
for (int i = 0; i < argc; ++i)
argv[i] = argvData[i].data();
q_ptr->createApplication(argc, argv.data());
QCoreApplication *app = QCoreApplication::instance();
if (!app)
return false;
QtServiceSysPrivate::nextFilter = app->setEventFilter(myEventFilter);
sys->controllerHandler = new QtServiceControllerHandler(sys);
sys->startSemaphore2.release(); // let serviceMain continue (and end)
sys->status.dwWin32ExitCode = q_ptr->executeApplication();
sys->setStatus(SERVICE_STOPPED);
if (ht->isRunning())
ht->wait(1000); // let the handler thread finish
delete sys->controllerHandler;
sys->controllerHandler = 0;
if (ht->isFinished())
delete ht;
delete app;
sysCleanup();
return true;
}
bool QtServiceBasePrivate::install(const QString &account, const QString &password)
{
bool result = false;
if (!winServiceInit())
return result;
// Open the Service Control Manager
SC_HANDLE hSCM = pOpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
if (hSCM) {
QString acc = account;
DWORD dwStartType = startupType == QtServiceController::AutoStartup ? SERVICE_AUTO_START : SERVICE_DEMAND_START;
DWORD dwServiceType = SERVICE_WIN32_OWN_PROCESS;
wchar_t *act = 0;
wchar_t *pwd = 0;
if (!acc.isEmpty()) {
// The act string must contain a string of the format "Domain\UserName",
// so if only a username was specified without a domain, default to the local machine domain.
if (!acc.contains(QChar('\\'))) {
acc.prepend(QLatin1String(".\\"));
}
if (!acc.endsWith(QLatin1String("\\LocalSystem")))
act = (wchar_t*)acc.utf16();
}
if (!password.isEmpty() && act) {
pwd = (wchar_t*)password.utf16();
}
// Only set INTERACTIVE if act is LocalSystem. (and act should be 0 if it is LocalSystem).
if (!act) dwServiceType |= SERVICE_INTERACTIVE_PROCESS;
// Create the service
SC_HANDLE hService = pCreateService(hSCM, (wchar_t *)controller.serviceName().utf16(),
(wchar_t *)controller.serviceName().utf16(),
SERVICE_ALL_ACCESS,
dwServiceType, // QObject::inherits ( const char * className ) for no inter active ????
dwStartType, SERVICE_ERROR_NORMAL, (wchar_t *)filePath().utf16(),
0, 0, 0,
act, pwd);
if (hService) {
result = true;
if (!serviceDescription.isEmpty()) {
SERVICE_DESCRIPTION sdesc;
sdesc.lpDescription = (wchar_t *)serviceDescription.utf16();
pChangeServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION, &sdesc);
}
pCloseServiceHandle(hService);
}
pCloseServiceHandle(hSCM);
}
return result;
}
QString QtServiceBasePrivate::filePath() const
{
wchar_t path[_MAX_PATH];
::GetModuleFileNameW( 0, path, sizeof(path) );
return QString::fromUtf16((unsigned short*)path);
}
bool QtServiceBasePrivate::sysInit()
{
sysd = new QtServiceSysPrivate();
sysd->serviceStatus = 0;
sysd->status.dwServiceType = SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS;
sysd->status.dwCurrentState = SERVICE_STOPPED;
sysd->status.dwControlsAccepted = sysd->serviceFlags(serviceFlags);
sysd->status.dwWin32ExitCode = NO_ERROR;
sysd->status.dwServiceSpecificExitCode = 0;
sysd->status.dwCheckPoint = 0;
sysd->status.dwWaitHint = 0;
return true;
}
void QtServiceBasePrivate::sysSetPath()
{
}
void QtServiceBasePrivate::sysCleanup()
{
if (sysd) {
delete sysd;
sysd = 0;
}
}
void QtServiceBase::setServiceFlags(QtServiceBase::ServiceFlags flags)
{
if (d_ptr->serviceFlags == flags)
return;
d_ptr->serviceFlags = flags;
if (d_ptr->sysd)
d_ptr->sysd->setServiceFlags(flags);
}

View file

@ -1,98 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include "qtunixserversocket.h"
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <string.h>
#include <unistd.h>
#ifndef SUN_LEN
#define SUN_LEN(ptr) ((size_t)(((struct sockaddr_un *) 0)->sun_path) \
+strlen ((ptr)->sun_path))
#endif
QtUnixServerSocket::QtUnixServerSocket(const QString &path, QObject *parent)
: QTcpServer(parent)
{
setPath(path);
}
QtUnixServerSocket::QtUnixServerSocket(QObject *parent)
: QTcpServer(parent)
{
}
void QtUnixServerSocket::setPath(const QString &path)
{
path_.clear();
int sock = ::socket(PF_UNIX, SOCK_STREAM, 0);
if (sock != -1) {
struct sockaddr_un addr;
::memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
::unlink(path.toLatin1().constData()); // ### This might need to be changed
unsigned int pathlen = strlen(path.toLatin1().constData());
if (pathlen > sizeof(addr.sun_path)) pathlen = sizeof(addr.sun_path);
::memcpy(addr.sun_path, path.toLatin1().constData(), pathlen);
if ((::bind(sock, (struct sockaddr *)&addr, SUN_LEN(&addr)) != -1) &&
(::listen(sock, 5) != -1)) {
setSocketDescriptor(sock);
path_ = path;
}
}
}
void QtUnixServerSocket::close()
{
QTcpServer::close();
if (!path_.isEmpty()) {
::unlink(path_.toLatin1().constData());
path_.clear();
}
}

View file

@ -1,67 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QTUNIXSERVERSOCKET_H
#define QTUNIXSERVERSOCKET_H
#include <QtNetwork/QTcpServer>
class QtUnixServerSocket : public QTcpServer
{
Q_OBJECT
public:
QtUnixServerSocket(const QString &path, QObject *parent = 0);
QtUnixServerSocket(QObject *parent = 0);
void setPath(const QString &path);
void close();
private:
QString path_;
};
#endif

View file

@ -1,84 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#include "qtunixsocket.h"
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
#include <string.h>
#include <unistd.h>
#ifndef SUN_LEN
#define SUN_LEN(ptr) ((size_t)(((struct sockaddr_un *) 0)->sun_path) \
+strlen ((ptr)->sun_path))
#endif
QtUnixSocket::QtUnixSocket(QObject *parent)
: QTcpSocket(parent)
{
}
bool QtUnixSocket::connectTo(const QString &path)
{
bool ret = false;
int sock = ::socket(PF_UNIX, SOCK_STREAM, 0);
if (sock != -1) {
struct sockaddr_un addr;
::memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
size_t pathlen = strlen(path.toLatin1().constData());
pathlen = qMin(pathlen, sizeof(addr.sun_path));
::memcpy(addr.sun_path, path.toLatin1().constData(), pathlen);
int err = ::connect(sock, (struct sockaddr *)&addr, SUN_LEN(&addr));
if (err != -1) {
setSocketDescriptor(sock);
ret = true;
} else {
::close(sock);
}
}
return ret;
}

View file

@ -1,61 +0,0 @@
/****************************************************************************
**
** This file is part of a Qt Solutions component.
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third
** Party Software they are using.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QTUNIXSOCKET_H
#define QTUNIXSOCKET_H
#include <QtNetwork/QTcpSocket>
class QtUnixSocket : public QTcpSocket
{
Q_OBJECT
public:
QtUnixSocket(QObject *parent = 0);
bool connectTo(const QString &path);
};
#endif

View file

@ -1,39 +0,0 @@
QT4_GENERATE_MOC( ${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice.cpp ${CMAKE_CURRENT_BINARY_DIR}/qtservice.moc )
SET( qtservice_SRCS
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtservice.moc
)
IF (UNIX)
QT4_GENERATE_MOC( ${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice_unix.cpp ${CMAKE_CURRENT_BINARY_DIR}/qtservice_unix.moc )
SET( qtservice_MOC_HDRS
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtunixsocket.h
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtunixserversocket.h
)
QT4_WRAP_CPP( qtservice_MOC_SRCS ${qtservice_MOC_HDRS} )
SET( qtservice_SRCS
${qtservice_SRCS}
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice_unix.cpp
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtunixsocket.cpp
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtunixserversocket.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtservice_unix.moc
${qtservice_MOC_SRCS}
)
ELSEIF (WIN32)
QT4_GENERATE_MOC( ${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice_win.cpp ${CMAKE_CURRENT_BINARY_DIR}/qtservice_win.moc )
SET(qtservice_SRCS
${qtservice_SRCS}
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/qtservice_win.cpp
${CMAKE_CURRENT_BINARY_DIR}/qtservice_win.moc
)
ENDIF (UNIX)
INCLUDE_DIRECTORIES(
${CMAKE_HOME_DIRECTORY}/3rdparty/qtservice-2.6-opensource/src/
${CMAKE_CURRENT_BINARY_DIR}
)

View file

@ -1,7 +0,0 @@
telldus-core has been developed by :
Micke Prag <micke.prag@telldus.se>
Fredrik Jacobsson <fredrik.jacobsson@telldus.se>
Stefan Persson
The package is maintained by Micke Prag <micke.prag@telldus.se>

View file

@ -1,95 +0,0 @@
PROJECT( telldus-core )
CMAKE_MINIMUM_REQUIRED( VERSION 2.6.0 )
OPTION(FORCE_COMPILE_FROM_TRUNK FALSE "Accept compiling source from trunk. This is unsupported and highly unrecommended")
IF(NOT FORCE_COMPILE_FROM_TRUNK)
MESSAGE(FATAL_ERROR "You are compiling sources from trunk. Don't do that!")
ENDIF(NOT FORCE_COMPILE_FROM_TRUNK)
IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_DIRECTORIES(/usr/local/lib)
ENDIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
cmake_policy(SET CMP0003 NEW)
SET(PACKAGE_MAJOR_VERSION 2)
SET(PACKAGE_MINOR_VERSION 0)
SET(PACKAGE_PATCH_VERSION 102)
SET(PACKAGE_VERSION "${PACKAGE_MAJOR_VERSION}.${PACKAGE_MINOR_VERSION}.${PACKAGE_PATCH_VERSION}")
SET(PACKAGE_SUBVERSION)
SET(PACKAGE_SOVERSION 2)
IF (PACKAGE_SUBVERSION)
SET(DISPLAYED_VERSION "${PACKAGE_VERSION}_${PACKAGE_SUBVERSION}")
ELSE (PACKAGE_SUBVERSION)
SET(DISPLAYED_VERSION ${PACKAGE_VERSION})
ENDIF(PACKAGE_SUBVERSION)
SET(BUILD_LIBTELLDUS-CORE TRUE CACHE BOOL "Build libtelldus-core")
SET(BUILD_LIBTELLDUS-CORE_AS_SERVICE TRUE CACHE BOOL "Build libtelldus-core as a service on Windows")
SET(SUPPORT_TELLSTICK_DUO FALSE CACHE BOOL "Include support for TellStick Duo")
IF (UNIX AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(SUPPORT_USB FALSE CACHE BOOL "Build support for usb-devices")
ELSE (UNIX AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(SUPPORT_USB TRUE CACHE BOOL "Build support for usb-devices")
ENDIF(UNIX AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(USE_QT_SETTINGS_BACKEND FALSE CACHE BOOL "Use QT as settings backend instead of the native one")
IF (WIN32)
SET(SIGN_FILES FALSE CACHE BOOL "Sign the generated files. This requires a certificate to be installed on the computer!")
ENDIF (WIN32)
IF (UNIX AND NOT APPLE)
SET(BUILD_RFCMD FALSE CACHE BOOL "Build rfcmd")
ELSE (UNIX AND NOT APPLE)
SET(BUILD_RFCMD TRUE CACHE BOOL "Build rfcmd")
ENDIF (UNIX AND NOT APPLE)
IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(BUILD_RFCMD_WITH_LIBFTDI TRUE CACHE BOOL "Enable support for using rfcmd with libftdi (does not need kernel-driver)")
SET(BUILD_RFCMD_WITH_SEMAPHORES FALSE CACHE BOOL "Enable support for using rfcmd with semaphores (Requires special kernel-config)")
ELSE(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(BUILD_RFCMD_WITH_LIBFTDI FALSE CACHE BOOL "Enable support for using rfcmd with libftdi (does not need kernel-driver)")
SET(BUILD_RFCMD_WITH_SEMAPHORES TRUE CACHE BOOL "Enable support for using rfcmd with semaphores")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(BUILD_TDTOOL TRUE CACHE BOOL "Build tdtool")
SET(GENERATE_MAN FALSE CACHE BOOL "Enable generation of man-files")
# Lets figure if we need to build against Qt or not
IF(USE_QT_SETTINGS_BACKEND)
SET(BUILD_WITH_QT TRUE)
ENDIF(USE_QT_SETTINGS_BACKEND)
ADD_SUBDIRECTORY(driver)
IF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
ADD_SUBDIRECTORY(telldus-service)
ENDIF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
if(BUILD_TDTOOL)
ADD_SUBDIRECTORY(tdtool)
endif(BUILD_TDTOOL)
if(BUILD_RFCMD)
ADD_SUBDIRECTORY(rfcmd)
endif(BUILD_RFCMD)
########## CPack #############
SET(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}${PACKAGE_SUBVERSION}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_CONTACT "Micke Prag <micke.prag@telldus.se>")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Utilities for a Telldus TellStick")
SET(CPACK_PACKAGE_DESCRIPTION "Utilities and driver to control NEXA and other RF remote receivers through a TellStick USB interface")
SET(CPACK_PACKAGE_VENDOR "Telldus Technologies AB")
SET(CPACK_STRIP_FILES "usr/bin/tdtool;usr/bin/rfcmd")
# SET(CPACK_PACKAGE_INSTALL_DIRECTORY "")
# SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
#### .deb ####
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.7-1), libconfuse0 (>=2.6-2), udev")
SET(CPACK_DEBIAN_PACKAGE_SECTION "utils")
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm")
INCLUDE(CPack)

View file

@ -1,10 +0,0 @@
telldus-core 2.0.1 (2009-11-10)
* Fixed bug when the number of devices is more then 9 on Windows
* Provided functions for possible memory leaks in some languages
* Better error-reporting when communication with TellStick doesn't work
* More friendlier configuration for GAO
telldus-core 2.0.0 (2009-09-22)
* Initial release

View file

@ -1,51 +0,0 @@
Unpacking
---------
Unpack the archive if you have not done so already:
cd /usr/src
gunzip telldus-core-{version}.tar.gz #Change {version} to the downloaded version
tar xvf telldus-core-{version}.tar
This creates the directory /usr/src/telldus-core-{version} containing the files
from the archive. We only support the GNU version of tar archiving utility. Note
on some systems it is called gtar.
Configuring
-----------
Telldus Core is built using CMake (http://www.cmake.org), version 2.4.0 is the
minimum required version. This means there is no configure-script, but you
need to run cmake.
To configure telldus-core for your machine type:
cmake .
in the package directory.
By default, Telldus Core is configured for installation in the /usr/local
directory, but this can be changed by using the -DCMAKE_INSTALL_PREFIX=/usr
option. Alternatively, the DESTDIR="/opt" option can be used to specify a "local"
installation within the source directory when running "make install".
Building
--------
To create the library and compile all the tools type:
make
If you did not configure Telldus Core using the -DCMAKE_INSTALL_PREFIX=/usr
option, you need to install the library and tools in the appropriate place. To
do this, type:
su -c "make install"
and enter the root password.
If you want to install in another directory, type:
su -c "make DESTDIR=/opt install"
Note that on some systems the make utility is named differently, e.g. gmake.

View file

@ -1,339 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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 2 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View file

@ -1,30 +0,0 @@
This is Telldus Core version {version}
Telldus Core is the driver and tools for controlling a Telldus Technologies
TellStick. It does not containing any GUI tools which makes it suitable for
server use.
INSTALLING Telldus Core
On Windows, if you want to install the precompiles binary packages, simply
launch the package and follow the instructions in the installation wizard.
If you have a source package (a .tag.gz file), follow the instruction in the
INSTALL file.
CONFIGURATION AND TOOLS
Once Telldus Core is installed, we suggest that you start by adding the devices
you want to control.
On Windows, this is done with the tool TelldusSetup. On Linux this is done in
the file /etc/tellstick.conf.
Telldus Core installs the tool tdtool for controlling devices with TellStick.
Have a look in the man page for a description how to use it:
man tdtool
TellStick is a trademark of Telldus Technologies AB

View file

@ -1,42 +0,0 @@
#!/bin/bash
CMAKE_LOG="$CC_BUILD_ARTIFACTS/cmake.log"
if [ ! -d "$CC_BUILD_ARTIFACTS" ]
then
echo "CC_BUILD_ARTIFACTS does not point to a valid directory!"
exit 1
fi
echo -n "Preparing directories... "
test -d build || mkdir build
echo "done."
(
echo -n "Preparing build... "
echo -n "running cmake... "
cd build
# cmake .. -DCMAKE_BUILD_TYPE=Profile > "$CMAKE_LOG"
cmake .. > "$CMAKE_LOG"
)
if [ "$?" -ne 0 ]
then
echo "failed"
exit 1
fi
echo "done."
echo "Building..."
make -C build
if [ "$?" -ne 0 ]
then
exit 1
fi
#Mina egna tester här
exit 0

View file

@ -1,5 +0,0 @@
Project.configure do |project|
project.email_notifier.emails = ["micke.prag@telldus.se"]
project.email_notifier.from = 'micke.prag@telldus.se'
project.build_command = './cruise_build.sh'
end

View file

@ -1,12 +0,0 @@
telldus-core (2.0.1-1) unstable; urgency=low
* New upstream version
-- Micke Prag <micke.prag@telldus.se> Tue, 10 Nov 2009 21:55:00 +0200
telldus-core (2.0.0-1) unstable; urgency=low
* Initial release (Closes: #544982)
-- Micke Prag <micke.prag@telldus.se> Thu, 03 Sep 2009 20:25:46 +0200

View file

@ -1,36 +0,0 @@
Source: telldus-core
Priority: extra
Maintainer: Micke Prag <micke.prag@telldus.se>
Build-Depends: debhelper (>= 7)
Standards-Version: 3.7.3
Section: libs
Homepage: http://www.telldus.se
Package: libtelldus-core-dev
Section: libdevel
Architecture: any
Depends: libtelldus-core2 (= ${binary:Version})
Description: Development file for libtelldus-core
This package contains the header file needed to
compile applications that use telldus-core.
Package: libtelldus-core2
Section: libs
Architecture: any
Depends: ${shlibs:Depends}
Description: Library to control a Telldus TellStick
libtelldus-core is the library for controlling wireless devices by a
Telldus TellStick.
.
It makes it very easy to add home automation capabilities to a
program using a simple API.
Package: telldus-core
Architecture: any
Depends: ${shlibs:Depends}
Description: Utilities and driver to control wireless receivers through a TellStick
TellStick from Telldus Technologies is a USB-interface to various remote
controlled RF receivers on 433,92 MHz.
.
This package contains the command line interface utilities for controling
the devices.

View file

@ -1,20 +0,0 @@
This package was debianized by Micke Prag <micke.prag@telldus.se> on
Thu, 03 Sep 2009 20:25:46 +0200.
It was downloaded from http://download.telldus.se/TellStick/Software/telldus-core/
Upstream Author:
Micke Prag <micke.prag@telldus.se>
Copyright:
Copyright (C) 2009 Telldus Technologies AB
License:
GPL-2
The Debian packaging is (C) 2009, Micke Prag <micke.prag@telldus.se> and
is licensed under the GPL-2, see `/usr/share/common-licenses/GPL-2'.

View file

@ -1,3 +0,0 @@
usr/include/*
usr/lib/lib*.so

View file

@ -1 +0,0 @@
usr/lib/lib*.so.*

View file

@ -1,117 +0,0 @@
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# shared library versions, option 1
version=2.0.0
major=2
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
#version=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
#major=`ls src/.libs/lib*.so.* | \
# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
configure: configure-stamp
configure-stamp:
dh_testdir
# Add here commands to configure the package.
mkdir build
cd build && \
cmake \
-DBUILD_RFCMD=1 \
-DBUILD_RFCMD_WITH_LIBFTDI=0 \
-DBUILD_LIBTELLDUS-CORE=1 \
-DBUILD_TDTOOL=1 \
-DSUPPORT_TELLSTICK_DUO=0 \
-DSUPPORT_USB=0 \
-DUSE_QT_SETTINGS_BACKEND=0 \
-DGENERATE_MAN=1 \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="-Wl,--as-needed" \
..
touch configure-stamp
build: build-stamp
build-stamp: configure-stamp
dh_testdir
# Add here commands to compile the package.
cd build && \
$(MAKE)
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
# Add here commands to clean up after the build process.
if test -d build; then rm -rf build;fi
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# Add here commands to install the package into debian/tmp
cd build && \
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
# Build architecture-dependent files here.
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs
dh_installdocs
dh_installexamples
dh_install
# dh_installmenu
# dh_installdebconf
# dh_installlogrotate
# dh_installemacsen
# dh_installpam
# dh_installmime
# dh_installinit
# dh_installcron
# dh_installinfo
dh_installman
dh_link
dh_strip
dh_compress
dh_fixperms
# dh_perl
# dh_python
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
dh_md5sums
dh_builddeb
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure

View file

@ -1,4 +0,0 @@
usr/bin/*
usr/share/man/man1/*
etc/*

View file

@ -1,48 +0,0 @@
#!/bin/sh
# postinst script for telldus-core
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
case "$1" in
configure)
chown root:plugdev /etc/tellstick.conf
chmod 664 /etc/tellstick.conf
mkdir -p /var/state
touch /var/state/telldus-core.conf
chown root:plugdev /var/state/telldus-core.conf
chmod 666 /var/state/telldus-core.conf
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

View file

@ -1,15 +0,0 @@
PROJECT( tellstick )
if(BUILD_LIBTELLDUS-CORE)
ADD_SUBDIRECTORY(libtelldus-core)
endif(BUILD_LIBTELLDUS-CORE)
IF (WIN32)
SET(BUILD_TELLUSBD101 TRUE CACHE BOOL "Build wrapper TellUsbD101.dll")
IF (BUILD_TELLUSBD101)
ADD_SUBDIRECTORY(TellUsbD101)
ENDIF (BUILD_TELLUSBD101)
ENDIF (WIN32)
ADD_SUBDIRECTORY(bindings)

View file

@ -1,20 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TellUsbD101", "TellUsbD101\TellUsbD101.vcproj", "{2A868E40-88D9-4800-A83F-21D0F8DCB611}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Debug|Win32.ActiveCfg = Release|Win32
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Debug|Win32.Build.0 = Release|Win32
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Release|Win32.ActiveCfg = Release|Win32
{2A868E40-88D9-4800-A83F-21D0F8DCB611}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -1,38 +0,0 @@
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
SET( tellusbd101_SRCS
TellUsbD101.cpp
TellUsbD101.def
)
SET( tellusbd101_HDRS
TellUsbD101.h
)
SET( tellusbd101_TARGET TellUsbD101 )
ADD_DEFINITIONS(
-D_WINDOWS
-DTellUsbD101_EXPORTS
)
SET( tellusbd101_LIBRARIES
"${LIBRARY_OUTPUT_PATH}/Release/TelldusCore.lib"
)
######## Configuring ########
ADD_LIBRARY(${tellusbd101_TARGET} SHARED
${tellusbd101_SRCS}
${tellusbd101_HDRS}
)
TARGET_LINK_LIBRARIES( ${tellusbd101_TARGET} ${tellusbd101_LIBRARIES} )
SET_PROPERTY(TARGET ${tellusbd101_TARGET}
PROPERTY PUBLIC_HEADER ${tellusbd101_HDRS}
)

View file

@ -1,85 +0,0 @@
//DLL entry point
#include "TellUsbD101.h"
#include "../libtelldus-core/telldus-core.h"
#include <stdio.h>
#include <windows.h>
#include <string>
#include <sstream>
int __stdcall devGetNumberOfDevices(void){
return tdGetNumberOfDevices();
}
int __stdcall devGetDeviceId(int intDeviceIndex){
return tdGetDeviceId(intDeviceIndex);
}
char * __stdcall devGetName(int intDeviceId){
return tdGetName(intDeviceId);
}
char* __stdcall devGetVendor(int intDeviceId){
return tdGetProtocol(intDeviceId);
}
char* __stdcall devGetModel(int intDeviceId){
return tdGetModel(intDeviceId);
}
int __stdcall devGetNumberOfArguments(int intDeviceId){
return 0;
}
int __stdcall devGetArgument(int intDeviceId, int intArgumentIndex){
return 0;
}
bool __stdcall devSetName(int intDeviceId, char* strNewName){
return tdSetName(intDeviceId, strNewName);
}
bool __stdcall devSetVendor(int intDeviceId, char* strVendor) {
if (_stricmp(strVendor, "nexa") == 0) {
return tdSetProtocol(intDeviceId, "arctech");
} else {
return tdSetProtocol(intDeviceId, strVendor);
}
}
bool __stdcall devSetModel(int intDeviceId, char* strNewModel){
return tdSetModel(intDeviceId, strNewModel);
}
bool __stdcall devSetArguments(int intDeviceId, char* strArguments){
return false;
}
int __stdcall devAddDevice(){
return tdAddDevice();
}
bool __stdcall devRemoveDevice(int intDeviceId){
return tdRemoveDevice(intDeviceId);
}
int __stdcall devMethods(int id){
return tdMethods(id, TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_BELL);
}
bool __stdcall devTurnOn(int intDeviceId){
return (tdTurnOn(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
}
bool __stdcall devTurnOff(int intDeviceId){
return (tdTurnOff(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
}
bool __stdcall devBell(int intDeviceId){
return (tdBell(intDeviceId) == TELLSTICK_SUCCESS ? true : false);
}
bool __stdcall devDim(int intDeviceId, unsigned char level){
return (tdDim(intDeviceId, level) == TELLSTICK_SUCCESS ? true : false);
}

View file

@ -1,24 +0,0 @@
LIBRARY TellUsbD101
EXPORTS
devGetNumberOfDevices @1
devGetDeviceId @2
devGetName @3
devGetVendor @4
devGetModel @5
devGetNumberOfArguments @6
devGetArgument @7
devSetName @8
devSetVendor @9
devSetModel @10
devSetArguments @11
devAddDevice @12
devRemoveDevice @13
devMethods @14
devTurnOn @16
devTurnOff @17
devBell @18
devDim @19

View file

@ -1,45 +0,0 @@
#ifndef TELLUSBD101_H
#define TELLUSBD101_H
// The following ifdef block is the standard way of creating macros
// which make exporting from a DLL simpler. All files within this DLL
// are compiled with the TellUsbD101_EXPORTS symbol defined on the command line.
// This symbol should not be defined on any project that uses this DLL.
// This way any other project whose source files include this file see
// TELLUSBD101_API functions as being imported from a DLL, whereas this DLL
// sees symbols defined with this macro as being exported.
#ifdef TellUsbD101_EXPORTS
#define TELLUSBD101_API __declspec(dllexport)
#else
#define TELLUSBD101_API __declspec(dllimport)
#endif
#ifdef _WINDOWS
#define WINAPI __stdcall
#else
#define WINAPI
#endif
extern "C" {
TELLUSBD101_API bool WINAPI devTurnOn(int intDeviceId);
TELLUSBD101_API bool WINAPI devTurnOff(int intDeviceId);
TELLUSBD101_API bool WINAPI devBell(int intDeviceId);
TELLUSBD101_API bool WINAPI devDim(int intDeviceId, unsigned char level);
TELLUSBD101_API int WINAPI devGetNumberOfDevices();
TELLUSBD101_API char * WINAPI devGetName(int intDeviceId);
TELLUSBD101_API bool WINAPI devSetName(int intDeviceId, const char* chNewName);
TELLUSBD101_API char* WINAPI devGetVendor(int intDeviceId);
TELLUSBD101_API bool WINAPI devSetVendor(int intDeviceId, const char* chNewName);
TELLUSBD101_API char* WINAPI devGetModel(int intDeviceId);
TELLUSBD101_API bool WINAPI devSetModel(int intDeviceId, const char* chNewName);
TELLUSBD101_API int WINAPI devGetArgument(int intDeviceId, int intArgumentIndex);
TELLUSBD101_API int WINAPI devGetNumberOfArguments(int intDeviceId);
TELLUSBD101_API bool WINAPI devSetArguments(int intDeviceId, const char* strArguments);
TELLUSBD101_API int WINAPI devAddDevice();
TELLUSBD101_API bool WINAPI devRemoveDevice(int intDeviceId);
TELLUSBD101_API int WINAPI devGetDeviceId(int intDeviceIndex);
TELLUSBD101_API int WINAPI devMethods(int id);
}
#endif

View file

@ -1,215 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="TellUsbD101"
ProjectGUID="{F2BD0723-1E66-4191-AF6D-DEDD9605B028}"
RootNamespace="TellUsbD101"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;TellUsbD101_EXPORTS"
GeneratePreprocessedFile="0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="oleaut32.lib"
LinkIncremental="2"
ModuleDefinitionFile="$(SolutionDir)\TellUsbD101\TellUsbD101.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;TellUsbD101_EXPORTS"
GeneratePreprocessedFile="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="advapi32.lib oleaut32.lib"
LinkIncremental="1"
ModuleDefinitionFile="TellUsbD101.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\TellUsbD101.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\TellUsbD101.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\TellUsbD101.def"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View file

@ -1,15 +0,0 @@
SET(BUILD_EXTENSION_JAVA FALSE CACHE BOOL "Build extension for Java")
IF(BUILD_EXTENSION_JAVA)
ADD_SUBDIRECTORY(java)
ENDIF(BUILD_EXTENSION_JAVA)
# ADD_SUBDIRECTORY(php)
SET(BUILD_EXTENSION_PYTHON FALSE CACHE BOOL "Build extension for Python")
IF(BUILD_EXTENSION_PYTHON)
ADD_SUBDIRECTORY(python)
ENDIF(BUILD_EXTENSION_PYTHON)
# ADD_SUBDIRECTORY(ruby)

View file

@ -1,18 +0,0 @@
#### JAVA ####
FIND_PACKAGE(SWIG REQUIRED)
FIND_PACKAGE(Java)
FIND_PACKAGE(JNI)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${JAVA_INCLUDE_PATH} ${JNI_INCLUDE_DIRS})
SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES CPLUSPLUS OFF)
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(tellduscore java ../tellduscore.i)
SWIG_LINK_LIBRARIES(tellduscore telldus-core ${JNI_LIBRARIES})

View file

@ -1,22 +0,0 @@
#### PYTHON ####
FIND_PACKAGE(SWIG REQUIRED)
FIND_PACKAGE(PythonInterp)
FIND_PACKAGE(PythonLibs)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_INCLUDE_PATH})
SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES CPLUSPLUS OFF)
SET_SOURCE_FILES_PROPERTIES(../tellduscore.i PROPERTIES SWIG_FLAGS "-includeall")
SWIG_ADD_MODULE(tellduscore python ../tellduscore.i)
SWIG_LINK_LIBRARIES(tellduscore telldus-core ${PYTHON_LIBRARIES})
EXECUTE_PROCESS( COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SWIG_MODULE_tellduscore_REAL_NAME}.so DESTINATION ${PYTHON_SITE_PACKAGES})
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tellduscore.py DESTINATION ${PYTHON_SITE_PACKAGES})

View file

@ -1,6 +0,0 @@
%module tellduscore
%{
#include "../../libtelldus-core/telldus-core.h"
%}
%include "../../libtelldus-core/telldus-core.h"

View file

@ -1,2 +0,0 @@
KERNEL=="ttyUSB*", BUS=="usb", SYSFS{idVendor}=="1781", SYSFS{idProduct}=="0c30", NAME="tellstick", GROUP="plugdev"

View file

@ -1,232 +0,0 @@
IF (BUILD_WITH_QT)
FIND_PACKAGE( Qt4 REQUIRED )
SET( QT_DONT_USE_QTGUI TRUE )
INCLUDE( ${QT_USE_FILE} )
ENDIF (BUILD_WITH_QT)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
######## Non configurable options ########
SET( telldus-core_SRCS
Device.cpp
DeviceBrateck.cpp
DeviceEverflourish.cpp
DeviceFuhaote.cpp
DeviceGroup.cpp
DeviceIkea.cpp
DeviceSilvanChip.cpp
DeviceNexa.cpp
DeviceRisingSun.cpp
DeviceSartano.cpp
DeviceUndefined.cpp
DeviceUpm.cpp
DeviceWaveman.cpp
DeviceX10.cpp
Controller.cpp
Manager.cpp
Settings.cpp
TellStick.cpp
Thread.cpp
telldus-core.cpp
)
SET( telldus-core_HDRS
telldus-core.h
telldus-core-service.h
)
IF (BUILD_WITH_QT)
QT4_WRAP_CPP( telldus-core_MOC_SRCS ${telldus-core_MOC_HDRS} )
QT4_AUTOMOC ( ${telldus-core_SRCS} )
SET( telldus-core_LIBRARIES
${QT_LIBRARIES}
)
ENDIF (BUILD_WITH_QT)
IF (SUPPORT_USB)
OPTION(USE_FTD2XX_RATHER_THEN_LIBFTDI "Link against ftd2xx even if libftdi is the preferred one" OFF)
IF (APPLE OR WIN32 OR USE_FTD2XX_RATHER_THEN_LIBFTDI)
FIND_LIBRARY(FTD2XX_LIBRARY ftd2xx)
SET( telldus-core_LIBRARIES
${telldus-core_LIBRARIES}
${FTD2XX_LIBRARY}
)
ADD_DEFINITIONS( -DLIBFTD2XX )
ELSE (APPLE OR WIN32 OR USE_FTD2XX_RATHER_THEN_LIBFTDI)
FIND_LIBRARY(FTDI_LIBRARY ftdi)
SET( telldus-core_LIBRARIES
${telldus-core_LIBRARIES}
${FTDI_LIBRARY}
)
ADD_DEFINITIONS( -DLIBFTDI )
ENDIF (APPLE OR WIN32 OR USE_FTD2XX_RATHER_THEN_LIBFTDI)
ENDIF (SUPPORT_USB)
######## Configurable options for the platform ########
#### TellStickDuo ####
IF (SUPPORT_TELLSTICK_DUO)
ADD_DEFINITIONS( -DTELLSTICK_DUO )
SET( telldus-core_SRCS
${telldus-core_SRCS}
TellStickDuo.cpp
)
ENDIF(SUPPORT_TELLSTICK_DUO)
#### Settings backend ####
IF(USE_QT_SETTINGS_BACKEND)
SET( telldus-core_SRCS
${telldus-core_SRCS}
SettingsQt.cpp
)
ELSE (USE_QT_SETTINGS_BACKEND)
IF (APPLE)
FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
SET( telldus-core_LIBRARIES
${telldus-core_LIBRARIES}
${COREFOUNDATION_LIBRARY}
)
SET( telldus-core_SRCS
${telldus-core_SRCS}
SettingsCoreFoundationPreferences.cpp
)
ELSEIF (WIN32)
SET( telldus-core_SRCS
${telldus-core_SRCS}
SettingsWinRegistry.cpp
)
ELSE (APPLE)
SET( telldus-core_LIBRARIES
${telldus-core_LIBRARIES}
confuse
)
SET( telldus-core_SRCS
${telldus-core_SRCS}
SettingsConfuse.cpp
)
ADD_DEFINITIONS( -D_CONFUSE )
ENDIF (APPLE)
ENDIF(USE_QT_SETTINGS_BACKEND)
######## Platforms-specific, non configurable ########
IF (APPLE)
#### Mac OS X ####
IF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET TelldusCoreLib )
ELSE(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET TelldusCore )
ENDIF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_SRCS
${telldus-core_SRCS}
win/Device.cpp
)
ADD_DEFINITIONS(
-D_MACOSX
)
ELSEIF (WIN32)
#### Windows ####
IF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET TelldusCoreLib )
SET( telldus-core_SRCS
${telldus-core_SRCS}
${FTD2XX_LIBRARY}
)
ELSE(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET TelldusCore )
SET( telldus-core_SRCS
${telldus-core_SRCS}
libtelldus-core.def
)
ENDIF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_SRCS
${telldus-core_SRCS}
win/Device.cpp
)
ADD_DEFINITIONS(
-D_WINDOWS
-DTELLDUSCORE_EXPORTS
)
ELSE (APPLE)
#### Linux ####
IF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET telldus-core-lib )
ELSE(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_TARGET telldus-core )
ENDIF(BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET( telldus-core_SRCS
${telldus-core_SRCS}
linux/Device.cpp
)
ADD_DEFINITIONS(
-D_LINUX
)
ENDIF (APPLE)
######## Configuring ########
SET(TYPE "SHARED")
IF (BUILD_LIBTELLDUS-CORE_AS_SERVICE)
SET(TYPE "STATIC")
ENDIF (BUILD_LIBTELLDUS-CORE_AS_SERVICE)
ADD_LIBRARY(${telldus-core_TARGET} ${TYPE}
${telldus-core_SRCS}
${telldus-core_HDRS}
)
TARGET_LINK_LIBRARIES( ${telldus-core_TARGET} ${telldus-core_LIBRARIES} )
SET_PROPERTY(TARGET ${telldus-core_TARGET}
PROPERTY FRAMEWORK TRUE
)
SET_PROPERTY(TARGET ${telldus-core_TARGET}
PROPERTY PUBLIC_HEADER ${telldus-core_HDRS}
)
SET_PROPERTY(TARGET ${telldus-core_TARGET}
PROPERTY VERSION ${PACKAGE_VERSION}
)
SET_PROPERTY(TARGET ${telldus-core_TARGET}
PROPERTY SOVERSION ${PACKAGE_SOVERSION}
)
IF (NOT LIBRARY_DIR)
SET(LIBRARY_DIR "lib")
ENDIF (NOT LIBRARY_DIR)
IF (UNIX)
INSTALL(TARGETS ${telldus-core_TARGET}
LIBRARY DESTINATION ${LIBRARY_DIR}
ARCHIVE DESTINATION ${LIBRARY_DIR}
FRAMEWORK DESTINATION "/Library/Frameworks"
PUBLIC_HEADER DESTINATION include
)
ENDIF (UNIX)
IF (UNIX AND NOT APPLE)
SET(SYSCONF_INSTALL_DIR "/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
SET(STATE_INSTALL_DIR "/var/state" CACHE PATH "The directory to store state information of the devices" )
SET(UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" )
INSTALL(FILES tellstick.conf
DESTINATION ${SYSCONF_INSTALL_DIR}
)
INSTALL(FILES telldus-core.conf
DESTINATION ${STATE_INSTALL_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_WRITE
)
INSTALL(FILES 99-tellstick.rules
DESTINATION ${UDEV_RULES_DIR}
)
ENDIF (UNIX AND NOT APPLE)

View file

@ -1,25 +0,0 @@
//
// C++ Implementation: controller
//
// Description:
//
//
// Author: Micke Prag <micke.prag@telldus.se>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "Controller.h"
using namespace TelldusCore;
Controller::Controller()
{
}
Controller::~Controller()
{
}

View file

@ -1,33 +0,0 @@
//
// C++ Interface: controller
//
// Description:
//
//
// Author: Micke Prag <micke.prag@telldus.se>, (C) 2009
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <string>
/**
@author Micke Prag <micke.prag@telldus.se>
*/
namespace TelldusCore {
class Controller {
public:
virtual ~Controller();
virtual int firmwareVersion() = 0;
virtual int send( const std::string &message ) = 0;
protected:
Controller();
};
}
#endif

View file

@ -1,122 +0,0 @@
#include "Device.h"
#include "Manager.h"
#include <stdlib.h>
using namespace TelldusCore;
/*
* Constructor
*/
Device::Device(int id, const std::string m, const std::string &name)
: deviceId(id),
deviceName(name),
model(m)
{
}
/*
* Destructor
*/
Device::~Device(void) {
}
std::string Device::getModel() const {
std::string strModel = model;
//Strip anything after : if it is found
size_t pos = strModel.find(":");
if (pos != std::string::npos) {
strModel = strModel.substr(0, pos);
}
return strModel;
}
std::string Device::getFullModel() const {
return model;
}
bool Device::setModel( const std::string &strModel ) {
Manager *manager = Manager::getInstance();
if (manager->setDeviceModel( deviceId, strModel )) {
model = strModel;
return true;
}
return false;
}
bool Device::setParameter(const std::string &strName, const std::string &strValue) {
if (setDeviceParameter( strName, strValue )) {
Manager *manager = Manager::getInstance();
return manager->setDeviceParameter(deviceId, strName, strValue);
}
return false;
}
/*
* Turn on, virtual
*/
int Device::turnOn(Controller *){
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
/*
* Turn off, virtual
*/
int Device::turnOff(Controller *){
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
/*
* Bell, virtual
*/
int Device::bell(Controller *){
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
/*
* Dim, virtual
*/
int Device::dim(unsigned char level, Controller *){
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
int Device::learn(Controller *controller) {
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
int Device::methodId( const std::string &methodName ) {
if (methodName.compare("turnon") == 0) {
return TELLSTICK_TURNON;
}
if (methodName.compare("turnoff") == 0) {
return TELLSTICK_TURNOFF;
}
if (methodName.compare("bell") == 0) {
return TELLSTICK_BELL;
}
if (methodName.compare("dim") == 0) {
return TELLSTICK_DIM;
}
return 0;
}
std::string Device::getName() const {
return deviceName;
}
bool Device::setName(const std::string & newName) {
Manager *manager = Manager::getInstance();
if (manager->setDeviceName(deviceId, newName)) {
deviceName = newName;
return true;
}
return false;
}
int TelldusCore::Device::maskUnsupportedMethods(int methods, int supportedMethods) {
// Bell -> On
if ((methods & TELLSTICK_BELL) && !(supportedMethods & TELLSTICK_BELL)) {
methods |= TELLSTICK_TURNON;
}
//Cut of the rest of the unsupported methods we don't have a fallback for
return methods & supportedMethods;
}

View file

@ -1,53 +0,0 @@
#pragma once
#include "telldus-core.h"
#include "Controller.h"
#include <string>
//#include <QMutex>
namespace TelldusCore {
class Device
{
public:
Device(int id, const std::string model, const std::string &name);
virtual ~Device(void);
// int switchState( int newState, const std::string &value = "" );
virtual int methods() = 0;
virtual std::string getProtocol() const = 0;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const = 0;
bool setParameter(const std::string &strName, const std::string &strValue);
std::string getModel() const;
std::string getFullModel() const;
bool setModel( const std::string & strModel );
std::string getName() const;
bool setName( const std::string &newName );
static int methodId( const std::string &methodName );
static int maskUnsupportedMethods( int methods, int supportedMethods );
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
virtual int bell(Controller *controller);
virtual int dim(unsigned char level, Controller *controller);
virtual int learn(Controller *controller);
#ifdef _LINUX
void setDevice(const std::string &device);
protected:
std::string strDevice;
#endif
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue) = 0;
int send(const std::string &strMessage);
private:
int deviceId;
std::string deviceName, model;
// static QMutex deviceMutex;
};
}

View file

@ -1,119 +0,0 @@
#include "DeviceBrateck.h"
#include <string>
#include <bitset>
#include <algorithm>
#include <fstream>
using namespace TelldusCore;
const char S = '!';
const char L = 'V';
const char B1[] = {L,S,L,S,0};
const char BX[] = {S,L,L,S,0};
const char B0[] = {S,L,S,L,0};
const char BUP[] = {L,S,L,S,S,L,S,L,S,L,S,L,S,L,S,L,S,0};
const char BSTOP[] = {S,L,S,L,L,S,L,S,S,L,S,L,S,L,S,L,S,0};
const char BDOWN[] = {S,L,S,L,S,L,S,L,S,L,S,L,L,S,L,S,S,0};
/*
* Constructor
*/
DeviceBrateck::DeviceBrateck(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
DeviceBrateck::~DeviceBrateck(void)
{
}
bool DeviceBrateck::setHouse(const std::string &strNewHouse) {
strHouse = strNewHouse;
return true;
}
bool DeviceBrateck::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("house") == 0) {
return setHouse(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceBrateck::turnOn(Controller *controller){
try{
std::string strCode = getStringCode();
strCode.insert(0, "S");
strCode.append(BUP);
strCode.append("+"); //the "turn on"-code!
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceBrateck::turnOff(Controller *controller){
try{
std::string strCode = getStringCode();
strCode.insert(0, "S");
strCode.append(BDOWN);
strCode.append("+"); //the "turn off"-code!
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
bool DeviceBrateck::parameterMatches( const std::string &name, const std::string &value ) const {
return false;
}
/*
* Has the device got the method?
*/
int DeviceBrateck::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
}
std::string DeviceBrateck::getStringCode(void){
std::string strReturn;
try{
for( size_t i = 0; i < strHouse.length(); ++i ) {
if (strHouse[i] == '1') {
strReturn.insert(0, B1);
} else if (strHouse[i] == '-') {
strReturn.insert(0, BX);
} else if (strHouse[i] == '0') {
strReturn.insert(0, B0);
}
}
}
catch(...){
throw;
}
return strReturn;
}
std::string DeviceBrateck::getProtocol() const {
return "brateck";
}

View file

@ -1,29 +0,0 @@
#pragma once
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceBrateck : public Device
{
public:
DeviceBrateck(int id, const std::string &model, const std::string &name);
virtual ~DeviceBrateck(void);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setHouse(const std::string &strNewHouse);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
std::string getStringCode(void);
std::string strHouse;
};
}

View file

@ -1,189 +0,0 @@
#include "DeviceEverflourish.h"
#include "common.h"
using namespace TelldusCore;
const unsigned char ON = 15;
const unsigned char OFF = 0;
const unsigned char LEARN = 10;
/*
* Constructor
*/
DeviceEverflourish::DeviceEverflourish(int id, const std::string &model, const std::string &name)
:Device(id, model, name),
intHouse(0),
intCode(0)
{
}
/*
* Destructor
*/
DeviceEverflourish::~DeviceEverflourish(void)
{}
bool DeviceEverflourish::setHouse(const std::string &newHouse) {
if (newHouse.length() > 0) {
intHouse = atoi(newHouse.c_str());
} else {
intHouse = 0;
}
if (intHouse < 0) {
intHouse = 0;
} else if (intHouse > 16383) {
intHouse = 16383;
}
return true;
}
bool DeviceEverflourish::setUnit(const std::string &newUnit) {
if (newUnit.length() > 0) {
intCode = atoi(newUnit.c_str()) - 1;
} else {
intCode = 0;
}
if (intCode < 0) {
intCode = 0;
} else if (intCode > 3) {
intCode = 3;
}
return true;
}
bool DeviceEverflourish::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("house") == 0) {
return setHouse(strValue);
} else if (strName.compare("unit") == 0) {
return setUnit(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceEverflourish::turnOn(Controller *controller){
try{
std::string strCode = getCode(ON);
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceEverflourish::turnOff(Controller *controller){
try{
std::string strCode = getCode(OFF);
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
int DeviceEverflourish::learn(Controller *controller){
try{
std::string strCode = getCode(LEARN);
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
bool DeviceEverflourish::parameterMatches( const std::string &name, const std::string &value ) const {
if (name.compare("house") == 0) {
return intHouse == atoi(value.c_str());
} else if (name.compare("unit") == 0) {
return intCode == atoi(value.c_str()) - 1;
}
return true;
}
/*
* Has the device got the method?
*/
int DeviceEverflourish::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
}
std::string DeviceEverflourish::getProtocol() const {
return "everflourish";
}
std::string DeviceEverflourish::getCode(unsigned char action) {
unsigned int deviceCode = intHouse;
const char ssss = 85;
const char sssl = 84; // 0
const char slss = 69; // 1
const char bits[2] = {sssl,slss};
int i, check;
std::string strCode;
deviceCode = (deviceCode << 2) | intCode;
check = calculateChecksum(deviceCode);
char preamble[] = {'R', 5, 'T', 114,60,1,1,105,ssss,ssss,0};
strCode.append(preamble);
for(i=15;i>=0;i--) {
strCode.append(1, bits[(deviceCode>>i)&0x01]);
}
for(i=3;i>=0;i--) {
strCode.append(1, bits[(check>>i)&0x01]);
}
for(i=3;i>=0;i--) {
strCode.append(1, bits[(action>>i)&0x01]);
}
strCode.append(1, ssss);
strCode.append(1, '+');
return strCode;
}
// The calculation used in this function is provided by Frank Stevenson
unsigned int DeviceEverflourish::calculateChecksum(unsigned int x) {
unsigned int bits[16] = {
0xf ,0xa ,0x7 ,0xe,
0xf ,0xd ,0x9 ,0x1,
0x1 ,0x2 ,0x4 ,0x8,
0x3 ,0x6 ,0xc ,0xb
};
unsigned int bit = 1;
unsigned int res = 0x5;
int i;
unsigned int lo,hi;
if ((x&0x3)==3) {
lo = x & 0x00ff;
hi = x & 0xff00;
lo += 4;
if (lo>0x100) {
lo = 0x12;
}
x = lo | hi;
}
for(i=0;i<16;i++) {
if (x&bit) {
res = res ^ bits[i];
}
bit = bit << 1;
}
return res;
}

View file

@ -1,38 +0,0 @@
#ifndef DEVICEEVERFLOURISH_H
#define DEVICEEVERFLOURISH_H
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceEverflourish : public Device
{
public:
DeviceEverflourish(int id, const std::string &model, const std::string &name);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setHouse(const std::string &newHouse);
bool setUnit(const std::string &newUnit);
public:
~DeviceEverflourish(void);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
virtual int learn(Controller *controller);
int intHouse;
int intCode;
std::string getCode(unsigned char action);
static unsigned int calculateChecksum(unsigned int x);
};
}
#endif //DEVICEEVERFLOURISH_H

View file

@ -1,113 +0,0 @@
#include "DeviceFuhaote.h"
//#include <string>
//#include <bitset>
//#include <algorithm>
//#include <fstream>
using namespace TelldusCore;
const char S = 19;
const char L = 58;
const char B0[] = {S,L,L,S,0};
const char B1[] = {L,S,L,S,0};
const char OFF[] = {S,L,S,L,S,L,L,S,0};
const char ON[] = {S,L,L,S,S,L,S,L,0};
/*
* Constructor
*/
DeviceFuhaote::DeviceFuhaote(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
DeviceFuhaote::~DeviceFuhaote(void)
{
}
bool DeviceFuhaote::setCode(const std::string &strNewCode) {
strCode = strNewCode;
return true;
}
bool DeviceFuhaote::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("code") == 0) {
return setCode(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceFuhaote::turnOn(Controller *controller){
std::string strCode = "S";
strCode.append(getStringCode());
strCode.append(ON);
strCode.append(1, S);
strCode.append("+");
return controller->send(strCode);
}
/*
* Turn off this device
*/
int DeviceFuhaote::turnOff(Controller *controller){
std::string strCode = "S";
strCode.append(getStringCode());
strCode.append(OFF);
strCode.append(1, S);
strCode.append("+");
return controller->send(strCode);
}
bool DeviceFuhaote::parameterMatches( const std::string &name, const std::string &value ) const {
if (name.compare("code") == 0 && value.compare(strCode) == 0) {
return true;
}
return false;
}
/*
* Has the device got the method?
*/
int DeviceFuhaote::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
}
std::string DeviceFuhaote::getStringCode(void){
std::string strReturn;
//House code
for(size_t i = 0; i < 5; ++i) {
if (strCode[i] == '0') {
strReturn.append(B0);
} else if (strCode[i] == '1') {
strReturn.append(B1);
}
}
//Unit code
for(size_t i = 5; i < 10; ++i) {
if (strCode[i] == '0') {
strReturn.append(B0);
} else if (strCode[i] == '1') {
strReturn.append(1, S);
strReturn.append(1, L);
strReturn.append(1, S);
strReturn.append(1, L);
}
}
return strReturn;
}
std::string DeviceFuhaote::getProtocol() const {
return "fuhaote";
}

View file

@ -1,33 +0,0 @@
#ifndef DEVICEFUHAOTE_H
#define DEVICEFUHAOTE_H
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceFuhaote : public Device
{
public:
DeviceFuhaote(int id, const std::string &model, const std::string &name);
virtual ~DeviceFuhaote(void);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setCode(const std::string &strNewCode);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
std::string getStringCode(void);
std::string strCode;
};
}
#endif //DEVICEFUHAOTE_H

View file

@ -1,145 +0,0 @@
#include <stdlib.h>
#include "DeviceGroup.h"
#include "Manager.h"
using namespace TelldusCore;
/*
* Constructor
*/
DeviceGroup::DeviceGroup(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
/*
* Destructor
*/
DeviceGroup::~DeviceGroup(void) {
}
bool DeviceGroup::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("devices") == 0) {
return setDevices(strValue);
}
return false;
}
bool DeviceGroup::setDevices(const std::string &newDevices) {
/* if (strDevices.length() > 0) {
char *tempDevices = new char[strDevices.size()+1];
#ifdef _WINDOWS
strcpy_s(tempDevices, strDevices.size()+1, strDevices.c_str());
#else
strcpy(tempDevices, strDevices.c_str());
#endif
Manager *manager = Manager::getInstance();
char *strToken = strtok(tempDevices, ",");
do {
int intDevice = atoi(strToken);
Device *device = manager->getDevice(intDevice);
if (device != NULL) {
deviceList.push_back( device );
}
} while ( (strToken = strtok(NULL, ",")) != NULL );
free(tempDevices);
}*/
return true;
}
/*
* Turn on this device
*/
int DeviceGroup::turnOn(void) {
int retVal = TELLSTICK_ERROR_UNKNOWN;
/*for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
int methods = (*it)->methods();
if (methods & TELLSTICK_TURNON) {
int success = (*it)->switchState( TELLSTICK_TURNON );
if (retVal != TELLSTICK_SUCCESS) {
retVal = success;
}
}
}*/
return retVal;
}
/*
* Turn off this device
*/
int DeviceGroup::turnOff(void) {
int retVal = TELLSTICK_ERROR_UNKNOWN;
/* for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
int methods = (*it)->methods();
if (methods & TELLSTICK_TURNOFF) {
int success = (*it)->switchState( TELLSTICK_TURNOFF );
if (retVal != TELLSTICK_SUCCESS) {
retVal = success;
}
}
}*/
return retVal;
}
/*
* Send a bell
*/
int DeviceGroup::bell(void){
int retVal = TELLSTICK_ERROR_UNKNOWN;
/* for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
int methods = (*it)->methods();
if (methods & TELLSTICK_BELL) {
int success = (*it)->switchState( TELLSTICK_BELL );
if (retVal != TELLSTICK_SUCCESS) {
retVal = success;
}
}
}*/
return retVal;
}
/*
* Turn off this device
*/
int DeviceGroup::dim(unsigned char level){
int retVal = TELLSTICK_ERROR_UNKNOWN;
/* for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
int methods = (*it)->methods();
if (methods & TELLSTICK_DIM) {
int success = (*it)->switchState( TELLSTICK_DIM, (char*)&level);
if (retVal != TELLSTICK_SUCCESS) {
retVal = success;
}
}
}*/
return retVal;
}
bool DeviceGroup::parameterMatches( const std::string &name, const std::string &value ) const {
return false;
}
/*
* Has the device got the method?
*/
int DeviceGroup::methods(){
int retVal = 0;
for (DeviceList::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) {
retVal = retVal | (*it)->methods();
}
return retVal;
}
std::string DeviceGroup::getProtocol() const {
return "group";
}

View file

@ -1,36 +0,0 @@
#pragma once
#include "Device.h"
#include <string.h>
#include <list>
class Controller;
namespace TelldusCore {
typedef std::list<Device *> DeviceList;
class DeviceGroup : public Device
{
public:
DeviceGroup(int id, const std::string &model, const std::string &name);
~DeviceGroup(void);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setDevices(const std::string &newDevices);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(void);
virtual int turnOff(void);
virtual int bell(void);
virtual int dim(unsigned char level);
private:
DeviceList deviceList;
};
}

View file

@ -1,233 +0,0 @@
// #include "StdAfx.h" //Needed?
#include "DeviceIkea.h"
#include <algorithm>
#include <bitset>
#include <iostream>
#include <fstream>
#include <string.h>
#ifdef _WINDOWS
#define strcasecmp(x, y) _strcmpi(x, y)
#endif
using namespace TelldusCore;
/*
* Constructor
*/
DeviceIkea::DeviceIkea(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
bool DeviceIkea::setSystem(const std::string &strSystem) {
if (strSystem.length() > 0) {
intSystem = atoi(strSystem.c_str()) - 1;
} else {
intSystem = 0;
}
return true;
}
bool DeviceIkea::setUnits(const std::string &strUnits) {
if (strUnits.length() > 0) {
intUnits = 0; //Start without any units
char *tempUnits = new char[strUnits.size()+1];
#ifdef _WINDOWS
strcpy_s(tempUnits, strUnits.size()+1, strUnits.c_str());
#else
strcpy(tempUnits, strUnits.c_str());
#endif
char *strToken = strtok(tempUnits, ",");
do {
int intUnit = atoi(strToken);
if (intUnit == 10) {
intUnit = 0;
}
intUnits = intUnits | ( 1<<(9-intUnit) );
} while ( (strToken = strtok(NULL, ",")) != NULL );
free(tempUnits);
}
return true;
}
bool DeviceIkea::setFade(const std::string &strFadeStyle) {
if (strFadeStyle.length() > 0 && strcasecmp(strFadeStyle.c_str(), "true") == 0) {
intFadeStyle = 1;
} else {
intFadeStyle = 0;
}
return true;
}
/*
* Destructor
*/
DeviceIkea::~DeviceIkea(void)
{
intSystem = -1;
intUnits = -1;
intFadeStyle = -1;
}
bool DeviceIkea::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("system") == 0) {
return setSystem(strValue);
} else if (strName.compare("units") == 0) {
return setUnits(strValue);
} else if (strName.compare("fade") == 0) {
return setFade(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceIkea::turnOn(Controller *controller){
try{
std::string strMessage = getStringCode(255);
return controller->send(strMessage);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceIkea::turnOff(Controller *controller){
try{
std::string strMessage = getStringCode(0);
return controller->send(strMessage);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceIkea::dim(unsigned char level, Controller *controller){
try{
std::string strMessage = getStringCode(level);
return controller->send(strMessage);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Convert an integer to byte string where 0 is represented by ª and 1 by TT
*/
std::string DeviceIkea::getStringCode(unsigned char level){
std::string strReturn = "STTTTTTª"; //Startcode, always like this;
try{
std::string strChannels = "";
int intCode = (intSystem << 10) | intUnits;
int checksum1 = 0;
int checksum2 = 0;
for (int i = 13; i >= 0; --i) {
if ((intCode>>i) & 1) {
strChannels.append("TT");
if (i % 2 == 0)
checksum2++;
else
checksum1++;
} else {
strChannels.append("ª");
}
}
strReturn.append(strChannels); //System + Units
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
int intLevel = 0;
if (level <= 12) {
intLevel = 10; // Level 10 is actually off
} else if (level <= 37) {
intLevel = 1;
} else if (level <= 62) {
intLevel = 2;
} else if (level <= 87) {
intLevel = 3;
} else if (level <= 112) {
intLevel = 4;
} else if (level <= 137) {
intLevel = 5;
} else if (level <= 162) {
intLevel = 6;
} else if (level <= 187) {
intLevel = 7;
} else if (level <= 212) {
intLevel = 8;
} else if (level <= 237) {
intLevel = 9;
} else {
intLevel = 0; // Level 0 is actually full on
}
int intFade = 0;
if (intFadeStyle == 1) {
intFade = 11 << 4; //Smooth
} else {
intFade = 1 << 4; //Instant
}
intCode = intLevel | intFade; //Concat level and fade
checksum1 = 0;
checksum2 = 0;
for (int i = 0; i < 6; ++i) {
if ((intCode>>i) & 1) {
strReturn.append("TT");
if (i % 2 == 0)
checksum1++;
else
checksum2++;
} else {
strReturn.append("ª");
}
}
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
strReturn.append("+");
}
catch(...){
throw;
}
return strReturn;
}
bool DeviceIkea::parameterMatches( const std::string &name, const std::string &value ) const {
return false;
}
/*
* Has the device got the method?
*/
int DeviceIkea::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM);
}
std::string DeviceIkea::getProtocol() const {
return "ikea";
}

View file

@ -1,34 +0,0 @@
#pragma once
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceIkea : public Device
{
public:
DeviceIkea(int id, const std::string &model, const std::string &name);
virtual ~DeviceIkea(void);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setSystem(const std::string &strSystem);
bool setUnits(const std::string &strUnits);
bool setFade(const std::string &strFade);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
virtual int dim(unsigned char level, Controller *controller);
int intSystem;
int intUnits;
int intFadeStyle;
std::string getStringCode(unsigned char);
};
}

View file

@ -1,299 +0,0 @@
// #include "StdAfx.h"
#include "DeviceNexa.h"
#include <string.h>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <fstream>
#include "common.h"
using namespace TelldusCore;
const char START[] = {'T',127,255,24,1,0};
//const char START[] = {'T',130,255,26,24,0};
/*
* Constructor
*/
DeviceNexa::DeviceNexa(int id, const std::string &model, const std::string &name)
:Device(id, model, name),
intHouse(0),
intCode(0)
{
}
/*
* Destructor
*/
DeviceNexa::~DeviceNexa(void)
{}
bool DeviceNexa::setHouse(const std::string &newHouse) {
int house = atoi(newHouse.c_str());
if (newHouse.length() == 1 && house == 0) { //Codeswitch
intHouse = newHouse[0] - 'A';
} else { //Selflearning
intHouse = house;
}
return true;
}
bool DeviceNexa::setUnit(const std::string &newUnit) {
if (newUnit.length() > 0) {
intCode = atoi(newUnit.c_str()) - 1;
} else {
intCode = 0;
}
return true;
}
bool DeviceNexa::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("house") == 0) {
return setHouse(strValue);
} else if (strName.compare("unit") == 0) {
return setUnit(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceNexa::turnOn(Controller *controller){
if (strcasecmp(this->getModel().c_str(), "bell") == 0) {
return bell(controller);
}
try{
std::string strCode = "";
if (isDimmer()) {
return dim(255, controller);
} else if (isSelflearning()) {
strCode.append( 1, 'R' );
strCode.append( 1, 5 );
strCode.append(getStringSelflearning(false, 255));
} else {
strCode.append("S");
strCode.append(getStringCodeSwitch(intHouse));
strCode.append(getStringCodeSwitch(intCode));
strCode.append("$k$k$kk$$kk$$kk$$k+"); //the "turn on"-code, keeps it like this, doesn't have to be regenerated each time
}
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceNexa::turnOff(Controller *controller){
try{
std::string strCode = "";
if (isSelflearning()) {
strCode.append( 1, 'R' );
strCode.append( 1, 5 );
strCode.append(getStringSelflearning(false, 0));
} else {
strCode.append("S");
strCode.append(getStringCodeSwitch(intHouse));
strCode.append(getStringCodeSwitch(intCode));
strCode.append("$k$k$kk$$kk$$k$k$k+"); //the "turn off"-code, keeps it like this, doesn't have to be regenerated each time
}
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Dim this device
*/
int DeviceNexa::dim(unsigned char level, Controller *controller) {
try{
std::string strMessage = "";
strMessage.append( 1, 'R' );
strMessage.append( 1, 5 );
strMessage.append(getStringSelflearning(true, level));
return controller->send(strMessage);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Send a bell
*/
int DeviceNexa::bell(Controller *controller){
try{
std::string strCode = getStringCodeSwitch(intHouse);
strCode.append("$kk$$kk$$kk$$k$k"); //the unit-code is always 7, doesn't have to be regenerated each time
strCode.insert(0, "S");
strCode.append("$kk$$kk$$kk$$kk$$k+"); //the "bell"-code, keeps it like this, doesn't have to be regenerated each time
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
int DeviceNexa::learn(Controller *controller){
std::string strCode = "";
strCode.append( 1, 'R' );
strCode.append( 1, 2 );
strCode.append(getStringSelflearning(false, 255));
int retVal = 0;
for (int i = 0; i < 5; ++i) {
retVal = controller->send(strCode);
if (retVal != TELLSTICK_SUCCESS) {
return retVal;
}
msleep(200);
}
return retVal;
}
/*
* Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed
*/
std::string DeviceNexa::getStringCodeSwitch(int intToConvert){
std::string strReturn = "";
try{
for( int i = 0; i < 4; ++i ) {
if (intToConvert & 1) { //Convert 1
strReturn.append("$kk$");
} else { //Convert 0
strReturn.append("$k$k");
}
intToConvert >>= 1;
}
}
catch(...){
throw;
}
return strReturn;
}
std::string DeviceNexa::getStringSelflearning(bool dim, unsigned char level) {
std::string strMessage = START;
strMessage.append(1,(dim ? 147 : 132)); //Number of pulses
std::string m;
for (int i = 25; i >= 0; --i) {
m.append( intHouse & 1 << i ? "10" : "01" );
}
m.append("01"); //Group
//On/off
if (dim) {
m.append("00");
} else if (level == 0) {
m.append("01");
} else {
m.append("10");
}
for (int i = 3; i >= 0; --i) {
m.append( intCode & 1 << i ? "10" : "01" );
}
if (dim) {
unsigned char newLevel = level/16;
for (int i = 3; i >= 0; --i) {
m.append(newLevel & 1 << i ? "10" : "01");
}
}
//The number of data is odd.
//Add this to make it even, otherwise the following loop will not work
m.append("0");
unsigned char code = 9; //b1001, startcode
for (unsigned int i = 0; i < m.length(); ++i) {
code <<= 4;
if (m[i] == '1') {
code |= 8; //b1000
} else {
code |= 10; //b1010
// code |= 11; //b1011
}
if (i % 2 == 0) {
strMessage.append(1,code);
code = 0;
}
}
strMessage.append("+");
// for( int i = 0; i < strMessage.length(); ++i ) {
// printf("%i,", (unsigned char)strMessage[i]);
// }
// printf("\n");
return strMessage;
}
bool DeviceNexa::parameterMatches( const std::string &name, const std::string &value ) const {
if (name.compare("house") == 0) {
if (isSelflearning()) {
return intHouse == atoi(value.c_str());
}
return intHouse == value[0] - 'A';
} else if (name.compare("unit") == 0) {
return intCode == atoi(value.c_str()) - 1;
} else if (name.compare("type") == 0) {
if (isSelflearning()) {
return (value.compare("selflearning") == 0);
}
}
return true;
}
/*
* Has the device got the method?
*/
int DeviceNexa::methods(){
std::string strModel = this->getModel();
if ( strcasecmp(strModel.c_str(), "codeswitch") == 0 ) {
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
} else if (strcasecmp(strModel.c_str(), "selflearning-switch") == 0) {
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
} else if (strcasecmp(strModel.c_str(), "selflearning-dimmer") == 0) {
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM | TELLSTICK_LEARN);
} else if (strcasecmp(strModel.c_str(), "bell") == 0) {
return TELLSTICK_BELL;
}
return 0;
}
bool DeviceNexa::isSelflearning() const {
return strncasecmp(getModel().c_str(), "selflearning", 12) == 0;
}
bool DeviceNexa::isDimmer() const {
return strcasecmp(getModel().c_str(), "selflearning-dimmer") == 0;
}
std::string DeviceNexa::getProtocol() const {
return "arctech";
}

View file

@ -1,38 +0,0 @@
#pragma once
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceNexa : public Device
{
public:
DeviceNexa(int id, const std::string &model, const std::string &name);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setHouse(const std::string &newHouse);
bool setUnit(const std::string &newUnit);
public:
~DeviceNexa(void);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
virtual int dim(unsigned char level, Controller *controller);
virtual int bell(Controller *controller);
virtual int learn(Controller *controller);
bool isSelflearning() const;
bool isDimmer() const;
int intHouse;
int intCode;
std::string getStringCodeSwitch(int);
std::string getStringSelflearning(bool dim, unsigned char level);
};
}

View file

@ -1,219 +0,0 @@
// #include "StdAfx.h"
#include "DeviceRisingSun.h"
#include <string.h>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <fstream>
#include "common.h"
using namespace TelldusCore;
/*
* Constructor
*/
DeviceRisingSun::DeviceRisingSun(int id, const std::string &model, const std::string &name)
:Device(id, model, name),
intHouse(0),
intCode(0)
{
}
/*
* Destructor
*/
DeviceRisingSun::~DeviceRisingSun(void)
{}
bool DeviceRisingSun::setHouse(const std::string &newHouse) {
if (newHouse.length() > 0) {
intHouse = atoi(newHouse.c_str()) - 1;
} else {
intHouse = 0;
}
return true;
}
bool DeviceRisingSun::setUnit(const std::string &newUnit) {
if (newUnit.length() > 0) {
intCode = atoi(newUnit.c_str()) - 1;
} else {
intCode = 0;
}
return true;
}
bool DeviceRisingSun::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("house") == 0) {
return setHouse(strValue);
} else if (strName.compare("unit") == 0) {
return setUnit(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceRisingSun::turnOn(Controller *controller){
try{
if (isSelflearning()) {
return controller->send(getStringSelflearning(true));
} else {
std::string strCode = getStringCodeswitch(intHouse);
std::string strUnit = getStringCodeswitch(intCode);
strCode.append(strUnit);
strCode.insert(0, "S.e");
strCode.append("e..ee..ee..ee..e+"); //the "turn on"-code, keeps it like this, doesn't have to be regenerated each time
return controller->send(strCode);
}
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceRisingSun::turnOff(Controller *controller){
try{
if (isSelflearning()) {
return controller->send(getStringSelflearning(false));
} else {
std::string strCode = getStringCodeswitch(intHouse);
std::string strUnit = getStringCodeswitch(intCode);
strCode.append(strUnit);
strCode.insert(0, "S.e");
strCode.append("e..ee..ee..e.e.e+"); //the "turn off"-code, keeps it like this, doesn't have to be regenerated each time
return controller->send(strCode);
}
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
int DeviceRisingSun::learn(Controller *controller){
std::string strCode = "R";
strCode.append( 1, 50 );
strCode.append(getStringSelflearning(true));
return controller->send(strCode);
}
/*
* Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed
*/
std::string DeviceRisingSun::getStringCodeswitch(int intToConvert){
std::string strReturn = "";
try{
for(int i = 0; i < 4; ++i) {
if (i == intToConvert) {
strReturn.append( ".e.e" );
} else {
strReturn.append( "e..e" );
}
}
}
catch(...){
throw;
}
return strReturn;
}
std::string DeviceRisingSun::getStringSelflearning(bool on){
const char code_on[][7] = {
"110110", "001110", "100110", "010110",
"111001", "000101", "101001", "011001",
"110000", "001000", "100000", "010000",
"111100", "000010", "101100", "011100"
};
const char code_off[][7] = {
"111110", "000001", "101110", "011110",
"110101", "001101", "100101", "010101",
"111000", "000100", "101000", "011000",
"110010", "001010", "100010", "010010"
};
const char l = 120;
const char s = 51;
std::string strCode = "10";
int code = intCode;
code = (code < 0 ? 0 : code);
code = (code > 15 ? 15 : code);
if (on) {
strCode.append(code_on[code]);
} else {
strCode.append(code_off[code]);
}
int house = intHouse;
for(int i = 0; i < 25; ++i) {
if (house & 1) {
strCode.append(1, '1');
} else {
strCode.append(1, '0');
}
house >>= 1;
}
std::string strReturn;
for(unsigned int i = 0; i < strCode.length(); ++i) {
if (strCode[i] == '1') {
strReturn.append(1, l);
strReturn.append(1, s);
} else {
strReturn.append(1, s);
strReturn.append(1, l);
}
}
std::string prefix = "P";
prefix.append(1, 5);
prefix.append("S");
strReturn.insert(0, prefix);
strReturn.append(1, '+');
return strReturn;
}
bool DeviceRisingSun::parameterMatches( const std::string &name, const std::string &value ) const {
if (value.length() == 0) {
return false;
}
return false;
}
/*
* Has the device got the method?
*/
int DeviceRisingSun::methods() {
std::string strModel = this->getModel();
if (strcasecmp(strModel.c_str(), "selflearning") == 0) {
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
}
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
}
std::string DeviceRisingSun::getProtocol() const {
return "risingsun";
}
bool DeviceRisingSun::isSelflearning() const {
return (strcasecmp(getModel().c_str(), "selflearning") == 0);
}

View file

@ -1,35 +0,0 @@
#pragma once
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceRisingSun : public Device
{
public:
DeviceRisingSun(int id, const std::string &model, const std::string &name);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setHouse(const std::string &newHouse);
bool setUnit(const std::string &newUnit);
public:
~DeviceRisingSun(void);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
virtual int learn(Controller *controller);
int intHouse;
int intCode;
bool isSelflearning() const;
std::string getStringCodeswitch(int);
std::string getStringSelflearning(bool on);
};
}

View file

@ -1,117 +0,0 @@
#include "DeviceSartano.h"
#include "DeviceNexa.h"
#include <string>
#include <bitset>
#include <algorithm>
#include <fstream>
using namespace TelldusCore;
/*
* Constructor
*/
DeviceSartano::DeviceSartano(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
DeviceSartano::~DeviceSartano(void)
{
}
bool DeviceSartano::setCode(const std::string &strNewCode) {
strCode = strNewCode;
return true;
}
bool DeviceSartano::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("code") == 0) {
return setCode(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceSartano::turnOn(Controller *controller){
try{
std::string strCode = getStringCode();
strCode.insert(0, "S");
strCode.append("$k$k$kk$$k+"); //the "turn on"-code, keeps it like this, doesn't have to be regenerated each time
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
/*
* Turn off this device
*/
int DeviceSartano::turnOff(Controller *controller){
try{
std::string strCode = getStringCode();
strCode.insert(0, "S");
strCode.append("$kk$$k$k$k+"); //the "turn off"-code, keeps it like this, doesn't have to be regenerated each time
return controller->send(strCode);
}
catch(...){
throw;
}
return TELLSTICK_ERROR_UNKNOWN;
}
bool DeviceSartano::parameterMatches( const std::string &name, const std::string &value ) const {
if (name.compare("code") == 0 && value.compare(strCode) == 0) {
return true;
}
return false;
}
/*
* Has the device got the method?
*/
int DeviceSartano::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF);
}
/*
* Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed
*/
std::string DeviceSartano::getStringCode(void){
std::string strReturn = strCode;
try{
size_t intPos = strReturn.find("0");
while (intPos < std::string::npos){
strReturn.replace(intPos, 1, "$kk$");
intPos = strReturn.find("0", intPos + 1);
}
intPos = strReturn.find("1");
while (intPos < std::string::npos){
strReturn.replace(intPos, 1, "$k$k");
intPos = strReturn.find("1", intPos + 1);
}
}
catch(...){
throw;
}
return strReturn;
}
std::string DeviceSartano::getProtocol() const {
return "sartano";
}

View file

@ -1,29 +0,0 @@
#pragma once
#include "Device.h"
#include <string>
namespace TelldusCore {
class DeviceSartano : public Device
{
public:
DeviceSartano(int id, const std::string &model, const std::string &name);
virtual ~DeviceSartano(void);
virtual int methods();
virtual std::string getProtocol() const;
virtual bool parameterMatches( const std::string &name, const std::string &value ) const;
bool setCode(const std::string &strNewCode);
protected:
virtual bool setDeviceParameter(const std::string &strName, const std::string &strValue);
virtual int turnOn(Controller *controller);
virtual int turnOff(Controller *controller);
std::string getStringCode(void);
std::string strCode;
};
}

View file

@ -1,140 +0,0 @@
#include "DeviceSilvanChip.h"
#include "TellStick.h"
#include <string>
using namespace TelldusCore;
/*
* Constructor
*/
DeviceSilvanChip::DeviceSilvanChip(int id, const std::string &model, const std::string &name)
:Device(id, model, name)
{
}
DeviceSilvanChip::~DeviceSilvanChip(void)
{
}
bool DeviceSilvanChip::setHouse(const std::string &strNewHouse) {
intHouse = atoi(strNewHouse.c_str());
return true;
}
bool DeviceSilvanChip::setDeviceParameter(const std::string &strName, const std::string &strValue) {
if (strName.compare("house") == 0) {
return setHouse(strValue);
}
return false;
}
/*
* Turn on this device
*/
int DeviceSilvanChip::turnOn(Controller *controller){
std::string strCode = getStringCode(controller, TELLSTICK_TURNON);
return controller->send(strCode);
}
/*
* Turn off this device
*/
int DeviceSilvanChip::turnOff(Controller *controller){
std::string strCode = getStringCode(controller, TELLSTICK_TURNOFF);
return controller->send(strCode);
}
int DeviceSilvanChip::learn(Controller *controller) {
std::string strCode = getStringCode(controller, TELLSTICK_LEARN);
return controller->send(strCode);
}
bool DeviceSilvanChip::parameterMatches( const std::string &name, const std::string &value ) const {
return false;
}
/*
* Has the device got the method?
*/
int DeviceSilvanChip::methods(){
return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_LEARN);
}
std::string DeviceSilvanChip::getStringCode(Controller *controller, int method){
std::string times = "\255\1\200\100";
const unsigned char S = '3';
const unsigned char L = '0';
const std::string LONG = "012";
const std::string ONE = LONG + "3";
const std::string ZERO = "3" + LONG;
std::string strReturn;
strReturn.append(1, S);
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, L);
strReturn.append(1, '1');
strReturn.append(1, S);
for( int i = 19; i >= 0; --i ) {
if (intHouse & (1 << i)) {
strReturn.append(ONE);
} else {
strReturn.append(ZERO);
}
}
if (method == TELLSTICK_TURNON) {
strReturn.append(ZERO);
strReturn.append(ZERO);
strReturn.append(ONE);
strReturn.append(ZERO);
} else if (method == TELLSTICK_LEARN) {
strReturn.append(ZERO);
strReturn.append(ZERO);
strReturn.append(ZERO);
strReturn.append(ONE);
} else {
strReturn.append(ONE);
strReturn.append(ZERO);
strReturn.append(ZERO);
strReturn.append(ZERO);
}
strReturn.append(ZERO);
return TellStick::convertSToT( 255, 1, 200, 100, strReturn);
}
std::string DeviceSilvanChip::getProtocol() const {
return "silvanchip";
}

Some files were not shown because too many files have changed in this diff Show more