added upload file window
This commit is contained in:
parent
763065a092
commit
cdec145255
|
@ -20,8 +20,8 @@
|
|||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#
|
||||
# Author : $Author: fgerlits $
|
||||
# Version : $Revision: 1.16 $
|
||||
# Author : $Author: maroy $
|
||||
# Version : $Revision: 1.17 $
|
||||
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/etc/Makefile.in,v $
|
||||
#
|
||||
# @configure_input@
|
||||
|
@ -55,6 +55,13 @@ USR_LIB_DIR = ${USR_DIR}/lib
|
|||
USR_BIN_DIR = ${USR_DIR}/bin
|
||||
BOOST_INCLUDE_DIR = ${USR_INCLUDE_DIR}/boost-1_31
|
||||
|
||||
HELIX_LIB_DIR = ${USR_LIB_DIR}/helix
|
||||
HELIX_LIBS = ${HELIX_LIB_DIR}/runtlib.a \
|
||||
${HELIX_LIB_DIR}/syslib.a \
|
||||
${HELIX_LIB_DIR}/contlib.a \
|
||||
${HELIX_LIB_DIR}/debuglib.a \
|
||||
${HELIX_LIB_DIR}/utillib.a
|
||||
|
||||
GENRB = ${USR_BIN_DIR}/genrb
|
||||
GENRBOPTS = --destdir ${TMP_DIR} \
|
||||
--encoding utf-8 \
|
||||
|
@ -89,6 +96,11 @@ SCHEDULER_CLIENT_LIB_DIR = ${SCHEDULER_CLIENT_DIR}/lib
|
|||
SCHEDULER_CLIENT_LIB = livesupport_scheduler_client
|
||||
SCHEDULER_CLIENT_LIB_FILE = ${SCHEDULER_CLIENT_LIB_DIR}/lib${SCHEDULER_CLIENT_LIB}.a
|
||||
|
||||
PLAYLIST_EXECUTOR_DIR = ${MODULES_DIR}/playlistExecutor
|
||||
PLAYLIST_EXECUTOR_INCLUDE_DIR = ${PLAYLIST_EXECUTOR_DIR}/include
|
||||
PLAYLIST_EXECUTOR_LIB_DIR = ${PLAYLIST_EXECUTOR_DIR}/lib
|
||||
PLAYLIST_EXECUTOR_LIB = livesupport_playlist_executor
|
||||
PLAYLIST_EXECUTOR_LIB_FILE = ${PLAYLIST_EXECUTOR_LIB_DIR}/lib${PLAYLIST_EXECUTOR_LIB}.a
|
||||
LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@
|
||||
LIBXMLPP_LIBS=@LIBXMLPP_LIBS@
|
||||
|
||||
|
@ -129,6 +141,7 @@ CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \
|
|||
-I${AUTHENTICATION_INCLUDE_DIR} \
|
||||
-I${STORAGE_INCLUDE_DIR} \
|
||||
-I${SCHEDULER_CLIENT_INCLUDE_DIR} \
|
||||
-I${PLAYLIST_EXECUTOR_INCLUDE_DIR} \
|
||||
-I${TMP_DIR}
|
||||
LDFLAGS = @LDFLAGS@ -pthread \
|
||||
${ICU_LIBS} \
|
||||
|
@ -136,10 +149,12 @@ LDFLAGS = @LDFLAGS@ -pthread \
|
|||
${CURL_LIBS} \
|
||||
${GTKMM_LIBS} \
|
||||
-L${USR_LIB_DIR} \
|
||||
-L${HELIX_LIB_DIR} \
|
||||
-L${CORE_LIB_DIR} \
|
||||
-L${AUTHENTICATION_LIB_DIR} \
|
||||
-L${STORAGE_LIB_DIR} \
|
||||
-L${SCHEDULER_CLIENT_LIB_DIR}
|
||||
-L${SCHEDULER_CLIENT_LIB_DIR} \
|
||||
-L${PLAYLIST_EXECUTOR_LIB_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -151,7 +166,8 @@ G_LIVESUPPORT_OBJS = ${TMP_DIR}/GLiveSupport.o \
|
|||
${TMP_DIR}/MasterPanelUserInfoWidget.o \
|
||||
${TMP_DIR}/LoginWindow.o \
|
||||
${TMP_DIR}/AudioClipListWindow.o \
|
||||
${TMP_DIR}/PlaylistListWindow.o
|
||||
${TMP_DIR}/PlaylistListWindow.o \
|
||||
${TMP_DIR}/UploadFileWindow.o
|
||||
|
||||
G_LIVESUPPORT_RES = ${TMP_DIR}/${PACKAGE_NAME}_root.res \
|
||||
${TMP_DIR}/${PACKAGE_NAME}_en.res \
|
||||
|
@ -161,10 +177,12 @@ G_LIVESUPPORT_EXE_OBJS = ${TMP_DIR}/main.o
|
|||
|
||||
FSDF = ${G_LIVESUPPORT_OBJS} \
|
||||
${TMP_DIR}/main.o
|
||||
G_LIVESUPPORT_EXE_LIBS = -l${AUTHENTICATION_LIB} \
|
||||
G_LIVESUPPORT_EXE_LIBS = -l${PLAYLIST_EXECUTOR_LIB} \
|
||||
-l${AUTHENTICATION_LIB} \
|
||||
-l${STORAGE_LIB} \
|
||||
-l${SCHEDULER_CLIENT_LIB} \
|
||||
-l${CORE_LIB} \
|
||||
${HELIX_LIBS} \
|
||||
-lboost_date_time-gcc \
|
||||
-lxmlrpc++ -lssl
|
||||
|
||||
|
@ -197,6 +215,7 @@ docclean:
|
|||
${RM} ${TEST_RESULTS}
|
||||
|
||||
depclean: clean
|
||||
${MAKE} -C ${PLAYLIST_EXECUTOR_DIR} clean
|
||||
${MAKE} -C ${SCHEDULER_CLIENT_DIR} clean
|
||||
${MAKE} -C ${STORAGE_DIR} clean
|
||||
${MAKE} -C ${AUTHENTICATION_DIR} clean
|
||||
|
@ -221,6 +240,7 @@ ${G_LIVESUPPORT_EXE}: ${CORE_LIB_FILE} \
|
|||
${AUTHENTICATION_LIB_FILE} \
|
||||
${STORAGE_LIB_FILE} \
|
||||
${SCHEDULER_CLIENT_LIB_FILE} \
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE} \
|
||||
${G_LIVESUPPORT_OBJS} ${G_LIVESUPPORT_EXE_OBJS}
|
||||
${CXX} ${LDFLAGS} -o $@ $^ ${G_LIVESUPPORT_EXE_LIBS}
|
||||
|
||||
|
@ -249,6 +269,9 @@ ${STORAGE_LIB_FILE}:
|
|||
${SCHEDULER_CLIENT_LIB_FILE}:
|
||||
${MAKE} -C ${SCHEDULER_CLIENT_DIR}
|
||||
|
||||
${PLAYLIST_EXECUTOR_LIB_FILE}:
|
||||
${MAKE} -C ${PLAYLIST_EXECUTOR_DIR}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Pattern rules
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
supportedLanguages,
|
||||
authenticationClientFactory,
|
||||
storageClientFactory,
|
||||
schedulerClientFactory) >
|
||||
schedulerClientFactory,
|
||||
audioPlayer) >
|
||||
|
||||
<!ELEMENT resourceBundle EMPTY >
|
||||
<!ATTLIST resourceBundle path CDATA #REQUIRED >
|
||||
|
@ -65,6 +66,11 @@
|
|||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
|
||||
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
|
||||
|
||||
<!ELEMENT audioPlayer (helixPlayer) >
|
||||
|
||||
<!ELEMENT helixPlayer EMPTY >
|
||||
<!ATTLIST helixPlayer dllPath CDATA #REQUIRED >
|
||||
|
||||
]>
|
||||
<gLiveSupport>
|
||||
<resourceBundle path = "./tmp/gLiveSupport"
|
||||
|
@ -130,5 +136,9 @@
|
|||
/>
|
||||
</schedulerClientFactory>
|
||||
|
||||
<audioPlayer>
|
||||
<helixPlayer dllPath = "../../usr/lib/helix"/>
|
||||
</audioPlayer>
|
||||
|
||||
</gLiveSupport>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.7 $
|
||||
Version : $Revision: 1.8 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -40,6 +40,7 @@
|
|||
#include "LiveSupport/Authentication/AuthenticationClientFactory.h"
|
||||
#include "LiveSupport/Storage/StorageClientFactory.h"
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientFactory.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerFactory.h"
|
||||
|
||||
#include "MasterPanelWindow.h"
|
||||
#include "GLiveSupport.h"
|
||||
|
@ -154,6 +155,17 @@ GLiveSupport :: configure(const xmlpp::Element & element)
|
|||
schcf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
scheduler = schcf->getSchedulerClient();
|
||||
|
||||
// configure the AudioPlayerFactory
|
||||
nodes = element.get_children(AudioPlayerFactory::getConfigElementName());
|
||||
if (nodes.size() < 1) {
|
||||
throw std::invalid_argument("no audioPlayer element");
|
||||
}
|
||||
Ptr<AudioPlayerFactory>::Ref apf = AudioPlayerFactory::getInstance();
|
||||
apf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
|
||||
|
||||
audioPlayer = apf->getAudioPlayer();
|
||||
audioPlayer->initialize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -251,3 +263,63 @@ GLiveSupport :: logout(void) throw ()
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Show the anonymous UI
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: showAnonymousUI(void) throw ()
|
||||
{
|
||||
if (masterPanel.get()) {
|
||||
masterPanel->showAnonymousUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Show the UI when someone is logged in
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: showLoggedInUI(void) throw ()
|
||||
{
|
||||
if (masterPanel.get()) {
|
||||
masterPanel->showLoggedInUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Upload a file to the server.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: uploadFile(Ptr<const Glib::ustring>::Ref title,
|
||||
Ptr<const std::string>::Ref fileName)
|
||||
throw (StorageException)
|
||||
{
|
||||
// create a URI from the file name
|
||||
Ptr<std::string>::Ref uri(new std::string("file://"));
|
||||
*uri += *fileName;
|
||||
|
||||
// determine the playlength of the audio clip
|
||||
Ptr<time_duration>::Ref playlength;
|
||||
try {
|
||||
audioPlayer->open(*uri);
|
||||
playlength = audioPlayer->getPlaylength();
|
||||
audioPlayer->close();
|
||||
} catch (std::invalid_argument &e) {
|
||||
throw StorageException(e.what());
|
||||
}
|
||||
|
||||
// get a unique id
|
||||
Ptr<UniqueId>::Ref uid = UniqueId::generateId();
|
||||
|
||||
// create and upload an AudioClip object
|
||||
Ptr<AudioClip>::Ref audioClip(new AudioClip(uid,
|
||||
title,
|
||||
playlength,
|
||||
uri));
|
||||
storage->storeAudioClip(sessionId, audioClip);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.9 $
|
||||
Version : $Revision: 1.10 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include "LiveSupport/Authentication/AuthenticationClientInterface.h"
|
||||
#include "LiveSupport/Storage/StorageClientInterface.h"
|
||||
#include "LiveSupport/SchedulerClient/SchedulerClientInterface.h"
|
||||
#include "LiveSupport/PlaylistExecutor/AudioPlayerInterface.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
@ -58,6 +59,7 @@ using namespace LiveSupport::Core;
|
|||
using namespace LiveSupport::SchedulerClient;
|
||||
using namespace LiveSupport::Authentication;
|
||||
using namespace LiveSupport::Storage;
|
||||
using namespace LiveSupport::PlaylistExecutor;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
@ -92,7 +94,7 @@ class MasterPanelWindow;
|
|||
* respective documentation.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.9 $
|
||||
* @version $Revision: 1.10 $
|
||||
* @see LocalizedObject#getBundle(const xmlpp::Element &)
|
||||
* @see AuthenticationClientFactory
|
||||
* @see StorageClientFactory
|
||||
|
@ -133,6 +135,11 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
*/
|
||||
Ptr<SchedulerClientInterface>::Ref scheduler;
|
||||
|
||||
/**
|
||||
* The audio player.
|
||||
*/
|
||||
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
||||
|
||||
/**
|
||||
* The session id for the user.
|
||||
*/
|
||||
|
@ -175,6 +182,9 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
virtual
|
||||
~GLiveSupport(void) throw ()
|
||||
{
|
||||
if (audioPlayer.get()) {
|
||||
audioPlayer->deInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,6 +303,30 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
return supportedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the UI components that are visible when no one is logged in.
|
||||
*/
|
||||
void
|
||||
showAnonymousUI(void) throw ();
|
||||
|
||||
/**
|
||||
* Show the UI components that are visible when someone is logged in.
|
||||
*/
|
||||
void
|
||||
showLoggedInUI(void) throw ();
|
||||
|
||||
/**
|
||||
* Upload a file to the storage.
|
||||
*
|
||||
* @param title the title of the audio clip.
|
||||
* @param fileName the full filename of the audio clip.
|
||||
* @exception StorageException on upload failures.
|
||||
*/
|
||||
void
|
||||
uploadFile(Ptr<const Glib::ustring>::Ref title,
|
||||
Ptr<const std::string>::Ref fileName)
|
||||
throw (StorageException);
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= 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/MasterPanelUserInfoWidget.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -124,6 +124,9 @@ MasterPanelUserInfoWidget :: onLogoutButtonClicked (void) throw ()
|
|||
logInOutSignalConnection =
|
||||
logInOutButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&MasterPanelUserInfoWidget::onLoginButtonClicked));
|
||||
|
||||
// show only the anonymous UI
|
||||
gLiveSupport->showAnonymousUI();
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,6 +169,7 @@ MasterPanelUserInfoWidget :: onLoginButtonClicked (void) throw ()
|
|||
} else {
|
||||
// TODO: get and set default locale for user
|
||||
}
|
||||
gLiveSupport->showLoggedInUI();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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/MasterPanelWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -36,8 +36,10 @@
|
|||
#include <iostream>
|
||||
#include <unicode/msgfmt.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/main.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "UploadFileWindow.h"
|
||||
#include "MasterPanelWindow.h"
|
||||
|
||||
|
||||
|
@ -71,6 +73,7 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
onAirWidget.reset(new Gtk::Label("on air"));
|
||||
radioLogoWidget.reset(new Gtk::Label("radio logo"));
|
||||
userInfoWidget.reset(new MasterPanelUserInfoWidget(gLiveSupport, bundle));
|
||||
uploadFileButton.reset(new Gtk::Button("upload file"));
|
||||
|
||||
// set up the time label
|
||||
timeWidget.reset(new Gtk::Label("time"));
|
||||
|
@ -88,14 +91,19 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
|||
layout->attach(*onAirWidget , 4, 5, 0, 1);
|
||||
layout->attach(*radioLogoWidget , 5, 6, 0, 1);
|
||||
layout->attach(*userInfoWidget , 4, 6, 1, 2);
|
||||
layout->attach(*uploadFileButton, 0, 1, 2, 3);
|
||||
|
||||
add(*layout);
|
||||
|
||||
// set the localized resources
|
||||
changeLanguage(bundle);
|
||||
|
||||
// show everything
|
||||
show_all();
|
||||
// bind events
|
||||
uploadFileButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&MasterPanelWindow::onUploadFileButtonClicked));
|
||||
|
||||
// show what's there to see
|
||||
showAnonymousUI();
|
||||
|
||||
// set the timer, that will update timeWidget
|
||||
setTimer();
|
||||
|
@ -181,3 +189,45 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The event when the upload file button has been clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: onUploadFileButtonClicked(void) throw ()
|
||||
{
|
||||
Ptr<ResourceBundle>::Ref bundle;
|
||||
try {
|
||||
// TODO: add and get the proper resource bundle for the upload window
|
||||
bundle = getBundle("loginWindow");
|
||||
} catch (std::invalid_argument &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Ptr<UploadFileWindow>::Ref uploadWindow(new UploadFileWindow(gLiveSupport,
|
||||
bundle));
|
||||
|
||||
Gtk::Main::run(*uploadWindow);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Show only the UI components that are visible when no one is logged in
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: showAnonymousUI(void) throw ()
|
||||
{
|
||||
show_all();
|
||||
uploadFileButton->hide();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Show the UI components that are visible to a specific user.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
MasterPanelWindow :: showLoggedInUI(void) throw ()
|
||||
{
|
||||
show_all();
|
||||
}
|
||||
|
||||
|
|
|
@ -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/MasterPanelWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -79,7 +79,7 @@ using namespace LiveSupport::Core;
|
|||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
||||
{
|
||||
|
@ -135,6 +135,11 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
*/
|
||||
Ptr<Gtk::Widget>::Ref radioLogoWidget;
|
||||
|
||||
/**
|
||||
* The button to invoke the upload file window.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref uploadFileButton;
|
||||
|
||||
/**
|
||||
* The gLiveSupport object, handling the logic of the application.
|
||||
*/
|
||||
|
@ -167,6 +172,13 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
virtual void
|
||||
resetTimer(void) throw ();
|
||||
|
||||
/**
|
||||
* Function to catch the event of the file upload button being
|
||||
* pressed.
|
||||
*/
|
||||
virtual void
|
||||
onUploadFileButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -199,6 +211,18 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
|||
void
|
||||
changeLanguage(Ptr<ResourceBundle>::Ref bundle) throw ();
|
||||
|
||||
/**
|
||||
* Show the UI components that are visible when no one is logged in.
|
||||
*/
|
||||
void
|
||||
showAnonymousUI(void) throw ();
|
||||
|
||||
/**
|
||||
* Show the UI components that are visible when someone is logged in.
|
||||
*/
|
||||
void
|
||||
showLoggedInUI(void) throw ();
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/UploadFileWindow.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <unicode/msgfmt.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/filechooserdialog.h>
|
||||
|
||||
#include "LiveSupport/Core/TimeConversion.h"
|
||||
#include "UploadFileWindow.h"
|
||||
|
||||
|
||||
using namespace LiveSupport::GLiveSupport;
|
||||
|
||||
/* =================================================== local data structures */
|
||||
|
||||
|
||||
/* ================================================ local constants & macros */
|
||||
|
||||
|
||||
/* =============================================== local function prototypes */
|
||||
|
||||
|
||||
/* ============================================================= module code */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constructor.
|
||||
*----------------------------------------------------------------------------*/
|
||||
UploadFileWindow :: UploadFileWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ()
|
||||
: LocalizedObject(bundle)
|
||||
{
|
||||
this->gLiveSupport = gLiveSupport;
|
||||
|
||||
set_title("Upload file window");
|
||||
chooseFileLabel.reset(new Gtk::Label("choose file"));
|
||||
fileNameEntry.reset(new Gtk::Entry());
|
||||
chooseFileButton.reset(new Gtk::Button("choose file"));
|
||||
nameLabel.reset(new Gtk::Label("clip name"));
|
||||
nameEntry.reset(new Gtk::Entry());
|
||||
uploadButton.reset(new Gtk::Button("upload"));
|
||||
closeButton.reset(new Gtk::Button("close"));
|
||||
|
||||
// set up the layout, which is a button box
|
||||
layout.reset(new Gtk::Table());
|
||||
|
||||
// set up the main window, and show everything
|
||||
set_border_width(10);
|
||||
layout->attach(*chooseFileLabel, 0, 1, 0, 1);
|
||||
layout->attach(*fileNameEntry, 1, 2, 0, 1);
|
||||
layout->attach(*chooseFileButton, 2, 3, 0, 1);
|
||||
layout->attach(*nameLabel, 0, 1, 1, 2);
|
||||
layout->attach(*nameEntry, 1, 2, 1, 2);
|
||||
layout->attach(*uploadButton, 1, 2, 2, 3);
|
||||
layout->attach(*closeButton, 1, 2, 3, 4);
|
||||
|
||||
add(*layout);
|
||||
|
||||
// bind events
|
||||
chooseFileButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&UploadFileWindow::onChooseFileButtonClicked));
|
||||
uploadButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&UploadFileWindow::onUploadButtonClicked));
|
||||
closeButton->signal_clicked().connect(sigc::mem_fun(*this,
|
||||
&UploadFileWindow::onCloseButtonClicked));
|
||||
|
||||
// show everything
|
||||
show_all();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The event when the choose file button has been clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
UploadFileWindow :: onChooseFileButtonClicked(void) throw ()
|
||||
{
|
||||
Ptr<Gtk::FileChooserDialog>::Ref dialog;
|
||||
|
||||
dialog.reset(new Gtk::FileChooserDialog("Please choose a file",
|
||||
Gtk::FILE_CHOOSER_ACTION_OPEN));
|
||||
|
||||
dialog->set_transient_for(*this);
|
||||
|
||||
//Add response buttons the the dialog:
|
||||
dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
||||
|
||||
int result = dialog->run();
|
||||
|
||||
if (result == Gtk::RESPONSE_OK) {
|
||||
fileName.reset(new std::string(dialog->get_filename()));
|
||||
fileNameEntry->set_text(*fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The event when the upload button has been clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
UploadFileWindow :: onUploadButtonClicked(void) throw ()
|
||||
{
|
||||
std::cerr << "upload clicked" << std::endl;
|
||||
try {
|
||||
Ptr<const Glib::ustring>::Ref title;
|
||||
Ptr<const std::string>::Ref fileName;
|
||||
|
||||
title.reset(new Glib::ustring(nameEntry->get_text()));
|
||||
fileName.reset(new std::string(fileNameEntry->get_text().raw()));
|
||||
|
||||
gLiveSupport->uploadFile(title, fileName);
|
||||
} catch (StorageException &e) {
|
||||
// TODO: signal error here
|
||||
std::cerr << "StorageException: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The event when the close button has been clicked.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
UploadFileWindow :: onCloseButtonClicked(void) throw ()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
|
||||
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/UploadFileWindow.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef UploadFileWindow_h
|
||||
#define UploadFileWindow_h
|
||||
|
||||
#ifndef __cplusplus
|
||||
#error This is a C++ include file
|
||||
#endif
|
||||
|
||||
|
||||
/* ============================================================ include files */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "configure.h"
|
||||
#endif
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/table.h>
|
||||
#include <gtkmm/entry.h>
|
||||
#include <gtkmm/window.h>
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
#include "LiveSupport/Core/LocalizedObject.h"
|
||||
|
||||
#include "GLiveSupport.h"
|
||||
#include "MasterPanelUserInfoWidget.h"
|
||||
|
||||
namespace LiveSupport {
|
||||
namespace GLiveSupport {
|
||||
|
||||
using namespace LiveSupport::Core;
|
||||
|
||||
/* ================================================================ constants */
|
||||
|
||||
|
||||
/* =================================================================== macros */
|
||||
|
||||
|
||||
/* =============================================================== data types */
|
||||
|
||||
/**
|
||||
* The upload file window.
|
||||
*
|
||||
* The layout of the window is roughly the following:
|
||||
* <pre><code>
|
||||
* +--- upload file window ----------------+
|
||||
* | choose file: +-- file browser --+ |
|
||||
* | name: +-- name input ----+ |
|
||||
* | +-- upload button -+ |
|
||||
* | +-- close button --+ |
|
||||
* | +-- status bar ---------------------+ |
|
||||
* +---------------------------------------+
|
||||
* </code></pre>
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.1 $
|
||||
*/
|
||||
class UploadFileWindow : public Gtk::Window, public LocalizedObject
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
* The layout used in the window.
|
||||
*/
|
||||
Ptr<Gtk::Table>::Ref layout;
|
||||
|
||||
/**
|
||||
* The choose file label
|
||||
*/
|
||||
Ptr<Gtk::Label>::Ref chooseFileLabel;
|
||||
|
||||
/**
|
||||
* The text entry for selecting a file name
|
||||
*/
|
||||
Ptr<Gtk::Entry>::Ref fileNameEntry;
|
||||
|
||||
/**
|
||||
* The file browser button.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref chooseFileButton;
|
||||
|
||||
/**
|
||||
* The name label
|
||||
*/
|
||||
Ptr<Gtk::Label>::Ref nameLabel;
|
||||
|
||||
/**
|
||||
* The text input for the name.
|
||||
*/
|
||||
Ptr<Gtk::Entry>::Ref nameEntry;
|
||||
|
||||
/**
|
||||
* The upload button.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref uploadButton;
|
||||
|
||||
/**
|
||||
* The close button.
|
||||
*/
|
||||
Ptr<Gtk::Button>::Ref closeButton;
|
||||
|
||||
// TODO: add status bar
|
||||
|
||||
/**
|
||||
* The gLiveSupport object, handling the logic of the application.
|
||||
*/
|
||||
Ptr<GLiveSupport>::Ref gLiveSupport;
|
||||
|
||||
/**
|
||||
* The name of the file to upload.
|
||||
*/
|
||||
Ptr<std::string>::Ref fileName;
|
||||
|
||||
/**
|
||||
* Function to catch the event of the choose file button being
|
||||
* pressed.
|
||||
*/
|
||||
virtual void
|
||||
onChooseFileButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Function to catch the event of the upload button being
|
||||
* pressed.
|
||||
*/
|
||||
virtual void
|
||||
onUploadButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* Function to catch the event of the close button being pressed.
|
||||
*/
|
||||
virtual void
|
||||
onCloseButtonClicked(void) throw ();
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param gLiveSupport the gLiveSupport object, handling the
|
||||
* logic of the application
|
||||
* @param bundle the resource bundle holding localized resources
|
||||
*/
|
||||
UploadFileWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
|
||||
Ptr<ResourceBundle>::Ref bundle)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Virtual destructor.
|
||||
*/
|
||||
virtual
|
||||
~UploadFileWindow(void) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* ================================================= external data structures */
|
||||
|
||||
|
||||
/* ====================================================== function prototypes */
|
||||
|
||||
|
||||
} // namespace GLiveSupport
|
||||
} // namespace LiveSupport
|
||||
|
||||
#endif // UploadFileWindow_h
|
||||
|
Loading…
Reference in New Issue