Skip to content
Snippets Groups Projects
Commit 8e99b826 authored by Oz Linden's avatar Oz Linden
Browse files

merge changes for DRTVWR-244

parents edcdce22 e2bd5f7a
Branches
Tags
No related merge requests found
Showing
with 364 additions and 302 deletions
...@@ -379,3 +379,4 @@ c23d734065ed593b2413385aecd8366d8e0ee96b DRTVWR-257 ...@@ -379,3 +379,4 @@ c23d734065ed593b2413385aecd8366d8e0ee96b DRTVWR-257
452ce96d4046dc05a3ecaecc203e2cc8ddd72e76 DRTVWR-259 452ce96d4046dc05a3ecaecc203e2cc8ddd72e76 DRTVWR-259
5cba5f39d0a81d659f24ebc4b5efd025a39e3db1 3.4.3-release 5cba5f39d0a81d659f24ebc4b5efd025a39e3db1 3.4.3-release
9aa1aa9f1fe13c194695a0b8f0af298296241dc2 DRTVWR-260 9aa1aa9f1fe13c194695a0b8f0af298296241dc2 DRTVWR-260
18c5f76ac07937e0b64bb874edba0d60a28cec56 DRTVWR-244
...@@ -15,7 +15,6 @@ include_directories( ...@@ -15,7 +15,6 @@ include_directories(
if (DARWIN) if (DARWIN)
include(CMakeFindFrameworks) include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon)
find_library(COCOA_LIBRARY Cocoa) find_library(COCOA_LIBRARY Cocoa)
endif (DARWIN) endif (DARWIN)
...@@ -68,7 +67,7 @@ add_dependencies(SLPlugin ...@@ -68,7 +67,7 @@ add_dependencies(SLPlugin
if (DARWIN) if (DARWIN)
# Mac version needs to link against Carbon # Mac version needs to link against Carbon
target_link_libraries(SLPlugin ${CARBON_LIBRARY} ${COCOA_LIBRARY}) target_link_libraries(SLPlugin ${COCOA_LIBRARY})
# Make sure the app bundle has a Resources directory (it will get populated by viewer-manifest.py later) # Make sure the app bundle has a Resources directory (it will get populated by viewer-manifest.py later)
add_custom_command( add_custom_command(
TARGET SLPlugin POST_BUILD TARGET SLPlugin POST_BUILD
......
...@@ -28,8 +28,26 @@ ...@@ -28,8 +28,26 @@
* @endcond * @endcond
*/ */
//Protos for ObjectiveC classes (cannot import cocoa here due to BOOL conflict)
class NSWindow;
/* Defined in slplugin-objc.mm: */ /* Defined in slplugin-objc.mm: */
class LLCocoaPlugin
{
public:
LLCocoaPlugin();
void setupCocoa(); void setupCocoa();
void createAutoReleasePool(); void createAutoReleasePool();
void deleteAutoReleasePool(); void deleteAutoReleasePool();
void setupGroup();
void updateWindows();
void processEvents();
public:
//EventTargetRef mEventTarget;
NSWindow* mFrontWindow;
NSWindow* mPluginWindow;
int mHackState;
};
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#import <Cocoa/Cocoa.h>
#include "slplugin-objc.h" #include "slplugin-objc.h"
//Note: NSApp is a global defined by cocoa which is an id to the application.
void setupCocoa() void LLCocoaPlugin::setupCocoa()
{ {
static bool inited = false; static bool inited = false;
...@@ -56,6 +58,8 @@ void setupCocoa() ...@@ -56,6 +58,8 @@ void setupCocoa()
// Must first call [[[NSWindow alloc] init] release] to get the NSWindow machinery set up so that NSCursor can use a window to cache the cursor image // Must first call [[[NSWindow alloc] init] release] to get the NSWindow machinery set up so that NSCursor can use a window to cache the cursor image
[[[NSWindow alloc] init] release]; [[[NSWindow alloc] init] release];
mPluginWindow = [NSApp mainWindow];
deleteAutoReleasePool(); deleteAutoReleasePool();
inited = true; inited = true;
...@@ -64,7 +68,7 @@ void setupCocoa() ...@@ -64,7 +68,7 @@ void setupCocoa()
static NSAutoreleasePool *sPool = NULL; static NSAutoreleasePool *sPool = NULL;
void createAutoReleasePool() void LLCocoaPlugin::createAutoReleasePool()
{ {
if(!sPool) if(!sPool)
{ {
...@@ -72,7 +76,7 @@ void createAutoReleasePool() ...@@ -72,7 +76,7 @@ void createAutoReleasePool()
} }
} }
void deleteAutoReleasePool() void LLCocoaPlugin::deleteAutoReleasePool()
{ {
if(sPool) if(sPool)
{ {
...@@ -80,3 +84,94 @@ void deleteAutoReleasePool() ...@@ -80,3 +84,94 @@ void deleteAutoReleasePool()
sPool = NULL; sPool = NULL;
} }
} }
LLCocoaPlugin::LLCocoaPlugin():mHackState(0)
{
NSArray* window_list = [NSApp orderedWindows];
mFrontWindow = [window_list objectAtIndex:0];
}
void LLCocoaPlugin::processEvents()
{
// Some plugins (webkit at least) will want an event loop. This qualifies.
NSEvent * event;
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
[NSApp sendEvent: event];
}
//Turns out the window ordering stuff never gets hit with any of the current plugins.
//Leaving the following code here 'just in case' for the time being.
void LLCocoaPlugin::setupGroup()
{
// CreateWindowGroup(kWindowGroupAttrFixedLevel, &layer_group);
// if(layer_group)
// {
// // Start out with a window layer that's way out in front (fixes the problem with the menubar not getting hidden on first switch to fullscreen youtube)
// SetWindowGroupName(layer_group, CFSTR("SLPlugin Layer"));
// SetWindowGroupLevel(layer_group, kCGOverlayWindowLevel);
// }
}
void LLCocoaPlugin::updateWindows() //SPATTERS give this a better name.
{
// NSArray* window_list = [NSApp orderedWindows];
// NSWindow* current_window = [window_list objectAtIndex:0];
// NSWindow* parent_window = [ current_window parentWindow ];
// bool this_is_front_process = false;
// bool parent_is_front_process = false;
//
//
// // Check for a change in this process's frontmost window.
// if ( current_window != mFrontWindow )
// {
// // and figure out whether this process or its parent are currently frontmost
// if ( current_window == parent_window ) parent_is_front_process = true;
// if ( current_window == mPluginWindow ) this_is_front_process = true;
//
// if (current_window != NULL && mFrontWindow == NULL)
// {
// // Opening the first window
//
// if(mHackState == 0)
// {
// // Next time through the event loop, lower the window group layer
// mHackState = 1;
// }
//
// if(parent_is_front_process)
// {
// // Bring this process's windows to the front.
// [mPluginWindow makeKeyAndOrderFront:NSApp];
// [mPluginWindow setOrderedIndex:0];
// }
//
// [NSApp activateIgnoringOtherApps:YES];
// }
//
// else if (( current_window == NULL) && (mFrontWindow != NULL))
// {
// // Closing the last window
//
// if(this_is_front_process)
// {
// // Try to bring this process's parent to the front
// [parent_window makeKeyAndOrderFront:NSApp];
// [parent_window setOrderedIndex:0];
// }
// }
// else if(mHackState == 1)
// {
//// if(layer_group)
//// {
//// // Set the window group level back to something less extreme
//// SetWindowGroupLevel(layer_group, kCGNormalWindowLevel);
//// }
// mHackState = 2;
// }
//
// mFrontWindow = [window_list objectAtIndex:0];
// }
}
...@@ -37,8 +37,12 @@ ...@@ -37,8 +37,12 @@
#include "llapr.h" #include "llapr.h"
#include "llstring.h" #include "llstring.h"
#include <iostream>
#include <fstream>
using namespace std;
#if LL_DARWIN #if LL_DARWIN
#include <Carbon/Carbon.h>
#include "slplugin-objc.h" #include "slplugin-objc.h"
#endif #endif
...@@ -176,6 +180,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL ...@@ -176,6 +180,7 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
int main(int argc, char **argv) int main(int argc, char **argv)
#endif #endif
{ {
ll_init_apr(); ll_init_apr();
// Set up llerror logging // Set up llerror logging
...@@ -216,26 +221,25 @@ int main(int argc, char **argv) ...@@ -216,26 +221,25 @@ int main(int argc, char **argv)
// Catch signals that most kinds of crashes will generate, and exit cleanly so the system crash dialog isn't shown. // Catch signals that most kinds of crashes will generate, and exit cleanly so the system crash dialog isn't shown.
signal(SIGILL, &crash_handler); // illegal instruction signal(SIGILL, &crash_handler); // illegal instruction
# if LL_DARWIN
signal(SIGEMT, &crash_handler); // emulate instruction executed
# endif // LL_DARWIN
signal(SIGFPE, &crash_handler); // floating-point exception signal(SIGFPE, &crash_handler); // floating-point exception
signal(SIGBUS, &crash_handler); // bus error signal(SIGBUS, &crash_handler); // bus error
signal(SIGSEGV, &crash_handler); // segmentation violation signal(SIGSEGV, &crash_handler); // segmentation violation
signal(SIGSYS, &crash_handler); // non-existent system call invoked signal(SIGSYS, &crash_handler); // non-existent system call invoked
#endif #endif
# if LL_DARWIN # if LL_DARWIN
setupCocoa(); signal(SIGEMT, &crash_handler); // emulate instruction executed
createAutoReleasePool();
#endif LLCocoaPlugin cocoa_interface;
cocoa_interface.setupCocoa();
cocoa_interface.createAutoReleasePool();
#endif //LL_DARWIN
LLPluginProcessChild *plugin = new LLPluginProcessChild(); LLPluginProcessChild *plugin = new LLPluginProcessChild();
plugin->init(port); plugin->init(port);
#if LL_DARWIN #if LL_DARWIN
deleteAutoReleasePool(); cocoa_interface.deleteAutoReleasePool();
#endif #endif
LLTimer timer; LLTimer timer;
...@@ -246,113 +250,21 @@ int main(int argc, char **argv) ...@@ -246,113 +250,21 @@ int main(int argc, char **argv)
#endif #endif
#if LL_DARWIN #if LL_DARWIN
// If the plugin opens a new window (such as the Flash plugin's fullscreen player), we may need to bring this plugin process to the foreground. // If the plugin opens a new window (such as the Flash plugin's fullscreen player), we may need to bring this plugin process to the foreground.
// Use this to track the current frontmost window and bring this process to the front if it changes. // Use this to track the current frontmost window and bring this process to the front if it changes.
WindowRef front_window = NULL; // cocoa_interface.mEventTarget = GetEventDispatcherTarget();
WindowGroupRef layer_group = NULL;
int window_hack_state = 0;
CreateWindowGroup(kWindowGroupAttrFixedLevel, &layer_group);
if(layer_group)
{
// Start out with a window layer that's way out in front (fixes the problem with the menubar not getting hidden on first switch to fullscreen youtube)
SetWindowGroupName(layer_group, CFSTR("SLPlugin Layer"));
SetWindowGroupLevel(layer_group, kCGOverlayWindowLevel);
}
#endif
#if LL_DARWIN
EventTargetRef event_target = GetEventDispatcherTarget();
#endif #endif
while(!plugin->isDone()) while(!plugin->isDone())
{ {
#if LL_DARWIN #if LL_DARWIN
createAutoReleasePool(); cocoa_interface.createAutoReleasePool();
#endif #endif
timer.reset(); timer.reset();
plugin->idle(); plugin->idle();
#if LL_DARWIN #if LL_DARWIN
{ {
// Some plugins (webkit at least) will want an event loop. This qualifies. cocoa_interface.processEvents();
EventRef event;
if(ReceiveNextEvent(0, 0, kEventDurationNoWait, true, &event) == noErr)
{
SendEventToEventTarget (event, event_target);
ReleaseEvent(event);
}
// Check for a change in this process's frontmost window.
if(GetFrontWindowOfClass(kAllWindowClasses, true) != front_window)
{
ProcessSerialNumber self = { 0, kCurrentProcess };
ProcessSerialNumber parent = { 0, kNoProcess };
ProcessSerialNumber front = { 0, kNoProcess };
Boolean this_is_front_process = false;
Boolean parent_is_front_process = false;
{
// Get this process's parent
ProcessInfoRec info;
info.processInfoLength = sizeof(ProcessInfoRec);
info.processName = NULL;
info.processAppSpec = NULL;
if(GetProcessInformation( &self, &info ) == noErr)
{
parent = info.processLauncher;
}
// and figure out whether this process or its parent are currently frontmost
if(GetFrontProcess(&front) == noErr)
{
(void) SameProcess(&self, &front, &this_is_front_process);
(void) SameProcess(&parent, &front, &parent_is_front_process);
}
}
if((GetFrontWindowOfClass(kAllWindowClasses, true) != NULL) && (front_window == NULL))
{
// Opening the first window
if(window_hack_state == 0)
{
// Next time through the event loop, lower the window group layer
window_hack_state = 1;
}
if(layer_group)
{
SetWindowGroup(GetFrontWindowOfClass(kAllWindowClasses, true), layer_group);
}
if(parent_is_front_process)
{
// Bring this process's windows to the front.
(void) SetFrontProcess( &self );
}
ActivateWindow(GetFrontWindowOfClass(kAllWindowClasses, true), true);
}
else if((GetFrontWindowOfClass(kAllWindowClasses, true) == NULL) && (front_window != NULL))
{
// Closing the last window
if(this_is_front_process)
{
// Try to bring this process's parent to the front
(void) SetFrontProcess(&parent);
}
}
else if(window_hack_state == 1)
{
if(layer_group)
{
// Set the window group level back to something less extreme
SetWindowGroupLevel(layer_group, kCGNormalWindowLevel);
}
window_hack_state = 2;
}
front_window = GetFrontWindowOfClass(kAllWindowClasses, true);
}
} }
#endif #endif
F64 elapsed = timer.getElapsedTimeF64(); F64 elapsed = timer.getElapsedTimeF64();
...@@ -378,6 +290,7 @@ int main(int argc, char **argv) ...@@ -378,6 +290,7 @@ int main(int argc, char **argv)
// LL_INFOS("slplugin") << "slept for "<< timer.getElapsedTimeF64() * 1000.0f << " ms" << LL_ENDL; // LL_INFOS("slplugin") << "slept for "<< timer.getElapsedTimeF64() * 1000.0f << " ms" << LL_ENDL;
} }
#if LL_WINDOWS #if LL_WINDOWS
// More agressive checking of interfering exception handlers. // More agressive checking of interfering exception handlers.
// Doesn't appear to be required so far - even for plugins // Doesn't appear to be required so far - even for plugins
...@@ -387,14 +300,14 @@ int main(int argc, char **argv) ...@@ -387,14 +300,14 @@ int main(int argc, char **argv)
#endif #endif
#if LL_DARWIN #if LL_DARWIN
deleteAutoReleasePool(); cocoa_interface.deleteAutoReleasePool();
#endif #endif
} }
delete plugin; delete plugin;
ll_cleanup_apr(); ll_cleanup_apr();
return 0; return 0;
} }
...@@ -36,6 +36,8 @@ set(llvfs_HEADER_FILES ...@@ -36,6 +36,8 @@ set(llvfs_HEADER_FILES
if (DARWIN) if (DARWIN)
LIST(APPEND llvfs_SOURCE_FILES lldir_mac.cpp) LIST(APPEND llvfs_SOURCE_FILES lldir_mac.cpp)
LIST(APPEND llvfs_HEADER_FILES lldir_mac.h) LIST(APPEND llvfs_HEADER_FILES lldir_mac.h)
LIST(APPEND llvfs_SOURCE_FILES llvfs_objc.mm)
LIST(APPEND llvfs_HEADER_FILES llvfs_objc.h)
endif (DARWIN) endif (DARWIN)
if (LINUX) if (LINUX)
...@@ -73,8 +75,8 @@ target_link_libraries(llvfs ...@@ -73,8 +75,8 @@ target_link_libraries(llvfs
if (DARWIN) if (DARWIN)
include(CMakeFindFrameworks) include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon) find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(llvfs ${CARBON_LIBRARY}) target_link_libraries(llvfs ${COCOA_LIBRARY})
endif (DARWIN) endif (DARWIN)
......
...@@ -73,10 +73,8 @@ class LLDir ...@@ -73,10 +73,8 @@ class LLDir
virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask);
// pure virtual functions // pure virtual functions
virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0;
virtual std::string getCurPath() = 0; virtual std::string getCurPath() = 0;
virtual BOOL fileExists(const std::string &filename) const = 0; virtual bool fileExists(const std::string &filename) const = 0;
const std::string findFile(const std::string& filename, const std::vector<std::string> filenames) const; const std::string findFile(const std::string& filename, const std::vector<std::string> filenames) const;
const std::string findFile(const std::string& filename, const std::string& searchPath1 = "", const std::string& searchPath2 = "", const std::string& searchPath3 = "") const; const std::string findFile(const std::string& filename, const std::string& searchPath1 = "", const std::string& searchPath2 = "", const std::string& searchPath3 = "") const;
......
...@@ -254,7 +254,7 @@ std::string LLDir_Linux::getCurPath() ...@@ -254,7 +254,7 @@ std::string LLDir_Linux::getCurPath()
} }
BOOL LLDir_Linux::fileExists(const std::string &filename) const bool LLDir_Linux::fileExists(const std::string &filename) const
{ {
struct stat stat_data; struct stat stat_data;
// Check the age of the file // Check the age of the file
......
...@@ -47,7 +47,7 @@ class LLDir_Linux : public LLDir ...@@ -47,7 +47,7 @@ class LLDir_Linux : public LLDir
virtual std::string getCurPath(); virtual std::string getCurPath();
virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
/*virtual*/ BOOL fileExists(const std::string &filename) const; /*virtual*/ bool fileExists(const std::string &filename) const;
/*virtual*/ std::string getLLPluginLauncher(); /*virtual*/ std::string getLLPluginLauncher();
/*virtual*/ std::string getLLPluginFilename(std::string base_name); /*virtual*/ std::string getLLPluginFilename(std::string base_name);
......
...@@ -35,73 +35,27 @@ ...@@ -35,73 +35,27 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <glob.h> #include <glob.h>
#include <boost/filesystem.hpp>
#include <Carbon/Carbon.h> #include "llvfs_objc.h"
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
static OSStatus CFCreateDirectory(FSRef *parentRef, CFStringRef name, FSRef *newRef) static bool CreateDirectory(const std::string &parent,
{ const std::string &child,
OSStatus result = noErr; std::string *fullname)
HFSUniStr255 uniStr;
uniStr.length = CFStringGetLength(name);
CFStringGetCharacters(name, CFRangeMake(0, uniStr.length), uniStr.unicode);
result = FSMakeFSRefUnicode(parentRef, uniStr.length, uniStr.unicode, kTextEncodingMacRoman, newRef);
if (result != noErr)
{ {
result = FSCreateDirectoryUnicode(parentRef, uniStr.length, uniStr.unicode, 0, NULL, newRef, NULL, NULL);
}
return result; boost::filesystem::path p(parent);
} p /= child;
// -------------------------------------------------------------------------------- if (fullname)
*fullname = std::string(p.string());
static void CFStringRefToLLString(CFStringRef stringRef, std::string &llString, bool releaseWhenDone) if (! boost::filesystem::create_directory(p))
{ {
if (stringRef) return (boost::filesystem::is_directory(p));
{
long stringSize = CFStringGetLength(stringRef) + 1;
long bufferSize = CFStringGetMaximumSizeForEncoding(stringSize,kCFStringEncodingUTF8);
char* buffer = new char[bufferSize];
memset(buffer, 0, bufferSize);
if (CFStringGetCString(stringRef, buffer, bufferSize, kCFStringEncodingUTF8))
llString = buffer;
delete[] buffer;
if (releaseWhenDone)
CFRelease(stringRef);
} }
} return true;
// --------------------------------------------------------------------------------
static void CFURLRefToLLString(CFURLRef urlRef, std::string &llString, bool releaseWhenDone)
{
if (urlRef)
{
CFURLRef absoluteURLRef = CFURLCopyAbsoluteURL(urlRef);
if (absoluteURLRef)
{
CFStringRef stringRef = CFURLCopyFileSystemPath(absoluteURLRef, kCFURLPOSIXPathStyle);
CFStringRefToLLString(stringRef, llString, true);
CFRelease(absoluteURLRef);
}
if (releaseWhenDone)
CFRelease(urlRef);
}
}
// --------------------------------------------------------------------------------
static void FSRefToLLString(FSRef *fsRef, std::string &llString)
{
OSStatus error = noErr;
char path[MAX_PATH];
error = FSRefMakePath(fsRef, (UInt8*) path, sizeof(path));
if (error == noErr)
llString = path;
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
...@@ -109,35 +63,26 @@ static void FSRefToLLString(FSRef *fsRef, std::string &llString) ...@@ -109,35 +63,26 @@ static void FSRefToLLString(FSRef *fsRef, std::string &llString)
LLDir_Mac::LLDir_Mac() LLDir_Mac::LLDir_Mac()
{ {
mDirDelimiter = "/"; mDirDelimiter = "/";
mCurrentDirIndex = -1;
mCurrentDirCount = -1;
CFBundleRef mainBundleRef = NULL; const std::string secondLifeString = "SecondLife";
CFURLRef executableURLRef = NULL;
CFStringRef stringRef = NULL;
OSStatus error = noErr;
FSRef fileRef;
CFStringRef secondLifeString = CFSTR("SecondLife");
mainBundleRef = CFBundleGetMainBundle(); std::string *executablepathstr = getSystemExecutableFolder();
executableURLRef = CFBundleCopyExecutableURL(mainBundleRef); //NOTE: LLINFOS/LLERRS will not output to log here. The streams are not initialized.
if (executableURLRef != NULL) if (executablepathstr)
{ {
// mExecutablePathAndName // mExecutablePathAndName
CFURLRefToLLString(executableURLRef, mExecutablePathAndName, false); mExecutablePathAndName = *executablepathstr;
// mExecutableFilename boost::filesystem::path executablepath(*executablepathstr);
stringRef = CFURLCopyLastPathComponent(executableURLRef);
CFStringRefToLLString(stringRef, mExecutableFilename, true);
// mExecutableDir mExecutableFilename = executablepath.filename();
CFURLRef executableParentURLRef = CFURLCreateCopyDeletingLastPathComponent(NULL, executableURLRef); mExecutableDir = executablepath.parent_path().string();
CFURLRefToLLString(executableParentURLRef, mExecutableDir, true);
// mAppRODataDir // mAppRODataDir
std::string *resourcepath = getSystemResourceFolder();
mAppRODataDir = *resourcepath;
// *NOTE: When running in a dev tree, use the copy of // *NOTE: When running in a dev tree, use the copy of
// skins in indra/newview/ rather than in the application bundle. This // skins in indra/newview/ rather than in the application bundle. This
...@@ -147,9 +92,6 @@ LLDir_Mac::LLDir_Mac() ...@@ -147,9 +92,6 @@ LLDir_Mac::LLDir_Mac()
// MBW -- This keeps the mac application from finding other things. // MBW -- This keeps the mac application from finding other things.
// If this is really for skins, it should JUST apply to skins. // If this is really for skins, it should JUST apply to skins.
CFURLRef resourcesURLRef = CFBundleCopyResourcesDirectoryURL(mainBundleRef);
CFURLRefToLLString(resourcesURLRef, mAppRODataDir, true);
U32 build_dir_pos = mExecutableDir.rfind("/build-darwin-"); U32 build_dir_pos = mExecutableDir.rfind("/build-darwin-");
if (build_dir_pos != std::string::npos) if (build_dir_pos != std::string::npos)
{ {
...@@ -166,55 +108,50 @@ LLDir_Mac::LLDir_Mac() ...@@ -166,55 +108,50 @@ LLDir_Mac::LLDir_Mac()
} }
// mOSUserDir // mOSUserDir
error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, true, &fileRef); std::string *appdir = getSystemApplicationSupportFolder();
if (error == noErr) std::string rootdir;
{
FSRef newFileRef;
// Create the directory //Create root directory
error = CFCreateDirectory(&fileRef, secondLifeString, &newFileRef); if (CreateDirectory(*appdir, secondLifeString, &rootdir))
if (error == noErr)
{ {
// Save the full path to the folder // Save the full path to the folder
FSRefToLLString(&newFileRef, mOSUserDir); mOSUserDir = rootdir;
// Create our sub-dirs // Create our sub-dirs
(void) CFCreateDirectory(&newFileRef, CFSTR("data"), NULL); CreateDirectory(rootdir, std::string("data"), NULL);
//(void) CFCreateDirectory(&newFileRef, CFSTR("cache"), NULL); CreateDirectory(rootdir, std::string("logs"), NULL);
(void) CFCreateDirectory(&newFileRef, CFSTR("logs"), NULL); CreateDirectory(rootdir, std::string("user_settings"), NULL);
(void) CFCreateDirectory(&newFileRef, CFSTR("user_settings"), NULL); CreateDirectory(rootdir, std::string("browser_profile"), NULL);
(void) CFCreateDirectory(&newFileRef, CFSTR("browser_profile"), NULL);
}
} }
//mOSCacheDir //mOSCacheDir
FSRef cacheDirRef; std::string *cachedir = getSystemCacheFolder();
error = FSFindFolder(kUserDomain, kCachedDataFolderType, true, &cacheDirRef);
if (error == noErr) if (cachedir)
{ {
FSRefToLLString(&cacheDirRef, mOSCacheDir); mOSCacheDir = *cachedir;
(void)CFCreateDirectory(&cacheDirRef, CFSTR("SecondLife"),NULL); //SPATTERS TODO: This changes from ~/Library/Cache/Secondlife to ~/Library/Cache/com.app.secondlife/Secondlife. Last dir level could go away.
CreateDirectory(mOSCacheDir, secondLifeString, NULL);
} }
// mOSUserAppDir // mOSUserAppDir
mOSUserAppDir = mOSUserDir; mOSUserAppDir = mOSUserDir;
// mTempDir // mTempDir
error = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, true, &fileRef); //Aura 120920 boost::filesystem::temp_directory_path() not yet implemented on mac. :(
if (error == noErr) std::string *tmpdir = getSystemTempFolder();
if (tmpdir)
{ {
FSRef tempRef;
error = CFCreateDirectory(&fileRef, secondLifeString, &tempRef); CreateDirectory(*tmpdir, secondLifeString, &mTempDir);
if (error == noErr) if (tmpdir) delete tmpdir;
FSRefToLLString(&tempRef, mTempDir);
} }
mWorkingDir = getCurPath(); mWorkingDir = getCurPath();
mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin"; mLLPluginDir = mAppRODataDir + mDirDelimiter + "llplugin";
CFRelease(executableURLRef);
executableURLRef = NULL;
} }
} }
...@@ -235,52 +172,18 @@ void LLDir_Mac::initAppDirs(const std::string &app_name, ...@@ -235,52 +172,18 @@ void LLDir_Mac::initAppDirs(const std::string &app_name,
mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins";
} }
mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem"); mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem");
//dumpCurrentDirectories();
}
U32 LLDir_Mac::countFilesInDir(const std::string &dirname, const std::string &mask)
{
U32 file_count = 0;
glob_t g;
std::string tmp_str;
tmp_str = dirname;
tmp_str += mask;
if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0)
{
file_count = g.gl_pathc;
globfree(&g);
}
return (file_count);
} }
std::string LLDir_Mac::getCurPath() std::string LLDir_Mac::getCurPath()
{ {
char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ return boost::filesystem::path( boost::filesystem::current_path() ).string();
getcwd(tmp_str, LL_MAX_PATH);
return tmp_str;
} }
BOOL LLDir_Mac::fileExists(const std::string &filename) const bool LLDir_Mac::fileExists(const std::string &filename) const
{ {
struct stat stat_data; return boost::filesystem::exists(filename);
// Check the age of the file
// Now, we see if the files we've gathered are recent...
int res = stat(filename.c_str(), &stat_data);
if (!res)
{
return TRUE;
}
else
{
return FALSE;
}
} }
......
...@@ -45,16 +45,10 @@ class LLDir_Mac : public LLDir ...@@ -45,16 +45,10 @@ class LLDir_Mac : public LLDir
const std::string& app_read_only_data_dir); const std::string& app_read_only_data_dir);
virtual std::string getCurPath(); virtual std::string getCurPath();
virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual bool fileExists(const std::string &filename) const;
virtual BOOL fileExists(const std::string &filename) const;
/*virtual*/ std::string getLLPluginLauncher(); /*virtual*/ std::string getLLPluginLauncher();
/*virtual*/ std::string getLLPluginFilename(std::string base_name); /*virtual*/ std::string getLLPluginFilename(std::string base_name);
private:
int mCurrentDirIndex;
int mCurrentDirCount;
std::string mCurrentDir;
}; };
#endif // LL_LLDIR_MAC_H #endif // LL_LLDIR_MAC_H
......
...@@ -272,7 +272,7 @@ std::string LLDir_Solaris::getCurPath() ...@@ -272,7 +272,7 @@ std::string LLDir_Solaris::getCurPath()
} }
BOOL LLDir_Solaris::fileExists(const std::string &filename) const bool LLDir_Solaris::fileExists(const std::string &filename) const
{ {
struct stat stat_data; struct stat stat_data;
// Check the age of the file // Check the age of the file
......
...@@ -47,7 +47,7 @@ class LLDir_Solaris : public LLDir ...@@ -47,7 +47,7 @@ class LLDir_Solaris : public LLDir
virtual std::string getCurPath(); virtual std::string getCurPath();
virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask);
/*virtual*/ BOOL fileExists(const std::string &filename) const; /*virtual*/ bool fileExists(const std::string &filename) const;
private: private:
DIR *mDirp; DIR *mDirp;
......
...@@ -249,7 +249,7 @@ std::string LLDir_Win32::getCurPath() ...@@ -249,7 +249,7 @@ std::string LLDir_Win32::getCurPath()
} }
BOOL LLDir_Win32::fileExists(const std::string &filename) const bool LLDir_Win32::fileExists(const std::string &filename) const
{ {
llstat stat_data; llstat stat_data;
// Check the age of the file // Check the age of the file
......
...@@ -44,7 +44,7 @@ class LLDir_Win32 : public LLDir ...@@ -44,7 +44,7 @@ class LLDir_Win32 : public LLDir
/*virtual*/ std::string getCurPath(); /*virtual*/ std::string getCurPath();
/*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask); /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask);
/*virtual*/ BOOL fileExists(const std::string &filename) const; /*virtual*/ bool fileExists(const std::string &filename) const;
/*virtual*/ std::string getLLPluginLauncher(); /*virtual*/ std::string getLLPluginLauncher();
/*virtual*/ std::string getLLPluginFilename(std::string base_name); /*virtual*/ std::string getLLPluginFilename(std::string base_name);
......
/**
* @file llvfs_objc.h
* @brief Definition of directory utilities class for Mac OS X
*
* $LicenseInfo:firstyear=2000&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#if !LL_DARWIN
#error This header must not be included when compiling for any target other than Mac OS. Consider including lldir.h instead.
#endif // !LL_DARWIN
#ifndef LL_LLVFS_OBJC_H
#define LL_LLVFS_OBJC_H
#include <iostream>
std::string* getSystemTempFolder();
std::string* getSystemCacheFolder();
std::string* getSystemApplicationSupportFolder();
std::string* getSystemResourceFolder();
std::string* getSystemExecutableFolder();
#endif LL_LLVFS_OBJC_H
/**
* @file llvfs_objc.cpp
* @brief Cocoa implementation of directory utilities for Mac OS X
*
* $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#if LL_DARWIN
//WARNING: This file CANNOT use standard linden includes due to conflicts between definitions of BOOL
#include "llvfs_objc.h"
#import <Cocoa/Cocoa.h>
std::string* getSystemTempFolder()
{
NSString * tempDir = NSTemporaryDirectory();
if (tempDir == nil)
tempDir = @"/tmp";
return ( new std::string([tempDir UTF8String]) );
}
//findSystemDirectory scoped exclusively to this file.
std::string* findSystemDirectory(NSSearchPathDirectory searchPathDirectory,
NSSearchPathDomainMask domainMask)
{
std::string *result;
NSString *path = nil;
// Search for the path
NSArray* paths = NSSearchPathForDirectoriesInDomains(searchPathDirectory,
domainMask,
YES);
if ([paths count])
{
path = [paths objectAtIndex:0];
//SPATTERS HACK: Always attempt to create directory, ignore errors.
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
result = new std::string([path UTF8String]);
}
return result;
}
std::string* getSystemExecutableFolder()
{
NSString *bundlePath = [[NSBundle mainBundle] executablePath];
return (new std::string([bundlePath UTF8String]));
}
std::string* getSystemResourceFolder()
{
NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
return (new std::string([bundlePath UTF8String]));
}
std::string* getSystemCacheFolder()
{
return findSystemDirectory (NSCachesDirectory,
NSUserDomainMask);
}
std::string* getSystemApplicationSupportFolder()
{
return findSystemDirectory (NSApplicationSupportDirectory,
NSUserDomainMask);
}
#endif // LL_DARWIN
...@@ -23,12 +23,14 @@ include_directories( ...@@ -23,12 +23,14 @@ include_directories(
set(mac_crash_logger_SOURCE_FILES set(mac_crash_logger_SOURCE_FILES
mac_crash_logger.cpp mac_crash_logger.cpp
llcrashloggermac.cpp llcrashloggermac.cpp
llcrashloggermacdelegate.mm
) )
set(mac_crash_logger_HEADER_FILES set(mac_crash_logger_HEADER_FILES
CMakeLists.txt CMakeLists.txt
llcrashloggermac.h llcrashloggermac.h
llcrashloggermacdelegate.h
) )
set_source_files_properties(${mac_crash_logger_HEADER_FILES} set_source_files_properties(${mac_crash_logger_HEADER_FILES}
...@@ -55,9 +57,12 @@ set_target_properties(mac-crash-logger ...@@ -55,9 +57,12 @@ set_target_properties(mac-crash-logger
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
) )
find_library(COCOA_LIBRARY Cocoa)
target_link_libraries(mac-crash-logger target_link_libraries(mac-crash-logger
${LLCRASHLOGGER_LIBRARIES} ${LLCRASHLOGGER_LIBRARIES}
${LLVFS_LIBRARIES} ${LLVFS_LIBRARIES}
${COCOA_LIBRARIES}
${LLXML_LIBRARIES} ${LLXML_LIBRARIES}
${LLMESSAGE_LIBRARIES} ${LLMESSAGE_LIBRARIES}
${LLVFS_LIBRARIES} ${LLVFS_LIBRARIES}
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment