added GLiveSupport application object
This commit is contained in:
parent
70968ffbcf
commit
80d1a0915f
|
@ -21,7 +21,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Author : $Author: maroy $
|
# Author : $Author: maroy $
|
||||||
# Version : $Revision: 1.4 $
|
# Version : $Revision: 1.5 $
|
||||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
|
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
|
||||||
#
|
#
|
||||||
# @configure_input@
|
# @configure_input@
|
||||||
|
@ -72,6 +72,12 @@ CORE_LIB_DIR = ${CORE_DIR}/lib
|
||||||
CORE_LIB = livesupport_core
|
CORE_LIB = livesupport_core
|
||||||
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a
|
||||||
|
|
||||||
|
AUTHENTICATION_DIR = ${MODULES_DIR}/authentication
|
||||||
|
AUTHENTICATION_INCLUDE_DIR = ${AUTHENTICATION_DIR}/include
|
||||||
|
AUTHENTICATION_LIB_DIR = ${AUTHENTICATION_DIR}/lib
|
||||||
|
AUTHENTICATION_LIB = livesupport_authentication
|
||||||
|
AUTHENTICATION_LIB_FILE = ${AUTHENTICATION_LIB_DIR}/lib${AUTHENTICATION_LIB}.a
|
||||||
|
|
||||||
STORAGE_DIR = ${MODULES_DIR}/storage
|
STORAGE_DIR = ${MODULES_DIR}/storage
|
||||||
STORAGE_INCLUDE_DIR = ${STORAGE_DIR}/include
|
STORAGE_INCLUDE_DIR = ${STORAGE_DIR}/include
|
||||||
STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
||||||
|
@ -90,6 +96,7 @@ TEST_XSLT = ../etc/testResultToHtml.xsl
|
||||||
|
|
||||||
G_LIVESUPPORT_EXE = ${TMP_DIR}/gLiveSupport
|
G_LIVESUPPORT_EXE = ${TMP_DIR}/gLiveSupport
|
||||||
G_LIVESUPPORT_CFG = ${ETC_DIR}/gLiveSupport.xml
|
G_LIVESUPPORT_CFG = ${ETC_DIR}/gLiveSupport.xml
|
||||||
|
G_LIVESUPPORT_CFG = ${ETC_DIR}/gLiveSupport.xml
|
||||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||||
|
|
||||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||||
|
@ -109,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
||||||
-I${BOOST_INCLUDE_DIR} \
|
-I${BOOST_INCLUDE_DIR} \
|
||||||
-I${LIBXMLPP_INCLUDE_DIR} \
|
-I${LIBXMLPP_INCLUDE_DIR} \
|
||||||
-I${CORE_INCLUDE_DIR} \
|
-I${CORE_INCLUDE_DIR} \
|
||||||
|
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||||
-I${STORAGE_INCLUDE_DIR} \
|
-I${STORAGE_INCLUDE_DIR} \
|
||||||
-I${TMP_DIR}
|
-I${TMP_DIR}
|
||||||
LDFLAGS = @LDFLAGS@ -pthread \
|
LDFLAGS = @LDFLAGS@ -pthread \
|
||||||
|
@ -116,13 +124,15 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
||||||
${GTKMM_LIBS} \
|
${GTKMM_LIBS} \
|
||||||
-L${USR_LIB_DIR} \
|
-L${USR_LIB_DIR} \
|
||||||
-L${CORE_LIB_DIR} \
|
-L${CORE_LIB_DIR} \
|
||||||
|
-L${AUTHENTICATION_LIB_DIR} \
|
||||||
-L${STORAGE_LIB_DIR}
|
-L${STORAGE_LIB_DIR}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Dependencies
|
# Dependencies
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
G_LIVESUPPORT_OBJS = ${TMP_DIR}/UiTestMainWindow.o \
|
G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
|
||||||
|
${TMP_DIR}/UiTestMainWindow.o \
|
||||||
${TMP_DIR}/GtkLocalizedObject.o \
|
${TMP_DIR}/GtkLocalizedObject.o \
|
||||||
${TMP_DIR}/LoginWindow.o
|
${TMP_DIR}/LoginWindow.o
|
||||||
|
|
||||||
|
@ -135,6 +145,7 @@ G_LIVESUPPORT_EXE_OBJS = ${TMP_DIR}/main.o
|
||||||
FSDF = ${G_LIVESUPPORT_OBJS} \
|
FSDF = ${G_LIVESUPPORT_OBJS} \
|
||||||
${TMP_DIR}/main.o
|
${TMP_DIR}/main.o
|
||||||
G_LIVESUPPORT_EXE_LIBS = -l${CORE_LIB} \
|
G_LIVESUPPORT_EXE_LIBS = -l${CORE_LIB} \
|
||||||
|
-l${AUTHENTICATION_LIB} \
|
||||||
-lboost_date_time-gcc \
|
-lboost_date_time-gcc \
|
||||||
-lxmlrpc++ -lssl -lxml++-1.0
|
-lxmlrpc++ -lssl -lxml++-1.0
|
||||||
|
|
||||||
|
@ -168,6 +179,7 @@ docclean:
|
||||||
|
|
||||||
depclean: clean
|
depclean: clean
|
||||||
${MAKE} -C ${STORAGE_DIR} clean
|
${MAKE} -C ${STORAGE_DIR} clean
|
||||||
|
${MAKE} -C ${AUTHENTICATION_DIR} clean
|
||||||
${MAKE} -C ${CORE_DIR} clean
|
${MAKE} -C ${CORE_DIR} clean
|
||||||
|
|
||||||
distclean: clean docclean
|
distclean: clean docclean
|
||||||
|
@ -179,13 +191,15 @@ run_tests: ${TEST_RUNNER}
|
||||||
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||||
|
|
||||||
run: all
|
run: all
|
||||||
${G_LIVESUPPORT_EXE}
|
${G_LIVESUPPORT_EXE} -c ${G_LIVESUPPORT_CFG}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Specific targets
|
# Specific targets
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
${G_LIVESUPPORT_EXE}: ${CORE_LIB_FILE} ${STORAGE_LIB_FILE} \
|
${G_LIVESUPPORT_EXE}: ${CORE_LIB_FILE} \
|
||||||
|
${AUTHENTICATION_LIB_FILE} \
|
||||||
|
${STORAGE_LIB_FILE} \
|
||||||
${G_LIVESUPPORT_OBJS} ${G_LIVESUPPORT_EXE_OBJS}
|
${G_LIVESUPPORT_OBJS} ${G_LIVESUPPORT_EXE_OBJS}
|
||||||
${CXX} ${LDFLAGS} -o $@ $^ ${G_LIVESUPPORT_EXE_LIBS}
|
${CXX} ${LDFLAGS} -o $@ $^ ${G_LIVESUPPORT_EXE_LIBS}
|
||||||
|
|
||||||
|
@ -195,13 +209,18 @@ ${TMP_DIR}:
|
||||||
${DOXYGEN_DIR}:
|
${DOXYGEN_DIR}:
|
||||||
${MKDIR} ${DOXYGEN_DIR}
|
${MKDIR} ${DOXYGEN_DIR}
|
||||||
|
|
||||||
${TEST_RUNNER}: ${CORE_LIB_FILE} ${STORAGE_LIB_FILE} \
|
${TEST_RUNNER}: ${CORE_LIB_FILE} \
|
||||||
|
${AUTHENTICATION_LIB_FILE} \
|
||||||
|
${STORAGE_LIB_FILE} \
|
||||||
${TEST_RUNNER_OBJS}
|
${TEST_RUNNER_OBJS}
|
||||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||||
|
|
||||||
${CORE_LIB_FILE}:
|
${CORE_LIB_FILE}:
|
||||||
${MAKE} -C ${CORE_DIR}
|
${MAKE} -C ${CORE_DIR}
|
||||||
|
|
||||||
|
${AUTHENTICATION_LIB_FILE}:
|
||||||
|
${MAKE} -C ${AUTHENTICATION_DIR}
|
||||||
|
|
||||||
${STORAGE_LIB_FILE}:
|
${STORAGE_LIB_FILE}:
|
||||||
${MAKE} -C ${STORAGE_DIR}
|
${MAKE} -C ${STORAGE_DIR}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE gLiveSupport [
|
||||||
|
|
||||||
|
<!ELEMENT gLiveSupport (authenticationClientFactory) >
|
||||||
|
|
||||||
|
<!ELEMENT authenticationClientFactory (testAuthentication|
|
||||||
|
webAuthentication)>
|
||||||
|
|
||||||
|
<!ELEMENT testAuthentication (user) >
|
||||||
|
|
||||||
|
<!ELEMENT user EMPTY >
|
||||||
|
<!ATTLIST user login CDATA #REQUIRED >
|
||||||
|
<!ATTLIST user password CDATA #REQUIRED >
|
||||||
|
|
||||||
|
]>
|
||||||
|
<gLiveSupport>
|
||||||
|
<authenticationClientFactory>
|
||||||
|
<testAuthentication>
|
||||||
|
<user login="root" password="q" />
|
||||||
|
</testAuthentication>
|
||||||
|
</authenticationClientFactory>
|
||||||
|
</gLiveSupport>
|
|
@ -0,0 +1,152 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport 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.
|
||||||
|
|
||||||
|
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: maroy $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <gtkmm/main.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||||
|
|
||||||
|
#include "UiTestMainWindow.h"
|
||||||
|
#include "LoginWindow.h"
|
||||||
|
#include "GLiveSupport.h"
|
||||||
|
|
||||||
|
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
using namespace LiveSupport::Authentication;
|
||||||
|
using namespace LiveSupport::GLiveSupport;
|
||||||
|
|
||||||
|
|
||||||
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the config element for this class
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
const std::string LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: configElementNameStr = "gLiveSupport";
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================= module code */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Configure the gLiveSupport object
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: configure(const xmlpp::Element & element)
|
||||||
|
throw (std::invalid_argument,
|
||||||
|
std::logic_error)
|
||||||
|
{
|
||||||
|
if (element.get_name() != configElementNameStr) {
|
||||||
|
std::string eMsg = "Bad configuration element ";
|
||||||
|
eMsg += element.get_name();
|
||||||
|
throw std::invalid_argument(eMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlpp::Node::NodeList nodes;
|
||||||
|
|
||||||
|
// configure the AuthenticationClientFactory
|
||||||
|
nodes = element.get_children(
|
||||||
|
AuthenticationClientFactory::getConfigElementName());
|
||||||
|
if (nodes.size() < 1) {
|
||||||
|
throw std::invalid_argument("no authenticationClientFactory element");
|
||||||
|
}
|
||||||
|
Ptr<AuthenticationClientFactory>::Ref acf
|
||||||
|
= AuthenticationClientFactory::getInstance();
|
||||||
|
acf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||||
|
|
||||||
|
authentication = acf->getAuthenticationClient();
|
||||||
|
|
||||||
|
// load the resource bundle
|
||||||
|
// TODO: get resource bundle path from config file
|
||||||
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
|
resourceBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME,
|
||||||
|
"en",
|
||||||
|
status));
|
||||||
|
if (!U_SUCCESS(status)) {
|
||||||
|
throw std::invalid_argument("opening resource bundle a failure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Show the main window.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: show(void) throw ()
|
||||||
|
{
|
||||||
|
Ptr<UiTestMainWindow>::Ref mainWindow;
|
||||||
|
|
||||||
|
mainWindow.reset(new UiTestMainWindow(shared_from_this(), resourceBundle));
|
||||||
|
|
||||||
|
// Shows the window and returns when it is closed.
|
||||||
|
Gtk::Main::run(*mainWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Authenticate the user
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
bool
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: login(const std::string & login,
|
||||||
|
const std::string & password) throw ()
|
||||||
|
{
|
||||||
|
sessionId = authentication->login(login, password);
|
||||||
|
|
||||||
|
return sessionId.get() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Log the user out.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: logout(void) throw ()
|
||||||
|
{
|
||||||
|
if (sessionId.get() != 0) {
|
||||||
|
authentication->logout(sessionId);
|
||||||
|
sessionId.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2004 Media Development Loan Fund
|
||||||
|
|
||||||
|
This file is part of the LiveSupport project.
|
||||||
|
http://livesupport.campware.org/
|
||||||
|
To report bugs, send an e-mail to bugs@campware.org
|
||||||
|
|
||||||
|
LiveSupport 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.
|
||||||
|
|
||||||
|
LiveSupport 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 LiveSupport; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
|
Author : $Author: maroy $
|
||||||
|
Version : $Revision: 1.1 $
|
||||||
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------*/
|
||||||
|
#ifndef GLiveSupport_h
|
||||||
|
#define GLiveSupport_h
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#error This is a C++ include file
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ============================================================ include files */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "configure.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
|
#include <unicode/resbund.h>
|
||||||
|
|
||||||
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
#include "LiveSupport/Core/Configurable.h"
|
||||||
|
#include "LiveSupport/Core/AuthenticationClientInterface.h"
|
||||||
|
|
||||||
|
namespace LiveSupport {
|
||||||
|
namespace GLiveSupport {
|
||||||
|
|
||||||
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
/* ================================================================ constants */
|
||||||
|
|
||||||
|
|
||||||
|
/* =================================================================== macros */
|
||||||
|
|
||||||
|
|
||||||
|
/* =============================================================== data types */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main application object for the gLiveSupport GUI.
|
||||||
|
*
|
||||||
|
* @author $Author: maroy $
|
||||||
|
* @version $Revision: 1.1 $
|
||||||
|
*/
|
||||||
|
class GLiveSupport : public Configurable,
|
||||||
|
public boost::enable_shared_from_this<GLiveSupport>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* The name of the configuration XML elmenent used by Playlist.
|
||||||
|
*/
|
||||||
|
static const std::string configElementNameStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resource bundle used by the applicaton.
|
||||||
|
*/
|
||||||
|
Ptr<ResourceBundle>::Ref resourceBundle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authentication client used by the application.
|
||||||
|
*/
|
||||||
|
Ptr<AuthenticationClientInterface>::Ref authentication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The session id for the user.
|
||||||
|
*/
|
||||||
|
Ptr<SessionId>::Ref sessionId;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
GLiveSupport(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual destructor.
|
||||||
|
*/
|
||||||
|
virtual
|
||||||
|
~GLiveSupport(void) throw ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the XML element this object expects
|
||||||
|
* to be sent to a call to configure().
|
||||||
|
*
|
||||||
|
* @return the name of the expected XML configuration element.
|
||||||
|
*/
|
||||||
|
static const std::string
|
||||||
|
getConfigElementName(void) throw ()
|
||||||
|
{
|
||||||
|
return configElementNameStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the scheduler daemon based on the XML element
|
||||||
|
* supplied.
|
||||||
|
*
|
||||||
|
* @param element the XML element to configure the scheduler
|
||||||
|
* daemon from.
|
||||||
|
* @exception std::invalid_argument if the supplied XML element
|
||||||
|
* contains bad configuraiton information
|
||||||
|
* @exception std::logic_error if the object has already
|
||||||
|
* been configured.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
configure(const xmlpp::Element & element)
|
||||||
|
throw (std::invalid_argument,
|
||||||
|
std::logic_error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the main window, and run the application.
|
||||||
|
* This call will only return after the main window has been closed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
show(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform authentication for the user of the application.
|
||||||
|
* As a result, the user will be authenticated for later
|
||||||
|
* actions, that need authentication.
|
||||||
|
* The user has to be logged out later.
|
||||||
|
*
|
||||||
|
* @param login the login ID of the user
|
||||||
|
* @param password the password of the user
|
||||||
|
* @return true if the authentication was successful,
|
||||||
|
* false otherwise
|
||||||
|
* @see #logout
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
login(const std::string & login,
|
||||||
|
const std::string & password) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the session id for the user.
|
||||||
|
*
|
||||||
|
* @return the session id for the user, if he has been already
|
||||||
|
* successfully authenticated with a call to login(),
|
||||||
|
* and not yet logged out.
|
||||||
|
* otherwise, a reference to 0.
|
||||||
|
* @see #login
|
||||||
|
*/
|
||||||
|
Ptr<SessionId>::Ref
|
||||||
|
getSessionId(void) const throw ()
|
||||||
|
{
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log out the user, if he has been authenticated previously
|
||||||
|
* with a successful call to login().
|
||||||
|
*
|
||||||
|
* @see #logout
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
logout(void) throw ();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ================================================= external data structures */
|
||||||
|
|
||||||
|
|
||||||
|
/* ====================================================== function prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace GLiveSupport
|
||||||
|
} // namespace LiveSupport
|
||||||
|
|
||||||
|
#endif // GLiveSupport_h
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -70,3 +70,23 @@ GtkLocalizedObject :: unicodeStringToUstring(
|
||||||
return ustr;
|
return ustr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Create an ICU UnicodeString from a Glib ustring
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<UnicodeString>::Ref
|
||||||
|
GtkLocalizedObject :: ustringToUnicodeString(
|
||||||
|
Ptr<const Glib::ustring>::Ref gString)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
Ptr<UnicodeString>::Ref uString(new UnicodeString());
|
||||||
|
|
||||||
|
Glib::ustring::const_iterator it = gString->begin();
|
||||||
|
Glib::ustring::const_iterator end = gString->end();
|
||||||
|
while (it < end) {
|
||||||
|
uString->append((UChar32) *it++);
|
||||||
|
}
|
||||||
|
|
||||||
|
return uString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -62,7 +62,7 @@ using namespace LiveSupport::Core;
|
||||||
* Base class for localized objects, using GTK+ strings.
|
* Base class for localized objects, using GTK+ strings.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
*/
|
*/
|
||||||
class GtkLocalizedObject : public LocalizedObject
|
class GtkLocalizedObject : public LocalizedObject
|
||||||
{
|
{
|
||||||
|
@ -89,13 +89,23 @@ class GtkLocalizedObject : public LocalizedObject
|
||||||
/**
|
/**
|
||||||
* Convert an ICU unicode string to a Glib ustring.
|
* Convert an ICU unicode string to a Glib ustring.
|
||||||
*
|
*
|
||||||
* @param unicodeString the ICU unicode string to conver.
|
* @param unicodeString the ICU unicode string to convert.
|
||||||
* @return the same string as supplied, in Glib ustring form.
|
* @return the same string as supplied, in Glib ustring form.
|
||||||
*/
|
*/
|
||||||
static Ptr<Glib::ustring>::Ref
|
static Ptr<Glib::ustring>::Ref
|
||||||
unicodeStringToUstring(Ptr<const UnicodeString>::Ref unicodeString)
|
unicodeStringToUstring(Ptr<const UnicodeString>::Ref unicodeString)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a Glib ustring to an ICU unicode string.
|
||||||
|
*
|
||||||
|
* @param gString the Glib ustring to convert
|
||||||
|
* @return the same string as supplied, in ICU unicode form.
|
||||||
|
*/
|
||||||
|
static Ptr<UnicodeString>::Ref
|
||||||
|
ustringToUnicodeString(Ptr<const Glib::ustring>::Ref gString)
|
||||||
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string from the resource bundle, as a Glib ustring.
|
* Get a string from the resource bundle, as a Glib ustring.
|
||||||
*
|
*
|
||||||
|
@ -110,6 +120,33 @@ class GtkLocalizedObject : public LocalizedObject
|
||||||
{
|
{
|
||||||
return unicodeStringToUstring(getResourceString(key));
|
return unicodeStringToUstring(getResourceString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A convenience function to format a message, based on a pattern
|
||||||
|
* loaded from a resource.
|
||||||
|
* For more information, see the ICU MessageFormat class
|
||||||
|
* documentation.
|
||||||
|
*
|
||||||
|
* @param patternKey the key of the pattern to format
|
||||||
|
* @param arguments the arguments to use in the formatting
|
||||||
|
* @param nArguments the number of arguments supplied
|
||||||
|
* @return the formatted string, in Glib ustring form
|
||||||
|
* @exception std::invalid_argument if the pattern is bad, or
|
||||||
|
* the arguments do not match, or there is no resource
|
||||||
|
* specified by patternKey
|
||||||
|
* @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html
|
||||||
|
*/
|
||||||
|
virtual Ptr<Glib::ustring>::Ref
|
||||||
|
formatMessageUstring(const char * patternKey,
|
||||||
|
Formattable * arguments,
|
||||||
|
unsigned int nArguments)
|
||||||
|
throw (std::invalid_argument)
|
||||||
|
{
|
||||||
|
return unicodeStringToUstring(formatMessage(patternKey,
|
||||||
|
arguments,
|
||||||
|
nArguments));
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================= external data structures */
|
/* ================================================= external data structures */
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -176,8 +176,8 @@ LoginWindow :: ~LoginWindow (void) throw ()
|
||||||
void
|
void
|
||||||
LoginWindow :: onOkButtonClicked (void) throw ()
|
LoginWindow :: onOkButtonClicked (void) throw ()
|
||||||
{
|
{
|
||||||
loginText.reset(new std::string(loginEntry->get_text()));
|
loginText.reset(new Glib::ustring(loginEntry->get_text()));
|
||||||
passwordText.reset(new std::string(passwordEntry->get_text()));
|
passwordText.reset(new Glib::ustring(passwordEntry->get_text()));
|
||||||
|
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LoginWindow.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -70,7 +70,7 @@ using namespace LiveSupport::Core;
|
||||||
* A window, handling user login.
|
* A window, handling user login.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
{
|
{
|
||||||
|
@ -109,12 +109,12 @@ class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
/**
|
/**
|
||||||
* The login text, that was entered by the user.
|
* The login text, that was entered by the user.
|
||||||
*/
|
*/
|
||||||
Ptr<std::string>::Ref loginText;
|
Ptr<Glib::ustring>::Ref loginText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The password text, that was entered by the user.
|
* The password text, that was entered by the user.
|
||||||
*/
|
*/
|
||||||
Ptr<std::string>::Ref passwordText;
|
Ptr<Glib::ustring>::Ref passwordText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal handler for the ok button clicked.
|
* Signal handler for the ok button clicked.
|
||||||
|
@ -143,7 +143,7 @@ class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
*
|
*
|
||||||
* @return the login entered by the user.
|
* @return the login entered by the user.
|
||||||
*/
|
*/
|
||||||
Ptr<const std::string>::Ref
|
Ptr<const Glib::ustring>::Ref
|
||||||
getLogin(void) const throw ()
|
getLogin(void) const throw ()
|
||||||
{
|
{
|
||||||
return loginText;
|
return loginText;
|
||||||
|
@ -154,7 +154,7 @@ class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
*
|
*
|
||||||
* @return the password entered by the user.
|
* @return the password entered by the user.
|
||||||
*/
|
*/
|
||||||
Ptr<const std::string>::Ref
|
Ptr<const Glib::ustring>::Ref
|
||||||
getPassword(void) const throw ()
|
getPassword(void) const throw ()
|
||||||
{
|
{
|
||||||
return passwordText;
|
return passwordText;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -34,7 +34,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <unicode/msgfmt.h>
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
|
#include <gtkmm/messagedialog.h>
|
||||||
|
|
||||||
#include "LoginWindow.h"
|
#include "LoginWindow.h"
|
||||||
#include "UiTestMainWindow.h"
|
#include "UiTestMainWindow.h"
|
||||||
|
@ -56,31 +58,46 @@ using namespace LiveSupport::GLiveSupport;
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
UiTestMainWindow :: UiTestMainWindow (Ptr<ResourceBundle>::Ref bundle)
|
UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
|
Ptr<ResourceBundle>::Ref bundle)
|
||||||
throw ()
|
throw ()
|
||||||
: GtkLocalizedObject(bundle)
|
: GtkLocalizedObject(bundle)
|
||||||
{
|
{
|
||||||
// set up the quit button
|
this->gLiveSupport = gLiveSupport;
|
||||||
quitButton.reset(new Gtk::Button("quit"));
|
|
||||||
quitButton->signal_clicked().connect(sigc::mem_fun(*this,
|
// set up the status label
|
||||||
&UiTestMainWindow::onQuitButtonClicked));
|
statusLabel.reset(new Gtk::Label(*getResourceUstring("welcomeMsg")));
|
||||||
|
|
||||||
// set up the login button
|
// set up the login button
|
||||||
loginButton.reset(new Gtk::Button("loginWindow"));
|
loginButton.reset(new Gtk::Button("loginWindow"));
|
||||||
loginButton->signal_clicked().connect(sigc::mem_fun(*this,
|
loginButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||||
&UiTestMainWindow::onLoginButtonClicked));
|
&UiTestMainWindow::onLoginButtonClicked));
|
||||||
|
|
||||||
|
// set up the logout button
|
||||||
|
logoutButton.reset(new Gtk::Button("logout"));
|
||||||
|
logoutButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||||
|
&UiTestMainWindow::onLogoutButtonClicked));
|
||||||
|
|
||||||
|
// set up the quit button
|
||||||
|
quitButton.reset(new Gtk::Button("quit"));
|
||||||
|
quitButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||||
|
&UiTestMainWindow::onQuitButtonClicked));
|
||||||
|
|
||||||
// set up the layout, which is a button box
|
// set up the layout, which is a button box
|
||||||
layout.reset(new Gtk::VButtonBox());
|
layout.reset(new Gtk::VButtonBox());
|
||||||
|
|
||||||
// set up the main window, and show everything
|
// set up the main window, and show everything
|
||||||
set_border_width(10);
|
set_border_width(10);
|
||||||
|
layout->add(*statusLabel);
|
||||||
layout->add(*loginButton);
|
layout->add(*loginButton);
|
||||||
|
layout->add(*logoutButton);
|
||||||
layout->add(*quitButton);
|
layout->add(*quitButton);
|
||||||
add(*layout);
|
add(*layout);
|
||||||
|
|
||||||
// show everything
|
// show everything
|
||||||
|
statusLabel->show();
|
||||||
loginButton->show();
|
loginButton->show();
|
||||||
|
logoutButton->show();
|
||||||
quitButton->show();
|
quitButton->show();
|
||||||
layout->show();
|
layout->show();
|
||||||
show();
|
show();
|
||||||
|
@ -95,6 +112,17 @@ UiTestMainWindow :: ~UiTestMainWindow (void) throw ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Event handler for the logout getting clicked.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
UiTestMainWindow :: onLogoutButtonClicked (void) throw ()
|
||||||
|
{
|
||||||
|
gLiveSupport->logout();
|
||||||
|
statusLabel->set_label(*getResourceUstring("welcomeMsg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Event handler for the quit getting clicked.
|
* Event handler for the quit getting clicked.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -123,7 +151,18 @@ UiTestMainWindow :: onLoginButtonClicked (void) throw ()
|
||||||
|
|
||||||
Gtk::Main::run(*loginWindow);
|
Gtk::Main::run(*loginWindow);
|
||||||
|
|
||||||
std::cout << "login: " << *loginWindow->getLogin() << std::endl;
|
Ptr<const Glib::ustring>::Ref login = loginWindow->getLogin();
|
||||||
std::cout << "password: " << *loginWindow->getPassword() << std::endl;
|
Ptr<const Glib::ustring>::Ref password = loginWindow->getPassword();
|
||||||
|
|
||||||
|
bool loggedIn = gLiveSupport->login(login->raw(), password->raw());
|
||||||
|
|
||||||
|
if (loggedIn) {
|
||||||
|
Ptr<UnicodeString>::Ref uLogin = ustringToUnicodeString(login);
|
||||||
|
Formattable arguments[] = { *uLogin };
|
||||||
|
Ptr<Glib::ustring>::Ref msg = formatMessageUstring("loggedInMsg",
|
||||||
|
arguments, 1);
|
||||||
|
|
||||||
|
statusLabel->set_label(*msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.2 $
|
Version : $Revision: 1.3 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/UiTestMainWindow.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -47,6 +47,7 @@
|
||||||
#include "LiveSupport/Core/Ptr.h"
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
|
||||||
#include "GtkLocalizedObject.h"
|
#include "GtkLocalizedObject.h"
|
||||||
|
#include "GLiveSupport.h"
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace GLiveSupport {
|
namespace GLiveSupport {
|
||||||
|
@ -65,7 +66,7 @@ using namespace LiveSupport::Core;
|
||||||
* A window, enabling interactive testing of UI components.
|
* A window, enabling interactive testing of UI components.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
{
|
{
|
||||||
|
@ -75,6 +76,11 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
*/
|
*/
|
||||||
Ptr<Gtk::VButtonBox>::Ref layout;
|
Ptr<Gtk::VButtonBox>::Ref layout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A label to display the status of the user.
|
||||||
|
*/
|
||||||
|
Ptr<Gtk::Label>::Ref statusLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The to quit the applicaiton.
|
* The to quit the applicaiton.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +91,16 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
*/
|
*/
|
||||||
Ptr<Gtk::Button>::Ref loginButton;
|
Ptr<Gtk::Button>::Ref loginButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The button to log out.
|
||||||
|
*/
|
||||||
|
Ptr<Gtk::Button>::Ref logoutButton;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The gLiveSupport object, handling the logic of the application.
|
||||||
|
*/
|
||||||
|
Ptr<GLiveSupport>::Ref gLiveSupport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signal handler for the quit button clicked.
|
* Signal handler for the quit button clicked.
|
||||||
*/
|
*/
|
||||||
|
@ -97,14 +113,23 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||||
virtual void
|
virtual void
|
||||||
onLoginButtonClicked(void) throw ();
|
onLoginButtonClicked(void) throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signal handler for the logout button clicked.
|
||||||
|
*/
|
||||||
|
virtual void
|
||||||
|
onLogoutButtonClicked(void) throw ();
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
|
* @param gLiveSupport the gLiveSupport object, handling the
|
||||||
|
* logic of the application
|
||||||
* @param bundle the resource bundle holding localized resources
|
* @param bundle the resource bundle holding localized resources
|
||||||
*/
|
*/
|
||||||
UiTestMainWindow(Ptr<ResourceBundle>::Ref bundle)
|
UiTestMainWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||||
|
Ptr<ResourceBundle>::Ref bundle)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.3 $
|
Version : $Revision: 1.4 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/main.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/main.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -37,15 +37,22 @@
|
||||||
#include "configure.h"
|
#include "configure.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_GETOPT_H
|
||||||
|
#include <getopt.h>
|
||||||
|
#else
|
||||||
|
#error "Need getopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <unicode/resbund.h>
|
#include <unicode/resbund.h>
|
||||||
|
#include <libxml++/libxml++.h>
|
||||||
#include <gtkmm/main.h>
|
#include <gtkmm/main.h>
|
||||||
|
|
||||||
#include "LiveSupport/Core/Ptr.h"
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
#include "LiveSupport/Core/LocalizedObject.h"
|
#include "LiveSupport/Core/LocalizedObject.h"
|
||||||
|
|
||||||
#include "UiTestMainWindow.h"
|
#include "GLiveSupport.h"
|
||||||
|
|
||||||
using namespace LiveSupport::Core;
|
using namespace LiveSupport::Core;
|
||||||
using namespace LiveSupport::GLiveSupport;
|
using namespace LiveSupport::GLiveSupport;
|
||||||
|
@ -55,9 +62,49 @@ using namespace LiveSupport::GLiveSupport;
|
||||||
|
|
||||||
/* ================================================ local constants & macros */
|
/* ================================================ local constants & macros */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our copyright notice, should be at most 80 columns
|
||||||
|
*/
|
||||||
|
static const char copyrightNotice[] =
|
||||||
|
"Copyright (c) 2004 Media Development Loan Fund under the GNU GPL";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* String describing the short options.
|
||||||
|
*/
|
||||||
|
static const char options[] = "c:hv";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure describing the long options
|
||||||
|
*/
|
||||||
|
static const struct option longOptions[] = {
|
||||||
|
{ "config", required_argument, 0, 'c' },
|
||||||
|
{ "help", no_argument, 0, 'h' },
|
||||||
|
{ "version", no_argument, 0, 'v' },
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* =============================================== local function prototypes */
|
/* =============================================== local function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print program version.
|
||||||
|
*
|
||||||
|
* @param os the std::ostream to print to.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
printVersion ( std::ostream & os );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print program usage information.
|
||||||
|
*
|
||||||
|
* @param invocation the command line command used to invoke this program.
|
||||||
|
* @param os the std::ostream to print to.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
printUsage ( const char invocation[],
|
||||||
|
std::ostream & os );
|
||||||
|
|
||||||
|
|
||||||
/* ============================================================= module code */
|
/* ============================================================= module code */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,30 +117,92 @@ using namespace LiveSupport::GLiveSupport;
|
||||||
int main ( int argc,
|
int main ( int argc,
|
||||||
char * argv[] )
|
char * argv[] )
|
||||||
{
|
{
|
||||||
|
// initialize the Gtk library, with the Gtk options first
|
||||||
Gtk::Main kit(argc, argv);
|
Gtk::Main kit(argc, argv);
|
||||||
|
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
// take a look at our options
|
||||||
Ptr<ResourceBundle>::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME,
|
int i;
|
||||||
"en",
|
std::string configFileName;
|
||||||
status));
|
|
||||||
if (!U_SUCCESS(status)) {
|
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
|
||||||
std::cerr << "opening resource bundle a failure" << std::endl;
|
switch (i) {
|
||||||
|
case 'c':
|
||||||
|
configFileName = optarg;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
case 'v':
|
||||||
|
printVersion(std::cout);
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
|
||||||
|
default:
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc) {
|
||||||
|
printUsage(argv[0], std::cout);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<UiTestMainWindow>::Ref mainWindow(new UiTestMainWindow(bundle));
|
std::cerr << "using config file '" << configFileName << '\'' << std::endl;
|
||||||
|
|
||||||
|
Ptr<GLiveSupport>::Ref gLiveSupport(new GLiveSupport());
|
||||||
|
|
||||||
Ptr<ResourceBundle>::Ref loginBundle;
|
|
||||||
try {
|
try {
|
||||||
loginBundle = mainWindow->getBundle("loginWindow");
|
std::auto_ptr<xmlpp::DomParser>
|
||||||
|
parser(new xmlpp::DomParser(configFileName, true));
|
||||||
|
const xmlpp::Document * document = parser->get_document();
|
||||||
|
gLiveSupport->configure(*(document->get_root_node()));
|
||||||
} catch (std::invalid_argument &e) {
|
} catch (std::invalid_argument &e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << "semantic error in configuration file" << std::endl
|
||||||
|
<< e.what() << std::endl;
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
} catch (xmlpp::exception &e) {
|
||||||
|
std::cerr << "error parsing configuration file" << std::endl
|
||||||
|
<< e.what() << std::endl;
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shows the window and returns when it is closed.
|
gLiveSupport->show();
|
||||||
Gtk::Main::run(*mainWindow);
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Print program version.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
printVersion ( std::ostream & os )
|
||||||
|
{
|
||||||
|
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||||
|
<< copyrightNotice << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Print program usage.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
printUsage ( const char invocation[],
|
||||||
|
std::ostream & os )
|
||||||
|
{
|
||||||
|
os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl
|
||||||
|
<< std::endl
|
||||||
|
<< "Usage: " << invocation << " [OPTION]"
|
||||||
|
<< std::endl
|
||||||
|
<< " mandatory options:" << std::endl
|
||||||
|
<< " -c, --config=file.name scheduler configuration file" << std::endl
|
||||||
|
<< " optional options:" << std::endl
|
||||||
|
<< " -h, --help display this help and exit" << std::endl
|
||||||
|
<< " -v, --version display version information and exit"
|
||||||
|
<< std::endl
|
||||||
|
<< std::endl
|
||||||
|
<< "Report bugs to " << PACKAGE_BUGREPORT << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
hu:table
|
hu:table
|
||||||
{
|
{
|
||||||
|
welcomeMsg:string { "Üdvözöljük" }
|
||||||
|
loggedInMsg:string { "Bejelentkezve {0} felhasználóként" }
|
||||||
|
|
||||||
loginWindow:table
|
loginWindow:table
|
||||||
{
|
{
|
||||||
loginLabel:string { "azonositó:" }
|
loginLabel:string { "azonositó:" }
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
root:table
|
root:table
|
||||||
{
|
{
|
||||||
|
welcomeMsg:string { "welcome" }
|
||||||
|
loggedInMsg:string { "Logged in as {0}" }
|
||||||
|
|
||||||
loginWindow:table
|
loginWindow:table
|
||||||
{
|
{
|
||||||
loginLabel:string { "login:" }
|
loginLabel:string { "login:" }
|
||||||
|
|
Loading…
Reference in New Issue