Delete unfinished and unused stuff from libaegisub

This commit is contained in:
Thomas Goyne 2012-10-25 08:27:14 -07:00
parent 56ced22c63
commit 67c01d11f6
11 changed files with 2 additions and 673 deletions

View file

@ -319,10 +319,6 @@
RelativePath="..\..\libaegisub\common\option_visit.h"
>
</File>
<File
RelativePath="..\..\libaegisub\common\path.cpp"
>
</File>
<File
RelativePath="..\..\libaegisub\common\thesaurus.cpp"
>
@ -331,10 +327,6 @@
RelativePath="..\..\libaegisub\common\util.cpp"
>
</File>
<File
RelativePath="..\..\libaegisub\common\validator.cpp"
>
</File>
<File
RelativePath="..\..\libaegisub\common\vfr.cpp"
>
@ -393,10 +385,6 @@
RelativePath="..\..\libaegisub\windows\log_win.cpp"
>
</File>
<File
RelativePath="..\..\libaegisub\windows\path_win.cpp"
>
</File>
<File
RelativePath="..\..\libaegisub\windows\util_win.cpp"
>
@ -481,10 +469,6 @@
RelativePath="..\..\libaegisub\include\libaegisub\option_value.h"
>
</File>
<File
RelativePath="..\..\libaegisub\include\libaegisub\path.h"
>
</File>
<File
RelativePath="..\..\libaegisub\include\libaegisub\scoped_ptr.h"
>
@ -509,10 +493,6 @@
RelativePath="..\..\libaegisub\include\libaegisub\util_win.h"
>
</File>
<File
RelativePath="..\..\libaegisub\include\libaegisub\validator.h"
>
</File>
<File
RelativePath="..\..\libaegisub\include\libaegisub\vfr.h"
>

View file

@ -30,17 +30,14 @@ SRC += \
common/mru.cpp \
common/option.cpp \
common/option_visit.cpp \
common/path.cpp \
common/keyframe.cpp \
common/util.cpp \
common/log.cpp \
common/thesaurus.cpp \
common/validator.cpp \
common/vfr.cpp \
unix/util.cpp \
unix/access.cpp \
unix/log.cpp \
unix/path.cpp
unix/log.cpp
ifeq (yes, $(BUILD_DARWIN))
SRC += osx/util.mm

View file

@ -1,151 +0,0 @@
// Copyright (c) 2010-2011, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file path.cpp
/// @brief Common paths.
/// @ingroup libaegisub
#include "../config.h"
#ifndef LAGI_PRE
#include <vector>
#endif
#include "libaegisub/path.h"
#include "libaegisub/access.h"
#include "libaegisub/log.h"
#include "libaegisub/option.h"
#include "libaegisub/option_value.h"
namespace agi {
Path::Path(const std::string &file, const std::string& default_path)
: path_file(file)
, path_default(default_path)
, opt(new agi::Options(file, default_path, Options::FLUSH_SKIP))
{
opt->ConfigUser();
LOG_D("agi/path") << "New Path object";
}
Path::~Path() {
}
std::string Path::Get(const char *name) {
std::string path;
try {
path = std::string(opt->Get(name)->GetString());
} catch (OptionErrorNotFound&) {
throw PathErrorNotFound("Invalid path key");
}
Decode(path);
return path;
}
void Path::Set(const char *name, const std::string &path) {
std::string set(path);
if (path[0] == 94) {
std::string tmp(path);
// Check that the used cookie exists.
Decode(tmp);
agi::acs::CheckDirWrite(path);
}
try {
opt->Get(name)->SetString(set);
} catch (OptionErrorNotFound&) {
throw PathErrorNotFound("Invalid path key");
}
}
void Path::ListGet(const char *name, std::vector<std::string> &out) {
out = opt->Get(name)->GetListString();
}
void Path::ListSet(const char *name, std::vector<std::string> list) {
opt->Get(name)->SetListString(list);
}
void Path::Decode(std::string &path) {
if (path[0] != 94) // "^"
return;
try {
if (path.find("^CONFIG") == 0) {
path.replace(0, 7, Config());
return;
}
if (path.find("^USER") == 0) {
path.replace(0, 5, User());
return;
}
if (path.find("^DATA") == 0) {
path.replace(0, 5, Data());
return;
}
if (path.find("^DOC") == 0) {
path.replace(0, 4, Doc());
return;
}
if (path.find("^TEMP") == 0) {
path.replace(0, 5, Temp());
return;
}
if (path.find("^AUDIO") == 0) {
std::string path_str(opt->Get("Last/Audio")->GetString());
Decode(path_str);
path.replace(0, 6, path_str);
return;
}
if (path.find("^VIDEO") == 0) {
std::string path_str(opt->Get("Last/Video")->GetString());
Decode(path_str);
path.replace(0, 6, path_str);
return;
}
if (path.find("^SUBTITLE") == 0) {
std::string path_str(opt->Get("Last/Subtitle")->GetString());
Decode(path_str);
path.replace(0, 5, path_str);
return;
}
throw PathErrorInvalid("Invalid cookie used");
} catch (OptionErrorNotFound&) {
throw PathErrorInternal("Failed to find key in Decode");
}
}
void Path::Encode(std::string &path) {
}
} // namespace agi

