diff options
author | Benny Prijono <bennylp@teluu.com> | 2013-04-15 10:47:28 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2013-04-15 10:47:28 +0000 |
commit | 7e629aee4795127c323551e153349bf904166717 (patch) | |
tree | 34ee314e202a072a3ed742b118badf6fc252c15c /pjsip-apps/src | |
parent | a88589110b443e7ebb5c355cd50190baaa7549a5 (diff) |
Re #1657, #1655: initial implementation of pjsua CLI app for BlackBerry BB10
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4471 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src')
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/Makefile | 6 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/PjsuaBB.pro | 30 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/assets/.assets.index | 4 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/assets/images/teluu-logo.png | bin | 0 -> 78108 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/assets/main.qml | 41 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/bar-descriptor.xml | 103 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/config.pri | 52 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/icon.png | bin | 0 -> 6078 bytes | |||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/precompiled.h | 2 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/src/applicationui.cpp | 147 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/src/applicationui.h | 37 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/src/main.cpp | 32 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/translations/Makefile | 12 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.pro | 1 | ||||
-rw-r--r-- | pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.ts | 22 |
15 files changed, 489 insertions, 0 deletions
diff --git a/pjsip-apps/src/pjsua/bb10/Makefile b/pjsip-apps/src/pjsua/bb10/Makefile new file mode 100644 index 00000000..9b922385 --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/Makefile @@ -0,0 +1,6 @@ +QMAKE_TARGET = PjsuaBB +PROJECT_DIR := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) +I18N_DIR := $(PROJECT_DIR)/translations + +include mk/cs-base.mk + diff --git a/pjsip-apps/src/pjsua/bb10/PjsuaBB.pro b/pjsip-apps/src/pjsua/bb10/PjsuaBB.pro new file mode 100644 index 00000000..78928ad9 --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/PjsuaBB.pro @@ -0,0 +1,30 @@ +APP_NAME = PjsuaBB + +CONFIG += qt warn_on cascades10 + +include(config.pri) + +SOURCES += ../../pjsua_app.c \ + ../../pjsua_cli_cmd.c \ + ../../pjsua_cli.c \ + ../../pjsua_common.c \ + ../../pjsua_config.c \ + ../../pjsua_legacy.c + +device { + CONFIG(debug, debug|release) { + # Device-Debug custom configuration + include(../../../../pjsip.pri) + LIBS += -lbb + } + + CONFIG(release, debug|release) { + # Device-Release custom configuration + } +} + +simulator { + CONFIG(debug, debug|release) { + # Simulator-Debug custom configuration + } +} diff --git a/pjsip-apps/src/pjsua/bb10/assets/.assets.index b/pjsip-apps/src/pjsua/bb10/assets/.assets.index new file mode 100644 index 00000000..d084d03d --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/assets/.assets.index @@ -0,0 +1,4 @@ +1 +2 +main.qml +images/teluu-logo.png diff --git a/pjsip-apps/src/pjsua/bb10/assets/images/teluu-logo.png b/pjsip-apps/src/pjsua/bb10/assets/images/teluu-logo.png Binary files differnew file mode 100644 index 00000000..97fadb5b --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/assets/images/teluu-logo.png diff --git a/pjsip-apps/src/pjsua/bb10/assets/main.qml b/pjsip-apps/src/pjsua/bb10/assets/main.qml new file mode 100644 index 00000000..dc3f7f34 --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/assets/main.qml @@ -0,0 +1,41 @@ +// Default empty project template +import bb.cascades 1.0 + +// creates one page with a label +Page { + Container { + layout: StackLayout { + } + background: Color.Black + Label { + text: qsTr("") + horizontalAlignment: HorizontalAlignment.Center + } + ImageView { + imageSource: "asset:///images/teluu-logo.png" + topMargin: 200 + preferredWidth: 500 + preferredHeight: 500 + verticalAlignment: VerticalAlignment.Center + horizontalAlignment: HorizontalAlignment.Center + } + Label { + text: qsTr("pjsua BB10") + textStyle.base: SystemDefaults.TextStyles.BigText + horizontalAlignment: HorizontalAlignment.Center + textStyle { + color: Color.White + } + } + Label { + objectName: "telnetMsg" + text: qsTr("Starting..") + topMargin: 200 + horizontalAlignment: HorizontalAlignment.Center + textStyle { + color: Color.White + } + } + } +} + diff --git a/pjsip-apps/src/pjsua/bb10/bar-descriptor.xml b/pjsip-apps/src/pjsua/bb10/bar-descriptor.xml new file mode 100644 index 00000000..90e71e3d --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/bar-descriptor.xml @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8" standalone="no"?> +<!-- + + Copyright (c) 2011, 2012, 2013 Research In Motion Limited. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<qnx xmlns="http://www.qnx.com/schemas/application/1.0"> + +<!-- BlackBerry Tablet OS application descriptor file. + + Specifies parameters for identifying, installing, and launching native applications on BlackBerry Tablet OS. + +--> + + <!-- A universally unique application identifier. Must be unique across all BlackBerry Tablet OS applications. + Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. --> + <id>com.example.PjsuaBB</id> + + <!-- The name that is displayed in the BlackBerry Tablet OS application installer. + May have multiple values for each language. See samples or xsd schema file. Optional. --> + <name>PjsuaBB</name> + + <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade. + Values can also be 1-part or 2-part. It is not necessary to have a 3-part value. + An updated version of application must have a versionNumber value higher than the previous version. Required. --> + <versionNumber>1.0.0</versionNumber> + + <!-- Fourth digit segment of the package version. First three segments are taken from the + <versionNumber> element. Must be an integer from 0 to 2^16-1 --> + <buildId>1</buildId> + + <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. --> + <!-- <versionLabel></versionLabel> --> + + <!-- Description, displayed in the BlackBerry Tablet OS application installer. + May have multiple values for each language. See samples or xsd schema file. Optional. --> + <description>Teluu Ltd. pjsua Demo App</description> + + <!-- Copyright information. Optional. --> + <!-- <copyright></copyright> --> + + <!-- Name of author which is used for signing. Must match the developer name of your development certificate. --> + <author>Teluu Ltd.</author> + + <!-- Unique author ID assigned by signing authority. Required if using debug tokens. --> + <!-- <authorId>ABC1234YjsnUk235h</authorId> --> + + <initialWindow> + <autoOrients>true</autoOrients> + <systemChrome>none</systemChrome> + <transparent>false</transparent> + </initialWindow> + + <!-- The category where the application appears. Either core.games or core.media. --> + <category>core.media</category> + <configuration name="Device-Debug"> + <platformArchitecture>armle-v7</platformArchitecture> + <asset path="arm/o.le-v7-g/PjsuaBB" entry="true" type="Qnx/Elf">PjsuaBB</asset> + </configuration> + <configuration name="Device-Release"> + <entryPointType>Qnx/Cascades</entryPointType> + <platformArchitecture>armle-v7</platformArchitecture> + <asset path="arm/o.le-v7/PjsuaBB.so" entry="true" type="Qnx/Elf">PjsuaBB.so</asset> + </configuration> + <configuration name="Device-Profile"> + <platformArchitecture>armle-v7</platformArchitecture> + <asset path="arm-p/o.le-v7-g/PjsuaBB" entry="true" type="Qnx/Elf">PjsuaBB</asset> + </configuration> + <configuration name="Simulator-Debug"> + <platformArchitecture>x86</platformArchitecture> + <asset path="x86/o-g/PjsuaBB" entry="true" type="Qnx/Elf">PjsuaBB</asset> + </configuration> + + <!-- The icon for the application --> + <icon> + <image>icon.png</image> + </icon> + + <asset path="icon.png">icon.png</asset> + <asset path="assets">assets</asset> + + <!-- Locale support --> + + <!-- Request permission to execute native code. Required for native applications. --> + <permission system="true">run_native</permission> + <permission>access_internet</permission> + <permission>record_audio</permission> + <permission>run_when_backgrounded</permission> + <env var="LD_LIBRARY_PATH" value="app/native/lib:/usr/lib/qt4/lib"/> + +</qnx> diff --git a/pjsip-apps/src/pjsua/bb10/config.pri b/pjsip-apps/src/pjsua/bb10/config.pri new file mode 100644 index 00000000..2f80a4fa --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/config.pri @@ -0,0 +1,52 @@ +# Auto-generated by IDE. Any changes made by user will be lost! +BASEDIR = $$quote($$_PRO_FILE_PWD_) + +device { + CONFIG(debug, debug|release) { + SOURCES += $$quote($$BASEDIR/src/applicationui.cpp) \ + $$quote($$BASEDIR/src/main.cpp) + + HEADERS += $$quote($$BASEDIR/src/applicationui.h) + } + + CONFIG(release, debug|release) { + SOURCES += $$quote($$BASEDIR/src/applicationui.cpp) \ + $$quote($$BASEDIR/src/main.cpp) + + HEADERS += $$quote($$BASEDIR/src/applicationui.h) + } +} + +simulator { + CONFIG(debug, debug|release) { + SOURCES += $$quote($$BASEDIR/src/applicationui.cpp) \ + $$quote($$BASEDIR/src/main.cpp) + + HEADERS += $$quote($$BASEDIR/src/applicationui.h) + } +} + +INCLUDEPATH += $$quote($$BASEDIR/src) + +CONFIG += precompile_header + +PRECOMPILED_HEADER = $$quote($$BASEDIR/precompiled.h) + +lupdate_inclusion { + SOURCES += $$quote($$BASEDIR/../src/*.c) \ + $$quote($$BASEDIR/../src/*.c++) \ + $$quote($$BASEDIR/../src/*.cc) \ + $$quote($$BASEDIR/../src/*.cpp) \ + $$quote($$BASEDIR/../src/*.cxx) \ + $$quote($$BASEDIR/../assets/*.qml) \ + $$quote($$BASEDIR/../assets/*.js) \ + $$quote($$BASEDIR/../assets/*.qs) + + HEADERS += $$quote($$BASEDIR/../src/*.h) \ + $$quote($$BASEDIR/../src/*.h++) \ + $$quote($$BASEDIR/../src/*.hh) \ + $$quote($$BASEDIR/../src/*.hpp) \ + $$quote($$BASEDIR/../src/*.hxx) +} + +TRANSLATIONS = $$quote($${TARGET}.ts) diff --git a/pjsip-apps/src/pjsua/bb10/icon.png b/pjsip-apps/src/pjsua/bb10/icon.png Binary files differnew file mode 100644 index 00000000..dab6e7a9 --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/icon.png diff --git a/pjsip-apps/src/pjsua/bb10/precompiled.h b/pjsip-apps/src/pjsua/bb10/precompiled.h new file mode 100644 index 00000000..6213dc4b --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/precompiled.h @@ -0,0 +1,2 @@ +// This file is used to store precompiled headers. +// It is intentionally left blank. It is up to you to decide which headers should be included here. diff --git a/pjsip-apps/src/pjsua/bb10/src/applicationui.cpp b/pjsip-apps/src/pjsua/bb10/src/applicationui.cpp new file mode 100644 index 00000000..cc5aff0f --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/src/applicationui.cpp @@ -0,0 +1,147 @@ +// Default empty project template +#include "applicationui.h" + +#include <bb/cascades/Application> +#include <bb/cascades/QmlDocument> +#include <bb/cascades/AbstractPane> +#include <bb/cascades/Label> + +#define THIS_FILE "applicationui.cpp" + +using namespace bb::cascades; + +#include "../../pjsua_common.h" + +extern pj_cli_telnet_on_started on_started_cb; +extern pj_cli_on_quit on_quit_cb; + +extern "C" int main_func(int argc, char *argv[]); + +ApplicationUI *ApplicationUI::instance_; + +class CliThread : public QThread +{ + Q_OBJECT +public: + virtual ~CliThread() {} +protected: + void run(); +}; + +static void bb10_show_msg(const char *msg) +{ + /* Qt's way to invoke method from "foreign" thread */ + QMetaObject::invokeMethod((QObject*)ApplicationUI::instance(), "displayMsg", + Qt::QueuedConnection, + Q_ARG(QString,msg)); +} + +static void bb10_telnet_started(pj_cli_telnet_info *telnet_info) +{ + char msg[64]; + + pj_ansi_snprintf(msg, sizeof(msg), + "Telnet to %.*s:%d", + (int)telnet_info->ip_address.slen, + telnet_info->ip_address.ptr, + telnet_info->port); + + PJ_LOG(3,(THIS_FILE, "Started: %s", msg)); + + bb10_show_msg(msg); +} + +static void bb10_on_quit (pj_bool_t is_restarted) +{ + PJ_LOG(3,("ipjsua", "CLI quit, restart(%d)", is_restarted)); + if (!is_restarted) { + bb10_show_msg("Shutting down.."); + ApplicationUI::instance()->isShuttingDown = true; + bb::cascades::Application *app = bb::cascades::Application::instance(); + app->quit(); + } +} + +void CliThread::run() +{ + // TODO: read from config? + char *argv[] = { (char*)"pjsuabb", + (char*)"--use-cli", + (char*)"--no-cli-console", + (char*)"--cli-telnet-port=2323", + (char*)"--dis-codec=*", + (char*)"--add-codec=g722", + NULL }; + int argc = PJ_ARRAY_SIZE(argv) -1; + pj_thread_desc thread_desc; + pj_thread_t *thread; + + pj_thread_register("CliThread", thread_desc, &thread); + // Wait UI to be created + pj_thread_sleep(100); + + on_started_cb = &bb10_telnet_started; + on_quit_cb = &bb10_on_quit; + main_func(argc, argv); +} + +ApplicationUI::ApplicationUI(bb::cascades::Application *app) +: QObject(app), isShuttingDown(false) +{ + instance_ = this; + + // create scene document from main.qml asset + // set parent to created document to ensure it exists for the whole application lifetime + QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); + + // create root object for the UI + AbstractPane *root = qml->createRootObject<AbstractPane>(); + // set created root object as a scene + app->setScene(root); + + app->setAutoExit(true); + connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); + + pj_init(); + + // Run CLI + cliThread = new CliThread; + cliThread->start(); +} + +ApplicationUI::~ApplicationUI() +{ + pj_shutdown(); + instance_ = NULL; +} + +ApplicationUI* ApplicationUI::instance() +{ + return instance_; +} + +void ApplicationUI::aboutToQuit() +{ + static pj_thread_desc thread_desc; + pj_thread_t *thread; + + if (!pj_thread_is_registered()) + pj_thread_register("UIThread", thread_desc, &thread); + + if (!isShuttingDown) { + isShuttingDown = true; + PJ_LOG(3,(THIS_FILE, "Quit signal from GUI, shutting down pjsua..")); + pjsua_destroy(); + } +} + +void ApplicationUI::displayMsg(const QString &msg) +{ + bb::cascades::Application *app = bb::cascades::Application::instance(); + Label *telnetMsg = app->scene()->findChild<Label*>("telnetMsg"); + if (telnetMsg) { + telnetMsg->setText(msg); + } +} + +#include "applicationui.moc" diff --git a/pjsip-apps/src/pjsua/bb10/src/applicationui.h b/pjsip-apps/src/pjsua/bb10/src/applicationui.h new file mode 100644 index 00000000..785e017f --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/src/applicationui.h @@ -0,0 +1,37 @@ +// Default empty project template +#ifndef ApplicationUI_HPP_ +#define ApplicationUI_HPP_ + +#include <QObject> + +namespace bb { namespace cascades { class Application; }} + +class CliThread; + +/*! + * @brief Application pane object + * + *Use this object to create and init app UI, to create context objects, to register the new meta types etc. + */ +class ApplicationUI : public QObject +{ + Q_OBJECT +public: + ApplicationUI(bb::cascades::Application *app); + virtual ~ApplicationUI(); + + bool isShuttingDown; + static ApplicationUI *instance(); + +public slots: + void aboutToQuit(); + + Q_INVOKABLE void displayMsg(const QString &msg); + +private: + CliThread *cliThread; + static ApplicationUI *instance_; +}; + + +#endif /* ApplicationUI_HPP_ */ diff --git a/pjsip-apps/src/pjsua/bb10/src/main.cpp b/pjsip-apps/src/pjsua/bb10/src/main.cpp new file mode 100644 index 00000000..cd2a4b66 --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/src/main.cpp @@ -0,0 +1,32 @@ +// Default empty project template +#include <bb/cascades/Application> + +#include <QLocale> +#include <QTranslator> +#include "applicationui.h" + +// include JS Debugger / CS Profiler enabler +// this feature is enabled by default in the debug build only +#include <Qt/qdeclarativedebug.h> + +using namespace bb::cascades; + +Q_DECL_EXPORT int main(int argc, char **argv) +{ + // this is where the server is started etc + Application app(argc, argv); + + // localization support + QTranslator translator; + QString locale_string = QLocale().name(); + QString filename = QString( "PjsuaBB_%1" ).arg( locale_string ); + if (translator.load(filename, "app/native/qm")) { + app.installTranslator( &translator ); + } + + new ApplicationUI(&app); + + // we complete the transaction started in the app constructor and start the client event loop here + return Application::exec(); + // when loop is exited the Application deletes the scene which deletes all its children (per qt rules for children) +} diff --git a/pjsip-apps/src/pjsua/bb10/translations/Makefile b/pjsip-apps/src/pjsua/bb10/translations/Makefile new file mode 100644 index 00000000..28fd97cb --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/translations/Makefile @@ -0,0 +1,12 @@ +QMAKE_TARGET = PjsuaBB +LUPDATE = $(QNX_HOST)/usr/bin/lupdate +LRELEASE = $(QNX_HOST)/usr/bin/lrelease + +update: $(QMAKE_TARGET).pro FORCE + $(LUPDATE) $(QMAKE_TARGET).pro + +release: $(QMAKE_TARGET).pro $(QMAKE_TARGET).ts + $(LRELEASE) $(QMAKE_TARGET).pro + +FORCE: + diff --git a/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.pro b/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.pro new file mode 100644 index 00000000..3f7c659e --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.pro @@ -0,0 +1 @@ +include (../PjsuaBB.pro) diff --git a/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.ts b/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.ts new file mode 100644 index 00000000..cdc53c8c --- /dev/null +++ b/pjsip-apps/src/pjsua/bb10/translations/PjsuaBB.ts @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>main</name> + <message> + <location filename="../assets/main.qml" line="11"/> + <source></source> + <translation></translation> + </message> + <message> + <location filename="../assets/main.qml" line="23"/> + <source>pjsua BB10</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="../assets/main.qml" line="32"/> + <source>Starting..</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> |