Fix a typo in the examples (patity -> parity)

Change-Id: I92b6fbe5fbc1a402919a8339086f495e351ca6dc
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Add a new simple and command line writer example

Change-Id: I5d893d18477790def27bfa1fa051d459a8193db5
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Add a new simple and command line reader example

Change-Id: I69c05be5db564888986925d943aff32221f5b310
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Close the standard input right after reading to avoid duplicate calls

Change-Id: Idd4b5bf996d57f0cd22a30496af3841f7d5a806a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix a typo in the message printed to the stdout (creadersync)

Change-Id: Ide7ab7b0841977f1132d243c82206edd85cc699a
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Fix the broken example qdoc keyword value

The "cwritersync" example has been introduced in commit
9f8f2d6dc6f38b54a91f4a3d7ebf4285891005d3, and the "creadersync" example has been
introduced in commit ccdf42d9d10a32ccdd4a12c643130ffdea498552.

Initially, the "cwritersync" example was called "cwriter", but then it got
renamed to reflect the functionality more explicitly based on its name.

Having that renaming done, I had to sync up the writer and reader terms
everywhere, but this instance has been accidentally left out. It is not
intentional to have this name, so this is a bug.

This is a somewhat critical bugfix because it may trigger the example
unavailable from the main example page. Thereby, a useful example could become
useless for the end users.

Change-Id: I0f483ea037fc76a362f1d174b521075e8e9b0a3a
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Add support for loading udev at run-time

QtSerialPort is linked against udev by default if the development files can be
detected on the system. The reason for this is that, it is more common to link
against udev than loading it at run-time. People will usually use distribution
packages where there cannot be inconsistency between different versions, and
hence ABI breaks, etc.

The relevant LINK_LIBUDEV variable will be set. This can be overridden by
defining LOAD_LIBUDEV for qmake:

    qmake "DEFINES += LOAD_LIBUDEV" -r

It is also worth noting that the common code is separated into a private header,
and it can be included for either type of libudev usage. There is no need
for its user to handle the compile-time linking or run-time loading separately
on top of that.

Task-number: QTBUG-34329
Change-Id: I45ffaaede2a74498587a6452fbe3fec7eaf83483
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Make the enum value descriptions consistent

Currently, they are inconsistent and very hard to read. Hence, the minority is
changed to follow the majority, and also the "table" style used throughout Qt.

I also added a line break where the value explanation is long to have a mode
explicit separate between the values. Otherwise, the flow of the text is too
crowded, and the reader can lost the track.

Change-Id: Ia14162b162357ec2c85be1726b7f220e1e6b6ec6
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Set the error in the same method where the check against failure is done

This is done for consistency with other QIODevice subclasses, like in QtNetwork.
It also makes the code shorter due to the eliminated unnecessary Q_Q macro
usage.

Change-Id: Ibbd2be08e7aeff2bd0687d542cb256efb05f59bc
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Fix a typo (or copy/paste) error for the comment

It is incorrect English in there, and also incorrect content what it tries to
explain. Also, it is not consistent with the rest like QtNetwork, i.e
QAbstractSocket.

Change-Id: Ibfca1314145e1c49cda7a3e77d9d9ac97d2b6dd2
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Make the return value void for methods that would always return true

Change-Id: Iaa869b8b618db630d46726d7ebeac83e8a826af3
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Respect the configure script run for udev

Configure does not currently have an argument for udev, but still: it will try
to detect it and if it is available QT_CONFIG contains the "libudev" word.

We should respect that for Qt 5. Unfortunate, the configure script is not
checking this for Qt 4, so we still need to fall back to pkgconfig for Qt 4.

Change-Id: I9e755ee015f4f584e945cb176f1788b6dbac7374
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Disable QNX build

Nobody tested the serial port and it does not
compile as CRTSCTS is not defined. Lets disable
it until its fixed.

Change-Id: Ifc032194773b166a7fd9502f5d7f518019d80c7c
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Add an initial changelog for 5.2.0

Change-Id: Ibe5b597a490c37b43434624bdf6d1d5be05a7ce4
Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
Mark most of the the data error policy as deprecated

Unfortunately, this is a bit bad heritage of the QSerialDevice project. It is
not well-thought, and it was added in rush. If this feature ever comes back,
it has to be rethought and maybe redesigned. Currently, it is not much usable
nicely. It is done similarly to the following change:

