added GLiveSupport application object
This commit is contained in:
parent
70968ffbcf
commit
80d1a0915f
|
@ -21,7 +21,7 @@
|
|||
#
|
||||
#
|
||||
# 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 $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -72,6 +72,12 @@ CORE_LIB_DIR = ${CORE_DIR}/lib
|
|||
CORE_LIB = livesupport_core
|
||||
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_INCLUDE_DIR = ${STORAGE_DIR}/include
|
||||
STORAGE_LIB_DIR = ${STORAGE_DIR}/lib
|
||||
|
@ -90,6 +96,7 @@ TEST_XSLT = ../etc/testResultToHtml.xsl
|
|||
|
||||
G_LIVESUPPORT_EXE = ${TMP_DIR}/gLiveSupport
|
||||
G_LIVESUPPORT_CFG = ${ETC_DIR}/gLiveSupport.xml
|
||||
G_LIVESUPPORT_CFG = ${ETC_DIR}/gLiveSupport.xml
|
||||
TEST_RUNNER = ${TMP_DIR}/testRunner
|
||||
|
||||
DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config
|
||||
|
@ -109,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
-I${BOOST_INCLUDE_DIR} \
|
||||
-I${LIBXMLPP_INCLUDE_DIR} \
|
||||
-I${CORE_INCLUDE_DIR} \
|
||||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${STORAGE_INCLUDE_DIR} \
|
||||
-I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
|
@ -116,13 +124,15 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${GTKMM_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
-L${STORAGE_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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}/LoginWindow.o
|
||||
|
||||
|
@ -135,6 +145,7 @@ G_LIVESUPPORT_EXE_OBJS = ${TMP_DIR}/main.o
|
|||
FSDF = ${G_LIVESUPPORT_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
G_LIVESUPPORT_EXE_LIBS = -l${CORE_LIB} \
|
||||
-l${AUTHENTICATION_LIB} \
|
||||
-lboost_date_time-gcc \
|
||||
-lxmlrpc++ -lssl -lxml++-1.0
|
||||
|
||||
|
@ -168,6 +179,7 @@ docclean:
|
|||
|
||||
depclean: clean
|
||||
${MAKE} -C ${STORAGE_DIR} clean
|
||||
${MAKE} -C ${AUTHENTICATION_DIR} clean
|
||||
${MAKE} -C ${CORE_DIR} clean
|
||||
|
||||
distclean: clean docclean
|
||||
|
@ -179,13 +191,15 @@ run_tests: ${TEST_RUNNER}
|
|||
${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT}
|
||||
|
||||
run: all
|
||||
${G_LIVESUPPORT_EXE}
|
||||
${G_LIVESUPPORT_EXE} -c ${G_LIVESUPPORT_CFG}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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}
|
||||
${CXX} ${LDFLAGS} -o $@ $^ ${G_LIVESUPPORT_EXE_LIBS}
|
||||
|
||||
|
@ -195,13 +209,18 @@ ${TMP_DIR}:
|
|||
${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}
|
||||
${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS}
|
||||
|
||||
${CORE_LIB_FILE}:
|
||||
${MAKE} -C ${CORE_DIR}
|
||||
|
||||
${AUTHENTICATION_LIB_FILE}:
|
||||
${MAKE} -C ${AUTHENTICATION_DIR}
|
||||
|
||||
${STORAGE_LIB_FILE}:
|
||||
${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 $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/GtkLocalizedObject.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,3 +70,23 @@ GtkLocalizedObject :: unicodeStringToUstring(
|
|||
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 $
|
||||
Version : $Revision: 1.1 $
|
||||
Version : $Revision: 1.2 $
|
||||
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.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
class GtkLocalizedObject : public LocalizedObject
|
||||
{
|
||||
|
@ -89,13 +89,23 @@ class GtkLocalizedObject : public LocalizedObject
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
static Ptr<Glib::ustring>::Ref
|
||||
unicodeStringToUstring(Ptr<const UnicodeString>::Ref unicodeString)
|
||||
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.
|
||||
*
|
||||
|
@ -110,6 +120,33 @@ class GtkLocalizedObject : public LocalizedObject
|
|||
{
|
||||
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 */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -176,8 +176,8 @@ LoginWindow :: ~LoginWindow (void) throw ()
|
|||
void
|
||||
LoginWindow :: onOkButtonClicked (void) throw ()
|
||||
{
|
||||
loginText.reset(new std::string(loginEntry->get_text()));
|
||||
passwordText.reset(new std::string(passwordEntry->get_text()));
|
||||
loginText.reset(new Glib::ustring(loginEntry->get_text()));
|
||||
passwordText.reset(new Glib::ustring(passwordEntry->get_text()));
|
||||
|
||||
hide();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,7 +70,7 @@ using namespace LiveSupport::Core;
|
|||
* A window, handling user login.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
Ptr<std::string>::Ref loginText;
|
||||
Ptr<Glib::ustring>::Ref loginText;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@ -143,7 +143,7 @@ class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
|||
*
|
||||
* @return the login entered by the user.
|
||||
*/
|
||||
Ptr<const std::string>::Ref
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
getLogin(void) const throw ()
|
||||
{
|
||||
return loginText;
|
||||
|
@ -154,7 +154,7 @@ class LoginWindow : public Gtk::Window, public GtkLocalizedObject
|
|||
*
|
||||
* @return the password entered by the user.
|
||||
*/
|
||||
Ptr<const std::string>::Ref
|
||||
Ptr<const Glib::ustring>::Ref
|
||||
getPassword(void) const throw ()
|
||||
{
|
||||
return passwordText;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -34,7 +34,9 @@
|
|||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <unicode/msgfmt.h>
|
||||
#include <gtkmm/main.h>
|
||||
#include <gtkmm/messagedialog.h>
|
||||
|
||||
#include "LoginWindow.h"
|
||||
#include "UiTestMainWindow.h"
|
||||
|
@ -56,31 +58,46 @@ using namespace LiveSupport::GLiveSupport;
|
|||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
UiTestMainWindow :: UiTestMainWindow (Ptr<ResourceBundle>::Ref bundle)
|
||||
UiTestMainWindow :: UiTestMainWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
: GtkLocalizedObject(bundle)
|
||||
{
|
||||
// set up the quit button
|
||||
quitButton.reset(new Gtk::Button("quit"));
|
||||
quitButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&UiTestMainWindow::onQuitButtonClicked));
|
||||
this->gLiveSupport = gLiveSupport;
|
||||
|
||||
// set up the status label
|
||||
statusLabel.reset(new Gtk::Label(*getResourceUstring("welcomeMsg")));
|
||||
|
||||
// set up the login button
|
||||
loginButton.reset(new Gtk::Button("loginWindow"));
|
||||
loginButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&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
|
||||
layout.reset(new Gtk::VButtonBox());
|
||||
|
||||
// set up the main window, and show everything
|
||||
set_border_width(10);
|
||||
layout->add(*statusLabel);
|
||||
layout->add(*loginButton);
|
||||
layout->add(*logoutButton);
|
||||
layout->add(*quitButton);
|
||||
add(*layout);
|
||||
|
||||
// show everything
|
||||
statusLabel->show();
|
||||
loginButton->show();
|
||||
logoutButton->show();
|
||||
quitButton->show();
|
||||
layout->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.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -123,7 +151,18 @@ UiTestMainWindow :: onLoginButtonClicked (void) throw ()
|
|||
|
||||
Gtk::Main::run(*loginWindow);
|
||||
|
||||
std::cout << "login: " << *loginWindow->getLogin() << std::endl;
|
||||
std::cout << "password: " << *loginWindow->getPassword() << std::endl;
|
||||
Ptr<const Glib::ustring>::Ref login = loginWindow->getLogin();
|
||||
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 $
|
||||
Version : $Revision: 1.2 $
|
||||
Version : $Revision: 1.3 $
|
||||
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 "GtkLocalizedObject.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
@ -65,7 +66,7 @@ using namespace LiveSupport::Core;
|
|||
* A window, enabling interactive testing of UI components.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
||||
{
|
||||
|
@ -75,6 +76,11 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
|||
*/
|
||||
Ptr<Gtk::VButtonBox>::Ref layout;
|
||||
|
||||
/**
|
||||
* A label to display the status of the user.
|
||||
*/
|
||||
Ptr<Gtk::Label>::Ref statusLabel;
|
||||
|
||||
/**
|
||||
* The to quit the applicaiton.
|
||||
*/
|
||||
|
@ -85,6 +91,16 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -97,14 +113,23 @@ class UiTestMainWindow : public Gtk::Window, public GtkLocalizedObject
|
|||
virtual void
|
||||
onLoginButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Signal handler for the logout button clicked.
|
||||
*/
|
||||
virtual void
|
||||
onLogoutButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, handling the
|
||||
* logic of the application
|
||||
* @param bundle the resource bundle holding localized resources
|
||||
*/
|
||||
UiTestMainWindow(Ptr<ResourceBundle>::Ref bundle)
|
||||
UiTestMainWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
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 $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -37,15 +37,22 @@
|
|||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#else
|
||||
#error "Need getopt.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <unicode/resbund.h>
|
||||
#include <libxml++/libxml++.h>
|
||||
#include <gtkmm/main.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
|
||||
#include "UiTestMainWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
@ -55,9 +62,49 @@ using namespace LiveSupport::GLiveSupport;
|
|||
|
||||
/* ================================================ 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 */
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
|
||||
/**
|
||||
|
@ -70,30 +117,92 @@ using namespace LiveSupport::GLiveSupport;
|
|||
int main ( int argc,
|
||||
char * argv[] )
|
||||
{
|
||||
// initialize the Gtk library, with the Gtk options first
|
||||
Gtk::Main kit(argc, argv);
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
Ptr<ResourceBundle>::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME,
|
||||
"en",
|
||||
status));
|
||||
if (!U_SUCCESS(status)) {
|
||||
std::cerr << "opening resource bundle a failure" << std::endl;
|
||||
// take a look at our options
|
||||
int i;
|
||||
std::string configFileName;
|
||||
|
||||
while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) {
|
||||
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);
|
||||
}
|
||||
|
||||
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 {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
// Shows the window and returns when it is closed.
|
||||
Gtk::Main::run(*mainWindow);
|
||||
gLiveSupport->show();
|
||||
|
||||
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
|
||||
{
|
||||
welcomeMsg:string { "Üdvözöljük" }
|
||||
loggedInMsg:string { "Bejelentkezve {0} felhasználóként" }
|
||||
|
||||
loginWindow:table
|
||||
{
|
||||
loginLabel:string { "azonositó:" }
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
root:table
|
||||
{
|
||||
welcomeMsg:string { "welcome" }
|
||||
loggedInMsg:string { "Logged in as {0}" }
|
||||
|
||||
loginWindow:table
|
||||
{
|
||||
loginLabel:string { "login:" }
|
||||
|
|
Loading…
Reference in New Issue