diff --git a/extras/juce demo/src/ApplicationStartup.cpp b/extras/juce demo/src/ApplicationStartup.cpp index 52134eef29..c97930ad68 100644 --- a/extras/juce demo/src/ApplicationStartup.cpp +++ b/extras/juce demo/src/ApplicationStartup.cpp @@ -119,16 +119,18 @@ private: String systemInfo; systemInfo - << T("Time and date: ") << Time::getCurrentTime().toString (true, true) - << T("\nOperating system: ") << SystemStats::getOperatingSystemName() - << T("\nCPU vendor: ") << SystemStats::getCpuVendor() - << T("\nCPU speed: ") << SystemStats::getCpuSpeedInMegaherz() << T("MHz\n") - << T("\nNumber of CPUs: ") << SystemStats::getNumCpus() - << T("\nCPU has MMX: ") << (SystemStats::hasMMX() ? T("yes") : T("no")) - << T("\nCPU has SSE: ") << (SystemStats::hasSSE() ? T("yes") : T("no")) - << T("\nCPU has SSE2: ") << (SystemStats::hasSSE2() ? T("yes") : T("no")) - << T("\nCPU has 3DNOW: ") << (SystemStats::has3DNow() ? T("yes") : T("no")) - << T("\nMemory size: ") << SystemStats::getMemorySizeInMegabytes() << T("MB\n"); + << "Time and date: " << Time::getCurrentTime().toString (true, true) + << "\nUser logon name: " << SystemStats::getLogonName() + << "\nFull user name: " << SystemStats::getFullUserName() + << "\nOperating system: " << SystemStats::getOperatingSystemName() + << "\nCPU vendor: " << SystemStats::getCpuVendor() + << "\nCPU speed: " << SystemStats::getCpuSpeedInMegaherz() << "MHz\n" + << "\nNumber of CPUs: " << SystemStats::getNumCpus() + << "\nCPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") + << "\nCPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") + << "\nCPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") + << "\nCPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") + << "\nMemory size: " << SystemStats::getMemorySizeInMegabytes() << "MB\n"; int64 macAddresses[8]; const int numAddresses = SystemStats::getMACAddresses (macAddresses, 8, false); @@ -136,7 +138,7 @@ private: for (int i = 0; i < numAddresses; ++i) { systemInfo - << T("Found network card MAC address: ") + << "Found network card MAC address: " << String::formatted (T("%02x-%02x-%02x-%02x-%02x-%02x\n"), 0xff & (int) (macAddresses [i] >> 40), 0xff & (int) (macAddresses [i] >> 32), @@ -147,21 +149,21 @@ private: } systemInfo - << T("Current executable file: ") + << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile).getFullPathName() - << T("\nCurrent application file: ") + << "\nCurrent application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() - << T("\nUser home directory: ") + << "\nUser home directory: " << File::getSpecialLocation (File::userHomeDirectory).getFullPathName() - << T("\nUser documents directory: ") + << "\nUser documents directory: " << File::getSpecialLocation (File::userDocumentsDirectory).getFullPathName() - << T("\nUser application data directory: ") + << "\nUser application data directory: " << File::getSpecialLocation (File::userApplicationDataDirectory).getFullPathName() - << T("\nCommon application data directory: ") + << "\nCommon application data directory: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() - << T("\nTemp directory: ") + << "\nTemp directory: " << File::getSpecialLocation (File::tempDirectory).getFullPathName() - << T("\n\n"); + << "\n\n"; return systemInfo; } diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 114052a7c1..dcc25bf3a5 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -212409,6 +212409,20 @@ int SystemStats::getPageSize() throw() return systemInfo.dwPageSize; } +const String SystemStats::getLogonName() +{ + TCHAR text [256]; + DWORD len = numElementsInArray (text) - 2; + zerostruct (text); + GetUserName (text, &len); + return String (text, len); +} + +const String SystemStats::getFullUserName() +{ + return getLogonName(); +} + #endif /********* End of inlined file: juce_win32_SystemStats.cpp *********/ @@ -230238,6 +230252,25 @@ int SystemStats::getNumCpus() throw() return lastCpu + 1; } +const String SystemStats::getLogonName() +{ + const char* user = getenv ("USER"); + + if (user == 0) + { + struct passwd* const pw = getpwuid (getuid()); + if (pw != 0) + user = pw->pw_name; + } + + return String::fromUTF8 ((const uint8*) user); +} + +const String SystemStats::getFullUserName() +{ + return getLogonName(); +} + void SystemStats::initialiseStats() throw() { // Process starts off as root when running suid @@ -237564,6 +237597,16 @@ int SystemStats::getNumCpus() throw() #endif } +const String SystemStats::getLogonName() +{ + return nsStringToJuce (NSUserName()); +} + +const String SystemStats::getFullUserName() +{ + return nsStringToJuce (NSFullUserName()); +} + uint32 juce_millisecondsSinceStartup() throw() { return (uint32) (mach_absolute_time() * highResTimerToMillisecRatio); diff --git a/juce_amalgamated.h b/juce_amalgamated.h index c4aaaa8946..1547920158 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -7088,6 +7088,10 @@ public: static bool isOperatingSystem64Bit() throw(); + static const String getLogonName(); + + static const String getFullUserName(); + // CPU and memory information.. static int getCpuSpeedInMegaherz() throw(); diff --git a/src/core/juce_SystemStats.h b/src/core/juce_SystemStats.h index aeba75a52a..aad1e02ece 100644 --- a/src/core/juce_SystemStats.h +++ b/src/core/juce_SystemStats.h @@ -86,6 +86,18 @@ public: */ static bool isOperatingSystem64Bit() throw(); + //============================================================================== + /** Returns the current user's name, if available. + @see getFullUserName() + */ + static const String getLogonName(); + + /** Returns the current user's full name, if available. + On some OSes, this may just return the same value as getLogonName(). + @see getLogonName() + */ + static const String getFullUserName(); + //============================================================================== // CPU and memory information.. diff --git a/src/gui/components/code_editor/juce_CodeDocument.cpp b/src/gui/components/code_editor/juce_CodeDocument.cpp index 12235ffbc7..d5dd3277ea 100644 --- a/src/gui/components/code_editor/juce_CodeDocument.cpp +++ b/src/gui/components/code_editor/juce_CodeDocument.cpp @@ -116,26 +116,26 @@ public: //============================================================================== CodeDocument::Iterator::Iterator (CodeDocument* const document_) : document (document_), + currentLine (document_->lines[0]), line (0), - position (0), - currentLine (document_->lines[0]) + position (0) { } CodeDocument::Iterator::Iterator (const CodeDocument::Iterator& other) : document (other.document), + currentLine (other.currentLine), line (other.line), - position (other.position), - currentLine (other.currentLine) + position (other.position) { } const CodeDocument::Iterator& CodeDocument::Iterator::operator= (const CodeDocument::Iterator& other) throw() { document = other.document; + currentLine = other.currentLine; line = other.line; position = other.position; - currentLine = other.currentLine; return *this; } diff --git a/src/native/linux/juce_linux_SystemStats.cpp b/src/native/linux/juce_linux_SystemStats.cpp index 977d191c4a..f773d9767e 100644 --- a/src/native/linux/juce_linux_SystemStats.cpp +++ b/src/native/linux/juce_linux_SystemStats.cpp @@ -214,6 +214,25 @@ int SystemStats::getNumCpus() throw() return lastCpu + 1; } +//============================================================================== +const String SystemStats::getLogonName() +{ + const char* user = getenv ("USER"); + + if (user == 0) + { + struct passwd* const pw = getpwuid (getuid()); + if (pw != 0) + user = pw->pw_name; + } + + return String::fromUTF8 ((const uint8*) user); +} + +const String SystemStats::getFullUserName() +{ + return getLogonName(); +} //============================================================================== void SystemStats::initialiseStats() throw() diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index bdde1fc6d8..b1dc6b37b1 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -218,6 +218,17 @@ int SystemStats::getNumCpus() throw() #endif } +//============================================================================== +const String SystemStats::getLogonName() +{ + return nsStringToJuce (NSUserName()); +} + +const String SystemStats::getFullUserName() +{ + return nsStringToJuce (NSFullUserName()); +} + //============================================================================== uint32 juce_millisecondsSinceStartup() throw() { diff --git a/src/native/windows/juce_win32_SystemStats.cpp b/src/native/windows/juce_win32_SystemStats.cpp index 3921ff91d6..149ed08116 100644 --- a/src/native/windows/juce_win32_SystemStats.cpp +++ b/src/native/windows/juce_win32_SystemStats.cpp @@ -390,4 +390,20 @@ int SystemStats::getPageSize() throw() return systemInfo.dwPageSize; } +//============================================================================== +const String SystemStats::getLogonName() +{ + TCHAR text [256]; + DWORD len = numElementsInArray (text) - 2; + zerostruct (text); + GetUserName (text, &len); + return String (text, len); +} + +const String SystemStats::getFullUserName() +{ + return getLogonName(); +} + + #endif