Skip to content

Commit

Permalink
Merge 296a246 into f69b3a9
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster committed Apr 28, 2022
2 parents f69b3a9 + 296a246 commit cfe24d3
Show file tree
Hide file tree
Showing 9 changed files with 321 additions and 34 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,58 @@ jobs:
allowUpdates: true
token: ${{ secrets.GH_TOKEN }}

tinyphone_linux_job:
name: Build Tinyphone Linux
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '1'
submodules: 'recursive'

- name: Install Dependencies
shell: bash
run : |
sudo apt-get install -y build-essential cmake libcurl4-openssl-dev pkg-config libboost1.71-all-dev libasound-dev
- name: Compile Libraries
run : |
pushd lib/cryptopp/
make
sudo make install
popd
pushd lib/json
mkdir build
cd build
cmake ..
make
sudo make install
popd
pushd lib/portaudio
git checkout master #some issue with rb-hotplug-wmme branch
./configure
make
sudo make install
popd
pushd lib/pjproject
./configure
make realclean
make dep
make
sudo make install
popd
- name: Build Project
run : |
pushd tinyphone-linux
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
71 changes: 71 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "bento/ubuntu-20.04"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/vagrant"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "2048"
end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y build-essential cmake libcurl4-openssl-dev pkg-config libboost1.71-all-dev qtbase5-dev
SHELL
end
106 changes: 106 additions & 0 deletions tinyphone-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(tinyphone LANGUAGES C CXX)
set(PACKAGE "${PROJECT_NAME}")
set(PACKAGE_NAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "1.0.0")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "hi@kinsh.uk")
set(PACKAGE_TARNAME "${PROJECT_NAME}")
set(PACKAGE_URL "")
set(VERSION "${PACKAGE_VERSION}")

# CMake Policies

# CMP0074: find_package() uses <PackageName>_ROOT variables.
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()

# CMP0075 Include file check macros honor CMAKE_REQUIRED_LIBRARIES
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()


# set(CMAKE_C_COMPILER "/usr/bin/gcc")
# set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_WARN_DEPRECATED FALSE)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")

if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
# include(CMakePushCheckState)
# include(GNUInstallDirs)
# include(CMakeDependentOption)


set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
# set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.71 REQUIRED COMPONENTS date_time filesystem system)
include_directories(${Boost_INCLUDE_DIRS})

find_package(PkgConfig REQUIRED)
pkg_check_modules(PJSIP libpjproject REQUIRED)
include_directories(${PJSIP_INCLUDE_DIRS})

check_symbol_exists("res_ndestroy" "resolv.h" HAVE_RES_NDESTROY)
set(CMAKE_REQUIRED_LIBRARIES resolv)

find_package(Threads)