View file

@ -1,70 +0,0 @@
// Copyright (c) 2010, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file validator.cpp
/// @brief Input validation.
/// @ingroup libaegisub
#include <libaegisub/validator.h>
namespace agi {
bool ValidAny::CheckType(std::string &value) {
return true;
}
bool ValidAny::Check(std::string &value) {
return true;
}
bool ValidString::CheckType(std::string &value) {
return true;
}
bool ValidString::Check(std::string &value) {
return CheckType(value);
}
bool ValidInt::CheckType(std::string &value) {
return true;
}
bool ValidInt::Check(std::string &value) {
return CheckType(value);
}
bool ValidBool::CheckType(std::string &value) {
return true;
}
bool ValidBool::Check(std::string &value) {
return CheckType(value);
}
bool ValidColour::Check(std::string &value) {
if (ValidString::CheckType(value)) {
// check if it's a valid colour
return 1;
}
return 0;
}
} // namespace agi

View file

@ -1,112 +0,0 @@
// Copyright (c) 2010-2011, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file path.h
/// @brief Common paths.
/// @ingroup libaegisub
#include <libaegisub/exception.h>
#include <libaegisub/scoped_ptr.h>
namespace agi {
DEFINE_BASE_EXCEPTION_NOINNER(PathError, Exception)
DEFINE_SIMPLE_EXCEPTION_NOINNER(PathErrorNotFound, PathError, "path/not_found")
DEFINE_SIMPLE_EXCEPTION_NOINNER(PathErrorInvalid, PathError, "path/invalid")
DEFINE_SIMPLE_EXCEPTION_NOINNER(PathErrorInternal, PathError, "path")
class Options;
/// @class Path
// Internal representation of all paths in aegisub.
class Path {
public:
// For unit testing.
friend class PathTest;
/// Constructor
Path(const std::string &file, const std::string& default_path);
/// Destructor
~Path();
/// @brief Get a path, this is automatically decoded.
/// @param name Path to get
/// @return Full path name in UTF-8
std::string Get(const char *name);
/// @brief Set a path, this will be automaticalled encoded if a cookie matches.
/// @param[in] name Path name to save to.
void Set(const char *name, const std::string &path);
/// @brief Set a list of paths
/// @param name Path name.
/// @param out[out] Map to load list into
void ListGet(const char *name, std::vector<std::string> &out);
/// @brief Set a list of paths.
/// @param name Path name.
/// @param list List to set.
void ListSet(const char *name, std::vector<std::string> list);
/// @brief Get the default 'open' directory when no alternative is available.
/// @return Directory
/// This returns several different values based on OS:
/// Windows: Documents folder
/// OS X: ~/Documents
/// Unix: ~ or Documents folder if set in the environment
std::string Default();
/// @brief Decode a path
/// @param path Decode a path in-place.
void Decode(std::string &path);
/// Configuration directory
static std::string Config();
private:
/// Location of path config file.
const std::string path_file;
/// Internal default config.
const std::string path_default;
/// @brief Encode a path.
/// @param path Encode a path in-place.
/// ^CONFIG - Configuration directory (not changable)
/// ^USER - Users home directory
/// ^DATA - Aegisub data files
/// ^VIDEO - Last opened video directory
/// ^SUBTITLE - Last opened subtitle directory
/// ^AUDIO - Last opened audio directory
void Encode(std::string &path);
/// Options object.
scoped_ptr<Options> opt;
/// @brief Locale files
/// @return Locale location
/// This is directly assessibly as the Locale directory will never change on any platform.
std::string Locale();
protected:
std::string Data(); ///< Shared resources
std::string Doc(); ///< Documents
std::string User(); ///< User config directory
std::string Temp(); ///< Temporary storage
};
} // namespace agi

View file

