From 094250568518d36e18d17d3065291390a3e8d68a Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 14 Dec 2004 03:09:26 +0000 Subject: [PATCH] Added a Qt-3 client by Dorin Lazar. Cleaned up build system and also made it detect Qt libraries. git-svn-id: http://yate.null.ro/svn/yate/trunk@128 acf43c95-373e-0410-b603-e72c3f656dc1 --- Makefile.in | 7 +-- clients/main-qt.cpp | 100 ++++++++++++++++++++++++++++++++++++++++ configure.in | 26 ++++++++++- contrib/iax/Makefile.in | 2 - modules/Makefile.in | 22 ++++++--- test/Makefile.in | 11 ++--- 6 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 clients/main-qt.cpp diff --git a/Makefile.in b/Makefile.in index 96421b37..ed64dfba 100644 --- a/Makefile.in +++ b/Makefile.in @@ -7,7 +7,7 @@ DESTDIR := # override DEBUG at compile time to enable full debug or remove it all DEBUG := -CC := @CXX@ -Wall +CXX := @CXX@ -Wall SED := sed DEFS := LIBAUX:= -ldl @@ -32,8 +32,8 @@ OBJS := main.o LIBOBJS := $(ENGOBJS) $(TELOBJS) CLEANS = $(PROGS) $(SLIBS) $(LIBS) $(OBJS) $(LIBOBJS) core -COMPILE = $(CC) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS) -LINK = $(CC) $(LDFLAGS) +COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS) +LINK = $(CXX) $(LDFLAGS) prefix = @prefix@ exec_prefix = @exec_prefix@ @@ -56,6 +56,7 @@ clean: $(MAKE) -C ./modules $@ $(MAKE) -C ./test $@ $(MAKE) -C ./contrib/iax $@ + $(MAKE) -C ./contrib/qt $@ .PHONY: engine engine: tables yatepaths.h $(LIBS) $(SLIBS) $(PROGS) diff --git a/clients/main-qt.cpp b/clients/main-qt.cpp new file mode 100644 index 00000000..017b6415 --- /dev/null +++ b/clients/main-qt.cpp @@ -0,0 +1,100 @@ +/** + * qtclient.cpp + * This file is part of the YATE Project http://YATE.null.ro + * + * A Qt based universal telephony client + * Author: Dorin Lazar + * + * Yet Another Telephony Engine - a fully featured software PBX and IVR + * Copyright (C) 2004 Null Team + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include + +#include "../contrib/qt/qtclientform.hpp" +#include + +using namespace TelEngine; + +class QtClientThread : public Thread +{ + public: + QtClientThread () : Thread("QtClient"),m_app(0),m_frm(0) {} + ~QtClientThread() {} + public: + void run(void); + void cleanup(void); + private: + QApplication *m_app; + QtClientForm *m_frm; +}; + +void QtClientThread::run (void) +{ + int argc = 1; + char *argv[] = {"QYate", NULL}; + m_app = new QApplication(argc, argv); + m_frm = new QtClientForm(); + m_app->setMainWidget (m_frm); + m_frm->show(); + m_app->exec(); + Engine::halt(0); + Output ("QtClientThread finished"); +} + +void QtClientThread::cleanup (void) +{ + delete m_frm; + m_frm = NULL; + delete m_app; + m_app = NULL; + qApp = NULL; +} + +class QtYateClientPlugin : public Plugin +{ + QtClientThread *thread; + public: + QtYateClientPlugin(); + ~QtYateClientPlugin(); + virtual void initialize(void); + virtual bool isBusy() const { return true; } +}; + +QtYateClientPlugin::QtYateClientPlugin () + : thread(0) +{ + Output ("Loading QtYateClientPlugin"); +} + +QtYateClientPlugin::~QtYateClientPlugin () +{ +// the thread should be already dead at this point + Output ("Unloaded QtYateClientPlugin"); +} + +void QtYateClientPlugin::initialize (void) +{ + if (!thread) { + Output ("Initializing Qt Client"); + thread = new QtClientThread; + thread->startup(); + } +} + +INIT_PLUGIN(QtYateClientPlugin); diff --git a/configure.in b/configure.in index a27db8ed..4133ede8 100644 --- a/configure.in +++ b/configure.in @@ -383,7 +383,7 @@ AC_SUBST(SPANDSP_LIB) HAVE_GTK=no GTK_INC="" GTK_LIB="" -AC_ARG_WITH(libgtk,AC_HELP_STRING([--with-libgtk],[use Gtk for graphical clients)]),[ac_cv_use_libgtk=$withval],[ac_cv_use_libgtk=yes]) +AC_ARG_WITH(libgtk,AC_HELP_STRING([--with-libgtk],[use Gtk for graphical clients (default)]),[ac_cv_use_libgtk=$withval],[ac_cv_use_libgtk=yes]) if [[ "x$ac_cv_use_libgtk" = "xyes" ]]; then AC_MSG_CHECKING([for Gtk using gtk-config]) vergt=`gtk-config --version gtk 2>/dev/null` @@ -401,6 +401,29 @@ AC_SUBST(HAVE_GTK) AC_SUBST(GTK_INC) AC_SUBST(GTK_LIB) +HAVE_QT=no +QT_DIR="" +AC_ARG_WITH(libqt,AC_HELP_STRING([--with-libqt],[use Qt for graphical clients (default)]),[ac_cv_use_libqt=$withval],[ac_cv_use_libqt=yes]) +if [[ "x$ac_cv_use_libqt" != "xno" ]]; then + qtdir="$ac_cv_use_libqt" + if [[ "x$ac_cv_use_libqt" = "xyes" ]]; then + qtdir="$QTDIR" + if [[ "x$qtdir" = "x" ]]; then + qtdir=`ls -d -1 /opt/qt-3* /usr/lib/qt-3* 2>/dev/null | tail -1` + fi + fi + if [[ "x$qtdir" != "x" ]]; then + AC_MSG_CHECKING([for multithreaded Qt in $qtdir]) + if [[ -x "$qtdir/bin/moc" -a -f "$qtdir/lib/libqt-mt.so" -a -f "$qtdir/include/qobject.h" ]]; then + HAVE_QT=yes + QT_DIR="$qtdir" + fi + AC_MSG_RESULT([$HAVE_QT]) + fi +fi +AC_SUBST(HAVE_QT) +AC_SUBST(QT_DIR) + RTTI_OPT="" AC_ARG_ENABLE(rtti,AC_HELP_STRING([--enable-rtti],[Enable RTTI support (default: like pwlib)]),want_rtti=$enableval,want_rtti=auto) AC_MSG_CHECKING([whether to enable RTTI support]) @@ -447,6 +470,7 @@ AC_CONFIG_FILES([yate.spec scripts/Makefile conf.d/Makefile contrib/iax/Makefile + contrib/qt/Makefile test/Makefile]) AC_CONFIG_FILES([yate-config],[chmod +x yate-config]) AC_CONFIG_FILES([run],[chmod +x run]) diff --git a/contrib/iax/Makefile.in b/contrib/iax/Makefile.in index d6168bce..90287503 100644 --- a/contrib/iax/Makefile.in +++ b/contrib/iax/Makefile.in @@ -3,7 +3,6 @@ CC := @CC@ -Wall AR := ar -RANLIB:= ranlib SED := sed DEFS := INCLUDES := -I@top_srcdir@ @@ -41,4 +40,3 @@ Makefile: @srcdir@/Makefile.in ../../config.status libiax.a: $(OBJS) $(AR) rcs $@ $^ - $(RANLIB) $@ diff --git a/modules/Makefile.in b/modules/Makefile.in index feef0a1a..56f3732e 100644 --- a/modules/Makefile.in +++ b/modules/Makefile.in @@ -7,7 +7,7 @@ DESTDIR := # override DEBUG at compile time to enable full debug or remove it all DEBUG := -CC := @CXX@ -Wall +CXX := @CXX@ -Wall SED := sed DEFS := INCLUDES := -I@top_srcdir@ @@ -61,11 +61,15 @@ ifneq (@HAVE_GTK@,no) PROGS := $(PROGS) gtkclient.yate endif +ifneq (@HAVE_QT@,no) +PROGS := $(PROGS) qtclient.yate +endif + LOCALFLAGS = LOCALLIBS = -COMPILE = $(CC) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS) -LINK = $(CC) $(LDFLAGS) -MODLINK = $(CC) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) +COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS) +LINK = $(CXX) $(LDFLAGS) +MODLINK = $(CXX) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) MODCOMP = $(COMPILE) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) prefix = @prefix@ @@ -99,9 +103,6 @@ uninstall: do-uninstall %.o: @srcdir@/%.cpp $(MKDEPS) $(INCFILES) $(COMPILE) -c $< -%.o: @srcdir@/%.c $(MKDEPS) - $(COMPILE) -c $< - do-all do-strip do-clean do-install do-uninstall: $(if $(SUBDIRS),\ @target=`echo $@ | $(SED) -e 's/^do-//'`; \ @@ -145,5 +146,12 @@ gsmcodec.yate: LOCALLIBS = -lgsm gtkclient.yate: LOCALFLAGS = @GTK_INC@ @GTK_LIB@ +qtclient.yate: ../contrib/qt/libqtclientform.a +qtclient.yate: LOCALFLAGS = -I@QT_DIR@/include +qtclient.yate: LOCALLIBS = ../contrib/qt/libqtclientform.a -L@QT_DIR@/lib -lqt-mt + ../contrib/iax/libiax.a: $(MAKE) -C ../contrib/iax + +../contrib/qt/libqtclientform.a: + $(MAKE) -C ../contrib/qt diff --git a/test/Makefile.in b/test/Makefile.in index 8d2d2ed3..5bb9161e 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,7 +1,7 @@ # Makefile # This file holds the make rules for the Telephony Engine test cases -CC := @CXX@ -Wall +CXX := @CXX@ -Wall SED := sed DEFS := INCLUDES := -I@top_srcdir@ @@ -17,9 +17,9 @@ OBJS = LOCALFLAGS = LOCALLIBS = -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) -LINK = $(CC) $(LDFLAGS) -MODLINK = $(CC) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) +COMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CFLAGS) +LINK = $(CXX) $(LDFLAGS) +MODLINK = $(CXX) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) MODCOMP = $(COMPILE) $(MODFLAGS) $(MODSTRIP) $(LDFLAGS) prefix = @prefix@ @@ -39,9 +39,6 @@ clean: %.o: @srcdir@/%.cpp $(MKDEPS) @top_srcdir@/telengine.h $(COMPILE) -c $< -%.o: @srcdir@/%.c $(MKDEPS) - $(COMPILE) -c $< - Makefile: @srcdir@/Makefile.in $(MKDEPS) cd .. && ./config.status