Make FilePicker context sensitive default paths persistent over logins.

Also, make newview/statemachine a separate project.
This commit is contained in:
Aleric Inglewood
2011-05-13 23:50:56 +02:00
parent 5f72cbb103
commit ea2cc3e0de
16 changed files with 168 additions and 34 deletions

View File

@@ -106,6 +106,7 @@ if (VIEWER)
add_dependencies(viewer solaris-crash-logger) add_dependencies(viewer solaris-crash-logger)
endif (LINUX) endif (LINUX)
add_subdirectory(${VIEWER_PREFIX}newview/statemachine)
add_subdirectory(${VIEWER_PREFIX}newview) add_subdirectory(${VIEWER_PREFIX}newview)
add_dependencies(viewer secondlife-bin) add_dependencies(viewer secondlife-bin)
endif (VIEWER) endif (VIEWER)

View File

@@ -0,0 +1,4 @@
# -*- cmake -*-
set(AISTATEMACHINE_INCLUDE_DIRS statemachine)
set(AISTATEMACHINE_LIBRARIES statemachine)

View File

@@ -39,6 +39,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
#include <deque> #include <deque>
#include "stdtypes.h" // llcommon/stdtypes.h, needed for S32 and U32.
// Use to compare the first element only of a pair // Use to compare the first element only of a pair
// e.g. typedef std::set<std::pair<int, Data*>, compare_pair<int, Data*> > some_pair_set_t; // e.g. typedef std::set<std::pair<int, Data*>, compare_pair<int, Data*> > some_pair_set_t;

View File

@@ -37,7 +37,6 @@
#define LL_LLPLUGINCLASSMEDIA_H #define LL_LLPLUGINCLASSMEDIA_H
#include "llpluginclassbasic.h" #include "llpluginclassbasic.h"
#include "llgltypes.h"
#include "llrect.h" #include "llrect.h"
#include "v4color.h" #include "v4color.h"
@@ -232,9 +231,9 @@ protected:
bool mTextureParamsReceived; // the mRequestedTexture* fields are only valid when this is true bool mTextureParamsReceived; // the mRequestedTexture* fields are only valid when this is true
S32 mRequestedTextureDepth; S32 mRequestedTextureDepth;
LLGLenum mRequestedTextureInternalFormat; U32 mRequestedTextureInternalFormat;
LLGLenum mRequestedTextureFormat; U32 mRequestedTextureFormat;
LLGLenum mRequestedTextureType; U32 mRequestedTextureType;
bool mRequestedTextureSwapBytes; bool mRequestedTextureSwapBytes;
bool mRequestedTextureCoordsOpenGL; bool mRequestedTextureCoordsOpenGL;

View File

