UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. Craig
    3. Best
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 42
    • Groups 0

    Posts

    Recent Best Controversial
    • C++ and SDL with Clickable. A little help please.

      I've written a program in C++ and SDL2 and would like to publish it to the Ubuntu Touch open store. I have installed clickable and I've gotten the "Hello World" screen on my tablet. I added the SDL dependencies to the clickable.json file.

      Could someone be kind enough to tell me how/where to put my C++ files and what settings to make in the CMakeLists.txt file? I have four .cpp and four .h files. I wont need to use Qml.

      When I run clickable it almost compiles, but it appears to not be able to link to the SDL libraries.

      Thanks!

      posted in App Development link c++ app sdl2 sdl
      CraigC
      Craig
    • RE: C++ and SDL with Clickable. A little help please.

      Thanks to all for your input and suggestions so far. I ran searches online for "CMakeLists.txt SDL tutorial", and read many tutorials. This is what I have so far that seems to almost work:

      1. sudo apt install libsdl2-dev
        clickable create
        I chose option [7] main-cpp - C++/QML App (built using CMake with a main.cpp)

      2. I replaced the main.cpp file in my project directory with a very small 512 byte SDL test program. It just produces a blank screen for 5 seconds and then quits. I compiled and tested it with the Code::Blocks IDE and it works fine there.

      3. I added these lines to my CMakeLists.txt file in my project directory and finally I got it to link up with the SDL library:
        add_executable(${PROJECT_NAME} main.cpp)
        find_package(SDL2 REQUIRED)
        include_directories(${SDL2_INCLUDE_DIRS})
        set(SDL2_LIBRARIES "-lSDL2")
        target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES})

      4. I run clickable from my project directory and it compiles the program just fine and sends it to my Ubuntu Touch tablet where I see the logo.svg flash on the screen for only 1 second. Finally, no error messages not being able to link up with SDL. However, I don't get the expected blank screen for 5 seconds. The logo.svg shows on the screen along with my project name for only 1 second, but it seems to quit before running the program which should show a blank screen for 5 seconds. On my tablet I now have the logo.svg icon displayed as one of my apps. When I click on it the icon shows along with the app name for about 1 second and then closes.

      Does anyone know what I need to tweak to get SDL to run on UT through clickable? Then, like Wendigo said, we will have a working SDL recipe for UT/clickable for other app developers.

      posted in App Development
      CraigC
      Craig
    • RE: SOLVED: How do I get my app to launch the web browser?

      @dobey You are right. I was testing QDesktopServices::openUrl when you posted this.

      My C++/SDL app launches the morph web browser. Here's how to make a C++/SDL app launch the web browser in Ubuntu Touch:

      Step 1:
      You need to add these to your CMakeLists.txt:
      (You may have more than one CMakeList.txt file and some of the code lines below will go in different CMakeList.txt files.)

      (Add these lines below after "project(...)" and "cmake_minimum_required(..)")

      find_package(Qt5Core)
      find_package(Qt5Qml)
      find_package(Qt5Quick)
      

      (Add this line below after "execute_process(... OUTPUT_VARIABLE ARCH_TRIPLET ...)" )

      set(QT_IMPORTS_DIR "lib/${ARCH_TRIPLET}")
      

      (Add this line below after "add_executable(... main.cpp ...)" )

      qt5_use_modules(YOURPROJECTNAMEHERE Gui Qml Quick QuickControls2)
      

      Replace YOURPROJECTNAMEHERE with your project name.

      Step 2:
      Put these headers near the top of main.h/main.cpp:

      #include <QGuiApplication>
      #include <QDesktopServices>
      #include <QUrl>
      

      Put this at the top of main():

      QGuiApplication *app = new QGuiApplication(argc, (char**)argv);
      

      Near the end of main(), replace "return 0;" with this:

      return app->exec();
      

      Step 3:
      And now for the magic... Somewhere in your C++ code, make your link:

      if ( event.type == SDL_FINGERDOWN )
      {
          QDesktopServices::openUrl(QUrl("https://forums.ubports.com"));
      }
      

      If you have any comments, suggestions or ways to improve this code, let me know. Thank you all for your help.

      posted in App Development
      CraigC
      Craig
    • RE: SOLVED: How do I get my app to launch the web browser?

      So, just to recap, here's how to make a C++ app launch the web browser in Ubuntu Touch:

      Step 1:
      You need to add/change these in your CMakeLists.txt:

      find_package(Qt5 COMPONENTS Core Gui)
      target_link_libraries(YOURPROJECTNAMEHERE ... Qt5::Core Qt5::Gui)
      

      Step 2:
      Put these headers near the top of main.h/main.cpp:

      #include <QGuiApplication>
      #include <QDesktopServices>
      #include <QUrl>
      

      Put this at the top of main():

      QGuiApplication *app = new QGuiApplication(argc, (char**)argv);
      

      Near the end of main(), replace "return 0;" with this:

      return app->exec();
      

      Step 3:
      Somewhere in your C++ code, when the app user clicks on your button, call this:

      QDesktopServices::openUrl(QUrl("https://forums.ubports.com"));
      
      posted in App Development
      CraigC
      Craig
    • Automatically Delete Unauthorized Cookies from Morph upon Close

      I wrote a bash script that automatically deletes all cookies in the Morph browser with an sqlite3 command (except the domains you've told it to keep) each time you close the browser.

      The companion cookies-delete.conf file will auto start the script for you each time you boot UT.

      Originally developed on Ubuntu Touch 16.04 Xenial OTA-25 stable with Pixel 3a hardware. You can download them here:

      https://www.dropbox.com/s/d4k5hf1pfj8igys/cookies-delete.sh
      https://www.dropbox.com/s/1byqwvbdbkps0n9/cookies-delete.conf

      The instructions are near at the top of the script. Code improvement suggestions? Let me know. If anyone gets inspired to make a full UT App with it, please do!

      posted in App Development
      CraigC
      Craig
    • RE: How to install PIA VPN on UT (Working!)

      @daryl I'm not 100% sure if PIA's VPN script will work with that Aquarius hardware. I have installed and ran it on three: Nexus 4, Nexus 5 and Pixel3a. Here's the current incarnation of the script as I use it and instructions for how to install it.

      https://www.dropbox.com/s/7g0xfiam53ytf61/pia-nm-install.txt
      https://www.dropbox.com/s/dd4oj7dd2o05vv9/pia-nm.sh

      Please post your results and let the community know if it works with your hardware, too.

      posted in General
      CraigC
      Craig
    • RE: C++ and SDL with Clickable. A little help please.

      Here's the source of the main.cpp:

      #include <SDL.h>

      int main(int argc, char *argv[])
      {
      SDL_Init(SDL_INIT_VIDEO);

      SDL_Window *window = SDL_CreateWindow( "SDL2Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, 0 );

      SDL_SetWindowFullscreen( window, SDL_TRUE );

      SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
      SDL_SetRenderDrawColor(renderer, 255, 0, 0, SDL_ALPHA_OPAQUE);
      SDL_RenderClear(renderer);
      SDL_RenderPresent(renderer);

      SDL_Delay(5000);

      SDL_DestroyWindow(window);
      SDL_Quit();

      return 0;
      }

      posted in App Development
      CraigC
      Craig
    • RE: How to install PIA VPN on UT (Working!)

      @wgarcia About six years ago I installed Private Internet Access's OpenVPN script on my Ubuntu Touch device. Over time I noticed certain VPN connections stopped working. PIA had retired or changed some IP addresses for certain VPN locations.

      I ran a search today and found about 4 pages on PIA's website regarding OpenVPN. Some of the pages have links to support files that no longer work.
      https://helpdesk.privateinternetaccess.com/kb/openvpn

      This page appears to be the most recent:
      https://helpdesk.privateinternetaccess.com/kb/articles/linux-setting-up-manual-openvpn-connection-through-the-terminal

      The old PIA OpenVPN script from about six years ago had a certain URL in it that allowed it to fetch the latest VPN server IP addresses from the PIA website. A few years ago, PIA began retiring those old servers and released a new Wireguard script. Inside that script, the URL where the new server IP addresses are to be fetched is now different.

      This may help explain why some PIA VPN server locations don't work.

      posted in General
      CraigC
      Craig
    • RE: C++ and SDL with Clickable. A little help please.

      I got my C++/SDL2 program working via clickable on Ubuntu Touch. I got frustrated and put the project aside for several months, but I got back at it a few days ago. I used this demo to start with:
      https://gitlab.com/zub2/SDLDemo
      I'm not using the SDL2pp wrapper, just the regular SDL2 libraries. I have images, fonts, touchscreen and audio mixer working good.

      The only problem I need to fix before I can publish it is my app wont seem to run completely full screen. How do I get rid of the Top Bar? The one with the clock and battery icon, etc. It's covering the top of my app window.

      posted in App Development
      CraigC
      Craig
    • RE: apparmor picture_files_read

      @AppLee Thank you. I read those pages before and I read them again. I added hooks in my manifest.json and a contenthub.json file. I see my app listed when I open Gallery, select a photo and click the share icon.

      I'm programming my app in C++ and SDL2. So my question is: How can I get my app to open the content hub so a user can select a photo from their Gallery?

      posted in App Development
      CraigC
      Craig
    • SOLVED: How do I get my app to launch the web browser?

      I'm making apps with C++ and SDL, I've read the UBports documentation but I can't figure out how to launch the web browser from my app. On a desktop system, I use the C++ system() command and can open other programs. Example:

      if ( event.type == SDL_FINGERDOWN ) {
      system("sensible-browser https://forums.ubports.com/");
      }

      It's not working on Ubuntu Touch. I've tried this:
      system("morph-browser --desktop_file_hint=/usr/share/applications/morph-browser.desktop https://forums.ubports.com/");

      Can someone point me to some documentation on how it's done with C++?

      Thank you.

      posted in App Development
      CraigC
      Craig
    • RE: Automatically Delete Unauthorized Cookies from Morph upon Close

      @domubpkm I don't use the private browsing feature in Morph. But what I understand is it will delete not only all cookies, but your history as well. If you run Morph in regular mode with this script, you can keep the cookies with sites you trust and all your history, too.

      Using this script would be similar to the Manage Exceptions feature in the Firefox Security and Privacy settings. There you can “Allow” certain websites to leave cookies while you have ticked a checkbox “Delete cookies when Firefox is closed”.

      So, you can login quicker with sites you trust and also quickly find that page you visited a couple days ago in your history.

      posted in App Development
      CraigC
      Craig