https://codereview.qt-project.org/#patch,all,43441,7

Having done this, the users will get a warning, and they will hopefully stop
using it. Then, the feature redesign it for 5.3 or later. It can get
undeprecated anytime in Qt 5.X, but it cannot be removed with bumping the
library version. That should be the last resort.

In fact, this feature is very likely not to be redesigned. It is unfortunately a
broken concept. The following long-living serial port frameworks do not provide
"Policy" API either which is a clear sign for its usage pattern:

* PySerial
* Java SerialPort
* C#/.NET SerialPort
* QextSerialPort

... so to recap: it was not a good idea to introduce it.

Unfortunately, the side effect is that we have got warnings for the deprecated
method since moc cannot handle it properly. It needs to call it for internal
reasons.

Note that enum and Q_PROPERTY cannot be deprecated because Q_PROPERTY simply
cannot be, and the enum cannot be deprecated either since that would cause
further warnings for the library itself due its usage for the accessor and
mutator, etc. However, they can be put behind the QT_DEPRECATED_SINCE macro so
that the users can get compilation errors if they define
QT_DISABLE_DEPRECATED_BEFORE to get rid of old deprecated symbols easily by
getting errors instead of warnings.

The following coding can be run to show the expected warnings when used from a
QtSerialPort based application or library:

main.cpp:

int main()
{
    QSerialPort serialPort;
    serialPort.dataErrorPolicy();
    return 0;
}

==============================================================================

1) Qt 5

g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt -lQt5SerialPort main.cpp

main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
     serialPort.dataErrorPolicy();

Tested on Linux with Qt 4.8.5 and then Qt 5.1.1.

==============================================================================

2) Qt 4

g++ -fPIC -Wall -DQT_DEPRECATED_WARNINGS -I/usr/include/qt4/ -lQtSerialPort main.cpp

main.cpp: In function ‘int main()’:
main.cpp:6:32: warning: ‘QSerialPort::DataErrorPolicy QSerialPort::dataErrorPolicy() const’ is deprecated (declared at /usr/include/qt4/QtSerialPort/qserialport.h:222) [-Wdeprecated-declarations]
     serialPort.dataErrorPolicy();
                                     ^

==============================================================================

Task-number: QTBUG-34429
Change-Id: Ia183817b841fb172d232f550b8402f7a314b8492
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Add /dev/ttyHS(L)* to the hard coded uart list on Unix

Some information can be found on the following link:

http://www.anyclub.org/2012/05/8960-android-gsbi-uart-debug-tips.html

Change-Id: Ie57d58f5a01c168ff9498694564e43e43c7919e3
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Add a new simple and command line async writer example

Change-Id: I8f33126de5c78da9a4a0dbddd16eecde7044f0c5
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Replace the home-grown QTtyLocker with QLockFile

This can be more widely adopted later, and not just for the Linux backend. It
would be more than a few-liner change for stable, so this change change is kept
minimal (of course apart from the big file integration).

The only big problem with QLockFile currently is that we cannot change the file
name on the fly as it seems, just for construction. Even the copy constructor
and assignment operators are private. It means the class currently seems to be
non-eligible for QtSerialPort needs where it is necessary to change for open
anytime, and be accessible by open/serial for the before and after read/write
session for the same file name.

Also, I had to get rid of the QTemporary file internals because we cannot have
access to the internal engine with Qt 4. I also had to make a small thread class
for the protected msleep in QThread for Qt 4.

There was a small improvement for the hidden dependency problem with
gethostname. That was also sent to QtCore proper. Also, the windows backend for
the QLockFile class is not copied for simplicity. It would not be used as of
now.

There is also a short convenience around QLockFile established to handle
system-wide lock file paths. There is also some error handling added if the lock
directory paths are not readable or writable. This will end users identify the
problems like on Android.

Tested on Archlinux with Qt 4 and then 5.

Task-number: QTBUG-34474
Change-Id: I7adf29527c01ad331d3eeff5ae4c5a4113bde083
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Use local QLatin1Char as opposed to a static QLatin1String

Change-Id: I3bf8a439bef4edc86943d19b3f0e8d2e0dcbe0c4
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Use the QLockFile source on Unix only to avoid errors on other platforms

Change-Id: I406ec1dc0a7e131db5ea93060e9a2adc47c50489
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>