@@ -22,6 +22,7 @@ include(LLInventory)
include(LLMath) include(LLMath)
include(LLMessage) include(LLMessage)
include(LLPlugin) include(LLPlugin)
include(AIStateMachine)
include(LLPrimitive) include(LLPrimitive)
include(LLRender) include(LLRender)
include(LLUI) include(LLUI)
@@ -43,6 +44,7 @@ if (WINDOWS)
endif (WINDOWS) endif (WINDOWS)
include_directories( include_directories(
${CMAKE_SOURCE_DIR}/newview
${DBUSGLIB_INCLUDE_DIRS} ${DBUSGLIB_INCLUDE_DIRS}
${HUNSPELL_INCLUDE_DIR} ${HUNSPELL_INCLUDE_DIR}
${ELFIO_INCLUDE_DIR} ${ELFIO_INCLUDE_DIR}
@@ -1006,18 +1008,6 @@ set(viewer_HEADER_FILES
source_group("CMake Rules" FILES ViewerInstall.cmake) source_group("CMake Rules" FILES ViewerInstall.cmake)
set(statemachine_SOURCE_FILES
statemachine/aistatemachine.cpp
statemachine/aifilepicker.cpp
)
set(statemachine_HEADER_FILES
statemachine/aistatemachine.h
statemachine/aifilepicker.h
statemachine/aidirpicker.h
)
list(APPEND viewer_SOURCE_FILES ${statemachine_SOURCE_FILES})
list(APPEND viewer_HEADER_FILES ${statemachine_HEADER_FILES})
if (DARWIN) if (DARWIN)
LIST(APPEND viewer_SOURCE_FILES llappviewermacosx.cpp) LIST(APPEND viewer_SOURCE_FILES llappviewermacosx.cpp)
@@ -1434,6 +1424,7 @@ target_link_libraries(${VIEWER_BINARY_NAME}
${LLINVENTORY_LIBRARIES} ${LLINVENTORY_LIBRARIES}
${LLMESSAGE_LIBRARIES} ${LLMESSAGE_LIBRARIES}
${LLPLUGIN_LIBRARIES} ${LLPLUGIN_LIBRARIES}
${AISTATEMACHINE_LIBRARIES}
${LLPRIMITIVE_LIBRARIES} ${LLPRIMITIVE_LIBRARIES}
${LLRENDER_LIBRARIES} ${LLRENDER_LIBRARIES}
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}

View File

@@ -72,6 +72,7 @@
#include "llmutelist.h" #include "llmutelist.h"
#include "llurldispatcher.h" #include "llurldispatcher.h"
#include "llurlhistory.h" #include "llurlhistory.h"
#include "statemachine/aifilepicker.h"
#include "llfirstuse.h" #include "llfirstuse.h"
#include "llrender.h" #include "llrender.h"
#include "llfont.h" #include "llfont.h"
@@ -1353,6 +1354,9 @@ bool LLAppViewer::cleanup()
// Save URL history file // Save URL history file
LLURLHistory::saveFile("url_history.xml"); LLURLHistory::saveFile("url_history.xml");
// Save file- and dirpicker {context, default paths} map.
AIFilePicker::saveFile("filepicker_contexts.xml");
// save mute list. gMuteList used to also be deleted here too. // save mute list. gMuteList used to also be deleted here too.
LLMuteList::getInstance()->cache(gAgent.getID()); LLMuteList::getInstance()->cache(gAgent.getID());

View File

@@ -54,6 +54,7 @@
#include "hippogridmanager.h" #include "hippogridmanager.h"
#include "hippolimits.h" #include "hippolimits.h"
#include "floaterao.h" #include "floaterao.h"
#include "statemachine/aifilepicker.h"
#include "llares.h" #include "llares.h"
#include "llcachename.h" #include "llcachename.h"
@@ -636,6 +637,12 @@ bool idle_startup()
LLStartUp::handleSocksProxy(false); LLStartUp::handleSocksProxy(false);
//-------------------------------------------------
// Load file- and dirpicker {context, default path} map.
//-------------------------------------------------
AIFilePicker::loadFile("filepicker_contexts.xml");
//------------------------------------------------- //-------------------------------------------------
// Init audio, which may be needed for prefs dialog // Init audio, which may be needed for prefs dialog
// or audio cues in connection UI. // or audio cues in connection UI.

View File

@@ -810,6 +810,16 @@ template <> eControlType get_control_type<LLSD>(const LLSD& in, LLSD& out)
return TYPE_LLSD; return TYPE_LLSD;
} }
void onCommitControlSetting_gSavedSettings(LLUICtrl* ctrl, void* name)
{
gSavedSettings.setValue((const char*)name,ctrl->getValue());
}
void onCommitControlSetting_gSavedPerAccountSettings(LLUICtrl* ctrl, void* name)
{
gSavedPerAccountSettings.setValue((const char*)name,ctrl->getValue());
}
#if TEST_CACHED_CONTROL #if TEST_CACHED_CONTROL
#define DECL_LLCC(T, V) static LLCachedControl<T> mySetting_##T("TestCachedControl"#T, V) #define DECL_LLCC(T, V) static LLCachedControl<T> mySetting_##T("TestCachedControl"#T, V)

View File

@@ -35,9 +35,10 @@
#include <map> #include <map>
#include "llcontrol.h" #include "llcontrol.h"
#include "lluictrl.h"
#include "aithreadsafe.h" #include "aithreadsafe.h"
class LLUICtrl;
// Enabled this definition to compile a 'hacked' viewer that // Enabled this definition to compile a 'hacked' viewer that
// allows a hacked godmode to be toggled on and off. // allows a hacked godmode to be toggled on and off.
#define TOGGLE_HACKED_GODLIKE_VIEWER #define TOGGLE_HACKED_GODLIKE_VIEWER
@@ -75,8 +76,8 @@ bool handleCloudSettingsChanged(const LLSD& newvalue);
//A template would be a little awkward to use here.. so.. a preprocessor macro. Alas. onCommitControlSetting(gSavedSettings) etc. //A template would be a little awkward to use here.. so.. a preprocessor macro. Alas. onCommitControlSetting(gSavedSettings) etc.
inline void onCommitControlSetting_gSavedSettings(LLUICtrl* ctrl, void* name) {gSavedSettings.setValue((const char*)name,ctrl->getValue());} void onCommitControlSetting_gSavedSettings(LLUICtrl* ctrl, void* name);
inline void onCommitControlSetting_gSavedPerAccountSettings(LLUICtrl* ctrl, void* name) {gSavedPerAccountSettings.setValue((const char*)name,ctrl->getValue());} void onCommitControlSetting_gSavedPerAccountSettings(LLUICtrl* ctrl, void* name);
#define onCommitControlSetting(controlgroup) onCommitControlSetting_##controlgroup #define onCommitControlSetting(controlgroup) onCommitControlSetting_##controlgroup
//#define TEST_CACHED_CONTROL 1 //#define TEST_CACHED_CONTROL 1

View File

@@ -32,6 +32,7 @@
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "llviewerpluginmanager.h" #include "llviewerpluginmanager.h"
#include "llnotifications.h"
void LLViewerPluginManager::destroyPlugin() void LLViewerPluginManager::destroyPlugin()
{ {
@@ -54,3 +55,12 @@ void LLViewerPluginManager::update()
return; return;
} }
} }
void LLViewerPluginManager::send_plugin_failure_warning(std::string const& plugin_basename)
{
LL_WARNS("Plugin") << "plugin intialization failed for plugin: " << plugin_basename << LL_ENDL;
LLSD args;
args["MIME_TYPE"] = plugin_basename; // FIXME: Use different notification.
LLNotifications::instance().add("NoPlugin", args);
}