@ -1,79 +0,0 @@
// Copyright (c) 2010, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file validator.h
/// @brief Input validation.
/// @ingroup libaegisub
#include <libaegisub/colour.h>
namespace agi {
class Validator {
public:
/// Types supported.
enum ValidType {
Type_Any = 0, ///< Any (should be used instead of "String"
/// to accept any value for code clarity.)
Type_String = 1, ///< String
Type_Int = 2, ///< Integer
Type_Bool = 3, ///< Bool
Type_Colour = 4 ///< Colour
};
/// @brief Check value type.
/// @param value Value
/// @return true/false
///
/// If the value type is "int" or "string" it will return true/false based on this alone.
/// This should validate against full values or single characters to make it suitable for input boxes.
virtual bool CheckType(std::string &value)=0;
/// @brief Check value including constraints.
/// @param value Value
/// @return true/false
///
/// Check value including bounds checking.
/// CheckType() should always be the first function called.
virtual bool Check(std::string &value)=0;
/// @brief Return validation type.
/// @return Type
virtual ValidType GetType()=0;
};
#define VALID_BASE(type_name) \
class Valid##type_name : public Validator { \
public: \
ValidType GetType() { return Type_##type_name; } \
bool CheckType(std::string &value); \
virtual bool Check(std::string &value); \
};
VALID_BASE(Any)
VALID_BASE(String)
VALID_BASE(Int)
VALID_BASE(Bool)
class ValidColour: public ValidString {
public:
ValidType GetType() { return Type_Colour; }
virtual bool Check(std::string &value);
};
} // namespace agi

View file

@ -1,73 +0,0 @@
// Copyright (c) 2010-2011, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file path.cpp
/// @brief Common paths.
/// @ingroup libaegisub
#include "config.h"
#ifndef LAGI_PRE
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#endif
#include <libaegisub/path.h>
namespace agi {
std::string home() {
char *ehome;
ehome = getenv("HOME");
if (ehome == NULL) {
printf("The HOME environment variable must be set\n");
exit(1);
}
return ehome;
}
std::string Path::Data() {
return P_DATA;
}
std::string Path::Doc() {
return P_DOC;
}
std::string Path::User() {
return home();
}
std::string Path::Locale() {
return P_LOCALE;
}
std::string Path::Config() {
return home() + "/.aegisub/";
}
std::string Path::Temp() {
return "/tmp/";
}
} // namespace agi

View file

@ -1,110 +0,0 @@
// Copyright (c) 2011, Niels Martin Hansen <nielsm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// $Id$
/// @file path.cpp
/// @brief Common paths.
/// @ingroup libaegisub
#ifndef LAGI_PRE
#include <string>
#endif
#include <libaegisub/path.h>
#include <libaegisub/charset_conv_win.h>
#include <libaegisub/util_win.h>
namespace {
#include <Shlobj.h>
#include <Shellapi.h>
std::string WinGetFolderPath(int folder) {
wchar_t path[MAX_PATH+1] = {0};
HRESULT res = SHGetFolderPathW(
0, // hwndOwner
folder, // nFolder
0, // hToken
0, // dwFlags
path // pszPath
);
if (FAILED(res))
throw agi::PathErrorInternal("SHGetFolderPath() failed"); //< @fixme error message?
return agi::charset::ConvertW(path);
}
std::string get_install_path() {
static std::string install_path;
if (install_path.empty()) {
// Excerpt from <http://msdn.microsoft.com/en-us/library/bb776391.aspx>:
// lpCmdLine [in]
// If this parameter is an empty string the function returns
// the path to the current executable file.
int argc;
LPWSTR *argv = CommandLineToArgvW(L"", &argc);
wchar_t path[MAX_PATH+1] = {0};
wchar_t *fn;
DWORD res = GetFullPathNameW(argv[0], MAX_PATH, path, &fn);
LocalFree(argv);
if (res > 0 && GetLastError() == 0) {
*fn = '\0'; // fn points to filename part of path, set an end marker there
install_path = agi::charset::ConvertW(std::wstring(path));
} else {
throw agi::PathErrorInternal(agi::util::ErrorString(GetLastError()));
}
}
return install_path;
}
}
namespace agi {
std::string Path::Data() {
return get_install_path();
}
std::string Path::Doc() {
return Data() + "docs\\";
}
std::string Path::User() {
return WinGetFolderPath(CSIDL_PERSONAL);
}
std::string Path::Locale() {
return Data() + "locale\\";
}
std::string Path::Config() {
return WinGetFolderPath(CSIDL_APPDATA) + "Aegisub3";
/// @fixme should get version number in a more dynamic manner
}
std::string Path::Temp() {
wchar_t path[MAX_PATH+1] = {0};
if (GetTempPath(MAX_PATH, path) == 0)
throw PathErrorInternal(util::ErrorString(GetLastError()));
else
return charset::ConvertW(path);
}
} // namespace agi

View file

@ -80,6 +80,7 @@
#include "version.h"
#include <libaegisub/exception.h>
#include <libaegisub/scoped_ptr.h>
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>

