summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-08-30 11:43:58 -0400
committerScott Murray <scott.murray@konsulko.com>2019-08-30 11:45:55 -0400
commitededa7e3ef24a8cea9e513fa008ef481c1675457 (patch)
tree86a4c79d066b9638b11c0f127ad8f3c66c38c4f7
parent706ad73eb02caf8532deaf5d38995bd258725cb8 (diff)
Initial check in
Initial check in of the original repository: git://github.com/AGLExport/genivi-navi-yelp-client.git as of commit c2691cb265d9198542482a860f1df378e8c2708b. Bug-AGL: SPEC-2787 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I7405367387622fb788a5712ed24005ee6d7ce495
-rw-r--r--.gitreview5
-rw-r--r--Business.h40
-rw-r--r--CMakeLists.txt59
-rw-r--r--COPYING129
-rw-r--r--ClickableLabel.h23
-rw-r--r--HMI_AppLauncher_POI_Active-01.pngbin0 -> 33356 bytes
-rw-r--r--InfoPanel.cpp121
-rw-r--r--InfoPanel.h33
-rw-r--r--InfoPanelLabel.cpp25
-rw-r--r--InfoPanelLabel.h21
-rw-r--r--Keyboard.cpp152
-rw-r--r--Keyboard.h29
-rw-r--r--LICENSE1
-rw-r--r--MainApp.cpp1049
-rw-r--r--MainApp.h98
-rw-r--r--README.md19
-rw-r--r--config.xml.in18
-rw-r--r--fonts/DroidSansJapanese.ttfbin0 -> 1173140 bytes
-rw-r--r--images/0.pngbin0 -> 19955 bytes
-rw-r--r--images/1.pngbin0 -> 19906 bytes
-rw-r--r--images/2.pngbin0 -> 20308 bytes
-rw-r--r--images/3.pngbin0 -> 20517 bytes
-rw-r--r--images/4.pngbin0 -> 19937 bytes
-rw-r--r--images/5.pngbin0 -> 20447 bytes
-rw-r--r--images/6.pngbin0 -> 20544 bytes
-rw-r--r--images/7.pngbin0 -> 20147 bytes
-rw-r--r--images/8.pngbin0 -> 20564 bytes
-rw-r--r--images/9.pngbin0 -> 20127 bytes
-rw-r--r--images/A.pngbin0 -> 20851 bytes
-rw-r--r--images/AGL_POI_Background.pngbin0 -> 1200761 bytes
-rw-r--r--images/B.pngbin0 -> 20549 bytes
-rw-r--r--images/C.pngbin0 -> 20981 bytes
-rw-r--r--images/D.pngbin0 -> 20892 bytes
-rw-r--r--images/E.pngbin0 -> 20816 bytes
-rw-r--r--images/F.pngbin0 -> 21051 bytes
-rw-r--r--images/G.pngbin0 -> 21831 bytes
-rw-r--r--images/H.pngbin0 -> 21476 bytes
-rw-r--r--images/I.pngbin0 -> 21570 bytes
-rw-r--r--images/J.pngbin0 -> 21987 bytes
-rw-r--r--images/K.pngbin0 -> 22363 bytes
-rw-r--r--images/L.pngbin0 -> 22186 bytes
-rw-r--r--images/M.pngbin0 -> 22650 bytes
-rw-r--r--images/N.pngbin0 -> 22886 bytes
-rw-r--r--images/O.pngbin0 -> 23414 bytes
-rw-r--r--images/P.pngbin0 -> 23244 bytes
-rw-r--r--images/Q.pngbin0 -> 23909 bytes
-rw-r--r--images/R.pngbin0 -> 23811 bytes
-rw-r--r--images/S.pngbin0 -> 24275 bytes
-rw-r--r--images/T.pngbin0 -> 23795 bytes
-rw-r--r--images/U.pngbin0 -> 24255 bytes
-rw-r--r--images/V.pngbin0 -> 24609 bytes
-rw-r--r--images/W.pngbin0 -> 24949 bytes
-rw-r--r--images/X.pngbin0 -> 25060 bytes
-rw-r--r--images/Y.pngbin0 -> 25168 bytes
-rw-r--r--images/Z.pngbin0 -> 25192 bytes
-rw-r--r--images/apostrophe.pngbin0 -> 25243 bytes
-rw-r--r--images/back.pngbin0 -> 26261 bytes
-rw-r--r--images/background.pngbin0 -> 357 bytes
-rw-r--r--images/et.pngbin0 -> 26685 bytes
-rw-r--r--images/exclam.pngbin0 -> 25887 bytes
-rw-r--r--images/loupe-90.pngbin0 -> 19896 bytes
-rw-r--r--images/minus.pngbin0 -> 25365 bytes
-rw-r--r--images/slash.pngbin0 -> 25744 bytes
-rw-r--r--images/space.pngbin0 -> 16034 bytes
-rw-r--r--images/stars_map_www.pngbin0 -> 106008 bytes
-rw-r--r--main.cpp88
-rw-r--r--traces.h36
-rw-r--r--yelp-client.qrc52
68 files changed, 1998 insertions, 0 deletions
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..a2ae721
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.automotivelinux.org
+port=29418
+project=apps/poi-yelp
+defaultbranch=master
diff --git a/Business.h b/Business.h
new file mode 100644
index 0000000..391df5f
--- /dev/null
+++ b/Business.h
@@ -0,0 +1,40 @@
+#ifndef __BUSINESS_H__
+#define __BUSINESS_H__
+
+#include <QString>
+
+class Business
+{
+ public:
+
+ Business():
+ ReviewCount(0),
+ Rating(0.0),
+ Latitude(0.0),
+ Longitude(0.0),
+ Distance(0.0),
+ Name(""),
+ ImageUrl(""),
+ Phone(""),
+ Address(""),
+ City(""),
+ State(""),
+ ZipCode(""),
+ Country("") {}
+
+ unsigned ReviewCount;
+ double Rating;
+ double Latitude;
+ double Longitude;
+ double Distance;
+ QString Name;
+ QString ImageUrl;
+ QString Phone;
+ QString Address;
+ QString City;
+ QString State;
+ QString ZipCode;
+ QString Country;
+};
+
+#endif // __BUSINESS_H__
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..10c2384
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 2.8.11)
+INCLUDE(FindPkgConfig)
+
+# usefull flags:
+# -DCMAKE_BUILD_TYPE=Debug
+# -DCMAKE_BUILD_TYPE=Release
+# -DCMAKE_INSTALL_PREFIX=install
+
+# Set a default build type if none was specified
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to 'Release' as none was specified.")
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
+endif()
+
+project(yelp-client)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC ")
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+find_package(Qt5Widgets REQUIRED)
+
+pkg_check_modules(QT5_CORE REQUIRED Qt5Core)
+pkg_check_modules(JSON REQUIRED json-c)
+pkg_check_modules(QT5_WIDGETS REQUIRED Qt5Widgets)
+pkg_check_modules(QT5_NETWORK REQUIRED Qt5Network)
+pkg_check_modules(AGL_NAVIAPI REQUIRED libnaviapi-agl)
+pkg_check_modules(AFBWSC REQUIRED libafbwsc)
+pkg_check_modules(QLIBWIN REQUIRED qlibwindowmanager)
+pkg_check_modules(LIBHS REQUIRED libhomescreen)
+
+
+
+include_directories( ${PROJECT_SOURCE_DIR}/ ${AFBWSC_INCLUDE_DIRS} ${AGL_NAVIAPI_INCLUDE_DIRS} ${QT5_CORE_INCLUDE_DIRS} ${QT5_WIDGETS_INCLUDE_DIRS} ${QT5_NETWORK_INCLUDE_DIRS} ${JSON_INCLUDE_DIRS} ${QLIBWIN_INCLUDE_DIRS} ${LIBHS_INCLUDE_DIRS} )
+
+qt5_wrap_cpp(yelp_client_SRC MainApp.h InfoPanelLabel.h ClickableLabel.h Keyboard.h)
+
+QT5_ADD_RESOURCES(yelp_client_QRC yelp-client.qrc)
+add_executable( yelp-client main.cpp MainApp.cpp InfoPanel.cpp InfoPanelLabel.cpp Keyboard.cpp yelp-client.qrc ${yelp_client_SRC} ${yelp_client_QRC})
+#target_link_libraries( yelp-client binderclient )
+target_link_libraries( yelp-client ${AFBWSC_LIBRARIES} ${AGL_NAVIAPI_LIBRARIES} ${JSON_LIBRARIES} ${QLIBWIN_LIBRARIES} ${LIBHS_LIBRARIES} )
+qt5_use_modules(yelp-client Core Widgets Network)
+
+install (TARGETS yelp-client DESTINATION bin)
+
+##########################################################################
+# AGL binding
+configure_file(config.xml.in config.xml)
+
+add_custom_command(
+ OUTPUT poi.wgt
+ DEPENDS yelp-client
+ COMMAND rm -rf package
+ COMMAND mkdir -p package/root
+ COMMAND cp config.xml package/root/
+ COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/HMI_AppLauncher_POI_Active-01.png package/root/icon.png
+ COMMAND cp yelp-client package/root/poi
+ COMMAND wgtpkg-pack -f -o package/poi.wgt package/root
+)
+add_custom_target(widget ALL DEPENDS poi.wgt)
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..4ace698
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,129 @@
+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 Library 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.
+
+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:
+
+g
+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:
+
+g
+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.
+
+g
+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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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:
+
+g
+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:
+
+g
+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 Library General Public License instead of this License.
diff --git a/ClickableLabel.h b/ClickableLabel.h
new file mode 100644
index 0000000..86d39e8
--- /dev/null
+++ b/ClickableLabel.h
@@ -0,0 +1,23 @@
+#ifndef __CLICKABLE_LABEL_H__
+#define __CLICKABLE_LABEL_H__
+
+#include <QLabel>
+#include <QWidget>
+#include <QString>
+
+class ClickableLabel : public QLabel
+{
+ Q_OBJECT
+ public:
+ ClickableLabel(const QString& text="", QWidget* parent=0 ):QLabel(parent)
+ {
+ setText(text);
+ }
+ ~ClickableLabel(){}
+ signals:
+ void clicked();
+ protected:
+ void mouseReleaseEvent(QMouseEvent* event) { emit clicked(); }
+};
+
+#endif // __CLICKABLE_LABEL_H__
diff --git a/HMI_AppLauncher_POI_Active-01.png b/HMI_AppLauncher_POI_Active-01.png
new file mode 100644
index 0000000..2df01d3
--- /dev/null
+++ b/HMI_AppLauncher_POI_Active-01.png
Binary files differ
diff --git a/InfoPanel.cpp b/InfoPanel.cpp
new file mode 100644
index 0000000..bc57e34
--- /dev/null
+++ b/InfoPanel.cpp
@@ -0,0 +1,121 @@
+#include <QWidget>
+#include <QFont>
+#include <QNetworkRequest>
+#include <QNetworkReply>
+#include <QEventLoop>
+#include <QPixmap>
+#include <QImageReader>
+#include "InfoPanel.h"
+#include "traces.h"
+
+#define BTN_STYLE "background-color: #333333; color: white;"
+
+#define FONT_SIZE_BOLD 22
+#define FONT_SIZE 16
+#define STARS_IMG_OFFSET 1520
+#define STARS_IMG_HEIGHT 69
+#define STARS_IMG_WIDTH 324
+
+#define LABEL_NAME_HEIGHT 37
+#define LABEL_ADDR_HEIGHT 30
+#define LABEL_PHONE_HEIGHT 30
+#define LABEL_IMG_HEIGHT 220
+#define LABEL_REVIEWS_HEIGHT 24
+
+InfoPanel::InfoPanel(QWidget *parent, Business & business, QRect rect):
+ nameLabel(parent, rect),
+ imageLabel(parent, rect),
+ addressLabel(parent, rect),
+ phoneLabel(parent, rect),
+ imgRatingLabel(parent, rect),
+ nbReviewsLabel(parent, rect),
+ btnsBackground(parent, rect),
+ cancelButton("Cancel", parent),
+ goButton("Go !", parent),
+ networkManager(parent)
+{
+ int y = 0;
+ QPixmap pixmap;
+ bool isImageDownloaded = false;
+ QFont font, fontBold;
+
+ font = nameLabel.font();
+ font.setPointSize(FONT_SIZE);
+
+ fontBold = nameLabel.font();
+ fontBold.setPointSize(FONT_SIZE_BOLD);
+ fontBold.setBold(true);
+
+ /* Preload image Url: */
+ TRACE_INFO("Image URL: %s", qPrintable(business.ImageUrl));
+ QEventLoop eventLoop;
+ QObject::connect(&networkManager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
+ QNetworkRequest req(QUrl(business.ImageUrl));
+ QNetworkReply* reply = networkManager.get(req);
+
+ eventLoop.exec(); // wait for answer
+ if (reply->error() == QNetworkReply::NoError)
+ {
+ QByteArray jpegData = reply->readAll();
+ pixmap.loadFromData(jpegData);
+ isImageDownloaded = true;
+ }
+ networkManager.disconnect();
+ delete reply;
+
+ /* Display Name: */
+ nameLabel.Init(y, LABEL_NAME_HEIGHT, business.Name, &fontBold);
+ y += LABEL_NAME_HEIGHT;
+
+ /* Display Address: */
+ addressLabel.Init(y, LABEL_ADDR_HEIGHT,
+ business.Address+", "+business.City+", "+business.State+" "+business.ZipCode+", "+business.Country,
+ &font);
+ y += LABEL_ADDR_HEIGHT;
+
+ /* Display phone number: */
+ phoneLabel.Init(y, LABEL_PHONE_HEIGHT, business.Phone, &font);
+ y += LABEL_PHONE_HEIGHT;
+
+ /* Image Url: */
+ imageLabel.Init(y, LABEL_IMG_HEIGHT, QString(""));
+ y += LABEL_IMG_HEIGHT;
+ if (isImageDownloaded)
+ {
+ imageLabel.setPixmap(pixmap.scaled(QSize(rect.width(), LABEL_IMG_HEIGHT-6), Qt::KeepAspectRatio));
+ }
+
+ /* Display number of reviews: */
+ nbReviewsLabel.Init(y, LABEL_REVIEWS_HEIGHT, QString("Number of reviews : %1").arg(business.ReviewCount), &font);
+ y += LABEL_REVIEWS_HEIGHT;
+
+ /* Rating image: */
+ QImageReader reader(QString(":/images/stars_map_www.png"));
+ int RatingImgIndex = (int)((double)business.Rating*2)-1;
+ if (RatingImgIndex < 0)
+ {
+ RatingImgIndex = 0;
+ }
+ reader.setClipRect(QRect(0,
+ STARS_IMG_OFFSET + RatingImgIndex*STARS_IMG_HEIGHT, STARS_IMG_WIDTH, STARS_IMG_HEIGHT));
+ const QImage image = reader.read();
+ imgRatingLabel.Init(y, STARS_IMG_HEIGHT, QString(""));
+ y += STARS_IMG_HEIGHT;
+ imgRatingLabel.setPixmap(QPixmap::fromImage(image).scaled(QSize(rect.width() / 3, STARS_IMG_HEIGHT), Qt::KeepAspectRatio));
+
+ /* Buttons: */
+ btnsBackground.Init(y, 70, QString(""));
+ y += 70;
+
+ cancelButton.setStyleSheet(BTN_STYLE);
+ cancelButton.setFont(font);
+ cancelButton.setMinimumSize(QSize(rect.width()/4, 50));
+ cancelButton.setGeometry(QRect(rect.x()+rect.width()/8, rect.y()+y-60, rect.width()/4, 50));
+ cancelButton.setVisible(true);
+
+ goButton.setStyleSheet(BTN_STYLE);
+ goButton.setFont(font);
+ goButton.setMinimumSize(QSize(rect.width()/4, 50));
+ goButton.setGeometry(QRect(rect.x()+rect.width()*5/8, rect.y()+y-60, rect.width()/4, 50));
+ goButton.setVisible(true);
+}
diff --git a/InfoPanel.h b/InfoPanel.h
new file mode 100644
index 0000000..0602c9f
--- /dev/null
+++ b/InfoPanel.h
@@ -0,0 +1,33 @@
+#ifndef __INFO_PANEL_H__
+#define __INFO_PANEL_H__
+
+#include <QWidget>
+#include <QNetworkAccessManager>
+#include <QRect>
+#include <QPushButton>
+
+#include "Business.h"
+#include "InfoPanelLabel.h"
+
+class InfoPanel
+{
+ public:
+ InfoPanel(QWidget *parent, Business & business, QRect rect);
+ virtual ~InfoPanel(){}
+ QPushButton * getCancelButton() { return &cancelButton; }
+ QPushButton * getGoButton() { return &goButton; }
+
+ private:
+ InfoPanelLabel nameLabel;
+ InfoPanelLabel imageLabel;
+ InfoPanelLabel addressLabel;
+ InfoPanelLabel phoneLabel;
+ InfoPanelLabel imgRatingLabel;
+ InfoPanelLabel nbReviewsLabel;
+ InfoPanelLabel btnsBackground;
+ QPushButton cancelButton;
+ QPushButton goButton;
+ QNetworkAccessManager networkManager;
+};
+
+#endif // __INFO_PANEL_H__
diff --git a/InfoPanelLabel.cpp b/InfoPanelLabel.cpp
new file mode 100644
index 0000000..c87e7e5
--- /dev/null
+++ b/InfoPanelLabel.cpp
@@ -0,0 +1,25 @@
+#include "InfoPanelLabel.h"
+
+InfoPanelLabel::InfoPanelLabel(QWidget *parent, QRect &r):QLabel(parent),rect(r)
+{
+}
+
+void InfoPanelLabel::Init(int pos, int height, const QString &text, QFont *font)
+{
+ if (text.length() > 0)
+ {
+ setText(text);
+ if (font)
+ setFont(*font);
+ }
+ setStyleSheet("QLabel { background-color : white; color : #FFFFFF; }");
+ setGeometry(QRect(rect.x(), rect.y()+pos, rect.width(), height));
+
+ /* if text is too big, align left so that we can at least read the beginning : */
+ if (this->text().length() > 0 && this->fontMetrics().width(this->text()) >= rect.width())
+ setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ else
+ setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+
+ setVisible(true);
+}
diff --git a/InfoPanelLabel.h b/InfoPanelLabel.h
new file mode 100644
index 0000000..81fc206
--- /dev/null
+++ b/InfoPanelLabel.h
@@ -0,0 +1,21 @@
+#ifndef __INFO_PANEL_LABEL_H__
+#define __INFO_PANEL_LABEL_H__
+
+#include <QWidget>
+#include <QLabel>
+#include <QRect>
+#include <QFont>
+#include <QString>
+
+class InfoPanelLabel : public QLabel
+{
+ Q_OBJECT
+ public:
+ InfoPanelLabel(QWidget *parent, QRect &r);
+ void Init(int pos, int height, const QString &text, QFont *font = NULL);
+
+ private:
+ QRect rect;
+};
+
+#endif // __INFO_PANEL_LABEL_H__
diff --git a/Keyboard.cpp b/Keyboard.cpp
new file mode 100644
index 0000000..447f6c7
--- /dev/null
+++ b/Keyboard.cpp
@@ -0,0 +1,152 @@
+/**
+ Source : inspired by https://www.kdab.com/qt-input-method-virtual-keyboard/
+ */
+
+#include "Keyboard.h"
+
+#include <QWidget>
+#include <QRect>
+#include <QString>
+#include <QSignalMapper>
+#include <QPushButton>
+#include <QImageReader>
+
+#define NEXT_ROW_MARKER '\0'
+
+#define SIZE_FACTOR 1 /* looks nice on AGL demo */
+//#define SIZE_FACTOR 0.5 /* looks nice on PC build */
+
+#define OFFSET_H ( 78 * SIZE_FACTOR )
+#define KEY_WIDTH ( 78 * SIZE_FACTOR )
+#define KEY_HEIGHT ( 94 * SIZE_FACTOR )
+#define MARGIN_H ( 12 * SIZE_FACTOR )
+#define MARGIN_V ( 18 * SIZE_FACTOR )
+#define SPACE_BAR_WIDTH ( 502 * SIZE_FACTOR )
+
+struct KeyboardLayoutEntry
+{
+ int key;
+ const char *image;
+};
+
+static KeyboardLayoutEntry keyboardLayout[] = {
+ { '1' , "1.png" },
+ { '2' , "2.png" },
+ { '3' , "3.png" },
+ { '4' , "4.png" },
+ { '5' , "5.png" },
+ { '6' , "6.png" },
+ { '7' , "7.png" },
+ { '8' , "8.png" },
+ { '9' , "9.png" },
+ { '0' , "0.png" },
+ { NEXT_ROW_MARKER, NULL },
+ { 'q' , "Q.png" },
+ { 'w' , "W.png" },
+ { 'e' , "E.png" },
+ { 'r' , "R.png" },
+ { 't' , "T.png" },
+ { 'y' , "Y.png" },
+ { 'u' , "U.png" },
+ { 'i' , "I.png" },
+ { 'o' , "O.png" },
+ { 'p' , "P.png" },
+ { NEXT_ROW_MARKER, NULL },
+ { 'a' , "A.png" },
+ { 's' , "S.png" },
+ { 'd' , "D.png" },
+ { 'f' , "F.png" },
+ { 'g' , "G.png" },
+ { 'h' , "H.png" },
+ { 'j' , "J.png" },
+ { 'k' , "K.png" },
+ { 'l' , "L.png" },
+ { NEXT_ROW_MARKER, NULL },
+ { 'z' , "Z.png" },
+ { 'x' , "X.png" },
+ { 'c' , "C.png" },
+ { 'v' , "V.png" },
+ { 'b' , "B.png" },
+ { 'n' , "N.png" },
+ { 'm' , "M.png" },
+ { '!' , "exclam.png" },
+ { '\b',"back.png" },
+ { NEXT_ROW_MARKER, NULL },
+ { '\'',"apostrophe.png" },
+ { '&' , "et.png" },
+ { ' ' , "space.png" },
+ { '-' , "minus.png" },
+ { '/' , "slash.png" }
+};
+
+const static int layoutSize = (sizeof(keyboardLayout) /
+ sizeof(KeyboardLayoutEntry));
+
+Keyboard::Keyboard(QRect r, QWidget *parent):QWidget(parent),background(parent),
+ rect(QRect(r.x() + (r.width()-(r.width()*SIZE_FACTOR))/2, r.y(), r.width()*SIZE_FACTOR, r.height()*SIZE_FACTOR)),
+ mapper(new QSignalMapper(this))
+{
+ int nbRowMarkers = 1;
+ for (int i = 0; i < layoutSize; ++i)
+ if (keyboardLayout[i].key == NEXT_ROW_MARKER)
+ nbRowMarkers++;
+
+ connect(mapper, SIGNAL(mapped(int)), SLOT(buttonClicked(int)));
+
+ int row = 0;
+ int offset_h = KEY_WIDTH;
+ int offset_v = (rect.height() - (KEY_HEIGHT*nbRowMarkers + MARGIN_V*(nbRowMarkers-1))) / 2;
+
+ background.setGeometry(rect);
+ QImageReader reader(QString(":/images/background.png"));
+ background.setPixmap(QPixmap::fromImage(reader.read()).scaled(rect.width(), rect.height(), Qt::IgnoreAspectRatio));
+
+ background.show();
+
+ for (int i = 0; i < layoutSize; ++i)
+ {
+ int key_width = KEY_WIDTH;
+ if (keyboardLayout[i].key == NEXT_ROW_MARKER)
+ {
+ row++;
+ offset_h = OFFSET_H;
+ if (row == 2)
+ offset_h += (KEY_WIDTH + MARGIN_H)/2;
+ else if (row == 3)
+ offset_h += (KEY_WIDTH + MARGIN_H);
+ offset_v += (KEY_HEIGHT+MARGIN_V);
+ continue;
+ }
+ else if (keyboardLayout[i].key == ' ')
+ {
+ key_width = SPACE_BAR_WIDTH;
+ }
+
+ QPushButton *button = new QPushButton(QIcon(tr(":/images/")+QString(keyboardLayout[i].image)), tr(""), &background);
+ button->setMinimumSize(QSize(key_width, KEY_HEIGHT));
+ button->setMaximumSize(QSize(key_width, KEY_HEIGHT));
+ button->setIconSize(button->size());
+ /* geometry of button is relative to its parent, ie 'background' : */
+ button->setGeometry(QRect(offset_h, offset_v, button->width(), button->height()));
+ button->show();
+
+ mapper->setMapping(button, keyboardLayout[i].key);
+ connect(button, SIGNAL(clicked()), mapper, SLOT(map()));
+
+ offset_h += (key_width+MARGIN_H);
+ }
+}
+
+void Keyboard::buttonClicked(int key)
+{
+ if (key == '\b') /* backspace */
+ emit specialKeyClicked(key);
+ else
+ emit keyClicked(QString(key));
+}
+
+Keyboard::~Keyboard()
+{
+ disconnect();
+ delete mapper;
+}
diff --git a/Keyboard.h b/Keyboard.h
new file mode 100644
index 0000000..67f47f2
--- /dev/null
+++ b/Keyboard.h
@@ -0,0 +1,29 @@
+#ifndef __KEYBOARD_H__
+#define __KEYBOARD_H__
+
+#include <QWidget>
+#include <QRect>
+#include <QLabel>
+#include <QSignalMapper>
+
+class Keyboard : public QWidget
+{
+ Q_OBJECT
+ public:
+ explicit Keyboard(QRect r, QWidget *parent = Q_NULLPTR);
+ virtual ~Keyboard();
+
+ signals:
+ void specialKeyClicked(int key);
+ void keyClicked(const QString &text);
+
+ private slots:
+ void buttonClicked(int key);
+
+ private:
+ QRect rect;
+ QLabel background;
+ QSignalMapper *mapper;
+};
+
+#endif // __KEYBOARD_H__
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1ea1912
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+TODO
diff --git a/MainApp.cpp b/MainApp.cpp
new file mode 100644
index 0000000..d5de395
--- /dev/null
+++ b/MainApp.cpp
@@ -0,0 +1,1049 @@
+#include <QNetworkReply>
+#include <QNetworkRequest>
+#include <QUrl>
+#include <QUrlQuery>
+#include <QNetworkProxy>
+#include <QTreeWidget>
+#include <iostream>
+#include <error.h>
+#include <json-c/json.h>
+#include <stdlib.h>
+#include <unistd.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
+#include "MainApp.h"
+#include "Business.h"
+#include "InfoPanel.h"
+#include "ClickableLabel.h"
+#include "Keyboard.h"
+#include "traces.h"
+
+#define DEFAULT_TEXT "Select your destination with Yelp !"
+#define URL_AUTH "https://api.yelp.com/oauth2/token"
+#define URL_AUTOCOMPLETE "https://api.yelp.com/v3/autocomplete"
+#define URL_SEARCH "https://api.yelp.com/v3/businesses/search"
+
+#define BIG_BUFFER_SIZE (1024*1024)
+#define LEFT_OFFSET 28
+#define FONT_SIZE_LINEDIT 20
+#define FONT_SIZE_LIST 18
+#define TEXT_INPUT_WIDTH 800
+#define SEARCH_BTN_SIZE 105
+#define SPACER 15
+#define WIDGET_WIDTH (SEARCH_BTN_SIZE + SPACER + TEXT_INPUT_WIDTH)
+#define DISPLAY_WIDTH TEXT_INPUT_WIDTH
+#define DISPLAY_HEIGHT 480
+#define COMPLETE_W_WITH_KB 1080
+#define COMPLETE_H_WITH_KB 1488
+#define RESULT_ITEM_HEIGHT 80
+#define MARGINS 25
+#define AGL_REFRESH_DELAY 75 /* milliseconds */
+
+#define SCROLLBAR_STYLE \
+"QScrollBar:vertical {" \
+" border: 2px solid grey;" \
+" background: gray;" \
+" width: 45px;" \
+"}"
+
+using namespace std;
+
+MainApp::MainApp():QMainWindow(Q_NULLPTR, Qt::FramelessWindowHint),
+ networkManager(this),searchBtn(QIcon(tr(":/images/loupe-90.png")), tr(""), this),
+ lineEdit(this),keyboard(QRect(0, 688, COMPLETE_W_WITH_KB, 720), this),
+ mutex(QMutex::Recursive),token(""),currentSearchingText(""),currentSearchedText(""),
+ pSearchReply(NULL),pInfoPanel(NULL),pResultList(NULL),currentLatitude(0.0),currentLongitude(0.0),
+ navicoreSession(0),currentIndex(0),fontId(-1),isInfoScreen(false),
+ isInputDisplayed(false),isKeyboard(false),isAglNavi(false)
+{
+ //this->setAttribute(Qt::WA_TranslucentBackground);
+ this->setStyleSheet("border: none;");
+
+ searchBtn.setStyleSheet("border: none; color: #FFFFFF;");
+ searchBtn.setMinimumSize(QSize(SEARCH_BTN_SIZE, SEARCH_BTN_SIZE));
+ searchBtn.setIconSize(searchBtn.size());
+ searchBtn.setGeometry(QRect(LEFT_OFFSET, 0, searchBtn.width(), searchBtn.height()));
+
+ lineEdit.setStyleSheet("border: none; color: #FFFFFF;");
+ lineEdit.setMinimumSize(QSize(TEXT_INPUT_WIDTH, SEARCH_BTN_SIZE));
+
+ lineEdit.setPlaceholderText(QString(DEFAULT_TEXT));
+ font = lineEdit.font();
+ font.setPointSize(FONT_SIZE_LINEDIT);
+ lineEdit.setFont(font);
+ lineEdit.setTextMargins(MARGINS/2, 0, 0, 0);
+ lineEdit.installEventFilter(this);
+ lineEdit.setGeometry(QRect(LEFT_OFFSET + searchBtn.width() + SPACER, 0, lineEdit.width(), lineEdit.height()));
+ lineEdit.setVisible(false);
+
+ /* We might need a Japanese font: */
+ QFile fontFile(":/fonts/DroidSansJapanese.ttf");
+ if (!fontFile.open(QIODevice::ReadOnly))
+ {
+ TRACE_ERROR("failed to open font file");
+ }
+ else
+ {
+ QByteArray fontData = fontFile.readAll();
+ fontId = QFontDatabase::addApplicationFontFromData(fontData);
+ if (fontId < 0)
+ {
+ TRACE_ERROR("QFontDatabase::addApplicationFontFromData failed");
+ }
+ }
+
+ /* Check if "AGL_NAVI" env variable is set. If yes, we must notify
+ * AGL environment when surface needs to be resized */
+ if (getenv("AGL_NAVI"))
+ isAglNavi = true;
+
+ connect(this, SIGNAL(allSessionsGotSignal()), this, SLOT(allSessionsGot()));
+ connect(this, SIGNAL(positionGotSignal()), this, SLOT(positionGot()));
+ connect(this, SIGNAL(allRoutesGotSignal()), this, SLOT(allRoutesGot()));
+ connect(this, SIGNAL(routeCreatedSignal()), this, SLOT(routeCreated()));
+
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+ this->setStyleSheet("background-image: url(:/images/AGL_POI_Background.png);");
+ this->show();
+}
+
+MainApp::~MainApp()
+{
+ mutex.lock();
+ if (fontId >= 0)
+ QFontDatabase::removeApplicationFont(fontId);
+
+ searchBtn.disconnect();
+ lineEdit.disconnect();
+ networkManager.disconnect();
+ keyboard.disconnect();
+
+ delete pSearchReply;
+ delete pInfoPanel;
+ mutex.unlock();
+}
+
+void MainApp::searchBtnClicked()
+{
+ isInputDisplayed = !isInputDisplayed;
+ TRACE_DEBUG("isInputDisplayed = %d", isInputDisplayed);
+ DisplayLineEdit(isInputDisplayed);
+}
+
+void MainApp::DisplayLineEdit(bool display)
+{
+ mutex.lock();
+
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+
+ if (display)
+ {
+ lineEdit.setVisible(true);
+ lineEdit.setFocus();
+ }
+ else
+ {
+ if (pResultList)
+ {
+ pResultList->removeEventFilter(this);
+ delete pResultList;
+ pResultList = NULL;
+ }
+ if (pInfoPanel)
+ {
+ delete pInfoPanel;
+ pInfoPanel = NULL;
+ }
+ lineEdit.setText(tr(""));
+ lineEdit.setVisible(false);
+ }
+ isInputDisplayed = display;
+
+ mutex.unlock();
+}
+
+void MainApp::UpdateAglSurfaces()
+{
+ char cmd[1024];
+
+ TRACE_DEBUG("handle AGL demo surfaces (new surface is bigger)");
+ snprintf(cmd, 1023, "/usr/bin/LayerManagerControl set surface $SURFACE_ID_CLIENT source region 0 0 %d %d",
+ this->width(), this->height());
+ TRACE_DEBUG("%s", cmd);
+ system(cmd);
+ snprintf(cmd, 1023, "/usr/bin/LayerManagerControl set surface $SURFACE_ID_CLIENT destination region $CLIENT_X $CLIENT_Y %d %d",
+ this->width(), this->height());
+ TRACE_DEBUG("%s", cmd);
+ system(cmd);
+}
+
+void MainApp::DisplayResultList(bool display, bool RefreshDisplay)
+{
+ mutex.lock();
+
+ if (display)
+ {
+ if (!pResultList)
+ {
+ pResultList = new QTreeWidget(this);
+ pResultList->setStyleSheet("border: none; color: #FFFFFF;");
+ pResultList->setRootIsDecorated(false);
+ pResultList->setEditTriggers(QTreeWidget::NoEditTriggers);
+ pResultList->setSelectionBehavior(QTreeWidget::SelectRows);
+ pResultList->setFrameStyle(QFrame::Box | QFrame::Plain);
+ pResultList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ //pResultList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ pResultList->setAttribute(Qt::WA_AcceptTouchEvents);
+ pResultList->verticalScrollBar()->setStyleSheet(SCROLLBAR_STYLE);
+ pResultList->header()->hide();
+ //font.setPointSize(FONT_SIZE_LIST);
+ //pResultList->setFont(font);
+ pResultList->installEventFilter(this);
+ }
+
+ pResultList->setGeometry(QRect( LEFT_OFFSET+searchBtn.width()+SPACER, searchBtn.height()+SPACER,
+ DISPLAY_WIDTH, DISPLAY_HEIGHT));
+ if (RefreshDisplay)
+ {
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+ }
+ pResultList->setVisible(true);
+ pResultList->setFocus();
+ }
+ else
+ {
+ if (pResultList)
+ {
+ pResultList->removeEventFilter(this);
+ pResultList->deleteLater();
+ pResultList = NULL;
+ }
+
+ lineEdit.setFocus();
+
+ if (RefreshDisplay)
+ {
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+ }
+ }
+
+ mutex.unlock();
+}
+
+void MainApp::textChanged(const QString & text)
+{
+ TRACE_INFO("New text is: %s", qPrintable(text));
+
+ /* do not handle text input if info panel is displayed: */
+ if (pInfoPanel) return;
+
+ mutex.lock();
+
+ delete pSearchReply; /* cancel current search */
+ pSearchReply = NULL;
+
+ if (text.length() == 0) /* if empty text -> no search */
+ {
+ DisplayResultList(false);
+ mutex.unlock();
+ return;
+ }
+
+ /* if text is the same as previous search -> no need to search again */
+ if (text == currentSearchedText)
+ {
+ DisplayResultList(true);
+ FillResultList(Businesses, currentIndex);
+ mutex.unlock();
+ return;
+ }
+ this->currentSearchingText = text;
+
+ /* we need to know our current position */
+ std::vector<int32_t> Params;
+ Params.push_back(naviapi::NAVICORE_LONGITUDE);
+ Params.push_back(naviapi::NAVICORE_LATITUDE);
+ naviapi.getPosition(Params);
+
+ mutex.unlock();
+}
+
+void MainApp::textAdded(const QString & text)
+{
+ mutex.lock();
+ lineEdit.setText(lineEdit.text() + text);
+ mutex.unlock();
+}
+
+void MainApp::keyPressed(int key)
+{
+ mutex.lock();
+ if (key == '\b') /* backspace */
+ {
+ int len = lineEdit.text().length();
+ if (len > 0)
+ lineEdit.setText(lineEdit.text().remove(len-1, 1));
+ }
+ mutex.unlock();
+}
+
+void MainApp::itemClicked()
+{
+ mutex.lock();
+ if (isInfoScreen)
+ {
+ DisplayInformation(true, false);
+ }
+ else
+ {
+ SetDestination();
+ DisplayLineEdit(false);
+ }
+ mutex.unlock();
+}
+
+void MainApp::ParseJsonBusinessList(const char* buf, std::vector<Business> & Output)
+{
+ json_object *jobj = json_tokener_parse(buf);
+ if (!jobj)
+ {
+ TRACE_ERROR("json_tokener_parse failed");
+ cerr << "json_tokener_parse failed: " << buf << endl;
+ return;
+ }
+
+ json_object_object_foreach(jobj, key, val)
+ {
+ (void)key;
+ json_object *value;
+
+ if (json_object_get_type(val) == json_type_array)
+ {
+ TRACE_DEBUG_JSON("an array was found");
+
+ if(json_object_object_get_ex(jobj, "businesses", &value))
+ {
+ TRACE_DEBUG_JSON("an business was found");
+
+ int arraylen = json_object_array_length(value);
+
+ for (int i = 0; i < arraylen; i++)
+ {
+ Business NewBusiness;
+
+ json_object* medi_array_obj, *medi_array_obj_elem;
+ medi_array_obj = json_object_array_get_idx(value, i);
+ if (medi_array_obj)
+ {
+ if (json_object_object_get_ex(medi_array_obj, "rating", &medi_array_obj_elem))
+ {
+ NewBusiness.Rating = json_object_get_double(medi_array_obj_elem);
+ TRACE_DEBUG_JSON("got Rating : %f", NewBusiness.Rating);
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "distance", &medi_array_obj_elem))
+ {
+ NewBusiness.Distance = json_object_get_double(medi_array_obj_elem);
+ TRACE_DEBUG_JSON("got Distance : %f", NewBusiness.Distance);
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "review_count", &medi_array_obj_elem))
+ {
+ NewBusiness.ReviewCount = json_object_get_int(medi_array_obj_elem);
+ TRACE_DEBUG_JSON("got ReviewCount : %u", NewBusiness.ReviewCount);
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "name", &medi_array_obj_elem))
+ {
+ NewBusiness.Name = QString(json_object_get_string(medi_array_obj_elem));
+ TRACE_DEBUG_JSON("got Name : %s", qPrintable(NewBusiness.Name));
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "image_url", &medi_array_obj_elem))
+ {
+ NewBusiness.ImageUrl = QString(json_object_get_string(medi_array_obj_elem));
+ TRACE_DEBUG_JSON("got ImageUrl : %s", qPrintable(NewBusiness.ImageUrl));
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "phone", &medi_array_obj_elem))
+ {
+ NewBusiness.Phone = QString(json_object_get_string(medi_array_obj_elem));
+ TRACE_DEBUG_JSON("got Phone : %s", qPrintable(NewBusiness.Phone));
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "coordinates", &medi_array_obj_elem))
+ {
+ json_object *value2;
+
+ TRACE_DEBUG_JSON("coordinates were found");
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "latitude", &value2))
+ {
+ NewBusiness.Latitude = json_object_get_double(value2);
+ TRACE_DEBUG_JSON("got Latitude : %f", NewBusiness.Latitude);
+ }
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "longitude", &value2))
+ {
+ NewBusiness.Longitude = json_object_get_double(value2);
+ TRACE_DEBUG_JSON("got Longitude : %f", NewBusiness.Longitude);
+ }
+ }
+
+ if (json_object_object_get_ex(medi_array_obj, "location", &medi_array_obj_elem))
+ {
+ json_object *value2;
+
+ TRACE_DEBUG_JSON("a location was found");
+
+ /* TODO: how do we deal with address2 and address3 ? */
+ if(json_object_object_get_ex(medi_array_obj_elem, "address1", &value2))
+ {
+ NewBusiness.Address = QString(json_object_get_string(value2));
+ TRACE_DEBUG_JSON("got Address : %s", qPrintable(NewBusiness.Address));
+ }
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "city", &value2))
+ {
+ NewBusiness.City = QString(json_object_get_string(value2));
+ TRACE_DEBUG_JSON("got City : %s", qPrintable(NewBusiness.City));
+ }
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "state", &value2))
+ {
+ NewBusiness.State = QString(json_object_get_string(value2));
+ TRACE_DEBUG_JSON("got State : %s", qPrintable(NewBusiness.State));
+ }
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "zip_code", &value2))
+ {
+ NewBusiness.ZipCode = QString(json_object_get_string(value2));
+ TRACE_DEBUG_JSON("got ZipCode : %s", qPrintable(NewBusiness.ZipCode));
+ }
+
+ if(json_object_object_get_ex(medi_array_obj_elem, "country", &value2))
+ {
+ NewBusiness.Country = QString(json_object_get_string(value2));
+ TRACE_DEBUG_JSON("got Country : %s", qPrintable(NewBusiness.Country));
+ }
+ }
+
+ /* TODO: parse categories */
+
+ /* Add business in our list: */
+ Businesses.push_back(NewBusiness);
+ }
+ }
+ }
+ }
+ }
+
+ json_object_put(jobj);
+}
+
+bool MainApp::eventFilter(QObject *obj, QEvent *ev)
+{
+ bool ret = false;
+
+ mutex.lock();
+
+ if (obj == pResultList)
+ {
+ //TRACE_DEBUG("ev->type() = %d", (int)ev->type());
+
+ if (ev->type() == QEvent::KeyPress)
+ {
+ bool consumed = false;
+ int key = static_cast<QKeyEvent*>(ev)->key();
+ TRACE_DEBUG("key pressed (%d)", key);
+ switch (key) {
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ TRACE_DEBUG("enter or return");
+ if (isInfoScreen)
+ {
+ DisplayInformation(true);
+ }
+ else
+ {
+ SetDestination();
+ DisplayLineEdit(false);
+ }
+ consumed = true;
+ break;
+
+ case Qt::Key_Escape:
+ TRACE_DEBUG("escape");
+ DisplayResultList(false);
+ consumed = true;
+ break;
+
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ TRACE_DEBUG("arrows");
+ break;
+
+ default:
+ TRACE_DEBUG("default");
+ lineEdit.event(ev);
+ break;
+ }
+
+ mutex.unlock();
+ return consumed;
+ }
+ }
+ else if (obj == &lineEdit)
+ {
+ if (pInfoPanel && ev->type() == QEvent::KeyPress)
+ {
+ switch(static_cast<QKeyEvent*>(ev)->key())
+ {
+ case Qt::Key_Escape:
+ TRACE_DEBUG("Escape !");
+ DisplayInformation(false, false);
+ DisplayResultList(true);
+ FillResultList(Businesses, currentIndex);
+ break;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ TRACE_DEBUG("Go !");
+ SetDestination(currentIndex);
+ DisplayLineEdit(false);
+ break;
+ default: break;
+ }
+ }
+ }
+ else
+ {
+ ret = QMainWindow::eventFilter(obj, ev);
+ }
+ mutex.unlock();
+ return ret;
+}
+
+void MainApp::resizeEvent(QResizeEvent* event)
+{
+ QMainWindow::resizeEvent(event);
+ if (isAglNavi)
+ {
+ QTimer::singleShot(AGL_REFRESH_DELAY, Qt::CoarseTimer, this, SLOT(UpdateAglSurfaces()));
+ }
+}
+
+void MainApp::SetDestination(int index)
+{
+ mutex.lock();
+
+ /* if pResultList exists, take the selected index
+ * otherwise, take the index given as parameter */
+ if (pResultList)
+ {
+ QList<QTreeWidgetItem *> SelectedItems = pResultList->selectedItems();
+ if (SelectedItems.size() > 0)
+ {
+ /* select the first selected item : */
+ index = pResultList->indexOfTopLevelItem(*SelectedItems.begin());
+ }
+ }
+
+ TRACE_DEBUG("index is: %d", index);
+
+ /* retrieve the coordinates of this item : */
+ this->destinationLatitude = Businesses[index].Latitude;
+ this->destinationLongitude = Businesses[index].Longitude;
+
+ naviapi.getAllRoutes();
+
+ mutex.unlock();
+}
+
+void MainApp::DisplayInformation(bool display, bool RefreshDisplay)
+{
+ mutex.lock();
+ if (display)
+ {
+ /* pResultList must exist, so that we can retrieve the selected index: */
+ if (!pResultList)
+ {
+ TRACE_ERROR("pResultList is null");
+ mutex.unlock();
+ return;
+ }
+
+ QList<QTreeWidgetItem *> SelectedItems = pResultList->selectedItems();
+ if (SelectedItems.size() <= 0)
+ {
+ TRACE_ERROR("no item is selected");
+ mutex.unlock();
+ return;
+ }
+
+ /* select the first selected item : */
+ currentIndex = pResultList->indexOfTopLevelItem(*SelectedItems.begin());
+
+ /* Resize window: */
+ DisplayResultList(false, false);
+
+ /* Display info for the selected item: */
+ QRect rect( LEFT_OFFSET+searchBtn.width()+SPACER, searchBtn.height()+SPACER,
+ DISPLAY_WIDTH, DISPLAY_HEIGHT);
+ pInfoPanel = new InfoPanel(this, Businesses[currentIndex], rect);
+
+ if (RefreshDisplay)
+ {
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+ }
+
+ connect(pInfoPanel->getGoButton(), SIGNAL(clicked(bool)), this, SLOT(goClicked()));
+ connect(pInfoPanel->getCancelButton(), SIGNAL(clicked(bool)), this, SLOT(cancelClicked()));
+ }
+ else
+ {
+ if (pInfoPanel)
+ {
+ pInfoPanel->getGoButton()->disconnect();
+ pInfoPanel->getCancelButton()->disconnect();
+ delete pInfoPanel;
+ pInfoPanel = NULL;
+ }
+ lineEdit.setFocus();
+
+ if (RefreshDisplay)
+ {
+ this->setGeometry(QRect(this->pos().x(), this->pos().y(), COMPLETE_W_WITH_KB, COMPLETE_H_WITH_KB));
+ }
+ }
+
+ mutex.unlock();
+}
+
+void MainApp::networkReplySearch(QNetworkReply* reply)
+{
+ char buf[BIG_BUFFER_SIZE];
+ int buflen;
+
+ mutex.lock();
+
+ /* memorize the text which gave this result: */
+ currentSearchedText = lineEdit.text();
+
+ if (reply->error() == QNetworkReply::NoError)
+ {
+ // we only handle this callback if it matches the last search request:
+ if (reply != pSearchReply)
+ {
+ TRACE_INFO("this reply is already too late (or about a different network request)");
+ mutex.unlock();
+ return;
+ }
+
+ buflen = reply->read(buf, BIG_BUFFER_SIZE-1);
+ buf[buflen] = '\0';
+
+ if (buflen == 0)
+ {
+ mutex.unlock();
+ return;
+ }
+
+
+
+ currentIndex = 0;
+ Businesses.clear();
+ ParseJsonBusinessList(buf, Businesses);
+ DisplayResultList(true);
+ FillResultList(Businesses);
+ }
+ else
+ {
+ fprintf(stderr,"POI: reply error network please check to poikey and system time (adjusted?)\n");
+ }
+
+ mutex.unlock();
+}
+
+/* pResultList must be allocated at this point ! */
+int MainApp::FillResultList(vector<Business> & list, int focusIndex)
+{
+ int nbElem = 0;
+
+ mutex.lock();
+
+ pResultList->setUpdatesEnabled(false);
+ pResultList->clear();
+
+ /* filling the dropdown menu: */
+ for (vector<Business>::iterator it = list.begin(); it != list.end(); it++)
+ {
+ /* workaround to avoid entries with wrong coordinates returned by Yelp: */
+ if (IsCoordinatesConsistent(*it) == false)
+ {
+ list.erase(it--);
+ continue;
+ }
+
+ QTreeWidgetItem * item = new QTreeWidgetItem(pResultList);
+
+ ClickableLabel *label = new ClickableLabel("<b>"+(*it).Name+
+ "</b><br>"+(*it).Address+", "+(*it).City+", "+(*it).State+
+ " "+(*it).ZipCode+", "+(*it).Country, pResultList);
+ label->setTextFormat(Qt::RichText);
+ font.setPointSize(FONT_SIZE_LIST);
+ label->setFont(font);
+ label->setIndent(MARGINS);
+ label->setAttribute(Qt::WA_AcceptTouchEvents);
+ item->setSizeHint(0, QSize(TEXT_INPUT_WIDTH, RESULT_ITEM_HEIGHT));
+ pResultList->setItemWidget(item, 0, label);
+ connect(label, SIGNAL(clicked()), this, SLOT(itemClicked()));
+
+ //item->setText(0, (*it).Name);
+
+ if (nbElem == focusIndex)
+ {
+ pResultList->setCurrentItem(item);
+ }
+ nbElem++;
+ }
+
+ pResultList->setUpdatesEnabled(true);
+
+ mutex.unlock();
+ return nbElem;
+}
+
+/* Well... some of the POI returned by Yelp have coordinates which are
+ * completely inconsistent with the distance at which the POI is
+ * supposed to be.
+ * https://github.com/Yelp/yelp-fusion/issues/104
+ * Let's skip them for the moment: */
+#define PI 3.14159265
+#define EARTH_RADIUS 6371000
+static inline double toRadians(double a) { return a * PI / 180.0; }
+bool MainApp::IsCoordinatesConsistent(Business & business)
+{
+ double lat1 = toRadians(currentLatitude);
+ double lon1 = toRadians(currentLongitude);
+ double lat2 = toRadians(business.Latitude);
+ double lon2 = toRadians(business.Longitude);
+ double x = (lon2 - lon1) * cos((lat1 + lat2)/2);
+ double y = lat2 - lat1;
+ double DistanceFromCoords = EARTH_RADIUS * sqrt(pow(x, 2) + pow(y, 2));
+
+ /* if calculated distance is not between +/- 10% of the announced
+ * distance -> skip this POI: */
+ if (DistanceFromCoords < business.Distance * 0.9 ||
+ DistanceFromCoords > business.Distance * 1.1)
+ {
+ TRACE_ERROR("Announced distance: %f, calculated distance: %f", business.Distance, DistanceFromCoords);
+ return false;
+ }
+
+ return true;
+}
+/* end of workaround */
+
+bool MainApp::CheckNaviApi(int argc, char *argv[])
+{
+ bool ret = naviapi.connect(argc, argv, this);
+
+ if (ret == true)
+ {
+ naviapi.getAllSessions();
+ }
+
+ return ret;
+}
+
+int MainApp::AuthenticatePOI(const QString & CredentialsFile)
+{
+ char buf[512];
+ QString AppId;
+ QString AppSecret;
+ QString ProxyHostName;
+ QString PortStr;
+ QString User;
+ QString Password;
+ int portnum;
+
+ /* First, read AppId and AppSecret from credentials file: */
+ FILE* filep = fopen(qPrintable(CredentialsFile), "r");
+ if (!filep)
+ {
+ fprintf(stderr,"Failed to open credentials file \"%s\": %m", qPrintable(CredentialsFile));
+ return -1;
+ }
+
+ if (!fgets(buf, 512, filep))
+ {
+ fprintf(stderr,"Failed to read AppId from credentials file \"%s\"", qPrintable(CredentialsFile));
+ fclose(filep);
+ return -1;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ AppId = QString(buf);
+
+ if (!fgets(buf, 512, filep))
+ {
+ fprintf(stderr,"Failed to read AppSecret from credentials file \"%s\"", qPrintable(CredentialsFile));
+ fclose(filep);
+ return -1;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ AppSecret = QString(buf);
+
+ QNetworkProxy proxy;
+
+ //ProxyHostName
+ if (!fgets(buf, 512, filep))
+ {
+ TRACE_INFO("Failed to read ProxyHostName from credentials file \"%s\"", qPrintable(CredentialsFile));
+ }
+ else
+ {
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ ProxyHostName = QString(buf);
+ ProxyHostName.replace(0, 14, tr(""));
+
+ //Port
+ if (!fgets(buf, 512, filep))
+ {
+ TRACE_ERROR("Failed to read Port from credentials file \"%s\"", qPrintable(CredentialsFile));
+ fclose(filep);
+ return -1;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ PortStr = QString(buf);
+ PortStr.replace(0, 5, tr(""));
+ portnum = PortStr.toInt();
+
+ //User
+ if (!fgets(buf, 512, filep))
+ {
+ TRACE_ERROR("Failed to read User from credentials file \"%s\"", qPrintable(CredentialsFile));
+ fclose(filep);
+ return -1;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ User = QString(buf);
+ User.replace(0, 5, tr(""));
+
+ //Password
+ if (!fgets(buf, 512, filep))
+ {
+ TRACE_ERROR("Failed to read Password from credentials file \"%s\"", qPrintable(CredentialsFile));
+ fclose(filep);
+ return -1;
+ }
+ if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n')
+ buf[strlen(buf)-1] = '\0';
+ Password = QString(buf);
+ Password.replace(0, 9, tr(""));
+
+ proxy.setType(QNetworkProxy::HttpProxy);
+ proxy.setHostName(qPrintable(ProxyHostName));
+ proxy.setPort(portnum);
+ proxy.setUser(qPrintable(User));
+ proxy.setPassword(qPrintable(Password));
+ QNetworkProxy::setApplicationProxy(proxy);
+ }
+
+ fclose(filep);
+
+ TRACE_INFO("Found credentials");
+
+ /* Then, send a HTTP request to get the token and wait for answer (synchronously): */
+
+ token = AppSecret;
+ return 0;
+}
+
+int MainApp::StartMonitoringUserInput()
+{
+ connect(&searchBtn, SIGNAL(clicked(bool)), this, SLOT(searchBtnClicked()));
+ connect(&lineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+ connect(&networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkReplySearch(QNetworkReply*)));
+ connect(&keyboard, SIGNAL(keyClicked(const QString &)), this, SLOT(textAdded(const QString &)));
+ connect(&keyboard, SIGNAL(specialKeyClicked(int)), this, SLOT(keyPressed(int)));
+ return 1;
+}
+
+void MainApp::SetWayPoints(uint32_t myRoute)
+{
+ /* set the destination : */
+ naviapi::Waypoint destWp(this->destinationLatitude, this->destinationLongitude);
+ std::vector<naviapi::Waypoint> myWayPoints;
+ myWayPoints.push_back(destWp);
+ naviapi.setWaypoints(navicoreSession, myRoute, true, myWayPoints);
+
+ naviapi.calculateRoute(navicoreSession, myRoute);
+
+ /* reset search: */
+ currentSearchingText = tr("");
+ currentSearchedText = tr("");
+ currentIndex = 0;
+ Businesses.clear();
+}
+
+void MainApp::goClicked()
+{
+ TRACE_DEBUG("Go clicked !");
+ SetDestination(currentIndex);
+ DisplayLineEdit(false);
+}
+
+void MainApp::cancelClicked()
+{
+ TRACE_DEBUG("Cancel clicked !");
+ DisplayInformation(false, false);
+ DisplayResultList(true, false);
+ FillResultList(Businesses, currentIndex);
+}
+
+void MainApp::getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions)
+{
+ mutex.lock();
+
+ if (allSessions.empty())
+ {
+ TRACE_ERROR("Error: could not find an instance of Navicore");
+ mutex.unlock();
+ return;
+ }
+
+ this->navicoreSession = allSessions.begin()->first;
+
+ TRACE_INFO("Current session: %d", this->navicoreSession);
+
+ mutex.unlock();
+
+ emit allSessionsGotSignal();
+}
+
+
+void MainApp::getPosition_reply(std::map< int32_t, naviapi::variant > position)
+{
+ mutex.lock();
+
+ std::map< int32_t, naviapi::variant >::iterator it;
+ for (it = position.begin(); it != position.end(); it++)
+ {
+ if (it->first == naviapi::NAVICORE_LATITUDE)
+ {
+ currentLatitude = it->second._double;
+ }
+ else if (it->first == naviapi::NAVICORE_LONGITUDE)
+ {
+ currentLongitude = it->second._double;
+ }
+ }
+
+ TRACE_INFO("Current position: %f, %f", currentLatitude, currentLongitude);
+
+ mutex.unlock();
+
+ emit positionGotSignal();
+}
+
+void MainApp::getAllRoutes_reply(std::vector< uint32_t > allRoutes)
+{
+ mutex.lock();
+
+ uint32_t routeHandle = 0;
+
+ if (allRoutes.size() != 0)
+ {
+ routeHandle = allRoutes[0];
+ }
+
+ this->currentRouteHandle = routeHandle;
+
+ mutex.unlock();
+
+ emit allRoutesGotSignal();
+}
+
+void MainApp::createRoute_reply(uint32_t routeHandle)
+{
+ mutex.lock();
+
+ this->currentRouteHandle = routeHandle;
+
+ mutex.unlock();
+
+ emit routeCreatedSignal();
+}
+
+void MainApp::allSessionsGot()
+{
+ mutex.lock();
+
+ // nothing to do
+
+ mutex.unlock();
+}
+
+void MainApp::positionGot()
+{
+ mutex.lock();
+
+ /* let's generate a search request : */
+ QString myUrlStr = URL_SEARCH + tr("?") + tr("term=") + currentSearchingText +
+ tr("&latitude=") + QString::number(currentLatitude) +
+ tr("&longitude=") + QString::number(currentLongitude);
+
+ TRACE_DEBUG("URL: %s", qPrintable(myUrlStr));
+
+ QUrl myUrl = QUrl(myUrlStr);
+ QNetworkRequest req(myUrl);
+ req.setRawHeader(QByteArray("Authorization"), (tr("bearer ") + token).toLocal8Bit());
+
+ /* Then, send a HTTP request to get the token and wait for answer (synchronously): */
+
+ pSearchReply = networkManager.get(req);
+
+ mutex.unlock();
+}
+
+void MainApp::allRoutesGot()
+{
+ mutex.lock();
+
+ /* check if a route already exists, if not create it : */
+ if (this->currentRouteHandle == 0)
+ {
+ naviapi.createRoute(navicoreSession);
+ }
+ else
+ {
+ naviapi.pauseSimulation(navicoreSession);
+ naviapi.setSimulationMode(navicoreSession, false);
+ naviapi.cancelRouteCalculation(navicoreSession, this->currentRouteHandle);
+ sleep(1);
+
+ SetWayPoints(this->currentRouteHandle);
+ }
+
+ mutex.unlock();
+}
+
+void MainApp::routeCreated()
+{
+ mutex.lock();
+
+ SetWayPoints(this->currentRouteHandle);
+
+ mutex.unlock();
+}
+
diff --git a/MainApp.h b/MainApp.h
new file mode 100644
index 0000000..7e80c32
--- /dev/null
+++ b/MainApp.h
@@ -0,0 +1,98 @@
+#ifndef __MAINAPP_H__
+#define __MAINAPP_H__
+
+#include <QMainWindow>
+#include <QtWidgets>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QMutex>
+#include <QTreeWidget>
+#include <vector>
+#include "Business.h"
+#include "InfoPanel.h"
+#include "Keyboard.h"
+
+#include <libnavicore.hpp>
+
+class MainApp: public QMainWindow, public naviapi::NavicoreListener
+{
+ Q_OBJECT
+
+ public:
+ explicit MainApp();
+ ~MainApp();
+ bool CheckNaviApi(int argc, char *argv[]);
+ int AuthenticatePOI(const QString & CredentialsFile);
+ int StartMonitoringUserInput();
+ void setInfoScreen(bool val) { isInfoScreen = val; }
+ void setKeyboard(bool val) { isKeyboard = val; }
+
+ private:
+ void ParseJsonBusinessList(const char* buf, std::vector<Business> & Output);
+ bool eventFilter(QObject *obj, QEvent *ev);
+ void resizeEvent(QResizeEvent* event);
+ void SetDestination(int index = 0);
+ bool IsCoordinatesConsistent(Business & business);
+ void DisplayLineEdit(bool display = true);
+ void DisplayResultList(bool display, bool RefreshDisplay = true);
+ void DisplayInformation(bool display, bool RefreshDisplay = true);
+ int FillResultList(std::vector<Business> & list, int focusIndex = 0);
+ void SetWayPoints(uint32_t myRoute);
+
+ naviapi::Navicore naviapi;
+ QNetworkAccessManager networkManager;
+ QPushButton searchBtn;
+ QLineEdit lineEdit;
+ Keyboard keyboard;
+ QMutex mutex; // to protect pointers from concurrent access
+ QString token;
+ QString currentSearchingText;
+ QString currentSearchedText;
+ QNetworkReply *pSearchReply;
+ InfoPanel *pInfoPanel;
+ QTreeWidget *pResultList;
+ double currentLatitude;
+ double currentLongitude;
+ double destinationLatitude;
+ double destinationLongitude;
+ uint32_t navicoreSession;
+ uint32_t currentRouteHandle;
+ int currentIndex;
+ int fontId;
+ bool isInfoScreen;
+ bool isInputDisplayed;
+ bool isKeyboard;
+ bool isAglNavi;
+ std::vector<Business> Businesses;
+ QFont font;
+
+ public:
+ void getAllSessions_reply(const std::map< uint32_t, std::string >& allSessions);
+ void getPosition_reply(std::map< int32_t, naviapi::variant > position);
+ void getAllRoutes_reply(std::vector< uint32_t > allRoutes);
+ void createRoute_reply(uint32_t routeHandle);
+
+ private slots:
+ void searchBtnClicked();
+ void textChanged(const QString & text);
+ void textAdded(const QString & text);
+ void keyPressed(int key);
+ void itemClicked();
+ void networkReplySearch(QNetworkReply* reply);
+ void UpdateAglSurfaces();
+ void goClicked();
+ void cancelClicked();
+
+ void allSessionsGot();
+ void positionGot();
+ void allRoutesGot();
+ void routeCreated();
+
+ signals:
+ void allSessionsGotSignal();
+ void positionGotSignal();
+ void allRoutesGotSignal();
+ void routeCreatedSignal();
+};
+
+#endif // __MAINAPP_H__
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6d941ed
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
+# AGL Reference POI application
+### This application provides the function of destination search to AGL. It uses the API provided by AGL Reference Navigation. This application uses yelp WebAPI.
+
+### The settings required to run POI application are as follows:
+
+#### 1. Please connect to the Internet. (Because POI-App uses yelp's web-API)
+
+#### 2. Please register yelp
+
+##### https://www.yelp.co.jp/developers?country=US
+##### Please do developer registration and obtain App ID and App Secret key.
+##### And please write it in /etc/poikey
+
+##### The contents are as follows (2 lines):
+###### your app id
+###### your sercret key
+
+### Restrictionsļ¼š
+#### POI App uses Navigation API. Push Navigation button before POI app.
diff --git a/config.xml.in b/config.xml.in
new file mode 100644
index 0000000..b8cfccd
--- /dev/null
+++ b/config.xml.in
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" id="poi" version="0.1">
+ <name>POI</name>
+ <icon src="icon.png"/>
+ <content src="poi" type="application/vnd.agl.native"/>
+ <description>POI App</description>
+ <author>AISIN AW</author>
+ <feature name="urn:AGL:widget:required-api">
+ <param name="naviapi" value="ws" />
+ <param name="windowmanager" value="ws" />
+ <param name="homescreen" value="ws" />
+ </feature>
+ <feature name="urn:AGL:widget:required-permission">
+ <param name="urn:AGL:permission::public:no-htdocs" value="required" />
+ <param name="http://tizen.org/privilege/internal/dbus" value="required" />
+ </feature>
+ <license>GPL</license>
+</widget>
diff --git a/fonts/DroidSansJapanese.ttf b/fonts/DroidSansJapanese.ttf
new file mode 100644
index 0000000..412fa3d
--- /dev/null
+++ b/fonts/DroidSansJapanese.ttf
Binary files differ
diff --git a/images/0.png b/images/0.png
new file mode 100644
index 0000000..c340687
--- /dev/null
+++ b/images/0.png
Binary files differ
diff --git a/images/1.png b/images/1.png
new file mode 100644
index 0000000..8cacec9
--- /dev/null
+++ b/images/1.png
Binary files differ
diff --git a/images/2.png b/images/2.png
new file mode 100644
index 0000000..03e9728
--- /dev/null
+++ b/images/2.png
Binary files differ
diff --git a/images/3.png b/images/3.png
new file mode 100644
index 0000000..e503038
--- /dev/null
+++ b/images/3.png
Binary files differ
diff --git a/images/4.png b/images/4.png
new file mode 100644
index 0000000..b6e7ff4
--- /dev/null
+++ b/images/4.png
Binary files differ
diff --git a/images/5.png b/images/5.png
new file mode 100644
index 0000000..79da9ad
--- /dev/null
+++ b/images/5.png
Binary files differ
diff --git a/images/6.png b/images/6.png
new file mode 100644
index 0000000..9fe0c44
--- /dev/null
+++ b/images/6.png
Binary files differ
diff --git a/images/7.png b/images/7.png
new file mode 100644
index 0000000..67b47e2
--- /dev/null
+++ b/images/7.png
Binary files differ
diff --git a/images/8.png b/images/8.png
new file mode 100644
index 0000000..eedc4f4
--- /dev/null
+++ b/images/8.png
Binary files differ
diff --git a/images/9.png b/images/9.png
new file mode 100644
index 0000000..9974bf4
--- /dev/null
+++ b/images/9.png
Binary files differ
diff --git a/images/A.png b/images/A.png
new file mode 100644
index 0000000..f7bc82c
--- /dev/null
+++ b/images/A.png
Binary files differ
diff --git a/images/AGL_POI_Background.png b/images/AGL_POI_Background.png
new file mode 100644
index 0000000..2b026ed
--- /dev/null
+++ b/images/AGL_POI_Background.png
Binary files differ
diff --git a/images/B.png b/images/B.png
new file mode 100644
index 0000000..7331ce1
--- /dev/null
+++ b/images/B.png
Binary files differ
diff --git a/images/C.png b/images/C.png
new file mode 100644
index 0000000..b7a2e32
--- /dev/null
+++ b/images/C.png
Binary files differ
diff --git a/images/D.png b/images/D.png
new file mode 100644
index 0000000..650aa05
--- /dev/null
+++ b/images/D.png
Binary files differ
diff --git a/images/E.png b/images/E.png
new file mode 100644
index 0000000..d306c44
--- /dev/null
+++ b/images/E.png
Binary files differ
diff --git a/images/F.png b/images/F.png
new file mode 100644
index 0000000..173296f
--- /dev/null
+++ b/images/F.png
Binary files differ
diff --git a/images/G.png b/images/G.png
new file mode 100644
index 0000000..53755ff
--- /dev/null
+++ b/images/G.png
Binary files differ
diff --git a/images/H.png b/images/H.png
new file mode 100644
index 0000000..569933c
--- /dev/null
+++ b/images/H.png
Binary files differ
diff --git a/images/I.png b/images/I.png
new file mode 100644
index 0000000..82d4507
--- /dev/null
+++ b/images/I.png
Binary files differ
diff --git a/images/J.png b/images/J.png
new file mode 100644
index 0000000..b4e600e
--- /dev/null
+++ b/images/J.png
Binary files differ
diff --git a/images/K.png b/images/K.png
new file mode 100644
index 0000000..9084f9e
--- /dev/null
+++ b/images/K.png
Binary files differ
diff --git a/images/L.png b/images/L.png
new file mode 100644
index 0000000..cbe3e7d
--- /dev/null
+++ b/images/L.png
Binary files differ
diff --git a/images/M.png b/images/M.png
new file mode 100644
index 0000000..e68c147
--- /dev/null
+++ b/images/M.png
Binary files differ
diff --git a/images/N.png b/images/N.png
new file mode 100644
index 0000000..f27510a
--- /dev/null
+++ b/images/N.png
Binary files differ
diff --git a/images/O.png b/images/O.png
new file mode 100644
index 0000000..50d45bc
--- /dev/null
+++ b/images/O.png
Binary files differ
diff --git a/images/P.png b/images/P.png
new file mode 100644
index 0000000..cb4bf58
--- /dev/null
+++ b/images/P.png
Binary files differ
diff --git a/images/Q.png b/images/Q.png
new file mode 100644
index 0000000..6d18438
--- /dev/null
+++ b/images/Q.png
Binary files differ
diff --git a/images/R.png b/images/R.png
new file mode 100644
index 0000000..9c51b6e
--- /dev/null
+++ b/images/R.png
Binary files differ
diff --git a/images/S.png b/images/S.png
new file mode 100644
index 0000000..a77923d
--- /dev/null
+++ b/images/S.png
Binary files differ
diff --git a/images/T.png b/images/T.png
new file mode 100644
index 0000000..f8baa35
--- /dev/null
+++ b/images/T.png
Binary files differ
diff --git a/images/U.png b/images/U.png
new file mode 100644
index 0000000..e8d89cc
--- /dev/null
+++ b/images/U.png
Binary files differ
diff --git a/images/V.png b/images/V.png
new file mode 100644
index 0000000..4453981
--- /dev/null
+++ b/images/V.png
Binary files differ
diff --git a/images/W.png b/images/W.png
new file mode 100644
index 0000000..a71a30b
--- /dev/null
+++ b/images/W.png
Binary files differ
diff --git a/images/X.png b/images/X.png
new file mode 100644
index 0000000..4c301eb
--- /dev/null
+++ b/images/X.png
Binary files differ
diff --git a/images/Y.png b/images/Y.png
new file mode 100644
index 0000000..af6333d
--- /dev/null
+++ b/images/Y.png
Binary files differ
diff --git a/images/Z.png b/images/Z.png
new file mode 100644
index 0000000..dd82fb9
--- /dev/null
+++ b/images/Z.png
Binary files differ
diff --git a/images/apostrophe.png b/images/apostrophe.png
new file mode 100644
index 0000000..65cb125
--- /dev/null
+++ b/images/apostrophe.png
Binary files differ
diff --git a/images/back.png b/images/back.png
new file mode 100644
index 0000000..e505e74
--- /dev/null
+++ b/images/back.png
Binary files differ
diff --git a/images/background.png b/images/background.png
new file mode 100644
index 0000000..435d5a8
--- /dev/null
+++ b/images/background.png
Binary files differ
diff --git a/images/et.png b/images/et.png
new file mode 100644
index 0000000..0b548ef
--- /dev/null
+++ b/images/et.png
Binary files differ
diff --git a/images/exclam.png b/images/exclam.png
new file mode 100644
index 0000000..c9e265f
--- /dev/null
+++ b/images/exclam.png
Binary files differ
diff --git a/images/loupe-90.png b/images/loupe-90.png
new file mode 100644
index 0000000..a2fb8e8
--- /dev/null
+++ b/images/loupe-90.png
Binary files differ
diff --git a/images/minus.png b/images/minus.png
new file mode 100644
index 0000000..ccce0c7
--- /dev/null
+++ b/images/minus.png
Binary files differ
diff --git a/images/slash.png b/images/slash.png
new file mode 100644
index 0000000..02e0d42
--- /dev/null
+++ b/images/slash.png
Binary files differ
diff --git a/images/space.png b/images/space.png
new file mode 100644
index 0000000..10871ef
--- /dev/null
+++ b/images/space.png
Binary files differ
diff --git a/images/stars_map_www.png b/images/stars_map_www.png
new file mode 100644
index 0000000..0b033ac
--- /dev/null
+++ b/images/stars_map_www.png
Binary files differ
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..a43e37b
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,88 @@
+#include <QApplication>
+#include <iostream>
+#include "MainApp.h"
+#include <getopt.h>
+
+#include <libhomescreen.hpp>
+#include <qlibwindowmanager.h>
+
+
+#define DEFAULT_CREDENTIALS_FILE "/etc/poikey"
+
+using namespace std;
+
+QLibWindowmanager* qwm;
+LibHomeScreen* hs;
+QString graphic_role;
+MainApp *mainapp;
+
+void SyncDrawHandler(json_object *object)
+{
+ qwm->endDraw(graphic_role);
+}
+
+void TapShortcutHandler(json_object *object)
+{
+ qwm->activateWindow(graphic_role);
+}
+
+int main(int argc, char *argv[], char *env[])
+{
+ int opt;
+ QApplication a(argc, argv);
+ QString credentialsFile(DEFAULT_CREDENTIALS_FILE);
+ qwm = new QLibWindowmanager();
+ hs = new LibHomeScreen();
+ graphic_role = QString("poi");
+
+ QString pt = QString(argv[1]);
+ int port = pt.toInt();
+ QString secret = QString(argv[2]);
+ std::string token = secret.toStdString();
+
+ if (qwm->init(port, secret) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ if (qwm->requestSurface(graphic_role) != 0) {
+ cerr << "Error: wm check failed" << endl;
+ exit(EXIT_FAILURE);
+ }
+
+ qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, SyncDrawHandler);
+
+ mainapp = new MainApp();
+
+ hs->init(port, token.c_str());
+
+ hs->set_event_handler(LibHomeScreen::Event_TapShortcut, TapShortcutHandler);
+
+ //force setting
+ mainapp->setInfoScreen(true);
+ mainapp->setKeyboard(true);
+
+ /* check naviapi */
+ if (mainapp->CheckNaviApi(argc, argv) == false)
+ {
+ cerr << "Error: naviapi check failed" << endl;
+ return -1;
+ }
+
+ /* then, authenticate connexion to POI service: */
+ if (mainapp->AuthenticatePOI(credentialsFile) < 0)
+ {
+ cerr << "Error: POI server authentication failed" << endl;
+ return -1;
+ }
+
+ cerr << "authentication succes !" << endl;
+
+ /* now, let's start monitor user inut (register callbacks): */
+ if (mainapp->StartMonitoringUserInput() < 0)
+ return -1;
+
+ qwm->activateWindow(graphic_role);
+
+ /* main loop: */
+ return a.exec();
+}
diff --git a/traces.h b/traces.h
new file mode 100644
index 0000000..6f2cf3a
--- /dev/null
+++ b/traces.h
@@ -0,0 +1,36 @@
+#ifndef __TRACE_H__
+#define __TRACE_H__
+
+#include <stdio.h>
+
+#define BLACK "\033[30m"
+#define RED "\033[31m"
+#define GREEN "\033[32m"
+#define YELLOW "\033[33m"
+#define BLUE "\033[34m"
+#define PURPLE "\033[35m"
+#define DGREEN "\033[6m"
+#define WHITE "\033[7m"
+#define CYAN "\x1b[36m"
+#define NONE "\033[0m"
+
+#ifdef NDEBUG
+
+#define TRACE_DEBUG_JSON(fmt, args...)
+#define TRACE_DEBUG(fmt, args...)
+#define TRACE_INFO(fmt, args...)
+#define TRACE_WARN(fmt, args...)
+#define TRACE_ERROR(fmt, args...)
+
+#else
+
+#define TRACE_DEBUG(fmt, args...) do { fprintf(stderr, "[%s:%d] " CYAN "DEBUG" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0)
+#define TRACE_INFO(fmt, args...) do { fprintf(stderr, "[%s:%d] " GREEN "INFO" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0)
+#define TRACE_WARN(fmt, args...) do { fprintf(stderr, "[%s:%d] " YELLOW "WARN" NONE": " fmt "\n", __func__, __LINE__, ##args); } while(0)
+#define TRACE_ERROR(fmt, args...) do { fprintf(stderr, "[%s:%d] " RED "ERROR" NONE ": " fmt "\n", __func__, __LINE__, ##args); } while(0)
+
+#define TRACE_DEBUG_JSON(fmt, args...)
+
+#endif
+
+#endif // __TRACE_H__
diff --git a/yelp-client.qrc b/yelp-client.qrc
new file mode 100644
index 0000000..b25ff70
--- /dev/null
+++ b/yelp-client.qrc
@@ -0,0 +1,52 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/stars_map_www.png</file>
+ <file>images/loupe-90.png</file>
+ <file>images/0.png</file>
+ <file>images/1.png</file>
+ <file>images/2.png</file>
+ <file>images/3.png</file>
+ <file>images/4.png</file>
+ <file>images/5.png</file>
+ <file>images/6.png</file>
+ <file>images/7.png</file>
+ <file>images/8.png</file>
+ <file>images/9.png</file>
+ <file>images/A.png</file>
+ <file>images/B.png</file>
+ <file>images/C.png</file>
+ <file>images/D.png</file>
+ <file>images/E.png</file>
+ <file>images/F.png</file>
+ <file>images/G.png</file>
+ <file>images/H.png</file>
+ <file>images/I.png</file>
+ <file>images/J.png</file>
+ <file>images/K.png</file>
+ <file>images/L.png</file>
+ <file>images/M.png</file>
+ <file>images/N.png</file>
+ <file>images/O.png</file>
+ <file>images/P.png</file>
+ <file>images/Q.png</file>
+ <file>images/R.png</file>
+ <file>images/S.png</file>
+ <file>images/T.png</file>
+ <file>images/U.png</file>
+ <file>images/V.png</file>
+ <file>images/W.png</file>
+ <file>images/X.png</file>
+ <file>images/Y.png</file>
+ <file>images/Z.png</file>
+ <file>images/apostrophe.png</file>
+ <file>images/back.png</file>
+ <file>images/et.png</file>
+ <file>images/exclam.png</file>
+ <file>images/minus.png</file>
+ <file>images/slash.png</file>
+ <file>images/space.png</file>
+ <file>images/background.png</file>
+ <file>fonts/DroidSansJapanese.ttf</file>
+ <file>images/AGL_POI_Background.png</file>
+ </qresource>
+</RCC>