View File

@@ -39,7 +39,6 @@
#include "lldir.h" #include "lldir.h"
#include "llfile.h" #include "llfile.h"
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "llnotifications.h"
#include "llpluginclassbasic.h" #include "llpluginclassbasic.h"
class LLViewerPluginManager : public LLRefCount class LLViewerPluginManager : public LLRefCount
@@ -65,6 +64,10 @@ public:
// Return pointer to plugin. // Return pointer to plugin.
LLPluginClassBasic* getPlugin(void) const { return mPluginBase; } LLPluginClassBasic* getPlugin(void) const { return mPluginBase; }
private:
// Called from createPlugin.
void send_plugin_failure_warning(std::string const& plugin_basename);
protected: protected:
LLPluginClassBasic* mPluginBase; //!< Pointer to the base class of the underlaying plugin. LLPluginClassBasic* mPluginBase; //!< Pointer to the base class of the underlaying plugin.
}; };
@@ -104,11 +107,7 @@ LLPluginClassBasic* LLViewerPluginManager::createPlugin(T* user_data)
if (mPluginBase) if (mPluginBase)
return mPluginBase; return mPluginBase;
LL_WARNS("Plugin") << "plugin intialization failed for plugin: " << PLUGIN_TYPE::plugin_basename() << LL_ENDL; send_plugin_failure_warning(PLUGIN_TYPE::plugin_basename());
LLSD args;
args["MIME_TYPE"] = PLUGIN_TYPE::plugin_basename(); // FIXME: Use different notification.
LLNotifications::instance().add("NoPlugin", args);
return NULL; return NULL;
} }

View File

