-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bindings for getKnownFolders(). Move stuff to mobase.utils. (#122)
- Loading branch information
Showing
5 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#include <KnownFolders.h> | ||
|
||
namespace mo2::python { | ||
|
||
struct KnownFolder { | ||
const char* name; | ||
KNOWNFOLDERID guid; | ||
}; | ||
|
||
const std::array<KnownFolder, 142> KNOWN_FOLDERS{{ | ||
{"AccountPictures", FOLDERID_AccountPictures}, | ||
{"AddNewPrograms", FOLDERID_AddNewPrograms}, | ||
{"AdminTools", FOLDERID_AdminTools}, | ||
{"AllAppMods", FOLDERID_AllAppMods}, | ||
{"AppCaptures", FOLDERID_AppCaptures}, | ||
{"AppDataDesktop", FOLDERID_AppDataDesktop}, | ||
{"AppDataDocuments", FOLDERID_AppDataDocuments}, | ||
{"AppDataFavorites", FOLDERID_AppDataFavorites}, | ||
{"AppDataProgramData", FOLDERID_AppDataProgramData}, | ||
{"ApplicationShortcuts", FOLDERID_ApplicationShortcuts}, | ||
{"AppsFolder", FOLDERID_AppsFolder}, | ||
{"AppUpdates", FOLDERID_AppUpdates}, | ||
{"CameraRoll", FOLDERID_CameraRoll}, | ||
{"CameraRollLibrary", FOLDERID_CameraRollLibrary}, | ||
{"CDBurning", FOLDERID_CDBurning}, | ||
{"ChangeRemovePrograms", FOLDERID_ChangeRemovePrograms}, | ||
{"CommonAdminTools", FOLDERID_CommonAdminTools}, | ||
{"CommonOEMLinks", FOLDERID_CommonOEMLinks}, | ||
{"CommonPrograms", FOLDERID_CommonPrograms}, | ||
{"CommonStartMenu", FOLDERID_CommonStartMenu}, | ||
{"CommonStartMenuPlaces", FOLDERID_CommonStartMenuPlaces}, | ||
{"CommonStartup", FOLDERID_CommonStartup}, | ||
{"CommonTemplates", FOLDERID_CommonTemplates}, | ||
{"ComputerFolder", FOLDERID_ComputerFolder}, | ||
{"ConflictFolder", FOLDERID_ConflictFolder}, | ||
{"ConnectionsFolder", FOLDERID_ConnectionsFolder}, | ||
{"Contacts", FOLDERID_Contacts}, | ||
{"ControlPanelFolder", FOLDERID_ControlPanelFolder}, | ||
{"Cookies", FOLDERID_Cookies}, | ||
{"CurrentAppMods", FOLDERID_CurrentAppMods}, | ||
{"Desktop", FOLDERID_Desktop}, | ||
{"DevelopmentFiles", FOLDERID_DevelopmentFiles}, | ||
{"Device", FOLDERID_Device}, | ||
{"DeviceMetadataStore", FOLDERID_DeviceMetadataStore}, | ||
{"Documents", FOLDERID_Documents}, | ||
{"DocumentsLibrary", FOLDERID_DocumentsLibrary}, | ||
{"Downloads", FOLDERID_Downloads}, | ||
{"Favorites", FOLDERID_Favorites}, | ||
{"Fonts", FOLDERID_Fonts}, | ||
{"Games", FOLDERID_Games}, | ||
{"GameTasks", FOLDERID_GameTasks}, | ||
{"History", FOLDERID_History}, | ||
{"HomeGroup", FOLDERID_HomeGroup}, | ||
{"HomeGroupCurrentUser", FOLDERID_HomeGroupCurrentUser}, | ||
{"ImplicitAppShortcuts", FOLDERID_ImplicitAppShortcuts}, | ||
{"InternetCache", FOLDERID_InternetCache}, | ||
{"InternetFolder", FOLDERID_InternetFolder}, | ||
{"Libraries", FOLDERID_Libraries}, | ||
{"Links", FOLDERID_Links}, | ||
{"LocalAppData", FOLDERID_LocalAppData}, | ||
{"LocalAppDataLow", FOLDERID_LocalAppDataLow}, | ||
{"LocalDocuments", FOLDERID_LocalDocuments}, | ||
{"LocalDownloads", FOLDERID_LocalDownloads}, | ||
{"LocalizedResourcesDir", FOLDERID_LocalizedResourcesDir}, | ||
{"LocalMusic", FOLDERID_LocalMusic}, | ||
{"LocalPictures", FOLDERID_LocalPictures}, | ||
{"LocalStorage", FOLDERID_LocalStorage}, | ||
{"LocalVideos", FOLDERID_LocalVideos}, | ||
{"Music", FOLDERID_Music}, | ||
{"MusicLibrary", FOLDERID_MusicLibrary}, | ||
{"NetHood", FOLDERID_NetHood}, | ||
{"NetworkFolder", FOLDERID_NetworkFolder}, | ||
{"Objects3D", FOLDERID_Objects3D}, | ||
{"OneDrive", FOLDERID_OneDrive}, | ||
{"OriginalImages", FOLDERID_OriginalImages}, | ||
{"PhotoAlbums", FOLDERID_PhotoAlbums}, | ||
{"Pictures", FOLDERID_Pictures}, | ||
{"PicturesLibrary", FOLDERID_PicturesLibrary}, | ||
{"Playlists", FOLDERID_Playlists}, | ||
{"PrintersFolder", FOLDERID_PrintersFolder}, | ||
{"PrintHood", FOLDERID_PrintHood}, | ||
{"Profile", FOLDERID_Profile}, | ||
{"ProgramData", FOLDERID_ProgramData}, | ||
{"ProgramFiles", FOLDERID_ProgramFiles}, | ||
{"ProgramFilesCommon", FOLDERID_ProgramFilesCommon}, | ||
{"ProgramFilesCommonX64", FOLDERID_ProgramFilesCommonX64}, | ||
{"ProgramFilesCommonX86", FOLDERID_ProgramFilesCommonX86}, | ||
{"ProgramFilesX64", FOLDERID_ProgramFilesX64}, | ||
{"ProgramFilesX86", FOLDERID_ProgramFilesX86}, | ||
{"Programs", FOLDERID_Programs}, | ||
{"Public", FOLDERID_Public}, | ||
{"PublicDesktop", FOLDERID_PublicDesktop}, | ||
{"PublicDocuments", FOLDERID_PublicDocuments}, | ||
{"PublicDownloads", FOLDERID_PublicDownloads}, | ||
{"PublicGameTasks", FOLDERID_PublicGameTasks}, | ||
{"PublicLibraries", FOLDERID_PublicLibraries}, | ||
{"PublicMusic", FOLDERID_PublicMusic}, | ||
{"PublicPictures", FOLDERID_PublicPictures}, | ||
{"PublicRingtones", FOLDERID_PublicRingtones}, | ||
{"PublicUserTiles", FOLDERID_PublicUserTiles}, | ||
{"PublicVideos", FOLDERID_PublicVideos}, | ||
{"QuickLaunch", FOLDERID_QuickLaunch}, | ||
{"Recent", FOLDERID_Recent}, | ||
{"RecordedCalls", FOLDERID_RecordedCalls}, | ||
{"RecordedTVLibrary", FOLDERID_RecordedTVLibrary}, | ||
{"RecycleBinFolder", FOLDERID_RecycleBinFolder}, | ||
{"ResourceDir", FOLDERID_ResourceDir}, | ||
{"RetailDemo", FOLDERID_RetailDemo}, | ||
{"Ringtones", FOLDERID_Ringtones}, | ||
{"RoamedTileImages", FOLDERID_RoamedTileImages}, | ||
{"RoamingAppData", FOLDERID_RoamingAppData}, | ||
{"RoamingTiles", FOLDERID_RoamingTiles}, | ||
{"SampleMusic", FOLDERID_SampleMusic}, | ||
{"SamplePictures", FOLDERID_SamplePictures}, | ||
{"SamplePlaylists", FOLDERID_SamplePlaylists}, | ||
{"SampleVideos", FOLDERID_SampleVideos}, | ||
{"SavedGames", FOLDERID_SavedGames}, | ||
{"SavedPictures", FOLDERID_SavedPictures}, | ||
{"SavedPicturesLibrary", FOLDERID_SavedPicturesLibrary}, | ||
{"SavedSearches", FOLDERID_SavedSearches}, | ||
{"Screenshots", FOLDERID_Screenshots}, | ||
{"SEARCH_CSC", FOLDERID_SEARCH_CSC}, | ||
{"SEARCH_MAPI", FOLDERID_SEARCH_MAPI}, | ||
{"SearchHistory", FOLDERID_SearchHistory}, | ||
{"SearchHome", FOLDERID_SearchHome}, | ||
{"SearchTemplates", FOLDERID_SearchTemplates}, | ||
{"SendTo", FOLDERID_SendTo}, | ||
{"SidebarDefaultParts", FOLDERID_SidebarDefaultParts}, | ||
{"SidebarParts", FOLDERID_SidebarParts}, | ||
{"SkyDrive", FOLDERID_SkyDrive}, | ||
{"SkyDriveCameraRoll", FOLDERID_SkyDriveCameraRoll}, | ||
{"SkyDriveDocuments", FOLDERID_SkyDriveDocuments}, | ||
{"SkyDriveMusic", FOLDERID_SkyDriveMusic}, | ||
{"SkyDrivePictures", FOLDERID_SkyDrivePictures}, | ||
{"StartMenu", FOLDERID_StartMenu}, | ||
{"StartMenuAllPrograms", FOLDERID_StartMenuAllPrograms}, | ||
{"Startup", FOLDERID_Startup}, | ||
{"SyncManagerFolder", FOLDERID_SyncManagerFolder}, | ||
{"SyncResultsFolder", FOLDERID_SyncResultsFolder}, | ||
{"SyncSetupFolder", FOLDERID_SyncSetupFolder}, | ||
{"System", FOLDERID_System}, | ||
{"SystemX86", FOLDERID_SystemX86}, | ||
{"Templates", FOLDERID_Templates}, | ||
{"UserPinned", FOLDERID_UserPinned}, | ||
{"UserProfiles", FOLDERID_UserProfiles}, | ||
{"UserProgramFiles", FOLDERID_UserProgramFiles}, | ||
{"UserProgramFilesCommon", FOLDERID_UserProgramFilesCommon}, | ||
{"UsersFiles", FOLDERID_UsersFiles}, | ||
{"UsersLibraries", FOLDERID_UsersLibraries}, | ||
{"Videos", FOLDERID_Videos}, | ||
{"VideosLibrary", FOLDERID_VideosLibrary}, | ||
{"Windows", FOLDERID_Windows}, | ||
}}; | ||
|
||
} // namespace mo2::python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include "wrappers.h" | ||
|
||
#include "../pybind11_all.h" | ||
|
||
#include <report.h> | ||
#include <utility.h> | ||
|
||
#include "known_folders.h" | ||
|
||
namespace py = pybind11; | ||
using namespace MOBase; | ||
|
||
namespace mo2::python { | ||
|
||
void add_utils_bindings(pybind11::module_ m) | ||
{ | ||
py::class_<KnownFolder> pyKnownFolder(m, "KnownFolder"); | ||
for (std::size_t i = 0; i < KNOWN_FOLDERS.size(); ++i) { | ||
pyKnownFolder.attr(KNOWN_FOLDERS[i].name) = py::int_(i); | ||
} | ||
|
||
m.def( | ||
"getKnownFolder", | ||
[](std::size_t knownFolderId, QString what) { | ||
return getKnownFolder(KNOWN_FOLDERS.at(knownFolderId).guid, what); | ||
}, | ||
py::arg("known_folder"), py::arg("what") = ""); | ||
|
||
m.def( | ||
"getOptionalKnownFolder", | ||
[](std::size_t knownFolderId) { | ||
const auto r = | ||
getOptionalKnownFolder(KNOWN_FOLDERS.at(knownFolderId).guid); | ||
return r.isEmpty() ? py::none{} : py::cast(r); | ||
}, | ||
py::arg("known_folder")); | ||
|
||
m.def("getFileVersion", wrap_for_filepath(&MOBase::getFileVersion), | ||
py::arg("filepath")); | ||
m.def("getProductVersion", wrap_for_filepath(&MOBase::getProductVersion), | ||
py::arg("executable")); | ||
m.def("getIconForExecutable", wrap_for_filepath(&MOBase::iconForExecutable), | ||
py::arg("executable")); | ||
} | ||
|
||
} // namespace mo2::python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE TS> | ||
<TS version="2.1" language="en_US"> | ||
<context> | ||
<name>ProxyPython</name> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="88"/> | ||
<source>Python Initialization failed</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="89"/> | ||
<source>On a previous start the Python Plugin failed to initialize. | ||
Do you want to try initializing python again (at the risk of another crash)? | ||
Suggestion: Select "no", and click the warning sign for further help.Afterwards you have to re-enable the python plugin.</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="162"/> | ||
<source>Python Proxy</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="172"/> | ||
<source>Proxy Plugin to allow plugins written in python to be loaded</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="244"/> | ||
<source>ModOrganizer path contains a semicolon</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="246"/> | ||
<source>Python DLL not found</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="248"/> | ||
<source>Invalid Python DLL</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="250"/> | ||
<source>Initializing Python failed</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="252"/> | ||
<location filename="proxy/proxypython.cpp" line="281"/> | ||
<source>invalid problem key %1</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="260"/> | ||
<source>The path to Mod Organizer (%1) contains a semicolon.<br>While this is legal on NTFS drives, many applications do not handle it correctly.<br>Unfortunately MO depends on libraries that seem to fall into that group.<br>As a result the python plugin cannot be loaded, and the only solution we can offer is to remove the semicolon or move MO to a path without a semicolon.</source> | ||
<oldsource>The path to Mod Organizer (%1) contains a semicolon. <br>While this is legal on NTFS drives, many softwares do not handle it correctly.<br>Unfortunately MO depends on libraries that seem to fall into that group.<br>As a result the python plugin cannot be loaded, and the only solution we canoffer is to remove the semicolon or move MO to a path without a semicolon.</oldsource> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="270"/> | ||
<source>The Python plugin DLL was not found, maybe your antivirus deleted it. Re-installing MO2 might fix the problem.</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="273"/> | ||
<source>The Python plugin DLL is invalid, maybe your antivirus is blocking it. Re-installing MO2 and adding exclusions for it to your AV might fix the problem.</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
<message> | ||
<location filename="proxy/proxypython.cpp" line="278"/> | ||
<source>The initialization of the Python plugin DLL failed, unfortunately without any details.</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
</context> | ||
<context> | ||
<name>QObject</name> | ||
<message> | ||
<location filename="runner/error.h" line="76"/> | ||
<source>An unknown exception was thrown in python code.</source> | ||
<translation type="unfinished"></translation> | ||
</message> | ||
</context> | ||
</TS> |