View file

@ -82,7 +82,6 @@
namespace config {
agi::Options *opt = 0;
agi::MRUManager *mru = 0;
agi::Path *path = 0;
}
@ -190,9 +189,6 @@ bool AegisubApp::OnInit() {
wxMessageBox("Configuration file is invalid. Error reported:\n" + lagi_wxString(err.GetMessage()), "Error");
}
std::string path(agi::Path::Config());
config::path = new agi::Path(path.append("path.json"), GET_DEFAULT_CONFIG(default_path));
// Init commands.
cmd::init_builtin_commands();
@ -305,7 +301,6 @@ int AegisubApp::OnExit() {
delete config::opt;
delete config::mru;
hotkey::clear();
delete config::path;
cmd::clear();
delete global_scripts;
@ -363,7 +358,6 @@ void AegisubApp::OnUnhandledException() {
UnhandledExeception(false);
}
/// @brief Called during a fatal exception.
void AegisubApp::OnFatalException() {
UnhandledExeception(true);
@ -389,8 +383,6 @@ void AegisubApp::HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEven
#undef SHOW_EXCEPTION
}
#if wxUSE_STACKWALKER == 1
/// @brief Called at the start of walking the stack.
/// @param cause cause of the crash.
@ -421,7 +413,6 @@ StackWalker::StackWalker(wxString cause) {
}
}
/// @brief Callback to format a single frame
/// @param frame frame to parse.
///
@ -444,12 +435,9 @@ void StackWalker::OnStackFrame(const wxStackFrame &frame) {
}
}
/// @brief Called at the end of walking the stack.
StackWalker::~StackWalker() {
if ((crash_text->IsOpened()) && (crash_xml->IsOpened())) {
crash_text->Write("End of stack dump.\n");
crash_text->Write("----------------------------------------\n\n");
@ -463,10 +451,6 @@ StackWalker::~StackWalker() {
}
#endif
/// @brief Call main loop
/// @return
///
int AegisubApp::OnRun() {
wxString error;
@ -510,13 +494,7 @@ int AegisubApp::OnRun() {
return 1;
}
////////////////
// Apple events
#ifdef __WXMAC__
/// @brief DOCME
/// @param filename
///
void AegisubApp::MacOpenFile(const wxString &filename) {
if (frame != NULL && !filename.empty()) {
frame->LoadSubtitles(filename);

View file

@ -45,13 +45,11 @@
#include <libaegisub/mru.h>
#include <libaegisub/option.h>
#include <libaegisub/option_value.h>
#include <libaegisub/path.h>
#ifndef wxUSE_EXCEPTIONS
#error wxWidgets is compiled without exceptions support. Aegisub requires exceptions support in wxWidgets to run safely.
#endif
class FrameMain;
class PluginManager;
@ -59,10 +57,8 @@ class PluginManager;
namespace config {
extern agi::Options *opt; ///< Options
extern agi::MRUManager *mru; ///< Most Recently Used
extern agi::Path *path; ///< Paths
}
/// DOCME
namespace Automation4 { class AutoloadScriptManager; }
/// Macro to get OptionValue object.
@ -74,23 +70,7 @@ namespace Automation4 { class AutoloadScriptManager; }
/// Macro to subscribe to OptionValue changes
#define OPT_SUB(x, ...) config::opt->Get(x)->Subscribe(__VA_ARGS__)
/// Macro to unsubscribe from OptionValue changes
#define OPT_UNSUB(x, ...) config::opt->Get(x)->Unsubscribe(__VA_ARGS__)
/// Macro to get a path.
#define PATH_GET(x) AegisubApp::Get()->path->Get(x)
/// Macro to set a path.
#define PATH_SET(x, y) AegisubApp::Get()->path->Set(x, y)
/// DOCME
/// @class AegisubApp
/// @brief DOCME
///
/// DOCME
class AegisubApp: public wxApp {
/// DOCME
PluginManager *plugins;
bool OnInit();
@ -113,13 +93,8 @@ class AegisubApp: public wxApp {
void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const;
public:
/// DOCME
AegisubLocale locale;
/// DOCME
FrameMain *frame;
/// DOCME
Automation4::AutoloadScriptManager *global_scripts;
#ifdef __WXMAC__
@ -130,15 +105,8 @@ public:
wxDECLARE_APP(AegisubApp);
#if wxUSE_STACKWALKER == 1
/// @class StackWalker
/// @brief DOCME
///
/// DOCME
class StackWalker: public wxStackWalker {
private:
wxFile *crash_text; // FP to the crash text file.
wxFile *crash_xml; // FP to the crash xml file.