@@ -0,0 +1,41 @@
# -*- cmake -*-
project(statemachine)
include(00-Common)
include(LLCommon)
include(LLPlugin)
include(LLMessage) # This is needed by LLPlugin.
include(LLMath)
include(LLVFS)
include(LLXML)
include_directories(
${CMAKE_SOURCE_DIR}/newview
${LLCOMMON_INCLUDE_DIRS}
${LLPLUGIN_INCLUDE_DIRS}
${LLMESSAGE_INCLUDE_DIRS}
${LLMATH_INCLUDE_DIRS}
${LLVFS_INCLUDE_DIRS}
${LLXML_INCLUDE_DIRS}
)
set(statemachine_SOURCE_FILES
aistatemachine.cpp
aifilepicker.cpp
)
set(statemachine_HEADER_FILES
CMakeLists.txt
aistatemachine.h
aifilepicker.h
aidirpicker.h
)
set_source_files_properties(${statemachine_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
list(APPEND statemachine_SOURCE_FILES ${statemachine_HEADER_FILES})
add_library (statemachine ${statemachine_SOURCE_FILES})
add_dependencies(statemachine prepare)

View File

@@ -28,14 +28,14 @@
* Initial version, written by Aleric Inglewood @ SL * Initial version, written by Aleric Inglewood @ SL
*/ */
#include "../llviewerprecompiledheaders.h" #include "linden_common.h"
#include "../llviewermedia.h" #include "lltrans.h"
#include "../lltrans.h"
#include "llpluginclassmedia.h" #include "llpluginclassmedia.h"
#include "llpluginmessageclasses.h" #include "llpluginmessageclasses.h"
#include "llsdserialize.h"
#include "aifilepicker.h" #include "aifilepicker.h"
#if LL_WINDOWS #if LL_WINDOWS
#include "../llviewerwindow.h" #include "llviewerwindow.h"
#endif #endif
#if LL_GTK && LL_X11 #if LL_GTK && LL_X11
#include "llwindowsdl.h" #include "llwindowsdl.h"
@@ -456,3 +456,62 @@ std::string AIFilePicker::getFolder(void) const
return gDirUtilp->getDirName(getFilename()); return gDirUtilp->getDirName(getFilename());
} }
// static
bool AIFilePicker::loadFile(std::string const& filename)
{
LLSD data;
std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename);
llifstream file(filepath);
if (file.is_open())
{
llinfos << "Loading filepicker context file at \"" << filepath << "\"." << llendl;
LLSDSerialize::fromXML(data, file);
}
if (!data.isMap())
{
llinfos << "File missing, ill-formed, or simply undefined; not changing the file (" << filepath << ")." << llendl;
return false;
}
AIAccess<context_map_type> wContextMap(sContextMap);
for (LLSD::map_const_iterator iter = data.beginMap(); iter != data.endMap(); ++iter)
{
wContextMap->insert(context_map_type::value_type(iter->first, iter->second.asString()));
}
return true;
}
// static
bool AIFilePicker::saveFile(std::string const& filename)
{
AIAccess<context_map_type> wContextMap(sContextMap);
if (wContextMap->empty())
return false;
LLSD context;
for (context_map_type::iterator iter = wContextMap->begin(); iter != wContextMap->end(); ++iter)
{
context[iter->first] = iter->second;
}
std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename);
llofstream file;
file.open(filepath.c_str());
if (!file.is_open())
{
llwarns << "Unable to open filepicker context file for save: \"" << filepath << "\"." << llendl;
return false;
}
LLSDSerialize::toPrettyXML(context, file);
file.close();
llinfos << "Saved default paths to \"" << filepath << "\"." << llendl;
return true;
}

View File

@@ -33,7 +33,7 @@
#include "aistatemachine.h" #include "aistatemachine.h"
#include "llpluginclassmedia.h" #include "llpluginclassmedia.h"
#include "../llviewermedia.h" #include "llviewerpluginmanager.h"
#include <vector> #include <vector>
enum ELoadFilter enum ELoadFilter
@@ -165,6 +165,11 @@ public:
std::string getFolder(void) const; std::string getFolder(void) const;
std::vector<std::string> const& getFilenames(void) const { return mFilenames; } std::vector<std::string> const& getFilenames(void) const { return mFilenames; }
// Load the sContextMap from disk.
static bool loadFile(std::string const& filename);
// Save the sContextMap to disk.
static bool saveFile(std::string const& filename);
private: private:
friend class AIPluginFilePicker; friend class AIPluginFilePicker;

View File

@@ -28,17 +28,18 @@
* Initial version, written by Aleric Inglewood @ SL * Initial version, written by Aleric Inglewood @ SL
*/ */
#include "../llviewerprecompiledheaders.h" #include "linden_common.h"
#include <algorithm> #include <algorithm>
#include "../llcallbacklist.h" #include "llcallbacklist.h"
#include "../llviewercontrol.h" #include "llcontrol.h"
#include "llfasttimer.h" #include "llfasttimer.h"
#include "aithreadsafe.h" #include "aithreadsafe.h"
#include "aistatemachine.h" #include "aistatemachine.h"
extern LLControlGroup gSavedSettings;
// Local variables. // Local variables.
namespace { namespace {
struct QueueElementComp; struct QueueElementComp;

View File

@@ -33,6 +33,7 @@
#include "aithreadsafe.h" #include "aithreadsafe.h"
#include "llfasttimer.h" #include "llfasttimer.h"
#include <boost/signal.hpp>
//! //!
// A AIStateMachine is a base class that allows derived classes to // A AIStateMachine is a base class that allows derived classes to