file(GLOB SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/*.cpp
)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/guicon.cpp)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/splash.cpp)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/guicon.h)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/splash.h)
list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone/winapp.cpp)

add_executable(tinyphone ${SOURCES} console.cpp)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pjproject/pjlib/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pjproject/pjlib-util/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pjproject/pjmedia/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pjproject/pjnath/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pjproject/pjsip/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/json/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/statsd-cpp/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/crow/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/portaudio/include)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib)
target_include_directories(tinyphone PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tinyphone)
link_directories(tinyphone ${Boost_LIBRARY_DIRS})
target_link_libraries(tinyphone ${Boost_LIBRARIES})
target_link_libraries(tinyphone ${PJSIP_LIBRARIES})

find_package(nlohmann_json 3.10.5 REQUIRED)
target_link_libraries(tinyphone nlohmann_json::nlohmann_json)

add_library(libcryptopp_static STATIC IMPORTED)
set_target_properties(libcryptopp_static PROPERTIES IMPORTED_LOCATION /usr/local/lib/libcryptopp.a)
set_target_properties(libcryptopp_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /usr/local/include)
target_link_libraries(tinyphone libcryptopp_static)
target_link_libraries(tinyphone "cryptopp")

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../lib/statsd-cpp ${CMAKE_CURRENT_SOURCE_DIR}/../lib/statsd-cpp/build)
target_link_libraries(tinyphone statsd_static)

pkg_check_modules(CURL libcurl REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
target_link_libraries(tinyphone ${CURL_LIBRARIES})


37 changes: 37 additions & 0 deletions tinyphone-linux/console.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// console.cpp : Defines the entry point for the console application.

#include <stdio.h>
#include <ctime>
#include <algorithm>
#include <vector>
#include <iostream>

#include "server.h"
#include "utils.h"
#include "net.h"
#include "consts.h"
#include "config.h"
#include "log.h"
#include "app.hpp"
#include "tpendpoint.h"

using namespace std;
using namespace pj;
using namespace tp;


void Start(){
tp::StartApp();
exit(0);
}

void Stop(){
tp::StopApp();
}

int main(int argc, char *argv[])
{
std::cout << "Hello Tinyphone!\n";
Start();
return 0;
}
31 changes: 0 additions & 31 deletions tinyphone-osx/src/osxapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
#include <stdio.h>
#include <ctime>
#include <algorithm>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <resolv.h>
#include <dns.h>
#include <vector>

#include <boost/foreach.hpp>

#include "server.h"
Expand All @@ -31,32 +26,6 @@ using namespace std;
using namespace pj;
using namespace tp;

namespace tp {

std::vector<std::string> GetLocalDNSServers() {
std::vector <std::string> dnsServers;
// Get native iOS System Resolvers
res_ninit(&_res);
res_state res = &_res;

for (int i = 0; i < res->nscount; i++) {
sa_family_t family = res->nsaddr_list[i].sin_family;
int port = ntohs(res->nsaddr_list[i].sin_port);
if (family == AF_INET) { // IPV4 address
char str[INET_ADDRSTRLEN]; // String representation of address
inet_ntop(AF_INET, & (res->nsaddr_list[i].sin_addr.s_addr), str, INET_ADDRSTRLEN);
dnsServers.push_back(str);

} else if (family == AF_INET6) { // IPV6 address
char str[INET6_ADDRSTRLEN]; // String representation of address
inet_ntop(AF_INET6, &(res->nsaddr_list [i].sin_addr.s_addr), str, INET6_ADDRSTRLEN);
}
}
res_ndestroy(res);
return dnsServers;
}
}

void Start(){
tp::StartApp();
exit(0);
Expand Down
39 changes: 39 additions & 0 deletions tinyphone/baseapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
#include <boost/foreach.hpp>
#include <math.h>

#ifndef _WIN32
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <resolv.h>
#endif

using namespace std;
using namespace pj;

Expand All @@ -30,6 +36,37 @@ namespace tp {
TinyPhoneHttpServer* tpHttpServer;
tp::Endpoint ep;

#ifndef _WIN32

std::vector<std::string> GetLocalDNSServers() {
std::vector <std::string> dnsServers;
// Get native iOS System Resolvers
res_ninit(&_res);
res_state res = &_res;

for (int i = 0; i < res->nscount; i++) {
sa_family_t family = res->nsaddr_list[i].sin_family;
int port = ntohs(res->nsaddr_list[i].sin_port);
if (family == AF_INET) { // IPV4 address
char str[INET_ADDRSTRLEN]; // String representation of address
inet_ntop(AF_INET, & (res->nsaddr_list[i].sin_addr.s_addr), str, INET_ADDRSTRLEN);
dnsServers.push_back(str);

} else if (family == AF_INET6) { // IPV6 address
char str[INET6_ADDRSTRLEN]; // String representation of address
inet_ntop(AF_INET6, &(res->nsaddr_list [i].sin_addr.s_addr), str, INET6_ADDRSTRLEN);
}
}
#ifndef HAVE_RES_NDESTROY
res_nclose(res);
#else
res_ndestroy(res);
#endif
return dnsServers;
}

#endif

void InitPJSUAEndpoint(std::string logfile) {
/* Create endpoint instance! */
try {
Expand Down Expand Up @@ -155,5 +192,7 @@ namespace tp {
TinyPhone* GetPhone(){
return tp::tpHttpServer->tinyPhone;
}



}
2 changes: 1 addition & 1 deletion tinyphone/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace tp {
std::cout << "Config Load From Primary Failed : Response Code " << remoteConfig.code << ", Content-Type: " << contentType << std::endl;
std::string productVersion;
#ifdef _DEBUG
productVersion = "HEAD";
productVersion = "master";
#else
GetProductVersion(productVersion);
productVersion = "v" + productVersion;
Expand Down
Loading

0 comments on commit cfe24d3

Please sign in to comment.